From 71c7d886cf444dd2dda92b8515491bf3ba423d61 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Tue, 25 Nov 2025 15:39:16 +0800 Subject: [PATCH] =?UTF-8?q?=E7=82=B9=E8=B5=9E=EF=BC=8C=E6=94=B6=E8=97=8F?= =?UTF-8?q?=EF=BC=8C=E6=B6=88=E6=81=AF=EF=BC=8C=E5=88=86=E7=B1=BB=E5=9B=BE?= =?UTF-8?q?=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/MessageNoticeController.php | 33 ++++++ .../controller/PostCategoryController.php | 5 + .../controller/PostFavoriteController.php | 33 ++++++ app/admin/controller/PostLikeController.php | 33 ++++++ .../controller/MessageNoticeController.php | 59 ++++++++++ .../controller/PostCategoryController.php | 21 ++-- .../controller/PostFavoriteController.php | 53 +++++++++ app/common/controller/PostLikeController.php | 53 +++++++++ app/common/controller/UserController.php | 64 ++++------ app/common/logic/MessageNoticeLogic.php | 17 +++ app/common/logic/PostFavoriteLogic.php | 17 +++ app/common/logic/PostLikeLogic.php | 17 +++ app/common/model/MessageNotice.php | 49 ++++++++ app/common/model/PostCategory.php | 2 +- app/common/model/PostFavorite.php | 49 ++++++++ app/common/model/PostLike.php | 49 ++++++++ app/common/service/MessageNoticeService.php | 92 +++++++++++++++ app/common/service/PostFavoriteService.php | 107 +++++++++++++++++ app/common/service/PostLikeService.php | 109 ++++++++++++++++++ app/common/service/UserService.php | 45 +++++++- app/common/service/WechatService.php | 55 +++++++++ app/common/validate/MessageNoticeValidate.php | 29 +++++ app/common/validate/PostFavoriteValidate.php | 29 +++++ app/common/validate/PostLikeValidate.php | 29 +++++ app/controller/IndexController.php | 14 +-- config/route.php | 71 +++++++++--- 26 files changed, 1055 insertions(+), 79 deletions(-) create mode 100644 app/admin/controller/MessageNoticeController.php create mode 100644 app/admin/controller/PostFavoriteController.php create mode 100644 app/admin/controller/PostLikeController.php create mode 100644 app/common/controller/MessageNoticeController.php create mode 100644 app/common/controller/PostFavoriteController.php create mode 100644 app/common/controller/PostLikeController.php create mode 100644 app/common/logic/MessageNoticeLogic.php create mode 100644 app/common/logic/PostFavoriteLogic.php create mode 100644 app/common/logic/PostLikeLogic.php create mode 100644 app/common/model/MessageNotice.php create mode 100644 app/common/model/PostFavorite.php create mode 100644 app/common/model/PostLike.php create mode 100644 app/common/service/MessageNoticeService.php create mode 100644 app/common/service/PostFavoriteService.php create mode 100644 app/common/service/PostLikeService.php create mode 100644 app/common/validate/MessageNoticeValidate.php create mode 100644 app/common/validate/PostFavoriteValidate.php create mode 100644 app/common/validate/PostLikeValidate.php diff --git a/app/admin/controller/MessageNoticeController.php b/app/admin/controller/MessageNoticeController.php new file mode 100644 index 0000000..c230675 --- /dev/null +++ b/app/admin/controller/MessageNoticeController.php @@ -0,0 +1,33 @@ +service = new MessageNoticeService(); + } + + /** + * 列表页数据格式化 + * + * @param array $data + * @return array + */ + // protected function indexFormat($data) + // { + // if (isset($data['created_at'])) + // $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); + // if (isset($data['updated_at'])) + // $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); + // return $data; + // } +} \ No newline at end of file diff --git a/app/admin/controller/PostCategoryController.php b/app/admin/controller/PostCategoryController.php index ff15e6c..c64fb4c 100644 --- a/app/admin/controller/PostCategoryController.php +++ b/app/admin/controller/PostCategoryController.php @@ -2,6 +2,7 @@ namespace app\admin\controller; use app\common\controller\BaseController; +use app\common\service\OssService; use app\common\traits\crud\CrudControllerTrait; use app\common\service\PostCategoryService; use support\Request; @@ -46,6 +47,10 @@ class PostCategoryController extends BaseController $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); if (isset($data['updated_at'])) $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); + if (!empty($data['icon'])){ + $ossservice = new OssService(); + $data['icon_pull'] = $ossservice->generatePrivateUrl($data['icon']); + } return $data; } } \ No newline at end of file diff --git a/app/admin/controller/PostFavoriteController.php b/app/admin/controller/PostFavoriteController.php new file mode 100644 index 0000000..6ee2d24 --- /dev/null +++ b/app/admin/controller/PostFavoriteController.php @@ -0,0 +1,33 @@ +service = new PostFavoriteService(); + } + + /** + * 列表页数据格式化 + * + * @param array $data + * @return array + */ + // protected function indexFormat($data) + // { + // if (isset($data['created_at'])) + // $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); + // if (isset($data['updated_at'])) + // $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); + // return $data; + // } +} \ No newline at end of file diff --git a/app/admin/controller/PostLikeController.php b/app/admin/controller/PostLikeController.php new file mode 100644 index 0000000..40bff67 --- /dev/null +++ b/app/admin/controller/PostLikeController.php @@ -0,0 +1,33 @@ +service = new PostLikeService(); + } + + /** + * 列表页数据格式化 + * + * @param array $data + * @return array + */ + // protected function indexFormat($data) + // { + // if (isset($data['created_at'])) + // $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); + // if (isset($data['updated_at'])) + // $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); + // return $data; + // } +} \ No newline at end of file diff --git a/app/common/controller/MessageNoticeController.php b/app/common/controller/MessageNoticeController.php new file mode 100644 index 0000000..1ed13cd --- /dev/null +++ b/app/common/controller/MessageNoticeController.php @@ -0,0 +1,59 @@ +service = new MessageNoticeService(); + } + + /** + * 获取列表 + * + * @param Request $request 请求对象 + * @return mixed 返回分页数据及总数 + */ + public function index(Request $request) + { + try { + $raw = $this->service->serviceSelfList($request); + $data = $this->transformData($raw, method_exists($this, 'indexFormat') + ? [$this, 'indexFormat'] + : null); + return $this->success($data); + } catch (\Throwable $e) { + return $this->error($e->getMessage()); + } + } + + /** + * 列表页数据格式化 + * + * @param array $data + * @return array + */ + protected function indexFormat($data) + { + if (isset($data['created_at'])) + $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); + if (isset($data['updated_at'])) + $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); + if (isset($data['post_id'])){ + $data['post'] = Post::where('id', $data['post_id'])->first(); + $data['post']['media'] = PostMedia::where('post_id', $data['post_id'])->get(); + } + return $data; + } +} \ No newline at end of file diff --git a/app/common/controller/PostCategoryController.php b/app/common/controller/PostCategoryController.php index a0fa71b..c1e4755 100644 --- a/app/common/controller/PostCategoryController.php +++ b/app/common/controller/PostCategoryController.php @@ -2,6 +2,7 @@ namespace app\common\controller; use app\common\controller\BaseController; +use app\common\service\OssService; use app\common\traits\crud\CrudControllerTrait; use app\common\service\PostCategoryService; @@ -22,12 +23,16 @@ class PostCategoryController extends BaseController * @param array $data * @return array */ - // protected function indexFormat($data) - // { - // if (isset($data['created_at'])) - // $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); - // if (isset($data['updated_at'])) - // $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); - // return $data; - // } + protected function indexFormat($data) + { + if (isset($data['created_at'])) + $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); + if (isset($data['updated_at'])) + $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); + if (!empty($data['icon'])){ + $ossservice = new OssService(); + $data['icon_pull'] = $ossservice->generatePrivateUrl($data['icon']); + } + return $data; + } } \ No newline at end of file diff --git a/app/common/controller/PostFavoriteController.php b/app/common/controller/PostFavoriteController.php new file mode 100644 index 0000000..27f0e6e --- /dev/null +++ b/app/common/controller/PostFavoriteController.php @@ -0,0 +1,53 @@ +service = new PostFavoriteService(); + } + + /** + * 获取列表 + * + * @param Request $request 请求对象 + * @return mixed 返回分页数据及总数 + */ + public function index(Request $request) + { + try { + $raw = $this->service->serviceSelfList($request); + $data = $this->transformData($raw, method_exists($this, 'indexFormat') + ? [$this, 'indexFormat'] + : null); + return $this->success($data); + } catch (\Throwable $e) { + return $this->error($e->getMessage()); + } + } + + /** + * 列表页数据格式化 + * + * @param array $data + * @return array + */ + protected function indexFormat($data) + { + if (isset($data['created_at'])) + $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); + if (isset($data['updated_at'])) + $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); + return $data; + } +} \ No newline at end of file diff --git a/app/common/controller/PostLikeController.php b/app/common/controller/PostLikeController.php new file mode 100644 index 0000000..ceea299 --- /dev/null +++ b/app/common/controller/PostLikeController.php @@ -0,0 +1,53 @@ +service = new PostLikeService(); + } + + /** + * 获取列表 + * + * @param Request $request 请求对象 + * @return mixed 返回分页数据及总数 + */ + public function index(Request $request) + { + try { + $raw = $this->service->serviceSelfList($request); + $data = $this->transformData($raw, method_exists($this, 'indexFormat') + ? [$this, 'indexFormat'] + : null); + return $this->success($data); + } catch (\Throwable $e) { + return $this->error($e->getMessage()); + } + } + + /** + * 列表页数据格式化 + * + * @param array $data + * @return array + */ + protected function indexFormat($data) + { + if (isset($data['created_at'])) + $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); + if (isset($data['updated_at'])) + $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); + return $data; + } +} \ No newline at end of file diff --git a/app/common/controller/UserController.php b/app/common/controller/UserController.php index 6146a03..c7a20c7 100644 --- a/app/common/controller/UserController.php +++ b/app/common/controller/UserController.php @@ -7,6 +7,7 @@ use app\common\traits\crud\CrudControllerTrait; use app\common\service\UserService; use app\common\service\WechatService; use support\Request; +use support\Response; class UserController extends BaseController { @@ -143,51 +144,30 @@ class UserController extends BaseController - - public function wechatLogin1($request) + /** + * 小程序登录 + */ + public function miniappLogin(Request $request): Response { - $loginCode = $request->post('login_code'); - $phoneCode = $request->post('phone_code'); - - if (!$loginCode || !$phoneCode) { - return json(['code'=>0, 'msg'=>'缺少参数']); + try { + $result = $this->service->miniappLogin($request->all()); + return $this->success($result); + } catch (\Throwable $th) { + return $this->error($th->getMessage()); } + } - // 1) code2Session - $session = $this->code2Session($loginCode); - if (!isset($session['openid'])) { - return json(['code'=>0, 'msg'=>'登录失败', 'data'=>$session]); + + /** + * 获取手机号 + */ + public function miniappPhoneNumber(Request $request): Response + { + try { + $result = $this->service->miniappPhoneNumber($request->all()); + return $this->success($result); + } catch (\Throwable $th) { + return $this->error($th->getMessage()); } - - $openid = $session['openid']; - - // 2) access_token - $tokenData = $this->getAccessToken(); - $token = $tokenData['access_token']; - - // 3) 换手机号 - $phoneData = $this->getPhoneNumber($token, $phoneCode); - - if (!isset($phoneData['phone_info']['phoneNumber'])) { - return json(['code'=>0, 'msg'=>'获取手机号失败', 'data'=>$phoneData]); - } - - $phone = $phoneData['phone_info']['phoneNumber']; - - // 4) 写入数据库或登录逻辑 - // 比如自动注册 - $user = User::firstOrCreate(['openid'=>$openid], [ - 'phone' => $phone - ]); - - return json([ - 'code' => 1, - 'msg' => '登录成功', - 'data' => [ - 'openid' => $openid, - 'phone' => $phone, - 'token' => md5($openid.time()), // 你自己的登录 token - ] - ]); } } \ No newline at end of file diff --git a/app/common/logic/MessageNoticeLogic.php b/app/common/logic/MessageNoticeLogic.php new file mode 100644 index 0000000..50fa17c --- /dev/null +++ b/app/common/logic/MessageNoticeLogic.php @@ -0,0 +1,17 @@ +validator; + } + + /** 分页列表 */ + public function serviceSelfList(Request $request, string $scene = 'self') + { + $result = $this->cqyProcess(ucfirst($scene), $request); + if ($result === false) { + $config = $this->buildQueryConfig($request, $scene); + $limit = (int)$request->get('size', 15); + $page = (int)$request->get('current', 1); + $result = $this->logicList($config, $limit, $page); + } + return $this->postProcess(ucfirst($scene), $result); + } + + /** + * 构造 CrudUtil 查询配置 + */ + protected function buildQueryConfig(Request $request, string $scene = 'default'): array + { + $p = $request->all(); + + $config = []; + $config['model'] = $this->modelClass; + switch ($scene) { + case 'default': + $config['order']['id'] = 'desc'; + break; + case 'self': + $config['where']['receiver_user_id'] = $request->user->uid; + $config['order']['id'] = 'desc'; + break; + case 'index': + $config['order']['id'] = 'desc'; + break; + case 'show': + $config['where']['id'] = $p['id']; + $config['where']['status'] = 1; + break; + case 'store': + break; + case 'update': + $config['where']['id'] = $p['id']; + break; + case 'destroy': + $config['where']['id'] = $p['id']; + break; + } + + return $config; + } + + + /** + * 添加后置处理 + */ + public function beforeServiceSelf($data, Request $request) + { + MessageNotice::where('receiver_user_id', $request->user->uid)->update(['is_read' => 1]); + return $data; + } +} \ No newline at end of file diff --git a/app/common/service/PostFavoriteService.php b/app/common/service/PostFavoriteService.php new file mode 100644 index 0000000..e725fba --- /dev/null +++ b/app/common/service/PostFavoriteService.php @@ -0,0 +1,107 @@ +validator; + } + + /** 分页列表 */ + public function serviceSelfList(Request $request, string $scene = 'self') + { + $result = $this->cqyProcess(ucfirst($scene), $request); + if ($result === false) { + $config = $this->buildQueryConfig($request, $scene); + $limit = (int)$request->get('size', 15); + $page = (int)$request->get('current', 1); + $result = $this->logicList($config, $limit, $page); + } + return $this->postProcess(ucfirst($scene), $result); + } + + /** + * 构造 CrudUtil 查询配置 + */ + protected function buildQueryConfig(Request $request, string $scene = 'default'): array + { + $p = $request->all(); + + $config = []; + $config['model'] = $this->modelClass; + switch ($scene) { + case 'default': + $config['order']['id'] = 'desc'; + break; + case 'self': + $config['where']['user_id'] = $request->user->uid; + $config['order']['id'] = 'desc'; + break; + case 'index': + $config['order']['id'] = 'desc'; + break; + case 'show': + $config['where']['id'] = $p['id']; + $config['where']['status'] = 1; + break; + case 'store': + break; + case 'update': + $config['where']['id'] = $p['id']; + break; + case 'destroy': + $config['where']['id'] = $p['id']; + break; + } + + return $config; + } + + + /** + * 添加前置处理 + */ + public function beforeServiceStore($data, Request $request) + { + $data['user_id'] = $request->user->uid;; + return $data; + } + + /** + * 添加后置处理 + */ + public function afterServiceStore($res) + { + $data = []; + $data['post_id'] = $res['post_id']; + $data['receiver_user_id'] = Post::where(['id' => $data['post_id']])->value('user_id'); + $data['sender_user_id'] = $res['user_id']; + $data['type'] = 2; + MessageNotice::create($data); + } +} \ No newline at end of file diff --git a/app/common/service/PostLikeService.php b/app/common/service/PostLikeService.php new file mode 100644 index 0000000..6842bbb --- /dev/null +++ b/app/common/service/PostLikeService.php @@ -0,0 +1,109 @@ +validator; + } + + /** 分页列表 */ + public function serviceSelfList(Request $request, string $scene = 'self') + { + $result = $this->cqyProcess(ucfirst($scene), $request); + if ($result === false) { + $config = $this->buildQueryConfig($request, $scene); + $limit = (int)$request->get('size', 15); + $page = (int)$request->get('current', 1); + $result = $this->logicList($config, $limit, $page); + } + return $this->postProcess(ucfirst($scene), $result); + } + + /** + * 构造 CrudUtil 查询配置 + */ + protected function buildQueryConfig(Request $request, string $scene = 'default'): array + { + $p = $request->all(); + + $config = []; + $config['model'] = $this->modelClass; + switch ($scene) { + case 'default': + $config['order']['id'] = 'desc'; + break; + case 'self': + $config['where']['user_id'] = $request->user->uid; + $config['order']['id'] = 'desc'; + break; + case 'index': + $config['order']['id'] = 'desc'; + break; + case 'show': + $config['where']['id'] = $p['id']; + $config['where']['status'] = 1; + break; + case 'store': + break; + case 'update': + $config['where']['id'] = $p['id']; + break; + case 'destroy': + $config['where']['id'] = $p['id']; + break; + } + + return $config; + } + + + /** + * 添加前置处理 + */ + public function beforeServiceStore($data, Request $request) + { + $data['user_id'] = $request->user->uid;; + return $data; + } + + /** + * 添加后置处理 + */ + public function afterServiceStore($res) + { + $data = []; + $data['post_id'] = $res['post_id']; + $data['receiver_user_id'] = Post::where(['id' => $data['post_id']])->value('user_id'); + $data['sender_user_id'] = $res['user_id']; + $data['type'] = 1; + MessageNotice::create($data); + } +} \ No newline at end of file diff --git a/app/common/service/UserService.php b/app/common/service/UserService.php index 786da49..be071c8 100644 --- a/app/common/service/UserService.php +++ b/app/common/service/UserService.php @@ -3,7 +3,6 @@ namespace app\common\service; use app\common\logic\AuthLogic; -use app\common\model\Corp; use app\common\validate\UserValidate; use app\common\traits\crud\CrudServiceTrait; use app\common\model\User; @@ -178,7 +177,7 @@ class UserService /** - * 获取微信小程序用户信息 + * 获取微信小程序用户信息(登录及获取手机号) */ public function wechatLogin(string $loginCode, string $phoneCode) { @@ -228,4 +227,46 @@ class UserService $refreshToken = (new AuthLogic())->generateRefreshToken($user->id, 'info'); return array_merge($user->toArray(), ['access_token' => $token, 'is_bind' => true, 'refresh_token'=> $refreshToken, 'expires_in' => config('jwt.jwt_expiration')]); } + + + /** + * 小程序登录 + */ + public function miniappLogin(array $data) + { + $logic = new UserLogic(); + $wechatService = new WechatService(); + $wxinfo = $wechatService->xcxOpenid($data['code']); + + // 用户信息 + $user = User::firstOrCreate( + ['openid' => $wxinfo['openid']], + ['nickname' => '微信用户_'.$wxinfo['openid'], 'avatar' => getenv('MAIN_DOMAIN').'/avatar.png'] + ); + + + $jwt = new Jwt(); + $JwtPayload = $logic->buildJwtPayload($user); + $JwtPayload['exp'] = $JwtPayload['exp'] + (86400 * 30); + $token = $jwt->generateToken($JwtPayload); + $refreshToken = (new AuthLogic())->generateRefreshToken($user->id, 'info'); + + return array_merge($user->toArray(), ['token' => $token, 'is_bind' => true, 'refresh_token'=> $refreshToken, 'expires_in' => config('jwt.jwt_expiration')]); + } + + /** + * 获取手机号 + */ + public function miniappPhoneNumber(array $data) + { + // 手机号 + $wechatService = new WechatService(); + $wxinfo = $wechatService->xcxPhoneNumber($data['phone_code']); + + $uinfo = User::where('id', $data['user_id'])->first(); + $uinfo->phone = $wxinfo['phone_info']['phoneNumber']; + $uinfo->save(); + + return $wxinfo; + } } \ No newline at end of file diff --git a/app/common/service/WechatService.php b/app/common/service/WechatService.php index 4883a1b..f9517f8 100644 --- a/app/common/service/WechatService.php +++ b/app/common/service/WechatService.php @@ -4,6 +4,7 @@ namespace app\common\service; use app\common\model\User; +use EasyWeChat\MiniApp\Application as xcxApplication; use EasyWeChat\OpenPlatform\Application; use support\Redis; use GuzzleHttp\Client; @@ -178,4 +179,58 @@ class WechatService return json_decode(file_get_contents($url, false, stream_context_create($options)), true); } + + /** + * 小程序获取openid + * @param string $code + * @return array + * @throws BusinessException + */ + public function xcxOpenid(string $code): array + { + + $config = [ + 'app_id' => getenv('WECHAT_MINI_APPID'), + 'secret' => getenv('WECHAT_MINI_SECRET'), + 'response_type' => 'array', + 'log' => [ + 'level' => 'debug', + 'file' => runtime_path().'/mzl/wechat.log', + ] + ]; + // 创建微信小程序对象 + $wechat = new xcxApplication($config); + // 获取 session_key 和 openid + return $wechat->getUtils()->codeToSession($code); + } + + /** + * 小程序获取手机号 + * @param string $phone_code + * @return mixed + * @throws BusinessException + */ + public function xcxPhoneNumber(string $phone_code) + { + $config = [ + 'app_id' => getenv('WECHAT_MINI_APPID'), + 'secret' => getenv('WECHAT_MINI_SECRET'), + 'response_type' => 'array', + 'log' => [ + 'level' => 'debug', + 'file' => runtime_path().'/mzl/wechat.log', + ] + ]; + // 创建微信小程序对象 + $wechat = new xcxApplication($config); + // getPhoneNumber + $data = ['code' => $phone_code]; + $result = $wechat->getClient()->postJson('wxa/business/getuserphonenumber', $data); + if (isset($result['phone_info'])) { + // 业务处理 $result['phone_info']['phoneNumber'] + return $result; + } else { + throw new BusinessException($result['errmsg']); + } + } } \ No newline at end of file diff --git a/app/common/validate/MessageNoticeValidate.php b/app/common/validate/MessageNoticeValidate.php new file mode 100644 index 0000000..ab62467 --- /dev/null +++ b/app/common/validate/MessageNoticeValidate.php @@ -0,0 +1,29 @@ + [ + + ], + + 'update' => [ + + ] + ]; +} \ No newline at end of file diff --git a/app/common/validate/PostFavoriteValidate.php b/app/common/validate/PostFavoriteValidate.php new file mode 100644 index 0000000..0660229 --- /dev/null +++ b/app/common/validate/PostFavoriteValidate.php @@ -0,0 +1,29 @@ + [ + + ], + + 'update' => [ + + ] + ]; +} \ No newline at end of file diff --git a/app/common/validate/PostLikeValidate.php b/app/common/validate/PostLikeValidate.php new file mode 100644 index 0000000..4f1af14 --- /dev/null +++ b/app/common/validate/PostLikeValidate.php @@ -0,0 +1,29 @@ + [ + + ], + + 'update' => [ + + ] + ]; +} \ No newline at end of file diff --git a/app/controller/IndexController.php b/app/controller/IndexController.php index ea744d4..b71dae0 100644 --- a/app/controller/IndexController.php +++ b/app/controller/IndexController.php @@ -26,26 +26,26 @@ class IndexController { $options = [ 'controller' => [ - 'module' => 'common', - 'name' => 'agreement' + 'module' => 'admin', + 'name' => 'message_notice' ], 'model' => [ 'module' => 'common', - 'name' => 'agreement' + 'name' => 'message_notice' ], 'service' => [ 'module' => 'common', - 'name' => 'agreement' + 'name' => 'message_notice' ], 'logic' => [ 'module' => 'common', - 'name' => 'agreement' + 'name' => 'message_notice' ], 'validate' => [ 'module' => 'common', - 'name' => 'agreement' + 'name' => 'message_notice' ], - 'table' => 'agreement' + 'table' => 'message_notice' ]; $result = (new Generate($options))->doGenerate(); diff --git a/config/route.php b/config/route.php index 426eb79..ad7ed36 100644 --- a/config/route.php +++ b/config/route.php @@ -21,7 +21,11 @@ Route::any('/qrcode/url', [app\common\controller\UserController::class, 'getQrUr Route::any('/user/info', [app\common\controller\UserController::class, 'getUserInfo']); Route::any('/bind/user', [app\common\controller\UserController::class, 'bindUser']); -Route::post('/wechat/login', [app\common\controller\UserController::class, 'wechatLogin']); +//Route::post('/wechat/login', [app\common\controller\UserController::class, 'wechatLogin']); +// 登录 +Route::post('/miniapp/login', [app\common\controller\UserController::class, 'miniappLogin']); +// 手机号 +Route::post('/miniapp/phone', [app\common\controller\UserController::class, 'miniappPhoneNumber']); // 代理oss文件地址 Route::any('/proxy/ossurl', [app\common\controller\UploadController::class, 'proxy']); @@ -59,6 +63,25 @@ Route::group('/common', function () { Route::any('/store', [app\common\controller\PostCommentController::class, 'store']); Route::any('/destroy', [app\common\controller\PostCommentController::class, 'destroy']); }); + + // 点赞 + Route::group('/like', function () { + Route::any('/list', [app\common\controller\PostLikeController::class, 'index']); + Route::any('/store', [app\common\controller\PostLikeController::class, 'store']); + Route::any('/destroy', [app\common\controller\PostLikeController::class, 'destroy']); + }); + + // 收藏 + Route::group('/favorite', function () { + Route::any('/list', [app\common\controller\PostFavoriteController::class, 'index']); + Route::any('/store', [app\common\controller\PostFavoriteController::class, 'store']); + Route::any('/destroy', [app\common\controller\PostFavoriteController::class, 'destroy']); + }); + + // 消息 + Route::group('/messageNotice', function () { + Route::any('/list', [app\common\controller\MessageNoticeController::class, 'index']); + }); }); //协议 @@ -126,16 +149,6 @@ Route::group('/admin', function () { Route::any('/set/resources', [app\admin\controller\UserController::class, 'updateResources']); Route::any('/update/password', [app\admin\controller\UserController::class, 'savePassword']); }); - - // 帖子分类 - Route::group('/post/category', function () { - Route::any('/list', [app\admin\controller\PostCategoryController::class, 'index']); - Route::any('/tree', [app\admin\controller\PostCategoryController::class, 'tree']); - Route::any('/show', [app\admin\controller\PostCategoryController::class, 'show']); - Route::any('/store', [app\admin\controller\PostCategoryController::class, 'store']); - Route::any('/update', [app\admin\controller\PostCategoryController::class, 'update']); - Route::any('/destroy', [app\admin\controller\PostCategoryController::class, 'destroy']); - }); // 帖子 Route::group('/post', function () { Route::any('/list', [app\admin\controller\PostController::class, 'index']); @@ -143,15 +156,35 @@ Route::group('/admin', function () { Route::any('/store', [app\admin\controller\PostController::class, 'store']); Route::any('/update', [app\admin\controller\PostController::class, 'update']); Route::any('/destroy', [app\admin\controller\PostController::class, 'destroy']); - }); - // 评论 - Route::group('/post/comment', function () { - Route::any('/list', [app\admin\controller\PostCommentController::class, 'index']); - Route::any('/show', [app\admin\controller\PostCommentController::class, 'show']); - Route::any('/store', [app\admin\controller\PostCommentController::class, 'store']); - Route::any('/update', [app\admin\controller\PostCommentController::class, 'update']); - Route::any('/destroy', [app\admin\controller\PostCommentController::class, 'destroy']); + // 评论 + Route::group('/comment', function () { + Route::any('/list', [app\admin\controller\PostCommentController::class, 'index']); + Route::any('/show', [app\admin\controller\PostCommentController::class, 'show']); + Route::any('/store', [app\admin\controller\PostCommentController::class, 'store']); + Route::any('/update', [app\admin\controller\PostCommentController::class, 'update']); + Route::any('/destroy', [app\admin\controller\PostCommentController::class, 'destroy']); + }); + + // 帖子分类 + Route::group('/category', function () { + Route::any('/list', [app\admin\controller\PostCategoryController::class, 'index']); + Route::any('/tree', [app\admin\controller\PostCategoryController::class, 'tree']); + Route::any('/show', [app\admin\controller\PostCategoryController::class, 'show']); + Route::any('/store', [app\admin\controller\PostCategoryController::class, 'store']); + Route::any('/update', [app\admin\controller\PostCategoryController::class, 'update']); + Route::any('/destroy', [app\admin\controller\PostCategoryController::class, 'destroy']); + }); + + // 点赞 + Route::group('/like', function () { + Route::any('/list', [app\admin\controller\PostLikeController::class, 'index']); + }); + + // 收藏 + Route::group('/favorite', function () { + Route::any('/list', [app\admin\controller\PostFavoriteController::class, 'index']); + }); }); // // 分类下内容