From 0a7221e9181f657622d22efdbbb54519eca6e9bd Mon Sep 17 00:00:00 2001 From: chenweijian <820961417@qq.com> Date: Mon, 17 Jul 2023 14:53:44 +0800 Subject: [PATCH] =?UTF-8?q?=E9=94=99=E8=AF=AF=E5=BC=B9=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- myerr/code.go | 2 ++ txop/msg/msg.go | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/myerr/code.go b/myerr/code.go index 7e49669..53ec066 100644 --- a/myerr/code.go +++ b/myerr/code.go @@ -160,6 +160,8 @@ type BusinessData struct { Timestamp int64 `json:"timestamp"` //官网充值地址 CheckOutUrl string `json:"checkOutUrl"` + Title string `json:"title"` + Detail string `json:"detail"` } func NewBusiness(err *BusinessError) *BusinessError { diff --git a/txop/msg/msg.go b/txop/msg/msg.go index e48cd22..3cc6c22 100644 --- a/txop/msg/msg.go +++ b/txop/msg/msg.go @@ -60,6 +60,26 @@ func GetErrByLanguage(model *domain.Model, msgId common.MsgIdType, lang string, return myerr.NewBusinessCodeNoCheck(myErr.GetCode(), msg, myerr.BusinessData{}) } +// 生成弹窗错误 +func NewAlertErrByLanguage(model *domain.Model, msgId1, msgId2 common.MsgIdType, lang string, args1 []interface{}, args2 []interface{}) *myerr.BusinessError { + var title, content string + if resMul, _ := res_m.GetResMultiTextBy(model, msgId1, lang); resMul != nil { + if len(args1) > 0 { + title = fmt.Sprintf(resMul.Content, args1...) + } else { + title = resMul.Content + } + } + if resMul, _ := res_m.GetResMultiTextBy(model, msgId2, lang); resMul != nil { + if len(args1) > 0 { + content = fmt.Sprintf(resMul.Content, args2...) + } else { + content = resMul.Content + } + } + return myerr.NewBusinessCodeNoCheck(1020, "", myerr.BusinessData{Title: title, Detail: content}) +} + func GetResMultiTextBy(model *domain.Model, msgId uint, Language mysql.Str) (string, error) { r := res_m.ResMultiText{} if err := model.DB().Where(&res_m.ResMultiText{ -- 2.22.0