276 lines
9.1 KiB
Go
276 lines
9.1 KiB
Go
package validator
|
|
|
|
import "lone-services/pkg/validate"
|
|
|
|
type ProductCreateValidator struct {
|
|
Name string `validate:"required,max=256"`
|
|
Subhead string `validate:"required,max=255"`
|
|
Content string `validate:"required"`
|
|
SalesModel uint32 `validate:"required,oneof=1 2"`
|
|
ModelCode string `validate:"required,max=255"`
|
|
Price float64 `validate:"required"`
|
|
StorePrice float64
|
|
SalePrice float64
|
|
SharePrice float64
|
|
AgentPrice float64
|
|
SaleReward string `validate:"max=255"`
|
|
Images []string `validate:"required,min=1,dive,required"`
|
|
Weight float64 `validate:"required"`
|
|
Cubage string `validate:"required,max=255"`
|
|
Waybill string `validate:"required,max=255"`
|
|
PeriodValidity int32 `validate:"required"`
|
|
NormsNumber uint32 `validate:"required,min=1"`
|
|
BoxNumber float64
|
|
Type uint32 `validate:"required,oneof=1 2 3"`
|
|
Number uint32
|
|
TryNumber uint32
|
|
PublishTime string `validate:"max=32"`
|
|
Label string `validate:"max=255"`
|
|
IsBuy uint32 `validate:"omitempty,oneof=1 2"`
|
|
IsIndex uint32 `validate:"omitempty,oneof=1 2"`
|
|
IndexImage string `validate:"max=255"`
|
|
}
|
|
|
|
func (p ProductCreateValidator) GetMessage() validate.ValidatorMessages {
|
|
return validate.ValidatorMessages{
|
|
"Name.required": "产品名不能为空",
|
|
"Name.max": "产品名长度不能超过256",
|
|
"Subhead.required": "副标题不能为空",
|
|
"Content.required": "内容不能为空",
|
|
"SalesModel.required": "销售类型不能为空",
|
|
"SalesModel.oneof": "销售类型不对",
|
|
"ModelCode.required": "请输入机器码",
|
|
"Price.required": "价格不能为空",
|
|
"Images.required": "图片不能为空",
|
|
"Images.min": "图片不能为空",
|
|
"Weight.required": "重量不能为空",
|
|
"Cubage.required": "体积不能为空",
|
|
"Waybill.required": "运货单图片不能为空",
|
|
"PeriodValidity.required": "有效期不能为空",
|
|
"NormsNumber.required": "缺少一份中有几个",
|
|
"Type.required": "请选择类型",
|
|
"Type.oneof": "类型不对",
|
|
}
|
|
}
|
|
|
|
type ProductInfoValidator struct {
|
|
Id int64 `validate:"required,gt=0"`
|
|
}
|
|
|
|
func (p ProductInfoValidator) GetMessage() validate.ValidatorMessages {
|
|
return validate.ValidatorMessages{
|
|
"Id.required": "ID不能为空",
|
|
"Id.gt": "ID必须大于0",
|
|
}
|
|
}
|
|
|
|
type ProductItemsValidator struct {
|
|
Name string `validate:"max=256"`
|
|
Page uint32 `validate:"omitempty,min=1"`
|
|
PageSize uint32 `validate:"omitempty,min=1,max=100"`
|
|
}
|
|
|
|
func (p ProductItemsValidator) GetMessage() validate.ValidatorMessages {
|
|
return validate.ValidatorMessages{
|
|
"Name.max": "产品名长度不能超过256",
|
|
"Page.min": "页码最小为1",
|
|
"PageSize.min": "每页数量最小为1",
|
|
"PageSize.max": "每页数量最大为100",
|
|
}
|
|
}
|
|
|
|
type ProductStatusValidator struct {
|
|
Id int64 `validate:"required,gt=0"`
|
|
Status uint32 `validate:"required,oneof=1 2 3"`
|
|
Reason string `validate:"max=255"`
|
|
}
|
|
|
|
func (p ProductStatusValidator) GetMessage() validate.ValidatorMessages {
|
|
return validate.ValidatorMessages{
|
|
"Id.required": "ID不能为空",
|
|
"Id.gt": "ID必须大于0",
|
|
"Status.required": "状态不能为空",
|
|
"Status.oneof": "状态不对",
|
|
}
|
|
}
|
|
|
|
type ProductSortValidator struct {
|
|
Id int64 `validate:"required,gt=0"`
|
|
Sort uint32 `validate:"required"`
|
|
}
|
|
|
|
func (p ProductSortValidator) GetMessage() validate.ValidatorMessages {
|
|
return validate.ValidatorMessages{
|
|
"Id.required": "ID不能为空",
|
|
"Id.gt": "ID必须大于0",
|
|
"Sort.required": "排序不能为空",
|
|
}
|
|
}
|
|
|
|
type ProductVerifyItemsValidator struct {
|
|
Status uint32 `validate:"required,oneof=1 2"`
|
|
Page uint32 `validate:"omitempty,min=1"`
|
|
PageSize uint32 `validate:"omitempty,min=1,max=100"`
|
|
}
|
|
|
|
func (p ProductVerifyItemsValidator) GetMessage() validate.ValidatorMessages {
|
|
return validate.ValidatorMessages{
|
|
"Status.required": "状态不能为空",
|
|
"Status.oneof": "状态不对",
|
|
"Page.min": "页码最小为1",
|
|
"PageSize.min": "每页数量最小为1",
|
|
"PageSize.max": "每页数量最大为100",
|
|
}
|
|
}
|
|
|
|
type ProductVerifyStatusValidator struct {
|
|
Id int64 `validate:"required,gt=0"`
|
|
Status uint32 `validate:"required,oneof=1 2"`
|
|
Reason string `validate:"max=255"`
|
|
}
|
|
|
|
func (p ProductVerifyStatusValidator) GetMessage() validate.ValidatorMessages {
|
|
return validate.ValidatorMessages{
|
|
"Id.required": "ID不能为空",
|
|
"Id.gt": "ID必须大于0",
|
|
"Status.required": "状态不能为空",
|
|
"Status.oneof": "状态不对",
|
|
}
|
|
}
|
|
|
|
type ProductEditApplyValidator struct {
|
|
Id int64 `validate:"required,gt=0"`
|
|
Reason string `validate:"required,max=255"`
|
|
}
|
|
|
|
func (p ProductEditApplyValidator) GetMessage() validate.ValidatorMessages {
|
|
return validate.ValidatorMessages{
|
|
"Id.required": "ID不能为空",
|
|
"Id.gt": "ID必须大于0",
|
|
"Reason.required": "原因不能为空",
|
|
}
|
|
}
|
|
|
|
type ProductEditApplyPassValidator struct {
|
|
Id int64 `validate:"required,gt=0"`
|
|
}
|
|
|
|
func (p ProductEditApplyPassValidator) GetMessage() validate.ValidatorMessages {
|
|
return validate.ValidatorMessages{
|
|
"Id.required": "ID不能为空",
|
|
"Id.gt": "ID必须大于0",
|
|
}
|
|
}
|
|
|
|
type ProductEditBaseValidator struct {
|
|
Id int64 `validate:"required,gt=0"`
|
|
Name string `validate:"required,max=256"`
|
|
Subhead string `validate:"required,max=255"`
|
|
Content string `validate:"required"`
|
|
Waybill string `validate:"required,max=255"`
|
|
Weight float64 `validate:"required"`
|
|
Cubage string `validate:"required,max=255"`
|
|
Images []string `validate:"required,min=1,dive,required"`
|
|
PeriodValidity int32 `validate:"required"`
|
|
PublishTime string `validate:"max=32"`
|
|
Label string `validate:"max=255"`
|
|
IsBuy uint32 `validate:"omitempty,oneof=1 2"`
|
|
IsIndex uint32 `validate:"omitempty,oneof=1 2"`
|
|
IndexImage string `validate:"max=255"`
|
|
}
|
|
|
|
func (p ProductEditBaseValidator) GetMessage() validate.ValidatorMessages {
|
|
return validate.ValidatorMessages{
|
|
"Id.required": "ID不能为空",
|
|
"Id.gt": "ID必须大于0",
|
|
"Name.required": "产品名不能为空",
|
|
"Subhead.required": "副标题不能为空",
|
|
"Content.required": "内容不能为空",
|
|
"Images.required": "图片不能为空",
|
|
"Images.min": "图片不能为空",
|
|
"PeriodValidity.required": "有效期不能为空",
|
|
"Waybill.required": "运货单图片不能为空",
|
|
"Weight.required": "重量不能为空",
|
|
"Cubage.required": "体积不能为空",
|
|
}
|
|
}
|
|
|
|
type ProductEditSusceptibleValidator struct {
|
|
Id int64 `validate:"required,gt=0"`
|
|
ModelCode string `validate:"required,max=255"`
|
|
Price float64 `validate:"required"`
|
|
StorePrice float64
|
|
SalePrice float64
|
|
SharePrice float64
|
|
AgentPrice float64
|
|
SaleReward string `validate:"max=255"`
|
|
NormsNumber uint32 `validate:"required,min=1"`
|
|
BoxNumber float64
|
|
Type uint32 `validate:"required,oneof=1 2 3"`
|
|
}
|
|
|
|
func (p ProductEditSusceptibleValidator) GetMessage() validate.ValidatorMessages {
|
|
return validate.ValidatorMessages{
|
|
"Id.required": "ID不能为空",
|
|
"Id.gt": "ID必须大于0",
|
|
"ModelCode.required": "请输入机器码",
|
|
"Price.required": "价格不能为空",
|
|
"NormsNumber.required": "缺少一份中有几个",
|
|
"Type.required": "请选择类型",
|
|
"Type.oneof": "类型不对",
|
|
}
|
|
}
|
|
|
|
type ProductNumberValidator struct {
|
|
Id int64 `validate:"required,gt=0"`
|
|
Type uint32 `validate:"required,oneof=1 2"`
|
|
Number uint32 `validate:"required,gt=0"`
|
|
}
|
|
|
|
func (p ProductNumberValidator) GetMessage() validate.ValidatorMessages {
|
|
return validate.ValidatorMessages{
|
|
"Id.required": "ID不能为空",
|
|
"Id.gt": "ID必须大于0",
|
|
"Type.required": "类型不能为空",
|
|
"Type.oneof": "类型不对",
|
|
"Number.required": "数量不能为空",
|
|
"Number.gt": "数量必须大于0",
|
|
}
|
|
}
|
|
|
|
type ProductNumberAddValidator struct {
|
|
Id int64 `validate:"required,gt=0"`
|
|
Number uint32 `validate:"required,gt=0"`
|
|
}
|
|
|
|
func (p ProductNumberAddValidator) GetMessage() validate.ValidatorMessages {
|
|
return validate.ValidatorMessages{
|
|
"Id.required": "ID不能为空",
|
|
"Id.gt": "ID必须大于0",
|
|
"Number.required": "数量不能为空",
|
|
"Number.gt": "数量必须大于0",
|
|
}
|
|
}
|
|
|
|
type ProductNumberItemsValidator struct {
|
|
Type uint32 `validate:"required,oneof=1 2"`
|
|
}
|
|
|
|
func (p ProductNumberItemsValidator) GetMessage() validate.ValidatorMessages {
|
|
return validate.ValidatorMessages{
|
|
"Type.required": "类型不能为空",
|
|
"Type.oneof": "类型不对",
|
|
}
|
|
}
|
|
|
|
type ProductItemsByIdsValidator struct {
|
|
Ids []int64 `validate:"required,min=1"`
|
|
}
|
|
|
|
func (p ProductItemsByIdsValidator) GetMessage() validate.ValidatorMessages {
|
|
return validate.ValidatorMessages{
|
|
"Ids.required": "ID列表不能为空",
|
|
"Ids.min": "ID列表不能为空",
|
|
}
|
|
}
|