AI hai 1 mes
pai
achega
6ba388eb85

+ 50 - 0
app/JsonRpc/ChatService.php

@@ -8,6 +8,7 @@ use App\Model\ChatRecords;
 use App\Model\ChatTopic;
 use App\Model\ChatTopicsReply;
 
+use App\Model\ChatTopicClass;
 use App\Model\User;
 use App\Tools\PublicData;
 use App\Tools\Result;
@@ -1093,4 +1094,53 @@ class ChatService implements ChatServiceInterface
             ->paginate($data['page_size'], ['*'], 'page', $data['page'] ?? 1);
         return Result::success($result);
     }
+    public function getTopicClassList(array $data): array
+    {
+        $where = [];
+        if (!empty($data['topicname'])) {
+            $where[] = ['topicname', 'like', '%' . $data['topicname'] . '%'];
+        }
+        $result = ChatTopicClass::where($where)->paginate($data['page_size'], ['*'], 'page', $data['page'] ?? 1);
+        return Result::success($result);
+    }
+    public function deleteTopicClass(array $data): array
+    {
+
+        $result = ChatTopicClass::where(['id' => $data['id']])->delete();
+        if ($result) {
+            return Result::success("删除成功");
+        }
+        return Result::error("删除失败");
+    }
+
+    public function updateTopicClass(array $data): array
+    {
+        $result = ChatTopicClass::where(['id' => $data['id']])->update([
+            'topicname' => $data['topicname'],
+        ]);
+        if ($result) {
+            return Result::success("修改成功");
+        }
+        return Result::error("修改失败");
+    }
+    public function addTopicClass(array $data): array
+    {
+        $result = ChatTopicClass::insert($data);
+
+        if ($result) {
+            return Result::success("添加成功");
+        }
+        return Result::error("添加失败");
+    }
+    /**
+     * 获取话题分类信息
+     * @param array $data
+     * @return array
+     */
+    public function getTopicClassInfo(array $data): array
+    {
+        $result = ChatTopicClass::where(['id' => $data['id']])->first();
+        return Result::success($result);
+    }
+
 }

+ 6 - 0
app/JsonRpc/ChatServiceInterface.php

@@ -217,4 +217,10 @@ interface ChatServiceInterface
 
     public function applyTopic(array $data): array;
 
+    public function getTopicClassList(array $data): array;
+    public function addTopicClass(array $data): array;
+    public function updateTopicClass(array $data): array;
+    public function deleteTopicClass(array $data): array;
+    public function getTopicClassInfo(array $data): array;
+
 }

+ 27 - 0
app/Model/ChatTopicClass.php

@@ -0,0 +1,27 @@
+<?php
+
+declare (strict_types = 1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class ChatTopicClass extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'chat_topic_class';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $fillable = [];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+}