feat: sale manager
This commit is contained in:
@@ -0,0 +1,200 @@
|
||||
package validator
|
||||
|
||||
import "lone-services/pkg/validate"
|
||||
|
||||
type GroupItemsValidator struct {
|
||||
Page uint32 `validate:"omitempty,min=1"`
|
||||
PageSize uint32 `validate:"omitempty,min=1,max=100"`
|
||||
Name string `validate:"omitempty,max=255"`
|
||||
}
|
||||
|
||||
func (p GroupItemsValidator) GetMessage() validate.ValidatorMessages {
|
||||
return validate.ValidatorMessages{
|
||||
"Page.min": "页码最小为1",
|
||||
"PageSize.min": "每页数量最小为1",
|
||||
"PageSize.max": "每页数量最大为100",
|
||||
"Name.max": "名称长度不能超过255",
|
||||
}
|
||||
}
|
||||
|
||||
type GroupCreateValidator struct {
|
||||
Name string `validate:"required,max=255"`
|
||||
}
|
||||
|
||||
func (p GroupCreateValidator) GetMessage() validate.ValidatorMessages {
|
||||
return validate.ValidatorMessages{
|
||||
"Name.required": "分组名称不能为空",
|
||||
"Name.max": "分组名称长度不能超过255",
|
||||
}
|
||||
}
|
||||
|
||||
type NamesValidator struct {
|
||||
Type uint32 `validate:"omitempty,oneof=1 2 3"`
|
||||
Name string `validate:"omitempty,max=255"`
|
||||
Level uint32 `validate:"omitempty,oneof=0 1"`
|
||||
}
|
||||
|
||||
func (p NamesValidator) GetMessage() validate.ValidatorMessages {
|
||||
return validate.ValidatorMessages{
|
||||
"Type.oneof": "类型不对",
|
||||
"Name.max": "名称长度不能超过255",
|
||||
"Level.oneof": "级别不对",
|
||||
}
|
||||
}
|
||||
|
||||
type CreateValidator struct {
|
||||
Mobile string `validate:"required,max=20"`
|
||||
Name string `validate:"required,max=256"`
|
||||
IdCardFront string `validate:"required,max=255"`
|
||||
IdCardBack string `validate:"required,max=255"`
|
||||
BusinessLicense string `validate:"omitempty,max=255"`
|
||||
Password string `validate:"required,min=6"`
|
||||
Account string `validate:"omitempty,max=255"`
|
||||
Sex uint32 `validate:"omitempty,oneof=1 2 3"`
|
||||
GroupId int64 `validate:"required,gt=0"`
|
||||
BirthDate string `validate:"omitempty,max=12"`
|
||||
SaleId int64 `validate:"omitempty,gte=0"`
|
||||
Type uint32 `validate:"required,oneof=1 2 3"`
|
||||
TerritoryId int64 `validate:"required,gt=0"`
|
||||
TerritoryName string `validate:"required,max=255"`
|
||||
ProvinceId int64 `validate:"required,gt=0"`
|
||||
CityId int64 `validate:"required,gt=0"`
|
||||
DistrictId int64 `validate:"required,gt=0"`
|
||||
RegionProvince string `validate:"required,max=64"`
|
||||
RegionCity string `validate:"required,max=64"`
|
||||
RegionDistrict string `validate:"required,max=64"`
|
||||
Address string `validate:"required,max=255"`
|
||||
}
|
||||
|
||||
func (p CreateValidator) GetMessage() validate.ValidatorMessages {
|
||||
return validate.ValidatorMessages{
|
||||
"Mobile.required": "手机号不能为空",
|
||||
"Name.required": "姓名不能为空",
|
||||
"IdCardFront.required": "身份证正面不能为空",
|
||||
"IdCardFront.max": "身份证正面地址过长",
|
||||
"IdCardBack.required": "身份证反面不能为空",
|
||||
"IdCardBack.max": "身份证反面地址过长",
|
||||
"BusinessLicense.max": "营业执照地址过长",
|
||||
"Password.required": "密码不能为空",
|
||||
"Password.min": "密码长度不能小于6位",
|
||||
"GroupId.required": "请选择销售分组",
|
||||
"GroupId.gt": "请选择销售分组",
|
||||
"Type.required": "请选择类型",
|
||||
"Type.oneof": "类型不对",
|
||||
"TerritoryId.required": "请选择地域",
|
||||
"TerritoryId.gt": "请选择地域",
|
||||
"TerritoryName.required": "地域名称不能为空",
|
||||
"ProvinceId.required": "请选择省份",
|
||||
"ProvinceId.gt": "请选择省份",
|
||||
"CityId.required": "请选择城市",
|
||||
"CityId.gt": "请选择城市",
|
||||
"DistrictId.required": "请选择区县",
|
||||
"DistrictId.gt": "请选择区县",
|
||||
"RegionProvince.required": "地区省份不能为空",
|
||||
"RegionCity.required": "地区城市不能为空",
|
||||
"RegionDistrict.required": "地区区县不能为空",
|
||||
"Address.required": "详细地址不能为空",
|
||||
}
|
||||
}
|
||||
|
||||
type EditValidator struct {
|
||||
Id int64 `validate:"required,gt=0"`
|
||||
Mobile string `validate:"required,max=20"`
|
||||
Name string `validate:"required,max=256"`
|
||||
IdCardFront string `validate:"required,max=255"`
|
||||
IdCardBack string `validate:"required,max=255"`
|
||||
BusinessLicense string `validate:"omitempty,max=255"`
|
||||
Account string `validate:"omitempty,max=255"`
|
||||
Sex uint32 `validate:"omitempty,oneof=1 2 3"`
|
||||
GroupId int64 `validate:"required,gt=0"`
|
||||
BirthDate string `validate:"omitempty,max=12"`
|
||||
SaleId int64 `validate:"omitempty,gte=0"`
|
||||
Type uint32 `validate:"required,oneof=1 2 3"`
|
||||
TerritoryId int64 `validate:"required,gt=0"`
|
||||
TerritoryName string `validate:"required,max=255"`
|
||||
ProvinceId int64 `validate:"required,gt=0"`
|
||||
CityId int64 `validate:"required,gt=0"`
|
||||
DistrictId int64 `validate:"required,gt=0"`
|
||||
RegionProvince string `validate:"required,max=64"`
|
||||
RegionCity string `validate:"required,max=64"`
|
||||
RegionDistrict string `validate:"required,max=64"`
|
||||
Address string `validate:"required,max=255"`
|
||||
}
|
||||
|
||||
func (p EditValidator) GetMessage() validate.ValidatorMessages {
|
||||
return validate.ValidatorMessages{
|
||||
"Id.required": "ID不能为空",
|
||||
"Id.gt": "ID必须大于0",
|
||||
"Mobile.required": "手机号不能为空",
|
||||
"Name.required": "姓名不能为空",
|
||||
"IdCardFront.required": "身份证正面不能为空",
|
||||
"IdCardFront.max": "身份证正面地址过长",
|
||||
"IdCardBack.required": "身份证反面不能为空",
|
||||
"IdCardBack.max": "身份证反面地址过长",
|
||||
"BusinessLicense.max": "营业执照地址过长",
|
||||
"GroupId.required": "请选择销售分组",
|
||||
"GroupId.gt": "请选择销售分组",
|
||||
"Type.required": "请选择类型",
|
||||
"Type.oneof": "类型不对",
|
||||
"TerritoryId.required": "请选择地域",
|
||||
"TerritoryId.gt": "请选择地域",
|
||||
"TerritoryName.required": "地域名称不能为空",
|
||||
"ProvinceId.required": "请选择省份",
|
||||
"ProvinceId.gt": "请选择省份",
|
||||
"CityId.required": "请选择城市",
|
||||
"CityId.gt": "请选择城市",
|
||||
"DistrictId.required": "请选择区县",
|
||||
"DistrictId.gt": "请选择区县",
|
||||
"RegionProvince.required": "地区省份不能为空",
|
||||
"RegionCity.required": "地区城市不能为空",
|
||||
"RegionDistrict.required": "地区区县不能为空",
|
||||
"Address.required": "详细地址不能为空",
|
||||
}
|
||||
}
|
||||
|
||||
type InfoValidator struct {
|
||||
Id int64 `validate:"required,gt=0"`
|
||||
}
|
||||
|
||||
func (p InfoValidator) GetMessage() validate.ValidatorMessages {
|
||||
return validate.ValidatorMessages{
|
||||
"Id.required": "ID不能为空",
|
||||
"Id.gt": "ID必须大于0",
|
||||
}
|
||||
}
|
||||
|
||||
type ItemsValidator struct {
|
||||
Name string `validate:"omitempty,max=256"`
|
||||
Page uint32 `validate:"omitempty,min=1"`
|
||||
PageSize uint32 `validate:"omitempty,min=1,max=100"`
|
||||
SaleId int64 `validate:"omitempty,gte=0"`
|
||||
Type uint32 `validate:"omitempty,oneof=1 2 3"`
|
||||
Status uint32 `validate:"omitempty,oneof=1 2 3 9"`
|
||||
}
|
||||
|
||||
func (p ItemsValidator) GetMessage() validate.ValidatorMessages {
|
||||
return validate.ValidatorMessages{
|
||||
"Page.min": "页码最小为1",
|
||||
"PageSize.min": "每页数量最小为1",
|
||||
"PageSize.max": "每页数量最大为100",
|
||||
"Type.oneof": "类型不对",
|
||||
"Status.oneof": "状态不对",
|
||||
}
|
||||
}
|
||||
|
||||
type StatusValidator struct {
|
||||
Id int64 `validate:"required,gt=0"`
|
||||
Status uint32 `validate:"required,oneof=1 2 3"`
|
||||
Reason string `validate:"required_if=Status 2 required_if=Status 3,max=255"`
|
||||
}
|
||||
|
||||
func (p StatusValidator) GetMessage() validate.ValidatorMessages {
|
||||
return validate.ValidatorMessages{
|
||||
"Id.required": "ID不能为空",
|
||||
"Id.gt": "ID必须大于0",
|
||||
"Status.required": "状态不能为空",
|
||||
"Status.oneof": "状态不对",
|
||||
"Reason.required_if": "未通过或禁用状态,理由不能为空",
|
||||
"Reason.max": "理由长度不能超过255",
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user