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:
@@ -121,7 +121,7 @@ func (s *PermissionStore) GetByIDs(ctx context.Context, ids []uint) ([]*model.Pe
|
||||
}
|
||||
|
||||
// GetAll 获取所有权限(用于构建权限树)
|
||||
func (s *PermissionStore) GetAll(ctx context.Context, availableForRoleType *int) ([]*model.Permission, error) {
|
||||
func (s *PermissionStore) GetAll(ctx context.Context, availableForRoleType *int, status *int) ([]*model.Permission, error) {
|
||||
var permissions []*model.Permission
|
||||
query := s.db.WithContext(ctx)
|
||||
|
||||
@@ -130,6 +130,10 @@ func (s *PermissionStore) GetAll(ctx context.Context, availableForRoleType *int)
|
||||
query = query.Where("available_for_role_types LIKE ?", "%"+roleTypeStr+"%")
|
||||
}
|
||||
|
||||
if status != nil {
|
||||
query = query.Where("status = ?", *status)
|
||||
}
|
||||
|
||||
if err := query.Order("sort ASC, id ASC").Find(&permissions).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user