From a92495936589666e6e0b0fd94d82607700c6e84f Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Wed, 26 Nov 2025 16:58:53 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF=EF=BC=8C?= =?UTF-8?q?=E5=B8=96=E5=AD=90=E6=8C=89=E5=B9=B4=E7=AD=9B=E9=80=89=EF=BC=8C?= =?UTF-8?q?=E6=8B=86=E5=88=86=E8=BF=94=E5=9B=9E=E5=88=9B=E5=BB=BA=E6=97=B6?= =?UTF-8?q?=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/controller/PostController.php | 6 +++++- app/common/controller/PostFavoriteController.php | 2 +- app/common/controller/PostLikeController.php | 2 +- app/common/service/PostFavoriteService.php | 2 +- app/common/service/PostLikeService.php | 2 +- app/common/service/PostService.php | 7 +++++++ app/common/service/UserService.php | 4 ++-- 7 files changed, 18 insertions(+), 7 deletions(-) diff --git a/app/common/controller/PostController.php b/app/common/controller/PostController.php index da8c281..b06bfcc 100644 --- a/app/common/controller/PostController.php +++ b/app/common/controller/PostController.php @@ -46,6 +46,10 @@ class PostController extends BaseController $record['is_like'] = PostLike::where($where)->count(); $record['is_favorite'] = PostFavorite::where($where)->count(); $record['is_comment'] = PostComment::where($where)->count(); + $created_at = strtotime($record['created_at']); + $record['year'] = date('Y', $created_at); + $record['month'] = date('m', $created_at); + $record['day'] = date('d', $created_at); } $data['records'] = $records; return $this->success($data); @@ -75,7 +79,7 @@ class PostController extends BaseController } if (isset($data['user_id'])){ $data['user'] = User::where('id', $data['user_id'])->first(); - + unset($data['user']['password']); $data['user']['avatar_pull'] = $data['user']['avatar']; if(!str_contains($data['user']['avatar'], 'http') && !empty($data['user']['avatar'])){ $data['user']['avatar_pull'] = $ossservice->generatePrivateUrl($data['user']['avatar']); diff --git a/app/common/controller/PostFavoriteController.php b/app/common/controller/PostFavoriteController.php index 93e76e6..2e75a84 100644 --- a/app/common/controller/PostFavoriteController.php +++ b/app/common/controller/PostFavoriteController.php @@ -60,7 +60,7 @@ class PostFavoriteController extends BaseController public function delete(Request $request) { try { - $count = $this->service->servicedelete($request); + $count = $this->service->serviceDelete($request); return $this->success([], "取消收藏成功"); } catch (\Throwable $e) { return $this->error($e->getMessage()); diff --git a/app/common/controller/PostLikeController.php b/app/common/controller/PostLikeController.php index 223b79b..279aa77 100644 --- a/app/common/controller/PostLikeController.php +++ b/app/common/controller/PostLikeController.php @@ -45,7 +45,7 @@ class PostLikeController extends BaseController public function delete(Request $request) { try { - $count = $this->service->servicedelete($request); + $count = $this->service->serviceDelete($request); return $this->success([], "取消点赞成功"); } catch (\Throwable $e) { return $this->error($e->getMessage()); diff --git a/app/common/service/PostFavoriteService.php b/app/common/service/PostFavoriteService.php index 2359c1f..25ec4c6 100644 --- a/app/common/service/PostFavoriteService.php +++ b/app/common/service/PostFavoriteService.php @@ -113,7 +113,7 @@ class PostFavoriteService /** * 添加后置处理 */ - public function servicedelete(Request $request) + public function serviceDelete(Request $request) { $param = $request->all(); diff --git a/app/common/service/PostLikeService.php b/app/common/service/PostLikeService.php index d2bad4b..770af9e 100644 --- a/app/common/service/PostLikeService.php +++ b/app/common/service/PostLikeService.php @@ -113,7 +113,7 @@ class PostLikeService /** * 添加后置处理 */ - public function servicedelete(Request $request) + public function serviceDelete(Request $request) { $param = $request->all(); diff --git a/app/common/service/PostService.php b/app/common/service/PostService.php index 1fbef8e..4973955 100644 --- a/app/common/service/PostService.php +++ b/app/common/service/PostService.php @@ -54,6 +54,13 @@ class PostService if (isset($p['scene']) && $p['scene']=='self') { $config['where']['user_id'] = $request->user->uid; } + if(isset($p['year']) && $p['year']){ + $from = strtotime($p['year'].'-01-01'); + $to = strtotime($p['year'].'-12-31 23:59:59'); + $config['where']['created_at'] = [ + 'between', [$from, $to] + ]; + } $config['where']['status'] = 1; $config['order']['sort'] = 'desc'; $config['order']['id'] = 'desc'; diff --git a/app/common/service/UserService.php b/app/common/service/UserService.php index 802aed2..1876859 100644 --- a/app/common/service/UserService.php +++ b/app/common/service/UserService.php @@ -103,8 +103,8 @@ class UserService 'email' => $user->email, 'nickname' => $user->nickname, 'status' => $user->status, - 'roles' => $user->roles->pluck('name'), - 'sn' => $user->sn, + 'openid' => $user->openid, + 'unionid' => $user->unionid, ], // 'menu' => $menuTree, // 'permissions' => $permissionCodes