role_create.go 563 字节
package command

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

type CreateRoleCommand struct {
	CompanyId   int64  `cname:"公司ID" json:"companyId"`
	Name        string `cname:"角色名称" json:"name" valid:"Required"`
	Description string `cname:"角色描述" json:"description"`
}

func (in *CreateRoleCommand) Valid(validation *validation.Validation) {
	if in.CompanyId == 0 {
		validation.SetError("companyId", "公司ID无效")
		return
	}

	if len(in.Name) > 30 {
		validation.SetError("name", "角色名称最大长度30个字符")
		return
	}
}