修改菜单,字典,角色

master
sugy 4 months ago
parent b7f516a5a6
commit 1ac546abd9
  1. 20
      src/main/java/com/nov/KgLowDurable/controller/RoleController.java
  2. 4
      src/main/java/com/nov/KgLowDurable/util/SpringUtil.java
  3. 12
      src/main/java/com/nov/KgLowDurable/wrapper/RoleWrapper.java
  4. 2
      src/main/resources/mapper/RoleMapper.xml
  5. 2
      src/main/resources/mapper/RoleMenuMapper.xml

@ -27,15 +27,19 @@ package com.nov.KgLowDurable.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.nov.KgLowDurable.pojo.entity.Role;
import com.nov.KgLowDurable.pojo.entity.User;
import com.nov.KgLowDurable.pojo.vo.RoleVO;
import com.nov.KgLowDurable.service.IRoleService;
import com.nov.KgLowDurable.util.Condition;
import com.nov.KgLowDurable.util.Result;
import com.nov.KgLowDurable.wrapper.RoleWrapper;
import io.swagger.annotations.*;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
@ -69,10 +73,10 @@ public class RoleController {
@ApiImplicitParam(name = "roleAlias", value = "角色别名")
})
@ApiOperation(value = "列表", notes = "传入role")
public Result<List<Role>> list(@ApiParam(hidden = true) @RequestParam Map<String, Object> role) {
public Result<List<RoleVO>> list(@ApiParam(hidden = true) @RequestParam Map<String, Object> role) {
QueryWrapper<Role> queryWrapper = Condition.getQueryWrapper(role, Role.class);
List<Role> list = roleService.list(queryWrapper);
return Result.OK(list);
return Result.OK(RoleWrapper.build().listNodeVO(list));
}
/**
@ -88,12 +92,12 @@ public class RoleController {
/**
* 获取指定角色树形结构
*/
// @GetMapping("/tree-by-id")
// @ApiOperation(value = "树形结构", notes = "树形结构")
// public Result<List<RoleVO>> treeById(Long roleId, Tuser bladeUser) {
// List<RoleVO> tree = roleService.tree(bladeUser.getUserId());
// return Result.OK(tree);
// }
@GetMapping("/tree-by-id")
@ApiOperation(value = "树形结构", notes = "树形结构")
public Result<List<RoleVO>> treeById(Long roleId, User bladeUser) {
List<RoleVO> tree = roleService.tree(bladeUser.getUserId());
return Result.OK(tree);
}
/**
* 新增或修改

@ -25,8 +25,8 @@ public class SpringUtil implements ApplicationContextAware {
return clazz == null ? null : context.getBean(clazz);
}
public static <T> T getBean(String beanId) {
return beanId == null ? null : (T) context.getBean(beanId);
public static <T> Object getBean(String beanId) {
return beanId == null ? null : context.getBean(beanId);
}
public static <T> T getBean(String beanName, Class<T> clazz) {

@ -28,8 +28,12 @@ package com.nov.KgLowDurable.wrapper;
import com.nov.KgLowDurable.mapper.RoleMapper;
import com.nov.KgLowDurable.pojo.entity.Role;
import com.nov.KgLowDurable.pojo.vo.LdDictVO;
import com.nov.KgLowDurable.pojo.vo.RoleVO;
import com.nov.KgLowDurable.util.*;
import com.nov.KgLowDurable.util.BeanUtil;
import com.nov.KgLowDurable.util.BladeConstant;
import com.nov.KgLowDurable.util.ForestNodeMerger;
import com.nov.KgLowDurable.util.Func;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
@ -43,8 +47,8 @@ import java.util.stream.Collectors;
*/
public class RoleWrapper extends BaseEntityWrapper<Role, RoleVO> {
private RoleMapper roleMapper= SpringUtil.getBean(RoleMapper.class);;
@Autowired
private RoleMapper roleMapper;
public static RoleWrapper build() {
return new RoleWrapper();
@ -64,7 +68,7 @@ public class RoleWrapper extends BaseEntityWrapper<Role, RoleVO> {
public List<RoleVO> listNodeVO(List<Role> list) {
List<RoleVO> collect = list.stream().map(this::entityVO).collect(Collectors.toList());
List<RoleVO> collect = list.stream().map(Role -> BeanUtil.copyProperties(Role, RoleVO.class)).collect(Collectors.toList());
return ForestNodeMerger.merge(collect);
}

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.springblade.modules.system.mapper.RoleMapper">
<mapper namespace="com.nov.KgLowDurable.mapper.RoleMapper">
<!-- 通用查询映射结果 -->
<resultMap id="roleResultMap" type="com.nov.KgLowDurable.pojo.entity.Role">

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.springblade.modules.system.mapper.RoleMenuMapper">
<mapper namespace="com.nov.KgLowDurable.mapper.RoleMenuMapper">
<!-- 通用查询映射结果 -->
<resultMap id="roleMenuResultMap" type="com.nov.KgLowDurable.pojo.entity.RoleMenu">

Loading…
Cancel
Save