feat: analysis user auth and ws
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
package validator
|
||||
|
||||
import "lone-services/pkg/validate"
|
||||
|
||||
type UserImproveValidator struct {
|
||||
Avatar string
|
||||
Nickname string
|
||||
Birthday string
|
||||
Mobile string
|
||||
Gender int32 `validate:"omitempty,oneof=0 1 2 3"`
|
||||
Password string
|
||||
District string
|
||||
Address string
|
||||
}
|
||||
|
||||
func (p UserImproveValidator) GetMessage() validate.ValidatorMessages {
|
||||
return validate.ValidatorMessages{
|
||||
"Gender.oneof": "性别不正确",
|
||||
}
|
||||
}
|
||||
|
||||
type UserRegisterValidator struct {
|
||||
Code string `validate:"required,max=128"`
|
||||
}
|
||||
|
||||
func (p UserRegisterValidator) GetMessage() validate.ValidatorMessages {
|
||||
return validate.ValidatorMessages{
|
||||
"Code.required": "code 不能为空",
|
||||
"Code.max": "code 过长",
|
||||
}
|
||||
}
|
||||
|
||||
type FaceBindValidator struct {
|
||||
FacePath string `validate:"required,max=512"`
|
||||
}
|
||||
|
||||
func (p FaceBindValidator) GetMessage() validate.ValidatorMessages {
|
||||
return validate.ValidatorMessages{
|
||||
"FacePath.required": "face_path 不能为空",
|
||||
"FacePath.max": "face_path 过长",
|
||||
}
|
||||
}
|
||||
|
||||
type AgreementInfoValidator struct {
|
||||
Type int32 `validate:"required,gt=0"`
|
||||
}
|
||||
|
||||
func (p AgreementInfoValidator) GetMessage() validate.ValidatorMessages {
|
||||
return validate.ValidatorMessages{
|
||||
"Type.required": "type 必传",
|
||||
"Type.gt": "type 必传",
|
||||
}
|
||||
}
|
||||
|
||||
type UserDeleteValidator struct {
|
||||
Id int64 `validate:"required,gt=0"`
|
||||
}
|
||||
|
||||
func (p UserDeleteValidator) GetMessage() validate.ValidatorMessages {
|
||||
return validate.ValidatorMessages{
|
||||
"Id.required": "id 不能为空",
|
||||
"Id.gt": "id 必须大于0",
|
||||
}
|
||||
}
|
||||
|
||||
type SwitchValidator struct {
|
||||
Type int32 `validate:"omitempty,gte=0"`
|
||||
}
|
||||
|
||||
func (p SwitchValidator) GetMessage() validate.ValidatorMessages {
|
||||
return validate.ValidatorMessages{}
|
||||
}
|
||||
|
||||
type StoreAuthValidator struct {
|
||||
Username string `validate:"required,max=32"`
|
||||
Password string `validate:"required,max=64"`
|
||||
ValidityTime string `validate:"required,max=32"`
|
||||
}
|
||||
|
||||
func (p StoreAuthValidator) GetMessage() validate.ValidatorMessages {
|
||||
return validate.ValidatorMessages{
|
||||
"Username.required": "账号必传",
|
||||
"Username.max": "账号过长",
|
||||
"Password.required": "密码必传",
|
||||
"Password.max": "密码过长",
|
||||
"ValidityTime.required": "有效时间必传",
|
||||
"ValidityTime.max": "有效时间过长",
|
||||
}
|
||||
}
|
||||
|
||||
type UserAuthValidator struct {
|
||||
Type int32 `validate:"required,oneof=1 2"`
|
||||
StoreId int64 `validate:"required,gt=0"`
|
||||
ValidityTime string `validate:"required_if=Type 1,omitempty,max=32"`
|
||||
}
|
||||
|
||||
func (p UserAuthValidator) GetMessage() validate.ValidatorMessages {
|
||||
return validate.ValidatorMessages{
|
||||
"Type.required": "类型必传",
|
||||
"Type.oneof": "类型只能是1或2",
|
||||
"StoreId.required": "门店id必传",
|
||||
"StoreId.gt": "门店id必传",
|
||||
"ValidityTime.required": "有效时间必传",
|
||||
"ValidityTime.max": "有效时间过长",
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user