rkljw 3 月之前
父節點
當前提交
d5c955c258
共有 2 個文件被更改,包括 27 次插入0 次删除
  1. 21 0
      app/JsonRpc/NewsService.php
  2. 6 0
      app/JsonRpc/NewsServiceInterface.php

+ 21 - 0
app/JsonRpc/NewsService.php

@@ -619,4 +619,25 @@ class NewsService implements NewsServiceInterface
         }
         return Result::error("参数必填!");
     }
+
+    /**
+     * 验证导航名称是否重复
+     * @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

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