18c9354095
- 注入数据库、运行时配置、统一响应、文件存储和平台 AI 能力,补充业务读写工具与客户快捷操作契约。 - 移除模块内重复的组织、客户、工单、标签、技能、旧工作流、MCP 和迁移实现,将身份权限与业务主体交由宿主管理。 - 使用 libSQL 重构向量存储,并完善图片消息、访客身份、排队调度、企业微信和支持聊天页面。 - 统一 HTTP、DTO 与 WebSocket 的 snake_case 协议,补齐模块初始化、业务动作和公共载荷等回归测试。
119 lines
3.4 KiB
Go
119 lines
3.4 KiB
Go
package dashboard
|
|
|
|
import (
|
|
"code.tczkiot.com/wlw/ai-agent/internal/builders"
|
|
"code.tczkiot.com/wlw/ai-agent/internal/pkg/constants"
|
|
"code.tczkiot.com/wlw/ai-agent/internal/pkg/dto/request"
|
|
"code.tczkiot.com/wlw/ai-agent/internal/pkg/enums"
|
|
"code.tczkiot.com/wlw/ai-agent/internal/pkg/httpx"
|
|
"code.tczkiot.com/wlw/ai-agent/internal/services"
|
|
|
|
"code.tczkiot.com/wlw/ai-agent/internal/pkg/httpx/params"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/mlogclub/simple/sqls"
|
|
"github.com/mlogclub/simple/web"
|
|
)
|
|
|
|
func QuickReplyAnyList(ctx *gin.Context) {
|
|
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionQuickReplyView); err != nil {
|
|
httpx.WriteJSON(ctx, err)
|
|
return
|
|
}
|
|
|
|
cnd := params.NewPagedSqlCnd(ctx,
|
|
params.QueryFilter{ParamName: "status"},
|
|
params.QueryFilter{ParamName: "group_name"},
|
|
params.QueryFilter{ParamName: "title", Op: params.Like},
|
|
).Asc("sort_no").Desc("id")
|
|
|
|
list, paging := services.QuickReplyService.FindPageByCnd(cnd)
|
|
results := builders.BuildQuickReplyResponses(list)
|
|
httpx.WriteJSON(ctx, &web.PageResult{Results: results, Page: paging})
|
|
}
|
|
|
|
func QuickReplyGetBy(ctx *gin.Context) {
|
|
id, ok := httpx.GetPathInt64(ctx, "id")
|
|
if !ok {
|
|
return
|
|
}
|
|
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionQuickReplyView); err != nil {
|
|
httpx.WriteJSON(ctx, err)
|
|
return
|
|
}
|
|
|
|
item := services.QuickReplyService.Get(id)
|
|
if item == nil {
|
|
httpx.WriteJSON(ctx, httpx.JsonErrorMsg(ctx, "error.e0203"))
|
|
return
|
|
}
|
|
httpx.WriteJSON(ctx, builders.BuildQuickReplyResponse(item))
|
|
}
|
|
|
|
func QuickReplyGetList_all(ctx *gin.Context) {
|
|
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionQuickReplyView); err != nil {
|
|
httpx.WriteJSON(ctx, err)
|
|
return
|
|
}
|
|
list := services.QuickReplyService.Find(sqls.NewCnd().Eq("status", enums.StatusOk).Asc("sort_no").Desc("id"))
|
|
results := builders.BuildQuickReplyResponses(list)
|
|
httpx.WriteJSON(ctx, results)
|
|
}
|
|
|
|
func QuickReplyPostCreate(ctx *gin.Context) {
|
|
user, err := services.AuthService.RequirePermission(ctx, constants.PermissionQuickReplyCreate)
|
|
if err != nil {
|
|
httpx.WriteJSON(ctx, err)
|
|
return
|
|
}
|
|
|
|
req := request.CreateQuickReplyRequest{}
|
|
if err := params.ReadJSON(ctx, &req); err != nil {
|
|
httpx.WriteJSON(ctx, err)
|
|
return
|
|
}
|
|
item, err := services.QuickReplyService.CreateQuickReply(req, user)
|
|
if err != nil {
|
|
httpx.WriteJSON(ctx, err)
|
|
return
|
|
}
|
|
httpx.WriteJSON(ctx, builders.BuildQuickReplyResponse(item))
|
|
}
|
|
|
|
func QuickReplyPostUpdate(ctx *gin.Context) {
|
|
user, err := services.AuthService.RequirePermission(ctx, constants.PermissionQuickReplyUpdate)
|
|
if err != nil {
|
|
httpx.WriteJSON(ctx, err)
|
|
return
|
|
}
|
|
|
|
req := request.UpdateQuickReplyRequest{}
|
|
if err := params.ReadJSON(ctx, &req); err != nil {
|
|
httpx.WriteJSON(ctx, err)
|
|
return
|
|
}
|
|
if err := services.QuickReplyService.UpdateQuickReply(req, user); err != nil {
|
|
httpx.WriteJSON(ctx, err)
|
|
return
|
|
}
|
|
httpx.WriteJSON(ctx, nil)
|
|
}
|
|
|
|
func QuickReplyPostDelete(ctx *gin.Context) {
|
|
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionQuickReplyDelete); err != nil {
|
|
httpx.WriteJSON(ctx, err)
|
|
return
|
|
}
|
|
|
|
req := request.DeleteQuickReplyRequest{}
|
|
if err := params.ReadJSON(ctx, &req); err != nil {
|
|
httpx.WriteJSON(ctx, err)
|
|
return
|
|
}
|
|
if err := services.QuickReplyService.DeleteQuickReply(req.ID); err != nil {
|
|
httpx.WriteJSON(ctx, err)
|
|
return
|
|
}
|
|
httpx.WriteJSON(ctx, nil)
|
|
}
|