cooperation_user_update.go
1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package command
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
)
type CooperationUserUpdateCommand struct {
// 用户编号
UsersId int64 `json:"usersId" valid:"Required"`
// 用户编号
UsersCode string `json:"usersCode" valid:"Required"`
// 用户姓名
UsersName string `json:"usersName" valid:"Required"`
// 共创公司
CooperationCompany string `json:"cooperationCompany" valid:"Required"`
// 共创公司到期时间
CooperationDeadline string `json:"cooperationDeadline" valid:"Required"`
// 启用状态(启用:1 禁用:2)
EnableStatus int `json:"enableStatus" valid:"Required"`
// 邮箱
Email string `json:"email" valid:"Required"`
}
func (cooperationUserUpdateCommand *CooperationUserUpdateCommand) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
}
func (cooperationUserUpdateCommand *CooperationUserUpdateCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(cooperationUserUpdateCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}