From 9b8ef2b11682923bdf37f625c5f9e88288d9dbfd Mon Sep 17 00:00:00 2001 From: chenweijian <820961417@qq.com> Date: Fri, 26 May 2023 18:25:07 +0800 Subject: [PATCH] =?UTF-8?q?=E9=94=99=E8=AF=AFtoast=E7=BF=BB=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/model/res_m/res_multi_text.go | 18 ------------------ txop/msg/msg.go | 22 ++++++++++++++++++++++ 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/internal/model/res_m/res_multi_text.go b/internal/model/res_m/res_multi_text.go index f091b0f..a13fbe3 100644 --- a/internal/model/res_m/res_multi_text.go +++ b/internal/model/res_m/res_multi_text.go @@ -1,7 +1,6 @@ package res_m import ( - "fmt" "git.hilo.cn/hilo-common/_const/common" "git.hilo.cn/hilo-common/domain" "git.hilo.cn/hilo-common/myerr" @@ -40,20 +39,3 @@ func GetResMultiTextBy(model *domain.Model, msgId uint, Language mysql.Str) (*Re } return &r, nil } - -func GetErrByLanguage(model *domain.Model, msgId common.MsgIdType, lang string, myErr *myerr.BusinessError, args ...interface{}) *myerr.BusinessError { - var msg string - if len(args) > 0 { - msg = fmt.Sprintf(myErr.GetMsg(), args...) - } else { - msg = myErr.GetMsg() - } - if resMul, _ := GetResMultiTextBy(model, msgId, lang); resMul != nil { - if len(args) > 0 { - msg = fmt.Sprintf(resMul.Content, args...) - } else { - msg = resMul.Content - } - } - return myerr.NewBusinessCodeNoCheck(myErr.GetCode(), msg, myerr.BusinessData{}) -} diff --git a/txop/msg/msg.go b/txop/msg/msg.go index 55a9b57..ca9d00f 100644 --- a/txop/msg/msg.go +++ b/txop/msg/msg.go @@ -1,10 +1,14 @@ package msg import ( + "fmt" + "git.hilo.cn/hilo-common/_const/common" "git.hilo.cn/hilo-common/domain" "git.hilo.cn/hilo-common/internal/enum/msg_e" "git.hilo.cn/hilo-common/internal/model/msg_m" + "git.hilo.cn/hilo-common/internal/model/res_m" "git.hilo.cn/hilo-common/internal/model/user_m" + "git.hilo.cn/hilo-common/myerr" "git.hilo.cn/hilo-common/resource/mysql" "git.hilo.cn/hilo-common/utils" ) @@ -36,3 +40,21 @@ func SendLittleAssistantMsg(model *domain.Model, userId mysql.ID, t msg_e.MsgUse } return nil } + +// 错误toast翻译 +func GetErrByLanguage(model *domain.Model, msgId common.MsgIdType, lang string, myErr *myerr.BusinessError, args ...interface{}) *myerr.BusinessError { + var msg string + if len(args) > 0 { + msg = fmt.Sprintf(myErr.GetMsg(), args...) + } else { + msg = myErr.GetMsg() + } + if resMul, _ := res_m.GetResMultiTextBy(model, msgId, lang); resMul != nil { + if len(args) > 0 { + msg = fmt.Sprintf(resMul.Content, args...) + } else { + msg = resMul.Content + } + } + return myerr.NewBusinessCodeNoCheck(myErr.GetCode(), msg, myerr.BusinessData{}) +} -- 2.22.0