优化结构

This commit is contained in:
Yvan
2026-08-23 02:36:58 +08:00
parent 7d89e2ea4d
commit 40632c5756
50 changed files with 408 additions and 115 deletions
+28
View File
@@ -0,0 +1,28 @@
package system
import (
"context"
"kra/internal/biz/system"
)
type AccessControlService struct{ uc *system.AccessControlUsecase }
func NewAccessControlService(uc *system.AccessControlUsecase) *AccessControlService {
return &AccessControlService{uc: uc}
}
func (s *AccessControlService) Authorize(ctx context.Context, authorityID uint, path, method string) (bool, error) {
return s.uc.Authorize(ctx, authorityID, path, method)
}
func (s *AccessControlService) ResolveDataScope(ctx context.Context, authorityID, userID uint) (system.DataScope, error) {
return s.uc.ResolveDataScope(ctx, authorityID, userID)
}
func (s *AccessControlService) ContextWithDataScope(ctx context.Context, authorityID, userID uint) (context.Context, error) {
scope, err := s.ResolveDataScope(ctx, authorityID, userID)
if err != nil {
return ctx, err
}
return system.NewDataScopeContext(ctx, scope), nil
}