Jonlin 6 년 전
부모
커밋
8d0429e5e9
3개의 변경된 파일19개의 추가작업 그리고 0개의 파일을 삭제
  1. 7 0
      application/admin/controller/Robot.php
  2. 5 0
      application/admin/controller/Sensitivec.php
  3. 7 0
      application/admin/controller/Words.php

+ 7 - 0
application/admin/controller/Robot.php

@@ -200,6 +200,7 @@ class Robot extends Base
         //获取表单上传文件
         $file = request()->file('excel');
         if(empty($file)){
+            $this->error('请先上传文件');
             return json(['code' => -4, 'data' => '', 'msg' => '请先上传文件']);
         }
 
@@ -228,13 +229,16 @@ class Robot extends Base
             //检查表中数据是否为空和重复
             for($a=0;$a<count($info);$a++){
                 if(empty($info[$a]['robot_name'])){
+                    $this->error('excel表第'.($a+2).'行智能问答问题为空');
                     return json(['code' => -3, 'data' => url('robot/index'), 'msg' => 'excel表第'.($a+2).'行智能问答问题为空']);
                 }
                 if(empty($info[$a]['robot_content'])){
+                    $this->error('excel表第'.($a+2).'行智能问答答案为空');
                     return json(['code' => -4, 'data' => url('robot/index'), 'msg' => 'excel表第'.($a+2).'行智能问答答案为空']);
                 }
                 for($b=$a+1;$b<count($info);$b++){
                     if($info[$a]['robot_name'] == $info[$b]['robot_name']){
+                        $this->error('excel表第'.($a+2).'行与第'.($b+2).'行智能问答问题重复');
                         return json(['code' => -2, 'data' => url('robot/index'), 'msg' => 'excel表第'.($a+2).'行与第'.($b+2).'行智能问答问题重复']);
                     }
                 }
@@ -244,13 +248,16 @@ class Robot extends Base
             for($i=0;$i<count($info);$i++){
                 for($j=0;$j<count($robot);$j++){
                     if($info[$i]['robot_name'] == $robot[$j]['robot_name']){
+                        $this->error('excel表第'.($i+2).'行智能问答问题已存在');
                         return json(['code' => -1, 'data' => url('robot/index'), 'msg' => 'excel表第'.($i+2).'行智能问答问题已存在']);
                     }
                 }
             }
             db('robot')->insertAll($info); //批量插入数据
+            $this->success('插入智能问答数据成功');
             return json(['code' => 1, 'data' => $this->redirect('robot/index'), 'msg' => '插入智能问答数据成功']);
         } else {
+            $this->error('插入智能问答数据失败');
             return json(['code' => -2, 'data' => url('robot/index'), 'msg' => '插入智能问答数据失败']);
         }
     }

+ 5 - 0
application/admin/controller/Sensitivec.php

@@ -206,10 +206,12 @@ class Sensitivec extends Base
             //检查表中数据是否为空和重复
             for($a=0;$a<count($info);$a++){
                 if(empty($info[$a]['sensitivewords_word'])){
+                    $this->error('excel表第'.($a+2).'行敏感词为空');
                     return json(['code' => -3, 'data' => url('sensitivec/index'), 'msg' => 'excel表第'.($a+2).'行敏感词为空']);
                 }
                 for($b=$a+1;$b<count($info);$b++){
                     if($info[$a]['sensitivewords_word'] == $info[$b]['sensitivewords_word'] && $info[$a]['sensitivewords_for'] == $info[$b]['sensitivewords_for']){
+                        $this->error('excel表第'.($a+2).'行与第'.($b+2).'行敏感词重复');
                         return json(['code' => -1, 'data' => url('sensitivec/index'), 'msg' => 'excel表第'.($a+2).'行与第'.($b+2).'行敏感词重复']);
                     }
                 }
@@ -219,13 +221,16 @@ class Sensitivec extends Base
             for($i=0;$i<count($info);$i++){
                 for($j=0;$j<count($sensitivewords);$j++){
                     if($info[$i]['sensitivewords_word'] == $sensitivewords[$j]['sensitivewords_word'] && $info[$i]['sensitivewords_for'] == $sensitivewords[$j]['sensitivewords_for']){
+                        $this->error('excel表第'.($i+2).'行敏感词已存在');
                         return json(['code' => -1, 'data' => url('sensitivec/index'), 'msg' => 'excel表第'.($i+2).'行敏感词已存在']);
                     }
                 }
             }
             db('sensitivewords')->insertAll($info); //批量插入数据
+            $this->success('插入敏感词成功');
             return json(['code' => 1, 'data' => $this->redirect('sensitivec/index'), 'msg' => '插入敏感词成功']);
         } else {
+            $this->error('插入敏感词失败');
             return json(['code' => -2, 'data' => url('sensitivec/index'), 'msg' => '插入敏感词失败']);
         }
     }

+ 7 - 0
application/admin/controller/Words.php

@@ -174,6 +174,7 @@ class Words extends Base
         //获取表单上传文件
         $file = request()->file('excel');
         if(empty($file)){
+            $this->error('请先上传文件');
             return json(['code' => -4, 'data' => '', 'msg' => '请先上传文件']);
         }
 
@@ -199,13 +200,16 @@ class Words extends Base
             //检查表中数据是否为空和重复
             for($a=0;$a<count($info);$a++){
                 if(empty($info[$a]['title'])){
+                    $this->error('excel表第'.($a+2).'行快捷词为空');
                     return json(['code' => -3, 'data' => url('words/index'), 'msg' => 'excel表第'.($a+2).'行快捷词为空']);
                 }
                 if(empty($info[$a]['content'])){
+                    $this->error('excel表第'.($a+2).'行内容为空');
                     return json(['code' => -4, 'data' => url('words/index'), 'msg' => 'excel表第'.($a+2).'行内容为空']);
                 }
                 for($b=$a+1;$b<count($info);$b++){
                     if($info[$a]['title'] == $info[$b]['title']){
+                        $this->error('excel表第'.($a+2).'行与第'.($b+2).'行快捷词重复');
                         return json(['code' => -1, 'data' => url('words/index'), 'msg' => 'excel表第'.($a+2).'行与第'.($b+2).'行快捷词重复']);
                     }
                 }
@@ -215,13 +219,16 @@ class Words extends Base
             for($i=0;$i<count($info);$i++){
                 for($j=0;$j<count($words);$j++){
                     if($info[$i]['title'] == $words[$j]['title']){
+                        $this->error('excel表第'.($i+2).'行快捷回复已存在');
                         return json(['code' => -1, 'data' => url('words/index'), 'msg' => 'excel表第'.($i+2).'行快捷回复已存在']);
                     }
                 }
             }
             db('words')->insertAll($info); //批量插入数据
+            $this->success('导入快捷回复成功');
             return json(['code' => 1, 'data' => $this->redirect('words/index'), 'msg' => '导入快捷回复成功']);
         } else {
+            $this->error('导入快捷回复失败');
             return json(['code' => -2, 'data' => url('words/index'), 'msg' => '导入快捷回复失败']);
         }
     }