41 lines
1.3 KiB
Go
41 lines
1.3 KiB
Go
package system
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
)
|
|
|
|
// AuthorityBtnRepo 角色按钮权限仓储接口
|
|
type AuthorityBtnRepo interface {
|
|
GetAuthorityBtn(ctx context.Context, authorityId, menuId uint) ([]uint, error)
|
|
SetAuthorityBtn(ctx context.Context, authorityId, menuId uint, btnIds []uint) error
|
|
CanRemoveAuthorityBtn(ctx context.Context, btnId uint) error
|
|
}
|
|
|
|
// AuthorityBtnUsecase 角色按钮权限用例
|
|
type AuthorityBtnUsecase struct {
|
|
repo AuthorityBtnRepo
|
|
}
|
|
|
|
// NewAuthorityBtnUsecase 创建角色按钮权限用例
|
|
func NewAuthorityBtnUsecase(repo AuthorityBtnRepo) *AuthorityBtnUsecase {
|
|
return &AuthorityBtnUsecase{repo: repo}
|
|
}
|
|
|
|
// GetAuthorityBtn 获取角色按钮权限
|
|
func (uc *AuthorityBtnUsecase) GetAuthorityBtn(ctx context.Context, authorityId, menuId uint) ([]uint, error) {
|
|
return uc.repo.GetAuthorityBtn(ctx, authorityId, menuId)
|
|
}
|
|
|
|
// SetAuthorityBtn 设置角色按钮权限
|
|
func (uc *AuthorityBtnUsecase) SetAuthorityBtn(ctx context.Context, authorityId, menuId uint, btnIds []uint) error {
|
|
return uc.repo.SetAuthorityBtn(ctx, authorityId, menuId, btnIds)
|
|
}
|
|
|
|
// CanRemoveAuthorityBtn 检查按钮是否可以删除
|
|
func (uc *AuthorityBtnUsecase) CanRemoveAuthorityBtn(ctx context.Context, btnId uint) error {
|
|
return uc.repo.CanRemoveAuthorityBtn(ctx, btnId)
|
|
}
|
|
|
|
var ErrBtnInUse = errors.New("此按钮正在被使用无法删除")
|