AI 1 месяц назад
Родитель
Сommit
5d7633ca53
2 измененных файлов с 26 добавлено и 4 удалено
  1. 25 3
      app/JsonRpc/NewsService.php
  2. 1 1
      app/Model/jobHunting.php

+ 25 - 3
app/JsonRpc/NewsService.php

@@ -185,6 +185,7 @@ class NewsService implements NewsServiceInterface
         unset($data['user_id']);
 
         $where = [];
+        $status1 = [];
 
         if (isset($data['title']) && $data['title']) {
             array_push($where, ['article.title', 'like', '%' . $data['title'] . '%']);
@@ -201,6 +202,9 @@ class NewsService implements NewsServiceInterface
         if (isset($data['status']) && $data['status'] !== "") {
             array_push($where, ['article.status', '=', $data['status']]);
         }
+        if (isset($data['status1'])) {
+            $status1 = json_decode(($data['status1']));
+        }
         //不是管理员展示个人数据;
         if ($type_id != 10000) {
             $where[] = ['article.admin_user_id', '=', $user_id];
@@ -208,12 +212,22 @@ class NewsService implements NewsServiceInterface
 
         $rep = Article::where($where)
             ->whereNotIn('article.status', [404])
+            ->when($status1, function ($query) use ($status1) {
+                if (isset($status1) && $status1) {
+                    $query->whereIn('article.status', $status1);
+                }
+            })
             ->leftJoin('category', 'article.catid', 'category.id')
             ->select("article.*", "category.name as category_name")
             ->orderBy("article.id", "desc")
             ->limit($data['pageSize'])
             ->offset(($data['page'] - 1) * $data['pageSize'])->get();
         $count = Article::where($where)->whereNotIn('article.status', [404])
+            ->when($status1, function ($query) use ($status1) {
+                if (isset($status1) && $status1) {
+                    $query->whereIn('article.status', $status1);
+                }
+            })
             ->leftJoin('category', 'article.catid', 'category.id')->count();
         $data = [
             'rows' => $rep->toArray(),
@@ -1044,15 +1058,23 @@ class NewsService implements NewsServiceInterface
 
             $where[] = ['name', 'like', '%' . $data['name'] . '%'];
         }
-        $result = JobHunting::where($where)->
-            orderBy("updated_at", "desc")
+        $result = JobHunting::where($where)
+            ->leftJoin('user', 'user.id', '=', 'job_hunting.user_id')
+            ->leftJoin('website', 'website.id', '=', 'job_hunting.website_id')
+            ->select('job_hunting.*', 'user.nickname as nickname', 'user.user_name as username', 'website.website_name as website_name')
+            ->orderBy("updated_at", "desc")
             ->limit($data['page_size'])
             ->offset(($data['page'] - 1) * $data['page_size'])
             ->get();
         if (empty($result)) {
             return Result::error("查询失败", 0);
         }
-        return Result::success($result);
+        $count = JobHunting::where($where)->count();
+        $data = [
+            'rows' => $result->toArray(),
+            'count' => $count,
+        ];
+        return Result::success($data);
     }
     public function addJobHunting(array $data): array
     {

+ 1 - 1
app/Model/jobHunting.php

@@ -18,7 +18,7 @@ class jobHunting extends Model
     /**
      * The attributes that are mass assignable.
      */
-    protected array $fillable = [];
+    protected array $guarded = [];
 
     /**
      * The attributes that should be cast to native types.