create_dictionary.go 1.0 KB
package command

import (
	"fmt"

	"github.com/beego/beego/v2/core/validation"
)

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 []*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
}