feat: 新增批量移除角色权限接口
Some checks failed
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Has been cancelled
Some checks failed
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Has been cancelled
- 新增 DELETE /api/admin/roles/:role_id/permissions 接口 - Store 层新增 BatchDelete 方法,单次 SQL 批量软删除 - Service 层新增 BatchRemovePermissions 方法 - Handler 层新增 BatchRemovePermissions 处理函数 - DTO 新增 BatchRemovePermissionsRequest/Params - 修复 openapi generator 对 DELETE 方法 requestBody 不生成的问题 - RouteSpec 新增 Body 字段,支持显式指定 JSON 请求体 💘 Generated with Crush Assisted-by: Claude Sonnet 4.6 via Crush <crush@charm.land>
This commit is contained in:
@@ -286,6 +286,23 @@ func (s *Service) RemovePermission(ctx context.Context, roleID, permID uint) err
|
||||
return nil
|
||||
}
|
||||
|
||||
// BatchRemovePermissions 批量移除角色的权限
|
||||
func (s *Service) BatchRemovePermissions(ctx context.Context, roleID uint, permIDs []uint) error {
|
||||
_, err := s.roleStore.GetByID(ctx, roleID)
|
||||
if err != nil {
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
return errors.New(errors.CodeRoleNotFound, "角色不存在")
|
||||
}
|
||||
return errors.Wrap(errors.CodeInternalError, err, "获取角色失败")
|
||||
}
|
||||
|
||||
if err := s.rolePermissionStore.BatchDelete(ctx, roleID, permIDs); err != nil {
|
||||
return errors.Wrap(errors.CodeInternalError, err, "批量删除角色-权限关联失败")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// UpdateStatus 更新角色状态
|
||||
func (s *Service) UpdateStatus(ctx context.Context, id uint, status int) error {
|
||||
currentUserID := middleware.GetUserIDFromContext(ctx)
|
||||
|
||||
Reference in New Issue
Block a user