feat(shop-role): 实现店铺角色继承功能和权限检查优化
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 6m39s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 6m39s
- 新增店铺角色管理 API 和数据模型 - 实现角色继承和权限检查逻辑 - 添加流程测试框架和集成测试 - 更新权限服务和账号管理逻辑 - 添加数据库迁移脚本 - 归档 OpenSpec 变更文档 Ultraworked with Sisyphus
This commit is contained in:
@@ -22,11 +22,16 @@ import (
|
||||
// permCodeRegex 权限编码格式验证正则(module:action)
|
||||
var permCodeRegex = regexp.MustCompile(`^[a-z][a-z0-9_]*:[a-z][a-z0-9_]*$`)
|
||||
|
||||
type AccountServiceInterface interface {
|
||||
GetRoleIDsForAccount(ctx context.Context, accountID uint) ([]uint, error)
|
||||
}
|
||||
|
||||
// Service 权限业务服务
|
||||
type Service struct {
|
||||
permissionStore *postgres.PermissionStore
|
||||
accountRoleStore *postgres.AccountRoleStore
|
||||
rolePermStore *postgres.RolePermissionStore
|
||||
accountService AccountServiceInterface
|
||||
redisClient *redis.Client
|
||||
}
|
||||
|
||||
@@ -35,12 +40,14 @@ func New(
|
||||
permissionStore *postgres.PermissionStore,
|
||||
accountRoleStore *postgres.AccountRoleStore,
|
||||
rolePermStore *postgres.RolePermissionStore,
|
||||
accountService AccountServiceInterface,
|
||||
redisClient *redis.Client,
|
||||
) *Service {
|
||||
return &Service{
|
||||
permissionStore: permissionStore,
|
||||
accountRoleStore: accountRoleStore,
|
||||
rolePermStore: rolePermStore,
|
||||
accountService: accountService,
|
||||
redisClient: redisClient,
|
||||
}
|
||||
}
|
||||
@@ -298,7 +305,7 @@ func (s *Service) CheckPermission(ctx context.Context, userID uint, permCode str
|
||||
}
|
||||
}
|
||||
|
||||
roleIDs, err := s.accountRoleStore.GetRoleIDsByAccountID(ctx, userID)
|
||||
roleIDs, err := s.accountService.GetRoleIDsForAccount(ctx, userID)
|
||||
if err != nil {
|
||||
return false, errors.Wrap(errors.CodeInternalError, err, "查询用户角色失败")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user