更换一个包

This commit is contained in:
Yun
2024-08-11 23:44:02 +08:00
parent d05963c86a
commit 603a9914a5
4 changed files with 13 additions and 7 deletions
+4 -4
View File
@@ -50,7 +50,7 @@ func GetPage(page, size, totalCount int64) pagination {
// Msg格式化响应
func FormatMessage(ctx context.Context, w http.ResponseWriter, message string, format map[string]string, data interface{}) {
code, msg := langx.GetTrans(message, message, format)
code, msg := langx.GetTransFormatCtx(ctx, message, format)
ResponseCtx(ctx, w, code, msg, data)
}
@@ -68,10 +68,10 @@ func Error(ctx context.Context, w http.ResponseWriter, err error) {
code := op.defaultErrorCode
msg := "请求失败"
if err != nil {
val, ok := err.(*langx.LangError)
val, ok := err.(langx.LangError)
if ok {
if langx.GetDefaultCode() != val.Code() {
code = val.Code()
if langx.GetDefaultCode() != val.GetCode() {
code = val.GetCode()
}
}
msg = err.Error()