微调
This commit is contained in:
@@ -12,6 +12,7 @@ import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.gather.user.user.pojo.param.SysFunctionParam;
|
||||
import com.njcn.gather.user.user.pojo.param.SysRoleParam;
|
||||
import com.njcn.gather.user.user.pojo.po.SysFunction;
|
||||
import com.njcn.gather.user.user.pojo.vo.MenuVO;
|
||||
import com.njcn.gather.user.user.service.ISysFunctionService;
|
||||
import com.njcn.gather.user.user.service.ISysRoleFunctionService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
@@ -108,39 +109,16 @@ public class SysFunctionController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
// @OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
// @GetMapping("/getFunctionById")
|
||||
// @ApiOperation("菜单详情")
|
||||
// @ApiImplicitParam(name = "id", value = "菜单id", required = true)
|
||||
// public HttpResult<SysFunction> getFunctionById(String id) {
|
||||
// String methodDescribe = getMethodDescribe("getFunctionById");
|
||||
// LogUtil.njcnDebug(log, "{},菜单id为:{}", methodDescribe, id);
|
||||
// SysFunction function = sysFunctionService.getFunctionById(id);
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, function, methodDescribe);
|
||||
// }
|
||||
|
||||
// @OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
// @GetMapping("/getButtonById")
|
||||
// @ApiOperation("获取按钮")
|
||||
// @ApiImplicitParam(name = "id", value = "菜单id", required = true)
|
||||
// public HttpResult<List<SysFunction>> getButtonById(String id) {
|
||||
// String methodDescribe = getMethodDescribe("getButtonById");
|
||||
// LogUtil.njcnDebug(log, "{},菜单id为:{}", methodDescribe, id);
|
||||
// List<SysFunction> list = sysFunctionService.getButtonsById(id);
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
// }
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@GetMapping("/getMenu")
|
||||
@ApiOperation("获取菜单")
|
||||
public HttpResult<List<SysFunction>> getMenu(HttpServletRequest request) {
|
||||
public HttpResult<List<MenuVO>> getMenu(HttpServletRequest request) {
|
||||
String methodDescribe = getMethodDescribe("getMenu");
|
||||
String tokenStr = request.getHeader(SecurityConstants.AUTHORIZATION_KEY);
|
||||
if (StrUtil.isNotBlank(tokenStr)) {
|
||||
tokenStr.replace(SecurityConstants.AUTHORIZATION_PREFIX, Strings.EMPTY);
|
||||
String userId = (String) JwtUtil.parseToken(tokenStr).get("userId");
|
||||
List<SysFunction> list = sysFunctionService.getMenuByUserId(userId);
|
||||
tokenStr = tokenStr.replace(SecurityConstants.AUTHORIZATION_PREFIX, Strings.EMPTY);
|
||||
String userId = (String) (JwtUtil.parseToken(tokenStr).get("userId"));
|
||||
List<MenuVO> list = sysFunctionService.getMenuByUserId(userId);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
@@ -153,13 +131,14 @@ public class SysFunctionController extends BaseController {
|
||||
String methodDescribe = getMethodDescribe("getButton");
|
||||
String tokenStr = request.getHeader(SecurityConstants.AUTHORIZATION_KEY);
|
||||
if (StrUtil.isNotBlank(tokenStr)) {
|
||||
tokenStr.replace(SecurityConstants.AUTHORIZATION_PREFIX, Strings.EMPTY);
|
||||
tokenStr = tokenStr.replace(SecurityConstants.AUTHORIZATION_PREFIX, Strings.EMPTY);
|
||||
String userId = (String) JwtUtil.parseToken(tokenStr).get("userId");
|
||||
Map<String, List<String>> map = sysFunctionService.getButtonByUserId(userId);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, map, methodDescribe);
|
||||
}
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/getFunctionsByRoleId")
|
||||
@ApiOperation("获取角色id绑定的菜单(资源)")
|
||||
|
||||
@@ -8,9 +8,7 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.gather.user.user.pojo.param.SysRoleParam;
|
||||
import com.njcn.gather.user.user.pojo.po.SysFunction;
|
||||
import com.njcn.gather.user.user.pojo.po.SysRole;
|
||||
import com.njcn.gather.user.user.service.ISysRoleFunctionService;
|
||||
import com.njcn.gather.user.user.service.ISysRoleService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.utils.HttpResultUtil;
|
||||
@@ -36,7 +34,6 @@ import java.util.List;
|
||||
@RequiredArgsConstructor
|
||||
public class SysRoleController extends BaseController {
|
||||
private final ISysRoleService sysRoleService;
|
||||
private final ISysRoleFunctionService sysRoleFunctionService;
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/list")
|
||||
@@ -94,36 +91,6 @@ public class SysRoleController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
// @OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
// @PostMapping("/listRoleByIds")
|
||||
// @ApiOperation("根据角色id集合查询角色信息")
|
||||
// @ApiImplicitParam(name = "ids", value = "角色id集合", required = true)
|
||||
// public HttpResult<List<SysRole>> listRoleByIds(@RequestBody List<String> ids) {
|
||||
// String methodDescribe = getMethodDescribe("listRoleByIds");
|
||||
// List<SysRole> roles = sysRoleService.list((new LambdaQueryWrapper<SysRole>().in(CollUtil.isNotEmpty(ids), SysRole::getId, ids)));
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, roles, methodDescribe);
|
||||
// }
|
||||
|
||||
// @OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
// @PostMapping("/listRoleByType")
|
||||
// @ApiOperation("根据权限类型查询相关角色")
|
||||
// @ApiImplicitParam(name = "type", value = "权限类型", required = true)
|
||||
// public HttpResult<List<SysRole>> listRoleByType(@RequestParam("type") Integer type) {
|
||||
// String methodDescribe = getMethodDescribe("listRoleByType");
|
||||
// LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, type);
|
||||
// List<SysRole> result = sysRoleService.listRoleByType(type);
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
// }
|
||||
|
||||
// @OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
// @GetMapping("/listAllRole")
|
||||
// @ApiOperation("查询所有角色")
|
||||
// public HttpResult<List<SysRole>> listAllRole() {
|
||||
// String methodDescribe = getMethodDescribe("listAllRole");
|
||||
// List<SysRole> result = sysRoleService.listAllRole();
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
// }
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@GetMapping("/simpleList")
|
||||
@ApiOperation("查询所有角色作为下拉框")
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
|
||||
|
||||
<select id="getMenuByUserId" resultType="com.njcn.gather.user.user.pojo.vo.MenuVO">
|
||||
SELECT distinct a.id as id,
|
||||
a.path as path,
|
||||
a.name as name,
|
||||
if(a.pId!= '0', a.component, '') as component,
|
||||
if(a.pId = '0', a.component, '') as redirect,
|
||||
a.icon as icon,
|
||||
a.pId as pId,
|
||||
a.sort as sort
|
||||
SELECT distinct a.id as id,
|
||||
a.path as path,
|
||||
a.name as name,
|
||||
a.code as code,
|
||||
a.component as component,
|
||||
a.icon as icon,
|
||||
a.pId as pId,
|
||||
a.sort as sort
|
||||
FROM sys_function a
|
||||
inner join sys_role_function b on a.id = b.Function_Id
|
||||
inner join sys_user_role c on b.Role_Id = c.Role_Id
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.njcn.gather.user.user.service;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.user.user.pojo.param.SysFunctionParam;
|
||||
import com.njcn.gather.user.user.pojo.po.SysFunction;
|
||||
import com.njcn.gather.user.user.pojo.vo.MenuVO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -52,28 +53,12 @@ public interface ISysFunctionService extends IService<SysFunction> {
|
||||
*/
|
||||
List<SysFunction> getFunctionTree(boolean isContainButton);
|
||||
|
||||
/**
|
||||
* 根据id获取菜单(资源)
|
||||
*
|
||||
* @param id 资源id
|
||||
* @return 资源
|
||||
*/
|
||||
//SysFunction getFunctionById(String id);
|
||||
|
||||
/**
|
||||
* 根据菜单(资源)id获取按钮
|
||||
*
|
||||
* @param id 菜单id
|
||||
* @return 菜单下面所有按钮
|
||||
*/
|
||||
//List<SysFunction> getButtonsById(String id);
|
||||
|
||||
/**
|
||||
* 根据用户id获取菜单
|
||||
*
|
||||
* @return 路由菜单
|
||||
*/
|
||||
List<SysFunction> getMenuByUserId(String userId);
|
||||
List<MenuVO> getMenuByUserId(String userId);
|
||||
|
||||
/**
|
||||
* 根据用户id获取按钮
|
||||
|
||||
@@ -17,7 +17,6 @@ import com.njcn.gather.user.user.pojo.vo.MenuVO;
|
||||
import com.njcn.gather.user.user.pojo.vo.MetaVO;
|
||||
import com.njcn.gather.user.user.service.ISysFunctionService;
|
||||
import com.njcn.gather.user.user.service.ISysRoleFunctionService;
|
||||
import com.njcn.gather.user.user.service.ISysUserRoleService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -37,7 +36,6 @@ import java.util.stream.Collectors;
|
||||
public class SysFunctionServiceImpl extends ServiceImpl<SysFunctionMapper, SysFunction> implements ISysFunctionService {
|
||||
|
||||
private final ISysRoleFunctionService sysRoleFunctionService;
|
||||
private final ISysUserRoleService sysUserRoleService;
|
||||
|
||||
@Override
|
||||
public List<SysFunction> getFunctionTreeByKeyword(String keyword) {
|
||||
@@ -119,7 +117,7 @@ public class SysFunctionServiceImpl extends ServiceImpl<SysFunctionMapper, SysFu
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysFunction> getMenuByUserId(String userId) {
|
||||
public List<MenuVO> getMenuByUserId(String userId) {
|
||||
List<MenuVO> menu = this.baseMapper.getMenuByUserId(userId);
|
||||
menu.stream().forEach(m -> {
|
||||
MetaVO meta = new MetaVO();
|
||||
@@ -131,8 +129,18 @@ public class SysFunctionServiceImpl extends ServiceImpl<SysFunctionMapper, SysFu
|
||||
meta.setAffix(false);
|
||||
meta.setKeepAlive(true);
|
||||
m.setMeta(meta);
|
||||
m.setName(m.getCode());
|
||||
});
|
||||
return menu.stream().filter(fun -> Objects.equals(FunctionConst.FATHER_PID, fun.getPid())).peek(funS -> funS.setChildren(getChildrenList(funS, menu))).sorted(Comparator.comparingInt(SysFunction::getSort)).collect(Collectors.toList());
|
||||
return menu.stream().filter(fun -> Objects.equals(FunctionConst.FATHER_PID, fun.getPid())).peek(funS -> {
|
||||
List<SysFunction> childrenList = getChildrenList(funS, menu);
|
||||
if (ObjectUtil.isNull(childrenList) || childrenList.size() == 0) {
|
||||
funS.setRedirect(null);
|
||||
} else {
|
||||
funS.setRedirect(funS.getComponent());
|
||||
funS.setComponent(null);
|
||||
}
|
||||
funS.setChildren(childrenList);
|
||||
}).sorted(Comparator.comparingInt(MenuVO::getSort)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -214,4 +222,44 @@ public class SysFunctionServiceImpl extends ServiceImpl<SysFunctionMapper, SysFu
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// @Override
|
||||
// public List<MenuVO> getMenuByUserId(String userId) {
|
||||
// List<MenuVO> menu = this.baseMapper.getMenuByUserId(userId);
|
||||
// HashSet<String> menuIdSet = new HashSet<>();
|
||||
// menuIdSet.addAll(menu.stream().map(MenuVO::getId).collect(Collectors.toList()));
|
||||
// menu.stream().forEach(m -> {
|
||||
// String pids = m.getPids();
|
||||
// if (StrUtil.isNotBlank(pids)) {
|
||||
// String[] pidArr = pids.split(",");
|
||||
// for (String pid : pidArr) {
|
||||
// menuIdSet.add(pid);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// List<MenuVO> menu this.baseMapper.getMenuByIds(menuIdSet);
|
||||
// menu.stream().forEach(m -> {
|
||||
// MetaVO meta = new MetaVO();
|
||||
// meta.setIcon(m.getIcon());
|
||||
// meta.setTitle(m.getName());
|
||||
// meta.setIsLink("");
|
||||
// meta.setHide(false);
|
||||
// meta.setFull(false);
|
||||
// meta.setAffix(false);
|
||||
// meta.setKeepAlive(true);
|
||||
// m.setMeta(meta);
|
||||
// m.setName(m.getCode());
|
||||
// });
|
||||
// return menu.stream().filter(fun -> Objects.equals(FunctionConst.FATHER_PID, fun.getPid())).peek(funS -> {
|
||||
// List<SysFunction> childrenList = getChildrenList(funS, menu);
|
||||
// if (ObjectUtil.isNull(childrenList) || childrenList.size() == 0) {
|
||||
// funS.setRedirect(null);
|
||||
// } else {
|
||||
// funS.setRedirect(funS.getComponent());
|
||||
// funS.setComponent(null);
|
||||
// }
|
||||
// funS.setChildren(childrenList);
|
||||
// })
|
||||
// .sorted(Comparator.comparingInt(MenuVO::getSort)).collect(Collectors.toList());
|
||||
// }
|
||||
}
|
||||
Reference in New Issue
Block a user