feat: product store
This commit is contained in:
@@ -4,6 +4,67 @@ import (
|
||||
"pkg.local/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,max=512"`
|
||||
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": "图片不能为空",
|
||||
"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"`
|
||||
@@ -18,3 +79,31 @@ func (p ProductItemsValidator) GetMessage() validate.ValidatorMessages {
|
||||
"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": "排序不能为空",
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user