Explorar el Código

网站导航排序修改

rkljw hace 3 meses
padre
commit
229c1156a2
Se han modificado 1 ficheros con 13 adiciones y 13 borrados
  1. 13 13
      app/JsonRpc/WebsiteService.php

+ 13 - 13
app/JsonRpc/WebsiteService.php

@@ -1075,31 +1075,31 @@ class WebsiteService implements WebsiteServiceInterface
     public function getWebsiteCategoryList(array $data): array
     {
         $where = [];
-        if (isset($data['keyword']) && !empty($data['keyword'])) {
-            array_push($where, ['website.website_name', 'like', '%' . $data['keyword'] . '%']);
+        if(isset($data['keyword']) && !empty($data['keyword'])){
+            array_push($where,['website.website_name','like','%'.$data['keyword'].'%']);
         }
-        if (isset($data['website_column_id']) && !empty($data['website_column_id'])) {
-            array_push($where, ['website.website_column_id', '=', $data['website_column_id']]);
+        if(isset($data['website_column_id']) && !empty($data['website_column_id'])){
+            array_push($where,['website.website_column_id','=',$data['website_column_id']]);
         }
         $result = Website::where($where)
-            ->with(["websiteCategory" => function ($query) {
-                $query->where(['pid' => 0])->select('website_id', 'name', 'alias', 'category_id');
+            ->with(["websiteCategory"=>function ($query) {
+                $query->where(['pid'=>0])->select('website_id','name','alias','category_id');
             }])
-            ->limit($data['pageSize'])->offset(($data['page'] - 1) * $data['pageSize'])
+            ->limit($data['pageSize'])->orderBy("updated_at","desc")->offset(($data['page']-1)*$data['pageSize'])
             ->get();
 
         $count = Website::where($where)->count();
         if (empty($result)) {
-            return Result::error("没有数据", 0);
+            return Result::error("没有数据",0);
         }
         $data = [
-            'rows' => $result->toArray(),
-            'count' => $count
+            'rows'=>$result->toArray(),
+            'count'=>$count
         ];
-        if ($result) {
+        if($result){
             return Result::success($data);
-        } else {
-            return Result::error("查询失败", 0);
+        }else{
+            return Result::error("查询失败",0);
         }
     }