优化快捷回复功能

This commit is contained in:
yml2213
2026-05-29 13:26:30 +08:00
parent 0f44b024cb
commit f89e694fd0
7 changed files with 78 additions and 15 deletions
+1
View File
@@ -83,6 +83,7 @@ type CreateQuickReplyRequest struct {
Title string `json:"title" binding:"required"`
Content string `json:"content" binding:"required"`
SortOrder int `json:"sort_order"`
IsGlobal bool `json:"is_global"`
}
type UpdateQuickReplyRequest struct {
+11 -3
View File
@@ -883,7 +883,11 @@ func (r *Repository) ListConversationsWithFilter(principal Principal, page, page
items := make([]ConversationDTO, 0, len(rows))
for _, row := range rows {
items = append(items, row.toDTO(nil))
participants, err := r.participants(row.ID)
if err != nil {
return nil, err
}
items = append(items, row.toDTO(participants))
}
return &PaginatedResult{Items: items, Total: total, Page: page, PageSize: pageSize}, nil
}
@@ -957,8 +961,12 @@ func (r *Repository) ListQuickReplies(adminID uint64) ([]QuickReplyDTO, error) {
// CreateQuickReply 创建快捷回复
func (r *Repository) CreateQuickReply(adminID uint64, req CreateQuickReplyRequest) (*QuickReplyDTO, error) {
ownerID := adminID
if req.IsGlobal {
ownerID = 0
}
reply := model.ChatQuickReply{
AdminUserID: adminID,
AdminUserID: ownerID,
Title: req.Title,
Content: req.Content,
SortOrder: req.SortOrder,
@@ -972,7 +980,7 @@ func (r *Repository) CreateQuickReply(adminID uint64, req CreateQuickReplyReques
Title: reply.Title,
Content: reply.Content,
SortOrder: reply.SortOrder,
IsGlobal: false,
IsGlobal: reply.AdminUserID == 0,
}, nil
}
+2
View File
@@ -161,6 +161,8 @@ func (s *Service) CreateQuickReply(adminID uint64, req CreateQuickReplyRequest)
if s.repo == nil {
return nil, ErrDependencyUnavailable
}
req.Title = strings.TrimSpace(req.Title)
req.Content = strings.TrimSpace(req.Content)
if req.Title == "" || req.Content == "" {
return nil, ErrInvalidMessage
}