feat(新增): 批量修改权限父级

This commit is contained in:
bunny 2024-10-10 10:32:38 +08:00
parent e493f282fa
commit 04a88305de
8 changed files with 84 additions and 21 deletions

View File

@ -3,8 +3,8 @@ import { $t } from '@/plugins/i18n';
// 表格列 // 表格列
export const columns: TableColumnList = [ export const columns: TableColumnList = [
{ type: 'selection', align: 'left' },
{ type: 'index', index: (index: number) => index + 1 }, { type: 'index', index: (index: number) => index + 1 },
// { type: 'selection', align: 'left' },
{ label: $t('id'), prop: 'id' }, { label: $t('id'), prop: 'id' },
#foreach($field in $baseFieldList) #foreach($field in $baseFieldList)
// $field.annotation // $field.annotation

View File

@ -0,0 +1,27 @@
package cn.bunny.dao.dto.system.rolePower;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Schema(name = "PowerUpdateBatchByParentIdDto对象", title = "批量修改权限", description = "批量修改权限表单")
public class PowerUpdateBatchByParentIdDto {
@Schema(name = "id", title = "主键")
@NotNull(message = "id不能为空")
private List<Long> ids;
@Schema(name = "parentId", title = "父级id")
@NotNull(message = "父级不能为空")
private Long parentId;
}

View File

@ -71,7 +71,7 @@ public class I18nController {
return Mono.just(Result.success(ResultCodeEnum.UPDATE_SUCCESS)); return Mono.just(Result.success(ResultCodeEnum.UPDATE_SUCCESS));
} }
@Operation(summary = "删除多语言类型", description = "删除多语言类型") @Operation(summary = "删除多语言", description = "删除多语言")
@DeleteMapping("deleteI18n") @DeleteMapping("deleteI18n")
public Mono<Result<String>> deleteI18n(@RequestBody List<Long> ids) { public Mono<Result<String>> deleteI18n(@RequestBody List<Long> ids) {
i18nService.deleteI18n(ids); i18nService.deleteI18n(ids);

View File

@ -2,6 +2,7 @@ package cn.bunny.services.controller;
import cn.bunny.dao.dto.system.rolePower.PowerAddDto; import cn.bunny.dao.dto.system.rolePower.PowerAddDto;
import cn.bunny.dao.dto.system.rolePower.PowerDto; import cn.bunny.dao.dto.system.rolePower.PowerDto;
import cn.bunny.dao.dto.system.rolePower.PowerUpdateBatchByParentIdDto;
import cn.bunny.dao.dto.system.rolePower.PowerUpdateDto; import cn.bunny.dao.dto.system.rolePower.PowerUpdateDto;
import cn.bunny.dao.entity.system.Power; import cn.bunny.dao.entity.system.Power;
import cn.bunny.dao.pojo.result.PageResult; import cn.bunny.dao.pojo.result.PageResult;
@ -49,6 +50,13 @@ public class PowerController {
return Mono.just(Result.success(pageResult)); return Mono.just(Result.success(pageResult));
} }
@Operation(summary = "获取所有权限", description = "获取所有权限")
@GetMapping("getAllPowers")
public Mono<Result<List<PowerVo>>> getAllPowers() {
List<PowerVo> voList = powerService.getAllPowers();
return Mono.just(Result.success(voList));
}
@Operation(summary = "添加权限", description = "添加权限") @Operation(summary = "添加权限", description = "添加权限")
@PostMapping("addPower") @PostMapping("addPower")
public Mono<Result<String>> addPower(@Valid @RequestBody PowerAddDto dto) { public Mono<Result<String>> addPower(@Valid @RequestBody PowerAddDto dto) {
@ -63,6 +71,13 @@ public class PowerController {
return Mono.just(Result.success(ResultCodeEnum.UPDATE_SUCCESS)); return Mono.just(Result.success(ResultCodeEnum.UPDATE_SUCCESS));
} }
@Operation(summary = "批量修改权限父级", description = "批量修改权限父级")
@PutMapping("updateBatchByPowerWithParentId")
public Mono<Result<String>> updateBatchByPowerWithParentId(@RequestBody @Valid PowerUpdateBatchByParentIdDto dto) {
powerService.updateBatchByPowerWithParentId(dto);
return Mono.just(Result.success(ResultCodeEnum.UPDATE_SUCCESS));
}
@Operation(summary = "删除权限", description = "删除权限") @Operation(summary = "删除权限", description = "删除权限")
@DeleteMapping("deletePower") @DeleteMapping("deletePower")
public Mono<Result<String>> deletePower(@RequestBody List<Long> ids) { public Mono<Result<String>> deletePower(@RequestBody List<Long> ids) {
@ -70,10 +85,4 @@ public class PowerController {
return Mono.just(Result.success(ResultCodeEnum.DELETE_SUCCESS)); return Mono.just(Result.success(ResultCodeEnum.DELETE_SUCCESS));
} }
@Operation(summary = "获取所有权限", description = "获取所有权限")
@GetMapping("getAllPowers")
public Mono<Result<List<PowerVo>>> getAllPowers() {
List<PowerVo> voList = powerService.getAllPowers();
return Mono.just(Result.success(voList));
}
} }

View File

@ -27,7 +27,7 @@ public class RouterRoleController {
@Autowired @Autowired
private RouterRoleService routerRoleService; private RouterRoleService routerRoleService;
@Operation(summary = "根据路由id获取所有角色", description = "根据路由id获取所有角色") @Operation(summary = "根据菜单id获取所有角色", description = "根据菜单id获取所有角色")
@GetMapping("getRoleListByRouterId") @GetMapping("getRoleListByRouterId")
public Mono<Result<List<String>>> getRoleListByRouterId(Long routerId) { public Mono<Result<List<String>>> getRoleListByRouterId(Long routerId) {
List<String> roleListByRouterId = routerRoleService.getRoleListByRouterId(routerId); List<String> roleListByRouterId = routerRoleService.getRoleListByRouterId(routerId);

View File

@ -2,6 +2,7 @@ package cn.bunny.services.service;
import cn.bunny.dao.dto.system.rolePower.PowerAddDto; import cn.bunny.dao.dto.system.rolePower.PowerAddDto;
import cn.bunny.dao.dto.system.rolePower.PowerDto; import cn.bunny.dao.dto.system.rolePower.PowerDto;
import cn.bunny.dao.dto.system.rolePower.PowerUpdateBatchByParentIdDto;
import cn.bunny.dao.dto.system.rolePower.PowerUpdateDto; import cn.bunny.dao.dto.system.rolePower.PowerUpdateDto;
import cn.bunny.dao.entity.system.Power; import cn.bunny.dao.entity.system.Power;
import cn.bunny.dao.pojo.result.PageResult; import cn.bunny.dao.pojo.result.PageResult;
@ -57,4 +58,10 @@ public interface PowerService extends IService<Power> {
*/ */
List<PowerVo> getAllPowers(); List<PowerVo> getAllPowers();
/**
* * 批量修改权限父级
*
* @param dto 批量修改权限表单
*/
void updateBatchByPowerWithParentId(PowerUpdateBatchByParentIdDto dto);
} }

View File

@ -3,6 +3,7 @@ package cn.bunny.services.service.impl;
import cn.bunny.common.service.exception.BunnyException; import cn.bunny.common.service.exception.BunnyException;
import cn.bunny.dao.dto.system.rolePower.PowerAddDto; import cn.bunny.dao.dto.system.rolePower.PowerAddDto;
import cn.bunny.dao.dto.system.rolePower.PowerDto; import cn.bunny.dao.dto.system.rolePower.PowerDto;
import cn.bunny.dao.dto.system.rolePower.PowerUpdateBatchByParentIdDto;
import cn.bunny.dao.dto.system.rolePower.PowerUpdateDto; import cn.bunny.dao.dto.system.rolePower.PowerUpdateDto;
import cn.bunny.dao.entity.system.Power; import cn.bunny.dao.entity.system.Power;
import cn.bunny.dao.pojo.result.PageResult; import cn.bunny.dao.pojo.result.PageResult;
@ -20,6 +21,7 @@ import jakarta.validation.Valid;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List; import java.util.List;
@ -32,6 +34,7 @@ import java.util.List;
* @since 2024-10-03 16:00:52 * @since 2024-10-03 16:00:52
*/ */
@Service @Service
@Transactional
public class PowerServiceImpl extends ServiceImpl<PowerMapper, Power> implements PowerService { public class PowerServiceImpl extends ServiceImpl<PowerMapper, Power> implements PowerService {
@Autowired @Autowired
@ -132,4 +135,21 @@ public class PowerServiceImpl extends ServiceImpl<PowerMapper, Power> implements
return powerVo; return powerVo;
}).toList(); }).toList();
} }
/**
* * 批量修改权限父级
*
* @param dto 批量修改权限表单
*/
@Override
public void updateBatchByPowerWithParentId(PowerUpdateBatchByParentIdDto dto) {
List<Power> powerList = dto.getIds().stream().map(id -> {
Power power = new Power();
power.setId(id);
power.setParentId(dto.getParentId());
return power;
}).toList();
updateBatchById(powerList);
}
} }