diff --git a/myerr/code.go b/myerr/code.go index 7e49669efdb71ee89dd91c2ee3a571706c810209..53ec06602103dfefd77ae536bf3b04230960f41d 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 e48cd224950df5583865667c3a6f731b1fe87e40..3cc6c227aed2dd02ce49504b52d3eb49c0dd5a44 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{