rkljw 2 månader sedan
förälder
incheckning
0348a58196
2 ändrade filer med 27 tillägg och 0 borttagningar
  1. 21 0
      app/JsonRpc/NewsService.php
  2. 6 0
      app/JsonRpc/NewsServiceInterface.php

+ 21 - 0
app/JsonRpc/NewsService.php

@@ -379,4 +379,25 @@ class NewsService implements NewsServiceInterface
         return Result::success($result);  
         
     }
+
+    /**
+     * 验证导航名称是否重复
+     * @return void
+     */
+    public function checkCategoryName(array $data): array
+    {
+        $result = Category::when($data, function ($query) use ($data) {
+            if(isset($data['name']) && $data['name']) {
+                $query->where("name", $data['name']);
+            }
+            if(isset($data['id']) && $data['id']) {
+                $query->where("id","!=" ,$data['id']);
+            }
+        })->first();
+        if($result){
+            return Result::error("已存在");
+        }else{
+            return Result::success();
+        }
+    }
 }

+ 6 - 0
app/JsonRpc/NewsServiceInterface.php

@@ -85,4 +85,10 @@ interface NewsServiceInterface
      */
     public function getWebsiteModelArticles(array $data):array;
 
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function checkCategoryName(array $data):array;
+
 }