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