微调
This commit is contained in:
@@ -79,4 +79,6 @@ public interface DeviceValidMessage {
|
||||
String STANDARD_NAME_NOT_BLANK = "参照标准名称不能为空,请检查standardName参数";
|
||||
|
||||
String STANDARD_TIME_NOT_BLANK = "标准推行时间不能为空,请检查standardTime参数";
|
||||
|
||||
String SCRIPT_TYPE_FORMAT_ERROR = "检测脚本类型格式错误,请检查scriptType参数";
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
系统模块主要包含以下功能:
|
||||
* 审计日志管理
|
||||
* 字典、树形字典管理
|
||||
* 版本注册
|
||||
* 主题管理
|
||||
* 系统文件资源管理
|
||||
* 定时任务管理
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.JwtUtil;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.gather.system.auth.pojo.Token;
|
||||
import com.njcn.gather.system.pojo.constant.SystemValidMessage;
|
||||
import com.njcn.gather.user.pojo.constant.UserValidMessage;
|
||||
import com.njcn.gather.user.user.pojo.param.SysUserParam;
|
||||
import com.njcn.gather.user.user.pojo.po.SysUser;
|
||||
@@ -27,6 +28,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@@ -66,11 +69,14 @@ public class AuthController extends BaseController {
|
||||
LogUtil.njcnDebug(log, "{},登录参数为:{}", methodDescribe, param);
|
||||
SysUser user = sysUserService.getUserByLoginNameAndPassword(param.getUsername(), param.getPassword());
|
||||
if (user == null) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, UserValidMessage.LOGIN_FAILED, methodDescribe);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL,null, UserValidMessage.LOGIN_FAILED);
|
||||
} else {
|
||||
String tokenStr = JwtUtil.generateToken(user.getId());
|
||||
Token token = new Token();
|
||||
token.setAccessToken(tokenStr);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("name", user.getName());
|
||||
token.setUserInfo(map);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, token, methodDescribe);
|
||||
}
|
||||
}
|
||||
@@ -85,8 +91,8 @@ public class AuthController extends BaseController {
|
||||
if (StrUtil.isNotBlank(authorization)) {
|
||||
String token = authorization.replace(SecurityConstants.AUTHORIZATION_PREFIX, Strings.EMPTY);
|
||||
JwtUtil.invalidateToken(token);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,13 @@ package com.njcn.gather.system.auth.pojo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
public class Token {
|
||||
|
||||
private String accessToken;
|
||||
|
||||
private Map<String, Object> userInfo;
|
||||
|
||||
}
|
||||
|
||||
@@ -82,4 +82,10 @@ public interface SystemValidMessage {
|
||||
String DATA_RULE_NOT_BLANK = "数据处理规则不能为空,请检查dataRule参数";
|
||||
|
||||
String DATA_RULE_FORMAT_ERROR = "数据处理规则格式错误,请检查dataRule参数";
|
||||
|
||||
String TYPE_NOT_BLANK = "版本类型不能为空,请检查type参数";
|
||||
|
||||
String AUTO_GENERATE_FORMAT_ERROR = "是否自动生成格式错误,请检查autoGenerate参数";
|
||||
|
||||
String TOKEN_VALID_ERROR = "token校验失败,请重新登录";
|
||||
}
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
package com.njcn.gather.user.user.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.OperateType;
|
||||
import com.njcn.common.pojo.constant.SecurityConstants;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.JwtUtil;
|
||||
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.ButtonVO;
|
||||
import com.njcn.gather.user.user.service.ISysFunctionService;
|
||||
import com.njcn.gather.user.user.service.ISysRoleFunctionService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
@@ -18,9 +22,11 @@ import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.logging.log4j.util.Strings;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -125,14 +131,35 @@ public class SysFunctionController extends BaseController {
|
||||
// }
|
||||
|
||||
|
||||
// @OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
// @GetMapping("/getRouteMenu")
|
||||
// @ApiOperation("路由菜单")
|
||||
// public HttpResult<List<SysFunction>> getRouteMenu() {
|
||||
// String methodDescribe = getMethodDescribe("getRouteMenu");
|
||||
// List<SysFunction> list = sysFunctionService.getRouteMenu();
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@GetMapping("/getMenu")
|
||||
@ApiOperation("获取菜单")
|
||||
public HttpResult<List<SysFunction>> 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);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@GetMapping("/getButton")
|
||||
@ApiOperation("获取按钮")
|
||||
public HttpResult<ButtonVO> getButton(HttpServletRequest request) {
|
||||
String methodDescribe = getMethodDescribe("getButton");
|
||||
// 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");
|
||||
// ButtonVO buttonVO = sysFunctionService.getButtonByUserId(userId);
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, buttonVO, methodDescribe);
|
||||
// }
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/getFunctionsByRoleId")
|
||||
@ApiOperation("获取角色id绑定的菜单(资源)")
|
||||
@@ -154,14 +181,5 @@ public class SysFunctionController extends BaseController {
|
||||
boolean result = sysRoleFunctionService.updateRoleFunction(param.getRoleId(), param.getFunctionIds());
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
// @OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
// @GetMapping("/userFunctionTree")
|
||||
// @ApiOperation("用户菜单树")
|
||||
// public HttpResult<List<SysFunction>> getUserFunctionTree() {
|
||||
// String methodDescribe = getMethodDescribe("getUserFunctionTree");
|
||||
// List<SysFunction> list = sysFunctionService.getUserFunctionTree();
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,9 @@ package com.njcn.gather.user.user.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.njcn.gather.user.user.pojo.po.SysFunction;
|
||||
import com.njcn.gather.user.user.pojo.vo.MenuVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
@@ -9,5 +12,11 @@ import com.njcn.gather.user.user.pojo.po.SysFunction;
|
||||
*/
|
||||
public interface SysFunctionMapper extends MPJBaseMapper<SysFunction> {
|
||||
|
||||
/**
|
||||
* 根据用户id获取菜单列表
|
||||
* @param userId 用户id
|
||||
* @return 菜单列表
|
||||
*/
|
||||
List<MenuVO> getMenuByUserId(String userId);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,5 +3,20 @@
|
||||
<mapper namespace="com.njcn.gather.user.user.mapper.SysFunctionMapper">
|
||||
|
||||
|
||||
<select id="getMenuByUserId" resultType="com.njcn.gather.user.user.pojo.vo.MenuVO">
|
||||
SELECT 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
|
||||
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
|
||||
WHERE c.User_Id = #{userId}
|
||||
AND a.type in (0, 1)
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
|
||||
@@ -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.ButtonVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -68,16 +69,12 @@ public interface ISysFunctionService extends IService<SysFunction> {
|
||||
//List<SysFunction> getButtonsById(String id);
|
||||
|
||||
/**
|
||||
* 获取路由菜单
|
||||
* 根据用户id获取菜单
|
||||
*
|
||||
* @return 路由菜单
|
||||
*/
|
||||
List<SysFunction> getRouteMenu();
|
||||
List<SysFunction> getMenuByUserId(String userId);
|
||||
|
||||
//ButtonVO getButtonByUserId(String userId);
|
||||
|
||||
/**
|
||||
* 获取用户拥有的资源树
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
//List<SysFunction> getUserFunctionTree();
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ import com.njcn.gather.user.pojo.enums.UserResponseEnum;
|
||||
import com.njcn.gather.user.user.mapper.SysFunctionMapper;
|
||||
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 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 lombok.RequiredArgsConstructor;
|
||||
@@ -130,44 +132,27 @@ public class SysFunctionServiceImpl extends ServiceImpl<SysFunctionMapper, SysFu
|
||||
// }
|
||||
|
||||
@Override
|
||||
public List<SysFunction> getRouteMenu() {
|
||||
// List<SysFunction> result = new ArrayList<>();
|
||||
// List<String> functionIds;
|
||||
// if (Objects.equals(RequestUtil.getUsername(), UserType.SUPER_ADMIN)) {
|
||||
// //查询所有菜单
|
||||
// functionIds = this.lambdaQuery().eq(SysFunction::getState, DataStateEnum.ENABLE.getCode()).list().stream().map(SysFunction::getId).distinct().collect(Collectors.toList());
|
||||
// } else {
|
||||
// List<String> roleIdList = sysUserRoleService.listRoleByUserId(RequestUtil.getUserIndex()).stream().map(SysUserRole::getRoleId).distinct().collect(Collectors.toList());
|
||||
// functionIds = sysRoleFunctionService.listRoleFunctionByRoleIds(roleIdList).stream().map(SysRoleFunction::getFunctionId).distinct().collect(Collectors.toList());
|
||||
// }
|
||||
// if (CollectionUtils.isEmpty(functionIds)) {
|
||||
// return result;
|
||||
// }
|
||||
// List<SysFunction> functionList = this.lambdaQuery().eq(SysFunction::getState, DataStateEnum.ENABLE.getCode())
|
||||
// .in(SysFunction::getId, functionIds)
|
||||
// .in(SysFunction::getType, FunctionConst.TYPE_MENU, FunctionConst.TYPE_BUTTON).list();
|
||||
// result = functionList.stream()
|
||||
// .filter(fun -> Objects.equals(FunctionConst.FATHER_PID, fun.getPid().trim()))
|
||||
// .peek(funS -> funS.setChildren(getChildrenList(funS, functionList)))
|
||||
// .sorted(Comparator.comparingInt(SysFunction::getSort))
|
||||
// .collect(Collectors.toList());
|
||||
// //组装驾驶舱
|
||||
// setDriverChildren(result);
|
||||
// 处理tab页
|
||||
// setTab(result);
|
||||
// return result;
|
||||
return Collections.emptyList();
|
||||
public List<SysFunction> getMenuByUserId(String userId) {
|
||||
List<MenuVO> menu = this.baseMapper.getMenuByUserId(userId);
|
||||
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);
|
||||
});
|
||||
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());
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public List<SysFunction> getUserFunctionTree() {
|
||||
// return Collections.emptyList();
|
||||
// }
|
||||
|
||||
/**
|
||||
* 根据当前分类找出子类,递归找出子类的子类
|
||||
*/
|
||||
private List<SysFunction> getChildrenList(SysFunction currMenu, List<SysFunction> categories) {
|
||||
private <T extends SysFunction> List<SysFunction> getChildrenList(T currMenu, List<? extends SysFunction> categories) {
|
||||
return categories.stream().filter(o -> Objects.equals(o.getPid(), currMenu.getId())).peek(o -> o.setChildren(getChildrenList(o, categories))).sorted(Comparator.comparingInt(SysFunction::getSort)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@@ -219,4 +204,5 @@ public class SysFunctionServiceImpl extends ServiceImpl<SysFunctionMapper, SysFu
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user