Просмотр исходного кода

修改验证关键词的接口

FengR 2 месяцев назад
Родитель
Сommit
66eb9a837e
1 измененных файлов с 9 добавлено и 4 удалено
  1. 9 4
      app/JsonRpc/PublicRpcService.php

+ 9 - 4
app/JsonRpc/PublicRpcService.php

@@ -4373,27 +4373,32 @@ class PublicRpcService implements PublicRpcServiceInterface
      */
     public function checkRepeatKeyword(array $data): array
     {
-        
         if(empty($data['keyword'])){
             return Result::error('关键词不能为空!');
         }
-        $keyword = explode(',',$data['keyword']);
+        $keyword = json_decode($data['keyword'],true);
+        $keyword = array_map('trim', $keyword);
         // $keyword_list = array_column($keyword,'keyword');
         if(count($keyword) != count(array_unique($keyword))){
             return Result::error('关键词不能重复!');
         }
-        $keyword = '['.$data['keyword'].']';
+        // return Result::success(json_encode($keyword,JSON_UNESCAPED_UNICODE));
+        $keyword = json_encode($keyword, JSON_UNESCAPED_UNICODE);
+        
         if($data['type'] == 'style'){
             $template_class_keyword = TemplateClass::pluck('keyword')->toArray();
+            $keyword = preg_replace('/,/', ', ', $keyword);
             if(in_array($keyword,$template_class_keyword)){
                 return Result::error('此风格关键词已存在!');
             }
         }
         if($data['type'] == 'skin'){
             $template_keyword = Template::pluck('template_keyword')->toArray();
+            $keyword = preg_replace('/,/', ', ', $keyword);
             if(in_array($keyword,$template_keyword)){
                 return Result::error('此皮肤关键词已存在!');
             }
+            return Result::success(['关键词'=>$keyword,'type'=>$template_keyword]);
         }
         if($data['type'] == 'sector'){
             $sector_keyword = Sector::where('template_id',$data['template_id'])->pluck('sector_keyword')->toArray();
@@ -4409,7 +4414,7 @@ class PublicRpcService implements PublicRpcServiceInterface
         }
         
         
-        return Result::success($data);
+        return Result::success(['验证通过']);
     }
     /**
      * 自助建站-验证网站模板相关类型