diff --git a/src/main/java/com/nov/KgLowDurable/controller/RoleController.java b/src/main/java/com/nov/KgLowDurable/controller/RoleController.java index 07922c7..8f78950 100644 --- a/src/main/java/com/nov/KgLowDurable/controller/RoleController.java +++ b/src/main/java/com/nov/KgLowDurable/controller/RoleController.java @@ -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(@ApiParam(hidden = true) @RequestParam Map role) { + public Result> list(@ApiParam(hidden = true) @RequestParam Map role) { QueryWrapper queryWrapper = Condition.getQueryWrapper(role, Role.class); List 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> treeById(Long roleId, Tuser bladeUser) { -// List tree = roleService.tree(bladeUser.getUserId()); -// return Result.OK(tree); -// } + @GetMapping("/tree-by-id") + @ApiOperation(value = "树形结构", notes = "树形结构") + public Result> treeById(Long roleId, User bladeUser) { + List tree = roleService.tree(bladeUser.getUserId()); + return Result.OK(tree); + } /** * 新增或修改 diff --git a/src/main/java/com/nov/KgLowDurable/util/SpringUtil.java b/src/main/java/com/nov/KgLowDurable/util/SpringUtil.java index 7f44261..e6d0ac2 100644 --- a/src/main/java/com/nov/KgLowDurable/util/SpringUtil.java +++ b/src/main/java/com/nov/KgLowDurable/util/SpringUtil.java @@ -25,8 +25,8 @@ public class SpringUtil implements ApplicationContextAware { return clazz == null ? null : context.getBean(clazz); } - public static T getBean(String beanId) { - return beanId == null ? null : (T) context.getBean(beanId); + public static Object getBean(String beanId) { + return beanId == null ? null : context.getBean(beanId); } public static T getBean(String beanName, Class clazz) { diff --git a/src/main/java/com/nov/KgLowDurable/wrapper/RoleWrapper.java b/src/main/java/com/nov/KgLowDurable/wrapper/RoleWrapper.java index 320bee5..e96379e 100644 --- a/src/main/java/com/nov/KgLowDurable/wrapper/RoleWrapper.java +++ b/src/main/java/com/nov/KgLowDurable/wrapper/RoleWrapper.java @@ -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 { - - 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 { public List listNodeVO(List list) { - List collect = list.stream().map(this::entityVO).collect(Collectors.toList()); + List collect = list.stream().map(Role -> BeanUtil.copyProperties(Role, RoleVO.class)).collect(Collectors.toList()); return ForestNodeMerger.merge(collect); } diff --git a/src/main/resources/mapper/RoleMapper.xml b/src/main/resources/mapper/RoleMapper.xml index 2ba0955..2295ab0 100644 --- a/src/main/resources/mapper/RoleMapper.xml +++ b/src/main/resources/mapper/RoleMapper.xml @@ -1,6 +1,6 @@ - + diff --git a/src/main/resources/mapper/RoleMenuMapper.xml b/src/main/resources/mapper/RoleMenuMapper.xml index d06bfdc..59895e3 100644 --- a/src/main/resources/mapper/RoleMenuMapper.xml +++ b/src/main/resources/mapper/RoleMenuMapper.xml @@ -1,6 +1,6 @@ - +