uid(); return app('json')->success($this->services->getInfo($authorUid, $uid)); } /** * 修改简介 * @param Request $request * @return \think\Response * User: liusl * DateTime: 2024/8/22 16:30 */ public function updateDesc(Request $request) { $uid = (int)$request->uid(); [$desc] = $request->postMore([['desc', '']], true); $info = $this->services->getUserInfo($uid); if (!$info) { return app('json')->fail('用户不存在'); } $info->desc = $desc; $info->save(); return app('json')->success('修改成功'); } /** * 关注/取消关注 * @param $id * @param Request $request * @return \think\Response * User: liusl * DateTime: 2024/8/22 16:31 */ public function setInterest($authorUid, Request $request) { [$status] = $request->postMore([ ['status', 1] ], true); $status = $status == 1 ? 1 : 0; $uid = (int)$request->uid(); if ($authorUid == $uid) { return app('json')->fail('不能关注自己'); } $this->services->setInterest($authorUid, $uid, $status); if ($status) { return app('json')->success('关注成功'); } else { return app('json')->success('取消成功'); } } public function follow(Request $request) { $uid = (int)$request->uid(); return app('json')->success($this->services->follow($uid)); } /** * 关注/粉丝列表 * @param $type 关注:follow 粉丝:fans * @param Request $request * @return \think\Response * @throws \ReflectionException * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * User: liusl * DateTime: 2024/8/26 11:28 */ public function followList($type, Request $request) { if (!in_array($type, ['follow', 'fans'])) { return app('json')->fail('参数错误'); } $uid = (int)$request->uid(); return app('json')->success($this->services->followList($uid, $type)); } /** * 我的好友 * @param Request $request * @return \think\Response * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * User: liusl * DateTime: 2024/8/26 12:05 */ public function userFriend(Request $request) { $uid = (int)$request->uid(); return app('json')->success($this->services->userFriend($uid)); } /** * 推荐 * @param Request $request * @return Response * User: liusl * DateTime: 2024/8/26 15:18 * @throws DataNotFoundException * @throws DbException * @throws ModelNotFoundException */ public function recommendList(Request $request) { $uid = (int)$request->uid(); return app('json')->success($this->services->recommendList($uid)); } }