feat(新增): 批量修改权限父级
This commit is contained in:
parent
e493f282fa
commit
04a88305de
|
@ -3,24 +3,24 @@ import { $t } from '@/plugins/i18n';
|
|||
|
||||
// 表格列
|
||||
export const columns: TableColumnList = [
|
||||
{ type: 'index', index: (index: number) => index + 1 },
|
||||
// { type: 'selection', align: 'left' },
|
||||
{ label: $t('id'), prop: 'id' },
|
||||
{ type: 'selection', align: 'left' },
|
||||
{ type: 'index', index: (index: number) => index + 1 },
|
||||
{ label: $t('id'), prop: 'id' },
|
||||
#foreach($field in $baseFieldList)
|
||||
// $field.annotation
|
||||
{ label: $t('${lowercaseName}_$field.name'), prop: '$field.name' },
|
||||
// $field.annotation
|
||||
{ label: $t('${lowercaseName}_$field.name'), prop: '$field.name' },
|
||||
#end
|
||||
{ label: $t('table.updateTime'), prop: 'updateTime', sortable: true, width: 160 },
|
||||
{ label: $t('table.createTime'), prop: 'createTime', sortable: true, width: 160 },
|
||||
{ label: $t('table.createUser'), prop: 'createUser', slot: 'createUser', width: 90 },
|
||||
{ label: $t('table.updateUser'), prop: 'updateUser', slot: 'updateUser', width: 90 },
|
||||
{ label: $t('table.operation'), fixed: 'right', width: 210, slot: 'operation' },
|
||||
{ label: $t('table.updateTime'), prop: 'updateTime', sortable: true, width: 160 },
|
||||
{ label: $t('table.createTime'), prop: 'createTime', sortable: true, width: 160 },
|
||||
{ label: $t('table.createUser'), prop: 'createUser', slot: 'createUser', width: 90 },
|
||||
{ label: $t('table.updateUser'), prop: 'updateUser', slot: 'updateUser', width: 90 },
|
||||
{ label: $t('table.operation'), fixed: 'right', width: 210, slot: 'operation' },
|
||||
];
|
||||
|
||||
// 添加规则
|
||||
export const rules = reactive({
|
||||
#foreach($field in $baseFieldList)
|
||||
// $field.annotation
|
||||
// $field.annotation
|
||||
$field.name: [{ required: true, message: `$leftBrace$t('input')}$leftBrace$t('${lowercaseName}_${field.name}')}`, trigger: 'blur' }],
|
||||
#end
|
||||
});
|
||||
|
|
|
@ -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;
|
||||
|
||||
}
|
|
@ -33,4 +33,4 @@ public class PowerUpdateDto {
|
|||
@Schema(name = "requestUrl", title = "请求路径")
|
||||
private String requestUrl;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ public class I18nController {
|
|||
return Mono.just(Result.success(ResultCodeEnum.UPDATE_SUCCESS));
|
||||
}
|
||||
|
||||
@Operation(summary = "删除多语言类型", description = "删除多语言类型")
|
||||
@Operation(summary = "删除多语言", description = "删除多语言")
|
||||
@DeleteMapping("deleteI18n")
|
||||
public Mono<Result<String>> deleteI18n(@RequestBody List<Long> ids) {
|
||||
i18nService.deleteI18n(ids);
|
||||
|
|
|
@ -2,6 +2,7 @@ package cn.bunny.services.controller;
|
|||
|
||||
import cn.bunny.dao.dto.system.rolePower.PowerAddDto;
|
||||
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.entity.system.Power;
|
||||
import cn.bunny.dao.pojo.result.PageResult;
|
||||
|
@ -49,6 +50,13 @@ public class PowerController {
|
|||
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 = "添加权限")
|
||||
@PostMapping("addPower")
|
||||
public Mono<Result<String>> addPower(@Valid @RequestBody PowerAddDto dto) {
|
||||
|
@ -63,6 +71,13 @@ public class PowerController {
|
|||
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 = "删除权限")
|
||||
@DeleteMapping("deletePower")
|
||||
public Mono<Result<String>> deletePower(@RequestBody List<Long> ids) {
|
||||
|
@ -70,10 +85,4 @@ public class PowerController {
|
|||
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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ public class RouterRoleController {
|
|||
@Autowired
|
||||
private RouterRoleService routerRoleService;
|
||||
|
||||
@Operation(summary = "根据路由id获取所有角色", description = "根据路由id获取所有角色")
|
||||
@Operation(summary = "根据菜单id获取所有角色", description = "根据菜单id获取所有角色")
|
||||
@GetMapping("getRoleListByRouterId")
|
||||
public Mono<Result<List<String>>> getRoleListByRouterId(Long routerId) {
|
||||
List<String> roleListByRouterId = routerRoleService.getRoleListByRouterId(routerId);
|
||||
|
|
|
@ -2,6 +2,7 @@ package cn.bunny.services.service;
|
|||
|
||||
import cn.bunny.dao.dto.system.rolePower.PowerAddDto;
|
||||
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.entity.system.Power;
|
||||
import cn.bunny.dao.pojo.result.PageResult;
|
||||
|
@ -57,4 +58,10 @@ public interface PowerService extends IService<Power> {
|
|||
*/
|
||||
List<PowerVo> getAllPowers();
|
||||
|
||||
/**
|
||||
* * 批量修改权限父级
|
||||
*
|
||||
* @param dto 批量修改权限表单
|
||||
*/
|
||||
void updateBatchByPowerWithParentId(PowerUpdateBatchByParentIdDto dto);
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package cn.bunny.services.service.impl;
|
|||
import cn.bunny.common.service.exception.BunnyException;
|
||||
import cn.bunny.dao.dto.system.rolePower.PowerAddDto;
|
||||
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.entity.system.Power;
|
||||
import cn.bunny.dao.pojo.result.PageResult;
|
||||
|
@ -20,6 +21,7 @@ import jakarta.validation.Valid;
|
|||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -32,6 +34,7 @@ import java.util.List;
|
|||
* @since 2024-10-03 16:00:52
|
||||
*/
|
||||
@Service
|
||||
@Transactional
|
||||
public class PowerServiceImpl extends ServiceImpl<PowerMapper, Power> implements PowerService {
|
||||
|
||||
@Autowired
|
||||
|
@ -97,7 +100,7 @@ public class PowerServiceImpl extends ServiceImpl<PowerMapper, Power> implements
|
|||
List<Power> powerList = list(Wrappers.<Power>lambdaQuery().eq(Power::getId, id));
|
||||
if (powerList.isEmpty()) throw new BunnyException(ResultCodeEnum.DATA_NOT_EXIST);
|
||||
if (dto.getId().equals(dto.getParentId())) throw new BunnyException(ResultCodeEnum.ILLEGAL_DATA_REQUEST);
|
||||
|
||||
|
||||
// 更新内容
|
||||
Power power = new Power();
|
||||
BeanUtils.copyProperties(dto, power);
|
||||
|
@ -132,4 +135,21 @@ public class PowerServiceImpl extends ServiceImpl<PowerMapper, Power> implements
|
|||
return powerVo;
|
||||
}).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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue