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
+6 -6
View File
@@ -22,24 +22,24 @@ type imMessageAssetPayload struct {
func parseIMMessageAssetPayload(payload string) (*imMessageAssetPayload, error) {
payload = strings.TrimSpace(payload)
if payload == "" {
return nil, errorsx.InvalidParam("附件消息缺少 payload")
return nil, errorsx.InvalidParamI18n("error.e0346")
}
ret := &imMessageAssetPayload{}
if err := json.Unmarshal([]byte(payload), ret); err != nil {
return nil, errorsx.InvalidParam("附件消息 payload 格式错误")
return nil, errorsx.InvalidParamI18n("error.e0344")
}
ret.AssetID = strings.TrimSpace(ret.AssetID)
ret.Provider = enums.AssetProvider(strings.TrimSpace(string(ret.Provider)))
ret.StorageKey = strings.TrimSpace(ret.StorageKey)
if ret.AssetID == "" {
return nil, errorsx.InvalidParam("附件消息缺少 assetId")
return nil, errorsx.InvalidParamI18n("error.e0345")
}
return ret, nil
}
func buildIMMessageAssetPayload(asset *models.Asset) (string, error) {
if asset == nil {
return "", errorsx.InvalidParam("附件不存在")
return "", errorsx.InvalidParamI18n("error.e0342")
}
payload, err := json.Marshal(imMessageAssetPayload{
AssetID: asset.AssetID,
@@ -107,10 +107,10 @@ func hydrateIMMessageAssetPayload(payload *imMessageAssetPayload) *imMessageAsse
func validateConversationAsset(asset *models.Asset, conversationID int64, messageType enums.IMMessageType) error {
if asset == nil {
return errorsx.InvalidParam("附件不存在")
return errorsx.InvalidParamI18n("error.e0342")
}
if asset.Status != enums.AssetStatusSuccess {
return errorsx.InvalidParam("附件尚未上传完成")
return errorsx.InvalidParamI18n("error.e0343")
}
return nil
}