command_set_role_access_request.go 506 字节
package rbac

import (
	"fmt"
	"github.com/astaxie/beego/validation"
)

type SetRoleAccessRequest struct {
	RoleId    int64   `json:"roleId"`
	AccessIds []int64 `json:"accessIds"`
}

func (SetRoleAccessRequest *SetRoleAccessRequest) ValidateCommand() error {
	valid := validation.Validation{}
	b, err := valid.Valid(SetRoleAccessRequest)
	if err != nil {
		return err
	}
	if !b {
		for _, validErr := range valid.Errors {
			return fmt.Errorf("%s  %s", validErr.Key, validErr.Message)
		}
	}
	return nil
}