refactor(server): 会话/访客/设置业务逻辑下沉 internal/service 层,handler 瘦身
- handler 只保留请求绑定、权限检查与响应映射;业务校验顺序、状态码与文案逐字保留 - 新增 service.Error 语义错误,由 handler 统一映射 HTTP 响应 - session 875→361 行、widget 745→321 行、settings 540→73 行 - 自动分配/租户设置(工作时间、欢迎语)/消息校验/黑名单检查/联系方式提取随迁 service 包 - 相关单元测试随迁 service 包,go test ./... 全部通过
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"kefu-cloud/server/internal/middleware"
|
||||
"kefu-cloud/server/internal/model"
|
||||
"kefu-cloud/server/internal/service"
|
||||
)
|
||||
|
||||
// Export 导出客户列表 CSV(沿用列表筛选与坐席可见范围)。
|
||||
@@ -128,7 +129,7 @@ func (h *SessionHandler) Export(c *gin.Context) {
|
||||
customerMap := map[uint]model.Customer{}
|
||||
if len(customerIDs) > 0 {
|
||||
var customers []model.Customer
|
||||
model.DB.Where("id IN ?", uniqueUint(customerIDs)).Find(&customers)
|
||||
model.DB.Where("id IN ?", service.UniqueUint(customerIDs)).Find(&customers)
|
||||
for _, cu := range customers {
|
||||
customerMap[cu.ID] = cu
|
||||
}
|
||||
@@ -136,7 +137,7 @@ func (h *SessionHandler) Export(c *gin.Context) {
|
||||
agentMap := map[uint]model.User{}
|
||||
if len(agentIDs) > 0 {
|
||||
var users []model.User
|
||||
model.DB.Where("id IN ?", uniqueUint(agentIDs)).Find(&users)
|
||||
model.DB.Where("id IN ?", service.UniqueUint(agentIDs)).Find(&users)
|
||||
for _, u := range users {
|
||||
agentMap[u.ID] = u
|
||||
}
|
||||
@@ -144,7 +145,7 @@ func (h *SessionHandler) Export(c *gin.Context) {
|
||||
channelMap := map[uint]model.Channel{}
|
||||
if len(channelIDs) > 0 {
|
||||
var channels []model.Channel
|
||||
model.DB.Where("id IN ?", uniqueUint(channelIDs)).Find(&channels)
|
||||
model.DB.Where("id IN ?", service.UniqueUint(channelIDs)).Find(&channels)
|
||||
for _, ch := range channels {
|
||||
channelMap[ch.ID] = ch
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user