role_user_create.go 616 字节
package command

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

// UserRoleCreateCommand 用户加入到该角色中
type UserRoleCreateCommand struct {
	CompanyId int64    `cname:"公司ID" json:"companyId"`
	RoleId    int64    `cname:"角色ID" json:"roleId,string" valid:"Required"`
	UserIds   []string `cname:"用户ID" json:"userIds"`
}

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

	if len(in.UserIds) == 0 {
		validation.SetError("userIds", "添加的用户不存在")
		return
	}
}