92 lines
3.0 KiB
Go
92 lines
3.0 KiB
Go
package validator
|
|
|
|
import "lone-services/pkg/validate"
|
|
|
|
type TaskCreateValidator struct {
|
|
Type int32 `form:"type" json:"type" validate:"required"`
|
|
Time int32 `form:"time" json:"time" validate:"required"`
|
|
ProductId int64 `form:"product_id" json:"product_id" validate:"required"`
|
|
Province int64 `form:"province" json:"province" validate:"required"`
|
|
ProvinceName string `form:"province_name" json:"province_name" validate:"required"`
|
|
Task int32 `form:"task" json:"task" validate:"required"`
|
|
Award float64 `form:"award" json:"award" validate:"required"`
|
|
}
|
|
|
|
// GetMessage 提示消息
|
|
func (p TaskCreateValidator) GetMessage() validate.ValidatorMessages {
|
|
return validate.ValidatorMessages{
|
|
"Type.required": "类型不能为空",
|
|
"Time.required": "时间不能为空",
|
|
"ProductId.required": "产品ID不能为空",
|
|
"Province.required": "省份不能为空",
|
|
"ProvinceName.required": "省份名不能为空",
|
|
"Task.required": "任务不能为空",
|
|
"Award.required": "奖励不能为空",
|
|
}
|
|
}
|
|
|
|
type TaskEditValidator struct {
|
|
Id int64 `form:"id" json:"id" validate:"required"`
|
|
Task int32 `form:"task" json:"task" validate:"required"`
|
|
Award float64 `form:"award" json:"award" validate:"required"`
|
|
}
|
|
|
|
// GetMessage 提示消息
|
|
func (p TaskEditValidator) GetMessage() validate.ValidatorMessages {
|
|
return validate.ValidatorMessages{
|
|
"Id.required": "ID不能为空",
|
|
"Task.required": "任务不能为空",
|
|
"Award.required": "奖励不能为空",
|
|
}
|
|
}
|
|
|
|
type TaskStatusValidator struct {
|
|
Id int64 `form:"id" json:"id" validate:"required"`
|
|
Status int32 `form:"status" json:"status" validate:"required"`
|
|
Reason string `form:"reason" json:"reason" validate:"required_if=Status 2"`
|
|
}
|
|
|
|
// GetMessage 提示消息
|
|
func (p TaskStatusValidator) GetMessage() validate.ValidatorMessages {
|
|
return validate.ValidatorMessages{
|
|
"Id.required": "ID不能为空",
|
|
"Status.required": "状态不能为空",
|
|
"Reason.required_if": "禁用状态,理由不能为空",
|
|
}
|
|
}
|
|
|
|
type TaskItemsValidator struct {
|
|
Page int32 `form:"page" json:"page"`
|
|
Size int32 `form:"size" json:"size"`
|
|
}
|
|
|
|
// GetMessage 提示消息
|
|
func (p TaskItemsValidator) GetMessage() validate.ValidatorMessages {
|
|
return validate.ValidatorMessages{}
|
|
}
|
|
|
|
type TaskAccountItemsValidator struct {
|
|
Name string `form:"name" json:"name"`
|
|
Page int32 `form:"page" json:"page"`
|
|
Size int32 `form:"size" json:"size"`
|
|
Type int32 `form:"type" json:"type"`
|
|
Time int32 `form:"time" json:"time"`
|
|
Month string `form:"month" json:"month"`
|
|
}
|
|
|
|
// GetMessage 提示消息
|
|
func (p TaskAccountItemsValidator) GetMessage() validate.ValidatorMessages {
|
|
return validate.ValidatorMessages{}
|
|
}
|
|
|
|
type TaskInfoValidator struct {
|
|
Id int64 `form:"id" json:"id" validate:"required"`
|
|
}
|
|
|
|
// GetMessage 提示消息
|
|
func (p TaskInfoValidator) GetMessage() validate.ValidatorMessages {
|
|
return validate.ValidatorMessages{
|
|
"Id.required": "ID不能为空",
|
|
}
|
|
}
|