|
@@ -53,6 +53,12 @@ func (ucCtrl *UserChatController) NewChat() {
|
|
|
br.ErrMsg = "创建失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
+ _ = llmService.AddChatRecord(&llm.UserChatRecordRedis{
|
|
|
+ ChatId: session.Id,
|
|
|
+ ChatUserType: "user",
|
|
|
+ Content: req.ChatTitle,
|
|
|
+ SendTime: time.Now().Format(utils.FormatDateTime),
|
|
|
+ })
|
|
|
br.Ret = 200
|
|
|
br.Success = true
|
|
|
br.Msg = "创建成功"
|
|
@@ -109,6 +115,52 @@ func (ucCtrl *UserChatController) RenameChat() {
|
|
|
br.Msg = "重命名成功"
|
|
|
}
|
|
|
|
|
|
+// DeleteChat @Title 删除对话框
|
|
|
+// @Description 删除对话框
|
|
|
+// @Success 101 {object} response.ListResp
|
|
|
+// @router /chat/delete_chat [post]
|
|
|
+func (ucCtrl *UserChatController) DeleteChat() {
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
+ defer func() {
|
|
|
+ ucCtrl.Data["json"] = br
|
|
|
+ ucCtrl.ServeJSON()
|
|
|
+ }()
|
|
|
+ var req llm_http.UserChatReq
|
|
|
+ err := json.Unmarshal(ucCtrl.Ctx.Input.RequestBody, &req)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "参数解析异常!"
|
|
|
+ br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ sysUser := ucCtrl.SysUser
|
|
|
+ if sysUser == nil {
|
|
|
+ br.Msg = "请登录"
|
|
|
+ br.ErrMsg = "请登录,SysUser Is Empty"
|
|
|
+ br.Ret = 408
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if req.ChatId <= 0 {
|
|
|
+ br.Msg = "非法的对话框Id"
|
|
|
+ br.ErrMsg = "非法的对话框Id"
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ session := llm.UserLlmChat{
|
|
|
+ Id: req.ChatId,
|
|
|
+ UpdateTime: time.Now(),
|
|
|
+ IsDeleted: 1,
|
|
|
+ }
|
|
|
+ err = session.DeleteChatSession()
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "删除失败"
|
|
|
+ br.ErrMsg = "删除失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "删除成功"
|
|
|
+}
|
|
|
+
|
|
|
// GetUserChatList @Title 获取用户对话框列表
|
|
|
// @Description 获取用户对话框列表
|
|
|
// @Success 101 {object} response.ListResp
|