From f89e694fd040b7649127edddea8158e52c0c64ce Mon Sep 17 00:00:00 2001 From: yml2213 Date: Fri, 29 May 2026 13:26:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=BF=AB=E6=8D=B7=E5=9B=9E?= =?UTF-8?q?=E5=A4=8D=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/internal/modules/chat/dto.go | 1 + backend/internal/modules/chat/repository.go | 14 ++++-- backend/internal/modules/chat/service.go | 2 + frontend/src/api/chats.ts | 3 +- frontend/src/layouts/AdminLayout.vue | 12 +++++ frontend/src/views/admin/AdminChatsView.vue | 13 ++++- .../admin/components/QuickReplyDialog.vue | 48 +++++++++++++++---- 7 files changed, 78 insertions(+), 15 deletions(-) diff --git a/backend/internal/modules/chat/dto.go b/backend/internal/modules/chat/dto.go index e7aa2a9..9b924f6 100644 --- a/backend/internal/modules/chat/dto.go +++ b/backend/internal/modules/chat/dto.go @@ -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 { diff --git a/backend/internal/modules/chat/repository.go b/backend/internal/modules/chat/repository.go index 3d48f5a..5920cf0 100644 --- a/backend/internal/modules/chat/repository.go +++ b/backend/internal/modules/chat/repository.go @@ -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 } diff --git a/backend/internal/modules/chat/service.go b/backend/internal/modules/chat/service.go index 1b51d5a..5f187a5 100644 --- a/backend/internal/modules/chat/service.go +++ b/backend/internal/modules/chat/service.go @@ -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 } diff --git a/frontend/src/api/chats.ts b/frontend/src/api/chats.ts index 93baa2d..0fa92de 100644 --- a/frontend/src/api/chats.ts +++ b/frontend/src/api/chats.ts @@ -156,11 +156,12 @@ export async function fetchQuickReplies() { return data.data } -export async function createQuickReply(title: string, content: string, sortOrder = 0) { +export async function createQuickReply(title: string, content: string, sortOrder = 0, isGlobal = false) { const { data } = await apiClient.post>('/admin/chats/quick-replies', { title, content, sort_order: sortOrder, + is_global: isGlobal, }) return data.data } diff --git a/frontend/src/layouts/AdminLayout.vue b/frontend/src/layouts/AdminLayout.vue index bfeb21d..18c464c 100644 --- a/frontend/src/layouts/AdminLayout.vue +++ b/frontend/src/layouts/AdminLayout.vue @@ -133,12 +133,16 @@ async function handleLogout() {