Przeglądaj źródła

检测导航池名称

rkljw 1 miesiąc temu
rodzic
commit
8b11f51341

+ 24 - 0
app/Controller/NewsController.php

@@ -424,5 +424,29 @@ class NewsController extends AbstractController
         return $result['code']==200 ? Result::success($result['data']) : Result::error($result['message']);
     }
 
+    /**
+     * 检测导航池名称是否存在
+     * @return array
+     */
+    public function  checkCategoryName()
+    {
+        $requireData = $this->request->all();
+        $validator = $this->validationFactory->make(
+            $requireData,
+            [
+                'name'=> 'required',
+            ],
+            [
+                'name.required' => 'name不能为空',
+            ]
+        );
+        if ($validator->fails()) {
+            $errorMessage = $validator->errors()->first();
+            return Result::error($errorMessage);
+        }
+
+        $result = $this->newsServiceClient->checkCategoryName($requireData);
+        return $result['code']==200 ? Result::success($result['data']) : Result::error($result['message']);
+    }
 
 }

+ 9 - 0
app/JsonRpc/NewsService.php

@@ -142,6 +142,15 @@ class NewsService extends AbstractServiceClient implements NewsServiceInterface
     {
         return $this->__request(__FUNCTION__, $data);
     }
+
+    /**
+     * @param array $data
+     * @return array|mixed
+     */
+    public function checkCategoryName(array $data)
+    {
+        return $this->__request(__FUNCTION__, $data);
+    }
     
     /**
      * @param array $data

+ 9 - 0
app/JsonRpc/NewsServiceInterface.php

@@ -71,6 +71,7 @@ interface NewsServiceInterface
      */
     public function upArticleStatus(array $data);
 
+
      /**
      * @param array $data
      * @return mixed
@@ -96,4 +97,12 @@ interface NewsServiceInterface
      * @return mixed
      */
     public function addWebsiteSurveyVote(array $data);
+
+    /**
+     * @param array $data
+     * @return mixed
+     */
+    public function checkCategoryName(array $data);
+
+
 }

+ 3 - 0
config/api/news.php

@@ -33,6 +33,9 @@ Router::addGroup(
         Router::get('/getCategoryInfo', [NewsController::class, 'getCategoryInfo']);
          //前端-获取资讯列表
          Router::get('/getWebsiteArticleList', [NewsController::class, 'getWebsiteArticleList']);
+        //检测导航池名称是否存在
+        Router::post('/checkCategoryName', [NewsController::class, 'checkCategoryName']);
+
 
 },
     ['middleware' => [FooMiddleware::class]]