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:
@@ -58,6 +58,17 @@ func (s *RolePermissionStore) Delete(ctx context.Context, roleID, permID uint) e
|
||||
return nil
|
||||
}
|
||||
|
||||
// BatchDelete 批量软删除角色-权限关联
|
||||
func (s *RolePermissionStore) BatchDelete(ctx context.Context, roleID uint, permIDs []uint) error {
|
||||
if err := s.db.WithContext(ctx).
|
||||
Where("role_id = ? AND perm_id IN ?", roleID, permIDs).
|
||||
Delete(&model.RolePermission{}).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
s.clearRoleUsersCaches(ctx, roleID)
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeleteByRoleID 删除角色的所有权限关联
|
||||
func (s *RolePermissionStore) DeleteByRoleID(ctx context.Context, roleID uint) error {
|
||||
if err := s.db.WithContext(ctx).
|
||||
|
||||
Reference in New Issue
Block a user