Ethan před 6 roky
rodič
revize
02aa93f547

+ 31 - 0
application/service/controller/Index.php

@@ -92,6 +92,37 @@ class Index extends Common
     }//end userWords()
 
 
+    /**
+     * 获取敏感词
+     *
+     * @access public
+     * @return array JsonString
+     */
+    public function sensitiveWords()
+    {
+        // 验证token.
+        $tokenStatus = $this->verifyToken();
+        $code        = -2;
+        $msg         = '错误';
+        if ($tokenStatus === false) {
+            return json(['code' => $code, 'data' => [], 'msg' => $msg]);
+        }
+
+        try {
+            // 获取快捷语.
+            $wordsField = ['*'];
+            $sysWordsWhere['sensitivewords_status'] = 1;
+            // 查询系统快捷语.
+            $sensitiveWords = model('sensitivewords')->selectWords($wordsField, $sysWordsWhere);
+
+            return json(['code' => 200, 'data' => $sensitiveWords, 'msg' => '成功']);
+        } catch (\Exception $e) {
+            return json(['code' => $code, 'data' => [], 'msg' => $msg]);
+        }//end try
+
+    }//end userWords()
+
+
     public function index()
     {
         $getUserInfo = $this->getUserInfo();

+ 55 - 20
application/service/controller/Words.php

@@ -107,12 +107,12 @@ class Words extends Common
 
 
     /**
-     * 获取会话历史详细
+     * 快捷语修改
      *
      * @access public
      * @return array JsonString
      */
-    public function historyInfo()
+    public function deleteWords()
     {
         // 验证token.
         $tokenStatus = $this->verifyToken();
@@ -124,30 +124,65 @@ class Words extends Common
 
         try {
             // 获取用户信息.
-            $servicelogId = input('get.servicelog_id');
-            $chatLogField = ['*'];
-            // 关联信息.
-            $chatLogWhere['servicelog_id'] = $servicelogId;
-            // 分页.
-            $currentPage = input('get.currentPage', '1');
-            $pageSize    = input('get.pageSize', '10');
-            $offset      = (($currentPage - 1) * $pageSize);
-            // 获取用户信息.
-            $chatLog      = model('ChatLog')->selectChatLog($chatLogField, $offset, $pageSize, $chatLogWhere);
-            $countChatLog = model('ChatLog')->countChatLog($chatLogWhere);
+            $getUserInfo    = $this->getUserInfo();
+            $userWordsWhere = [
+                'user_id' => $getUserInfo->id,
+                'id'      => input('post.id'),
+            ];
+            $deleteResult   = model('Words')->deleteWords($userWordsWhere);
+
+            // 参数返回.
+            if (empty($deleteResult) === false) {
+                return json(['code' => 200, 'data' => [], 'msg' => '成功']);
+            } else {
+                return json(['code' => 1, 'data' => [], 'msg' => 1]);
+            }
+        } catch (\Exception $e) {
+            return json(['code' => $code, 'data' => [], 'msg' => $msg]);
+        }//end try
+
+    }//end deleteWords()
 
-            $result['total']       = $countChatLog;
-            $result['countPage']   = (ceil(($result['total']) / $pageSize));
-            $result['currentPage'] = $currentPage;
-            $result['list']        = $chatLog;
-            $result['pageSize']    = $pageSize;
 
-            return json(['code' => 200, 'data' => $result, 'msg' => '成功']);
+    /**
+     * 快捷语修改
+     *
+     * @access public
+     * @return array JsonString
+     */
+    public function addWords()
+    {
+        // 验证token.
+        $tokenStatus = $this->verifyToken();
+        $code        = -2;
+        $msg         = '错误';
+        if ($tokenStatus === false) {
+            return json(['code' => $code, 'data' => [], 'msg' => $msg]);
+        }
+
+        try {
+            // 获取用户信息.
+            $getUserInfo    = $this->getUserInfo();
+            $userWordsData = [
+                'user_id' => $getUserInfo->id,
+                'title'      => input('post.title'),
+                'content'      => input('post.content'),
+                'status'      => input('post.status'),
+                'add_time'      => date('Y-m-d H:i:s'),
+            ];
+            $deleteResult   = model('Words')->addWords($userWordsData);
+
+            // 参数返回.
+            if (empty($deleteResult) === false) {
+                return json(['code' => 200, 'data' => [], 'msg' => '成功']);
+            } else {
+                return json(['code' => 1, 'data' => [], 'msg' => 1]);
+            }
         } catch (\Exception $e) {
             return json(['code' => $code, 'data' => [], 'msg' => $msg]);
         }//end try
 
-    }//end historyInfo()
+    }//end deleteWords()
 
 
 }

+ 34 - 0
application/service/model/Sensitivewords.php

@@ -0,0 +1,34 @@
+<?php
+namespace app\service\model;
+
+use think\Model;
+
+/**
+ * 敏感词模型
+ */
+class Sensitivewords extends Model
+{
+
+
+    /**
+     * 数据筛选
+     *
+     * @access public
+     * @param mixed $field 字段
+     * @param mixed $where 条件
+     * @return array 返回类型
+     */
+    public function selectWords($field, $where=[])
+    {
+        $result = $this->field($field);
+        if (empty($where) === false) {
+            $result = $result->where($where);
+        }
+
+        $result = $result->select();
+        return $result;
+
+    }//end selectWords()
+
+
+}

+ 32 - 0
application/service/model/Words.php

@@ -48,4 +48,36 @@ class Words extends Model
     }//end updateWords()
 
 
+    /**
+     * 数据删除
+     *
+     * @access public
+     * @param mixed $where 条件
+     * @return array 返回类型
+     */
+    public function deleteWords($where)
+    {
+        $result = $this->where($where)->delete();
+
+        return $result;
+
+    }//end deleteWords()
+
+
+    /**
+     * 数据增加
+     *
+     * @access public
+     * @param mixed $data 数据
+     * @return array 返回类型
+     */
+    public function addWords($data)
+    {
+        $result = $this->insert($data);
+
+        return $result;
+
+    }//end addWords()
+
+
 }

+ 1 - 0
vendor/GatewayWorker_windows/Applications/whisper/start_gateway.php

@@ -50,6 +50,7 @@ $gateway->onConnect = function ($connection) {
         $_SESSION['origin'] = $_SERVER['HTTP_ORIGIN'];
         $getToken = isset($_GET['apiToken']) ? $_GET['apiToken'] : '';
 
+
         if ($getToken !== $apiToken) {
              //$connection->close();
             // return;