日志初步结构
This commit is contained in:
@@ -8,7 +8,8 @@ type ErrorCode struct {
|
||||
var (
|
||||
ErrRespNotNil = &ErrorCode{Code: 10000, Message: "resp must not nil"}
|
||||
|
||||
ErrEncGcm = &ErrorCode{Code: 10001, Message: "gmc加密错误"}
|
||||
ErrEncGcm = &ErrorCode{Code: 10001, Message: "gmc加密错误"}
|
||||
ErrJSONUnMarshal = &ErrorCode{Code: 10002, Message: "json 解析错误"}
|
||||
|
||||
ErrParamParse = &ErrorCode{Code: 10100, Message: "参数解析错误"}
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package basic
|
||||
|
||||
import "reflect"
|
||||
import (
|
||||
"reflect"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func GetLangString(param any) string {
|
||||
// 获取参数的反射值
|
||||
@@ -18,10 +21,11 @@ func GetLangString(param any) string {
|
||||
|
||||
// 如果字段存在并且是字符串类型
|
||||
if langField.IsValid() && langField.Kind() == reflect.String {
|
||||
return langField.String()
|
||||
return strings.TrimSpace(langField.String())
|
||||
}
|
||||
}
|
||||
|
||||
// 如果无法获取有效的字符串值,则返回zh_cn
|
||||
|
||||
return "zh_cn"
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ func (resp *Response) ErrorErr(Code int, err error, Data ...interface{}) *Respon
|
||||
resp.ErrorText = err.Error()
|
||||
resp.IsSuccess = false
|
||||
resp.setData(Data)
|
||||
|
||||
log.Error(resp.ErrorText)
|
||||
return resp
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user