diff --git a/app/zeus/api/lark/internal/user/user.go b/app/zeus/api/lark/internal/user/user.go index 55b5a1e..e6f3d02 100644 --- a/app/zeus/api/lark/internal/user/user.go +++ b/app/zeus/api/lark/internal/user/user.go @@ -11,7 +11,7 @@ import ( func LoginHandle(c *fiber.Ctx) error { var p = struct { Code string `json:"code" validate:"required"` - Email string `json:"email" validate:"email"` + Email string `json:"email" label:"邮箱" validate:"email"` }{} err := Bind(c, &p) if err != nil { diff --git a/app/zeus/api/lark/internal/user/validator.go b/app/zeus/api/lark/internal/user/validator.go index 785d395..2d6349e 100644 --- a/app/zeus/api/lark/internal/user/validator.go +++ b/app/zeus/api/lark/internal/user/validator.go @@ -24,11 +24,16 @@ func init() { panic(fmt.Errorf("uni.GetTranslator(%s) failed", "zh")) } Validate.RegisterTagNameFunc(func(field reflect.StructField) string { - label := field.Tag.Get("json") - if label == "" { - return field.Name + addWarp := func(tag string) string { + return "[" + tag + "]" } - return label + if labelTag := field.Tag.Get("label"); labelTag != "" { + return addWarp(labelTag) + } + if jsonTag := field.Tag.Get("json"); jsonTag != "" { + return addWarp(jsonTag) + } + return addWarp(field.Name) }) err := zh_translations.RegisterDefaultTranslations(Validate, trans) if err != nil { diff --git a/app/zeus/api/lark/main.go b/app/zeus/api/lark/main.go index 887e254..0d0f8a0 100755 --- a/app/zeus/api/lark/main.go +++ b/app/zeus/api/lark/main.go @@ -41,7 +41,7 @@ func middlewareResp(c *fiber.Ctx) error { type Response struct { Code int `json:"code"` Message string `json:"message"` - Data json.RawMessage `json:"data"` + Data json.RawMessage `json:"data,omitempty"` } func middlewareError(ctx *fiber.Ctx, err error) error {