18c9354095
- 注入数据库、运行时配置、统一响应、文件存储和平台 AI 能力,补充业务读写工具与客户快捷操作契约。 - 移除模块内重复的组织、客户、工单、标签、技能、旧工作流、MCP 和迁移实现,将身份权限与业务主体交由宿主管理。 - 使用 libSQL 重构向量存储,并完善图片消息、访客身份、排队调度、企业微信和支持聊天页面。 - 统一 HTTP、DTO 与 WebSocket 的 snake_case 协议,补齐模块初始化、业务动作和公共载荷等回归测试。
89 lines
2.5 KiB
Go
89 lines
2.5 KiB
Go
package dashboard
|
|
|
|
import (
|
|
"code.tczkiot.com/wlw/ai-agent/internal/pkg/httpx"
|
|
"strings"
|
|
|
|
"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/dto/response"
|
|
"code.tczkiot.com/wlw/ai-agent/internal/pkg/enums"
|
|
"code.tczkiot.com/wlw/ai-agent/internal/services"
|
|
|
|
"code.tczkiot.com/wlw/ai-agent/internal/pkg/httpx/params"
|
|
"code.tczkiot.com/wlw/ai-agent/internal/pkg/i18nx"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/mlogclub/simple/web"
|
|
)
|
|
|
|
func NotificationAnyList(ctx *gin.Context) {
|
|
operator, err := services.AuthService.RequirePermission(ctx, constants.PermissionNotificationView)
|
|
if err != nil {
|
|
httpx.WriteJSON(ctx, err)
|
|
return
|
|
}
|
|
|
|
cnd := params.NewPagedSqlCnd(ctx,
|
|
params.QueryFilter{ParamName: "type", ColumnName: "notification_type"},
|
|
).Eq("recipient_user_id", operator.UserID).
|
|
Eq("status", enums.StatusOk).
|
|
Desc("id")
|
|
|
|
switch strings.TrimSpace(ctx.Query("read_status")) {
|
|
case "unread":
|
|
cnd.Where("read_at IS NULL")
|
|
case "read":
|
|
cnd.Where("read_at IS NOT NULL")
|
|
}
|
|
|
|
list, paging := services.NotificationService.FindPageByCnd(cnd)
|
|
httpx.WriteJSON(ctx, &web.PageResult{
|
|
Results: builders.BuildNotificationListWithLocale(list, i18nx.Locale(ctx)),
|
|
Page: paging,
|
|
})
|
|
}
|
|
|
|
func NotificationGetUnread_count(ctx *gin.Context) {
|
|
operator, err := services.AuthService.RequirePermission(ctx, constants.PermissionNotificationView)
|
|
if err != nil {
|
|
httpx.WriteJSON(ctx, err)
|
|
return
|
|
}
|
|
httpx.WriteJSON(ctx, &response.NotificationUnreadCountResponse{
|
|
UnreadCount: services.NotificationService.CountUnread(operator.UserID),
|
|
})
|
|
}
|
|
|
|
func NotificationPostMark_read(ctx *gin.Context) {
|
|
operator, err := services.AuthService.RequirePermission(ctx, constants.PermissionNotificationUpdate)
|
|
if err != nil {
|
|
httpx.WriteJSON(ctx, err)
|
|
return
|
|
}
|
|
req := request.MarkNotificationReadRequest{}
|
|
if err := params.ReadJSON(ctx, &req); err != nil {
|
|
httpx.WriteJSON(ctx, err)
|
|
return
|
|
}
|
|
if err := services.NotificationService.MarkRead(req.ID, operator.UserID); err != nil {
|
|
httpx.WriteJSON(ctx, err)
|
|
return
|
|
}
|
|
httpx.WriteJSON(ctx, nil)
|
|
}
|
|
|
|
func NotificationPostMark_all_read(ctx *gin.Context) {
|
|
operator, err := services.AuthService.RequirePermission(ctx, constants.PermissionNotificationUpdate)
|
|
if err != nil {
|
|
httpx.WriteJSON(ctx, err)
|
|
return
|
|
}
|
|
if err := services.NotificationService.MarkAllRead(operator.UserID); err != nil {
|
|
httpx.WriteJSON(ctx, err)
|
|
return
|
|
}
|
|
httpx.WriteJSON(ctx, nil)
|
|
}
|