service apis edit, info, items, status, names
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
package validator
|
||||
|
||||
import (
|
||||
"pkg.local/validate"
|
||||
)
|
||||
|
||||
// ServiceEditValidator 创建/编辑
|
||||
type ServiceEditValidator struct {
|
||||
Name string `validate:"required"`
|
||||
}
|
||||
|
||||
// GetMessage 创建 - 提示消息
|
||||
func (p ServiceEditValidator) GetMessage() validate.ValidatorMessages {
|
||||
return validate.ValidatorMessages{
|
||||
"Name.required": "名称不能为空",
|
||||
}
|
||||
}
|
||||
|
||||
// ServiceInfoValidator 查看信息
|
||||
type ServiceInfoValidator struct {
|
||||
Id int64 `validate:"required"`
|
||||
}
|
||||
|
||||
// GetMessage 查看信息 - 提示消息
|
||||
func (p ServiceInfoValidator) GetMessage() validate.ValidatorMessages {
|
||||
return validate.ValidatorMessages{
|
||||
"Id.required": "ID不能为空",
|
||||
}
|
||||
}
|
||||
|
||||
// ServiceStatusValidator 修改状态
|
||||
type ServiceStatusValidator struct {
|
||||
Id int64 `validate:"required"`
|
||||
Status int32 `validate:"required,oneof=1 2"`
|
||||
Reason string `validate:"required_if=Status 2"`
|
||||
}
|
||||
|
||||
// GetMessage 修改状态 - 提示消息
|
||||
func (p ServiceStatusValidator) GetMessage() validate.ValidatorMessages {
|
||||
return validate.ValidatorMessages{
|
||||
"Id.required": "ID不能为空",
|
||||
"Status.required": "状态不能为空",
|
||||
"Status.oneof": "状态传值不对",
|
||||
"Reason.required_if": "理由不能为空",
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user