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
149 lines
4.7 KiB
Go
149 lines
4.7 KiB
Go
package validator
|
|
|
|
import "lone-services/pkg/validate"
|
|
|
|
type BindItemsValidator struct {
|
|
Page int `form:"page" json:"page"`
|
|
Size int `form:"size" json:"size"`
|
|
Status int32 `form:"status" json:"status"`
|
|
NickName string `form:"nick_name" json:"nick_name"`
|
|
Code string `form:"code" json:"code"`
|
|
Time []string `form:"time" json:"time"`
|
|
Type int32 `form:"type" json:"type"`
|
|
}
|
|
|
|
// GetMessage 提示消息
|
|
func (p BindItemsValidator) GetMessage() validate.ValidatorMessages {
|
|
return validate.ValidatorMessages{}
|
|
}
|
|
|
|
type BindSetExpiryValidator struct {
|
|
Id int `form:"id" json:"id" validate:"required"`
|
|
Expiry string `form:"expiry" json:"expiry"`
|
|
Reason string `form:"reason" json:"reason" validate:"required"`
|
|
}
|
|
|
|
// GetMessage 提示消息
|
|
func (p BindSetExpiryValidator) GetMessage() validate.ValidatorMessages {
|
|
return validate.ValidatorMessages{
|
|
validate.FieldId: validate.FieldIdValue,
|
|
"Reason.required": "理由不能为空",
|
|
}
|
|
}
|
|
|
|
type InternalBindAddValidator struct {
|
|
UserId int64 `validate:"required,gt=0"`
|
|
UserNickname string `validate:"omitempty,max=128"`
|
|
HostNickname string `validate:"omitempty,max=128"`
|
|
HostCode string `validate:"required,max=64"`
|
|
Type int32 `validate:"required,gt=0"`
|
|
SkinType int32 `validate:"required,oneof=1 2"`
|
|
}
|
|
|
|
func (p InternalBindAddValidator) GetMessage() validate.ValidatorMessages {
|
|
return validate.ValidatorMessages{
|
|
"UserId.required": "缺少用户",
|
|
"UserId.gt": "缺少用户",
|
|
"HostCode.required": "缺少设备编码",
|
|
"HostCode.max": "设备编码过长",
|
|
"Type.required": "缺少设备类型",
|
|
"Type.gt": "缺少设备类型",
|
|
"SkinType.required": "缺少绑定类型",
|
|
"SkinType.oneof": "绑定类型只能是1或2",
|
|
}
|
|
}
|
|
|
|
type InternalBindInfoValidator struct {
|
|
UserId int64 `validate:"omitempty,gte=0"`
|
|
SkinType int32 `validate:"omitempty,oneof=1 2"`
|
|
HostCode string `validate:"omitempty,max=64"`
|
|
Type int32 `validate:"omitempty,gte=0"`
|
|
Id int64 `validate:"omitempty,gte=0"`
|
|
}
|
|
|
|
func (p InternalBindInfoValidator) GetMessage() validate.ValidatorMessages {
|
|
return validate.ValidatorMessages{
|
|
"SkinType.oneof": "绑定类型只能是1或2",
|
|
"HostCode.max": "设备编码过长",
|
|
}
|
|
}
|
|
|
|
type ApiBindInfoValidator struct {
|
|
Id int64 `validate:"omitempty,gte=0"`
|
|
HostCode string `validate:"omitempty,max=64"`
|
|
Type int32 `validate:"omitempty,gte=0"`
|
|
}
|
|
|
|
func (p ApiBindInfoValidator) GetMessage() validate.ValidatorMessages {
|
|
return validate.ValidatorMessages{
|
|
"HostCode.max": "设备编码过长",
|
|
}
|
|
}
|
|
|
|
type ApiBindUpdateValidator struct {
|
|
Id int64 `validate:"required,gt=0"`
|
|
HostNickname string `validate:"required,max=128"`
|
|
}
|
|
|
|
func (p ApiBindUpdateValidator) GetMessage() validate.ValidatorMessages {
|
|
return validate.ValidatorMessages{
|
|
"Id.required": "id 必传",
|
|
"Id.gt": "id 必传",
|
|
"HostNickname.required": "缺少设备名称",
|
|
"HostNickname.max": "设备名称过长",
|
|
}
|
|
}
|
|
|
|
type BindValidator struct {
|
|
HostNickname string `form:"host_nickname" json:"host_nickname"`
|
|
HostCode string `form:"host_code" json:"host_code" validate:"required"`
|
|
Type int32 `form:"type" json:"type"`
|
|
}
|
|
|
|
// GetMessage 提示消息
|
|
func (p BindValidator) GetMessage() validate.ValidatorMessages {
|
|
return validate.ValidatorMessages{
|
|
"HostCode.required": "缺少设备编码",
|
|
}
|
|
}
|
|
|
|
type BindUnbindValidator struct {
|
|
HostCode string `form:"host_code" json:"host_code" validate:"required"`
|
|
}
|
|
|
|
// GetMessage 提示消息
|
|
func (p BindUnbindValidator) GetMessage() validate.ValidatorMessages {
|
|
return validate.ValidatorMessages{
|
|
"HostCode.required": "缺少设备编码",
|
|
}
|
|
}
|
|
|
|
type BindExpiryValidator struct {
|
|
HostCode string `form:"host_code" json:"host_code" binding:"required"`
|
|
Type int32 `form:"type" json:"type" binding:"required,oneof=1 2"`
|
|
EquipmentType int32 `form:"equipment_type" json:"equipment_type" binding:"required"`
|
|
}
|
|
|
|
// GetMessage 提示消息
|
|
func (p BindExpiryValidator) GetMessage() validate.ValidatorMessages {
|
|
return validate.ValidatorMessages{
|
|
"HostCode.required": "缺少设备编码",
|
|
"Type.required": "缺少类型",
|
|
"Type.oneof": "类型错误",
|
|
"EquipmentType.required": "设备类型错误",
|
|
}
|
|
}
|
|
|
|
type BindGetExpiryValidator struct {
|
|
HostCode string `form:"host_code" json:"host_code" binding:"required"`
|
|
Type int32 `form:"type" json:"ype" binding:"required"`
|
|
}
|
|
|
|
// GetMessage 提示消息
|
|
func (p BindGetExpiryValidator) GetMessage() validate.ValidatorMessages {
|
|
return validate.ValidatorMessages{
|
|
"HostCode.required": "缺少设备编码",
|
|
"Type.required": "缺少类型",
|
|
}
|
|
}
|