package system

import "context"

type AccessControlUsecase struct {
	authorities AuthorityAccessRepo
	apis        APIRepo
}

func NewAccessControlUsecase(authorities AuthorityAccessRepo, apis APIRepo) *AccessControlUsecase {
	return &AccessControlUsecase{authorities: authorities, apis: apis}
}

func (uc *AccessControlUsecase) Authorize(ctx context.Context, authorityID uint, path, method string) (bool, error) {
	return uc.apis.Authorize(ctx, authorityID, path, method)
}

func (uc *AccessControlUsecase) ResolveDataScope(ctx context.Context, authorityID, userID uint) (DataScope, error) {
	return uc.authorities.ResolveDataScope(ctx, authorityID, userID)
}
