feat: 添加收藏备注功能
- 在 UsersController 中新增 favorite__remark 方法,支持用户修改收藏的备注 - 在 UserFavorite 模型中添加更新备注的逻辑 - 新增数据库迁移以添加备注字段 - 更新前端组件以支持备注的显示和编辑 - 优化收藏操作的用户体验
This commit is contained in:
@@ -3188,6 +3188,58 @@ class UsersController extends AbstractController
|
||||
return Base::retSuccess($message, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {post} api/users/favorite/remark 47-1. 修改收藏备注
|
||||
*
|
||||
* @apiDescription 需要token身份
|
||||
* @apiVersion 1.0.0
|
||||
* @apiGroup users
|
||||
* @apiName favorite__remark
|
||||
*
|
||||
* @apiParam {String} type 收藏类型 (task/project/file/message)
|
||||
* @apiParam {Number} id 收藏对象ID
|
||||
* @apiParam {String} remark 收藏备注(<=255个字符)
|
||||
*
|
||||
* @apiSuccess {Number} ret 返回状态码(1正确、0错误)
|
||||
* @apiSuccess {String} msg 返回信息(错误描述)
|
||||
* @apiSuccess {Object} data 返回数据
|
||||
*/
|
||||
public function favorite__remark()
|
||||
{
|
||||
$user = User::auth();
|
||||
//
|
||||
$type = trim(Request::input('type'));
|
||||
$id = intval(Request::input('id'));
|
||||
$remark = trim(Request::input('remark', ''));
|
||||
|
||||
if (!$type || $id <= 0) {
|
||||
return Base::retError('参数错误');
|
||||
}
|
||||
|
||||
$allowedTypes = [UserFavorite::TYPE_TASK, UserFavorite::TYPE_PROJECT, UserFavorite::TYPE_FILE, UserFavorite::TYPE_MESSAGE];
|
||||
if (!in_array($type, $allowedTypes)) {
|
||||
return Base::retError('无效的收藏类型');
|
||||
}
|
||||
|
||||
if ($remark === '') {
|
||||
return Base::retError('请输入修改备注');
|
||||
}
|
||||
|
||||
if (mb_strlen($remark) > 255) {
|
||||
return Base::retError('备注最多支持255个字符');
|
||||
}
|
||||
|
||||
$favorite = UserFavorite::updateRemark($user->userid, $type, $id, $remark);
|
||||
|
||||
if (!$favorite) {
|
||||
return Base::retError('收藏记录不存在');
|
||||
}
|
||||
|
||||
return Base::retSuccess('修改备注成功', [
|
||||
'remark' => $favorite->remark,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {post} api/users/favorites/clean 48. 清理用户收藏
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user