79 lines
2.0 KiB
Go
79 lines
2.0 KiB
Go
package validator
|
|
|
|
import "pkg.local/validate"
|
|
|
|
// RoleEditValidator 创建/编辑
|
|
type RoleEditValidator struct {
|
|
Id int64
|
|
Name string `validate:"required"`
|
|
ServiceId int64 `validate:"required"`
|
|
Rules []int64
|
|
}
|
|
|
|
// GetMessage 创建 - 提示消息
|
|
func (p RoleEditValidator) GetMessage() validate.ValidatorMessages {
|
|
return validate.ValidatorMessages{
|
|
"Name.required": "名称不能为空",
|
|
"ServiceId.required": "服务ID不能为空",
|
|
}
|
|
}
|
|
|
|
// RoleInfoValidator 查看信息
|
|
type RoleInfoValidator struct {
|
|
Id int64 `validate:"required"`
|
|
}
|
|
|
|
// GetMessage 查看信息 - 提示消息
|
|
func (p RoleInfoValidator) GetMessage() validate.ValidatorMessages {
|
|
return validate.ValidatorMessages{
|
|
"Id.required": "ID不能为空",
|
|
}
|
|
}
|
|
|
|
// RoleItemsValidator 查看列表
|
|
type RoleItemsValidator struct {
|
|
Page int32
|
|
Size int32
|
|
Name string
|
|
Status int32
|
|
ServiceId int64 `validate:"required"`
|
|
}
|
|
|
|
// GetMessage 查看列表 - 提示消息
|
|
func (p RoleItemsValidator) GetMessage() validate.ValidatorMessages {
|
|
return validate.ValidatorMessages{
|
|
"ServiceId.required": "服务ID不能为空",
|
|
}
|
|
}
|
|
|
|
// RoleStatusValidator 修改状态
|
|
type RoleStatusValidator struct {
|
|
Id int64 `validate:"required"`
|
|
Status int32 `validate:"required,oneof=1 2"`
|
|
Reason string `validate:"required_if=Status 2"`
|
|
}
|
|
|
|
// GetMessage 修改状态 - 提示消息
|
|
func (p RoleStatusValidator) GetMessage() validate.ValidatorMessages {
|
|
return validate.ValidatorMessages{
|
|
"Id.required": "ID不能为空",
|
|
"Status.required": "状态不能为空",
|
|
"Status.oneof": "状态传值不对",
|
|
"Reason.required_if": "理由不能为空",
|
|
}
|
|
}
|
|
|
|
// RoleRuleValidator 编辑权限
|
|
type RoleRuleValidator struct {
|
|
Id int64 ` validate:"required"`
|
|
Rule string `validate:"required"`
|
|
}
|
|
|
|
// GetMessage 修改状态 - 提示消息
|
|
func (p RoleRuleValidator) GetMessage() validate.ValidatorMessages {
|
|
return validate.ValidatorMessages{
|
|
"Id.required": "ID不能为空",
|
|
"Rule.required": "权限不能为空",
|
|
}
|
|
}
|