create_dictionary.go
1.1 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
package command
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/domain"
)
type CreateDictionaryCommand struct {
// 字典编号 主键
DictionaryId int `json:"dictionaryId,omitempty"`
// 字典编码
DictCode string `json:"dictCode,omitempty"`
// 字典名称
DictName string `json:"dictName,omitempty"`
// 备注信息
Desc string `json:"desc,omitempty"`
// 是否可见【1:不可以】【2:可以】
IsShow int `json:"isShow,omitempty"`
// 字典值列表
DictItems []*domain.DictionaryItem `json:"dictItems,omitempty"`
}
func (createDictionaryCommand *CreateDictionaryCommand) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
}
func (createDictionaryCommand *CreateDictionaryCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(createDictionaryCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}