feat(permission): 为权限树接口添加状态查询参数和返回值
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 6m22s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 6m22s
- 新增 PermissionTreeRequest DTO 支持 status 查询参数 - PermissionTreeNode 返回值新增 status 字段 - Store 层 GetAll 方法支持状态过滤 - Handler 层使用 QueryParser 解析请求参数
This commit is contained in:
@@ -301,7 +301,7 @@ func (s *Service) getUserPermissionsAndMenus(ctx context.Context, userID uint, u
|
||||
}
|
||||
|
||||
func (s *Service) getAllPermissionsForSuperAdmin(ctx context.Context, device string) ([]string, []dto.MenuNode, []string, error) {
|
||||
permissions, err := s.permissionStore.GetAll(ctx, nil)
|
||||
permissions, err := s.permissionStore.GetAll(ctx, nil, nil)
|
||||
if err != nil {
|
||||
return nil, nil, nil, errors.Wrap(errors.CodeInternalError, err, "查询所有权限失败")
|
||||
}
|
||||
|
||||
@@ -230,8 +230,8 @@ func (s *Service) List(ctx context.Context, req *dto.PermissionListRequest) ([]*
|
||||
}
|
||||
|
||||
// GetTree 获取权限树
|
||||
func (s *Service) GetTree(ctx context.Context, availableForRoleType *int) ([]*dto.PermissionTreeNode, error) {
|
||||
permissions, err := s.permissionStore.GetAll(ctx, availableForRoleType)
|
||||
func (s *Service) GetTree(ctx context.Context, req *dto.PermissionTreeRequest) ([]*dto.PermissionTreeNode, error) {
|
||||
permissions, err := s.permissionStore.GetAll(ctx, req.AvailableForRoleType, req.Status)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(errors.CodeInternalError, err, "获取权限列表失败")
|
||||
}
|
||||
@@ -252,6 +252,7 @@ func buildPermissionTree(permissions []*model.Permission) []*dto.PermissionTreeN
|
||||
AvailableForRoleTypes: p.AvailableForRoleTypes,
|
||||
URL: p.URL,
|
||||
Sort: p.Sort,
|
||||
Status: p.Status,
|
||||
Children: make([]*dto.PermissionTreeNode, 0),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user