46d3f672bf
CI / changes (push) Successful in 1m30s
CI / ad (push) Successful in 31s
CI / admin (push) Successful in 24s
CI / bff (push) Successful in 31s
CI / chore (push) Successful in 27s
CI / equipment (push) Successful in 21s
CI / express (push) Successful in 23s
CI / factory (push) Successful in 21s
CI / message (push) Successful in 21s
CI / order (push) Successful in 22s
CI / payment (push) Successful in 20s
CI / percutaneous (push) Successful in 20s
CI / product (push) Successful in 20s
CI / record (push) Successful in 19s
CI / sale (push) Successful in 19s
CI / support (push) Successful in 20s
CI / task (push) Successful in 19s
CI / user (push) Successful in 21s
CI / wecom (push) Successful in 22s
143 lines
3.7 KiB
Go
143 lines
3.7 KiB
Go
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": "有效时间过长",
|
|
}
|
|
}
|
|
|
|
type UserAuthDeleteValidator struct {
|
|
Id int64 `validate:"required,gt=0"`
|
|
}
|
|
|
|
func (p UserAuthDeleteValidator) GetMessage() validate.ValidatorMessages {
|
|
return validate.ValidatorMessages{
|
|
"Id.required": "id 不能为空",
|
|
"Id.gt": "id 必须大于0",
|
|
}
|
|
}
|
|
|
|
type DeviceBindValidator struct {
|
|
DeviceNo string `validate:"required,max=64"`
|
|
}
|
|
|
|
func (p DeviceBindValidator) GetMessage() validate.ValidatorMessages {
|
|
return validate.ValidatorMessages{
|
|
"DeviceNo.required": "device_no 必传",
|
|
"DeviceNo.max": "device_no 过长",
|
|
}
|
|
}
|
|
|
|
type UserAuthUpdateValidator struct {
|
|
Id int64 `validate:"required,gt=0"`
|
|
ValidityTime string `validate:"required,max=32"`
|
|
}
|
|
|
|
func (p UserAuthUpdateValidator) GetMessage() validate.ValidatorMessages {
|
|
return validate.ValidatorMessages{
|
|
"Id.required": "id 不能为空",
|
|
"Id.gt": "id 必须大于0",
|
|
"ValidityTime.required": "时间必传",
|
|
"ValidityTime.max": "时间过长",
|
|
}
|
|
}
|