Refactor error handling in services to use internationalized error messages

- Updated OSSStorage validation errors to use internationalized messages.
- Changed error messages in provider.go for unsupported file storage types.
- Refactored tag_service.go to replace hardcoded error messages with internationalized versions.
- Updated ticket_service.go to use internationalized error messages for various validation checks.
- Refactored ticket_tag_service.go to use internationalized error messages for tag validation.
- Changed ticket_view_service.go to use internationalized error messages for view validation.
- Updated tool_catalog_service.go to use internationalized error messages for tool code validation.
- Refactored user_service.go to replace error messages with internationalized versions.
- Updated ws_service.go to use internationalized error messages for WebSocket handling.
- Refactored wxwork_kf_inbound_service.go to use internationalized error messages for message handling.
- Updated wxwork_kf_outbound_service.go to use internationalized error messages for outbound message handling.
- Refactored wxwork_login_service.go to use internationalized error messages for login handling.
- Updated login.go in wxwork package to use internationalized error messages for login state and ticket validation.
This commit is contained in:
mlogclub
2026-06-02 20:51:13 +08:00
parent 77be1b4f5e
commit 0b4a1b4594
103 changed files with 1688 additions and 1350 deletions
@@ -11,7 +11,6 @@ import (
"agent-desk/internal/pkg/httpx/params"
"github.com/gin-gonic/gin"
"github.com/mlogclub/simple/web"
)
func ConversationGetBy(ctx *gin.Context) {
@@ -20,22 +19,22 @@ func ConversationGetBy(ctx *gin.Context) {
return
}
if services.ChannelService.GetEnabledChannel(ctx) == nil {
httpx.WriteJSON(ctx, web.JsonErrorMsg("接入渠道未初始化"))
httpx.WriteJSON(ctx, httpx.JsonErrorMsg(ctx, "error.e0211"))
return
}
external := httpx.GetExternalUser(ctx)
if external == nil {
httpx.WriteJSON(ctx, web.JsonErrorMsg("外部身份未初始化"))
httpx.WriteJSON(ctx, httpx.JsonErrorMsg(ctx, "error.e0150"))
return
}
item := services.ConversationService.Get(id)
if item == nil {
httpx.WriteJSON(ctx, web.JsonErrorMsg("会话不存在"))
httpx.WriteJSON(ctx, httpx.JsonErrorMsg(ctx, "error.e0116"))
return
}
if !services.ConversationService.IsCustomerConversationOwner(item, *external) {
httpx.WriteJSON(ctx, web.JsonErrorMsg("无权访问该会话"))
httpx.WriteJSON(ctx, httpx.JsonErrorMsg(ctx, "error.e0222"))
return
}
@@ -49,12 +48,12 @@ func ConversationGetBy(ctx *gin.Context) {
func ConversationPostCreate_or_match(ctx *gin.Context) {
channel := services.ChannelService.GetEnabledChannel(ctx)
if channel == nil {
httpx.WriteJSON(ctx, web.JsonErrorMsg("接入渠道未初始化"))
httpx.WriteJSON(ctx, httpx.JsonErrorMsg(ctx, "error.e0211"))
return
}
external := httpx.GetExternalUser(ctx)
if external == nil {
httpx.WriteJSON(ctx, web.JsonErrorMsg("外部身份未初始化"))
httpx.WriteJSON(ctx, httpx.JsonErrorMsg(ctx, "error.e0150"))
return
}
@@ -68,12 +67,12 @@ func ConversationPostCreate_or_match(ctx *gin.Context) {
func ConversationPostClose(ctx *gin.Context) {
if services.ChannelService.GetEnabledChannel(ctx) == nil {
httpx.WriteJSON(ctx, web.JsonErrorMsg("接入渠道未初始化"))
httpx.WriteJSON(ctx, httpx.JsonErrorMsg(ctx, "error.e0211"))
return
}
external := httpx.GetExternalUser(ctx)
if external == nil {
httpx.WriteJSON(ctx, web.JsonErrorMsg("外部身份未初始化"))
httpx.WriteJSON(ctx, httpx.JsonErrorMsg(ctx, "error.e0150"))
return
}