微调
This commit is contained in:
@@ -1,23 +0,0 @@
|
||||
package com.njcn.gather.system.menu.controller;
|
||||
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.gather.system.menu.pojo.ButtonVO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("admin")
|
||||
public class ButtonController {
|
||||
|
||||
@RequestMapping("/auth/buttons")
|
||||
public HttpResult<ButtonVO> buttons() {
|
||||
ButtonVO buttonVO = new ButtonVO();
|
||||
HttpResult<ButtonVO> result = new HttpResult<>();
|
||||
result.setMessage("成功");
|
||||
result.setCode("A0000");
|
||||
result.setData(buttonVO);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -1,132 +0,0 @@
|
||||
package com.njcn.gather.system.menu.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.gather.system.menu.pojo.MenuVO;
|
||||
import com.njcn.gather.system.menu.pojo.MetaVO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("admin")
|
||||
public class MenuController {
|
||||
|
||||
// @RequestMapping("/menu/list")
|
||||
// public HttpResult<List<MenuVO>> menuList() {
|
||||
//
|
||||
// List<MenuVO> menuVOList = new ArrayList<>();
|
||||
//
|
||||
// MenuVO menuVO = new MenuVO();
|
||||
// menuVO.setPath("/home/index");
|
||||
// menuVO.setName("home");
|
||||
// menuVO.setComponent("/home/index");
|
||||
//
|
||||
// MetaVO metaVO = new MetaVO();
|
||||
// metaVO.setIcon("HomeFilled");
|
||||
// metaVO.setTitle("检测计划");
|
||||
// metaVO.setIsLink("");
|
||||
// metaVO.setHide(false);
|
||||
// metaVO.setFull(false);
|
||||
// metaVO.setAffix(true);
|
||||
// metaVO.setKeepAlive(true);
|
||||
//
|
||||
// menuVO.setMeta(metaVO);
|
||||
// menuVOList.add(menuVO);
|
||||
//
|
||||
// MenuVO menuVO1 = getMenuVORedirect("/machine","machine","/machine/testScript","Operation","台账管理");
|
||||
// MenuVO menuVO11 = getMenuVO("/machine/testScript","testScript","/machine/testScript/index","Document","检测脚本");
|
||||
// MenuVO menuVO12 = getMenuVO("/machine/device","device","/machine/device/index","Cpu","被检设备");
|
||||
// MenuVO menuVO13 = getMenuVO("/machine/errorSystem","errorSystem","/machine/errorSystem/index","Tickets","误差体系");
|
||||
// MenuVO menuVO14 = getMenuVO("/machine/testSource","testSource","/machine/testSource/index","Help","检测源");
|
||||
// MenuVO menuVO15 = getMenuVO("/machine/devType","devType","/machine/devType/index","Cpu","设备类型");
|
||||
// menuVO1.setChildren(CollectionUtil.toList(menuVO11,menuVO12,menuVO13,menuVO14,menuVO15));
|
||||
// menuVOList.add(menuVO1);
|
||||
//
|
||||
//
|
||||
//
|
||||
// MenuVO menuVO2 = getMenuVORedirect("/authority","authority","/authority/user","Menu","权限管理");
|
||||
// MenuVO menuVO21 = getMenuVO("/authority/user","user","/authority/user/index","UserFilled","用户管理");
|
||||
// MenuVO menuVO22 = getMenuVO("/authority/role","role","/authority/role/index","Avatar","角色管理");
|
||||
// MenuVO menuVO23 = getMenuVO("/authority/resource","resource","/authority/resource/index","Connection","菜单管理");
|
||||
// menuVO2.setChildren(CollectionUtil.toList(menuVO21,menuVO22,menuVO23));
|
||||
// menuVOList.add(menuVO2);
|
||||
//
|
||||
//
|
||||
// MenuVO menuVO3 = getMenuVORedirect("/system","system","/system/base","Tools","系统配置");
|
||||
// MenuVO menuVO31 = getMenuVO("/system/base","base","/system/base/index","UserFilled","通用配置");
|
||||
// MenuVO menuVO32 = getMenuVO("/system/dict","dict","/system/dictionary/dictType/index","DataAnalysis","数据字典");
|
||||
// MenuVO menuVO33 = getMenuVO("/system/dictTree","dictTree","/system/dictionary/dictTree/index","DataAnalysis","树形字典");
|
||||
// MenuVO menuVO34 = getMenuVO("/system/dictPq","dictPq","/system/dictionary/dictPq/index","DataAnalysis","电能质量字典");
|
||||
// MenuVO menuVO35 = getMenuVO("/system/template","template","/system/template/index","Memo","报告模板");
|
||||
// MenuVO menuVO36 = getMenuVO("/system/versionRegister","versionRegister","/system/versionRegister/index","SetUp","版本注册");
|
||||
// menuVO3.setChildren(CollectionUtil.toList(menuVO31,menuVO32,menuVO33,menuVO34,menuVO35,menuVO36));
|
||||
// menuVOList.add(menuVO3);
|
||||
//
|
||||
// MenuVO menuVO4 = getMenuVO("/log","log","/log/index","TrendCharts","日志管理");
|
||||
// menuVOList.add(menuVO4);
|
||||
//
|
||||
//
|
||||
// MenuVO menuVO5 = getMenuVO("/analyse","analyse","/analyse/index","Monitor","统计分析");
|
||||
// menuVOList.add(menuVO5);
|
||||
//
|
||||
//
|
||||
// MenuVO menuVO6 = getMenuVORedirect("/demo","demo","/system/demo","Tools","示例");
|
||||
// MenuVO menuVO61 = getMenuVO("/system/proTable","table","/demo/proTable/index","UserFilled","普通表格");
|
||||
// MenuVO menuVO62 = getMenuVO("/system/proTableTree","tableTree","/demo/proTableTree/index","DataAnalysis","表格树");
|
||||
// menuVO6.setChildren(CollectionUtil.toList(menuVO61,menuVO62));
|
||||
// menuVOList.add(menuVO6);
|
||||
//
|
||||
//
|
||||
//
|
||||
// HttpResult<List<MenuVO>> result = new HttpResult<>();
|
||||
// result.setData(menuVOList);
|
||||
// result.setCode("A0000");
|
||||
// result.setMessage("成功");
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// private static MenuVO getMenuVO(String path, String name, String component,String icon,String title) {
|
||||
// MenuVO menu = new MenuVO();
|
||||
// menu.setPath(path);
|
||||
// menu.setName(name);
|
||||
// menu.setComponent(component);
|
||||
//
|
||||
// MetaVO meta = new MetaVO();
|
||||
// meta.setIcon(icon);
|
||||
// meta.setTitle(title);
|
||||
// meta.setIsLink("");
|
||||
// meta.setHide(false);
|
||||
// meta.setFull(false);
|
||||
// meta.setAffix(false);
|
||||
// meta.setKeepAlive(true);
|
||||
//
|
||||
// menu.setMeta(meta);
|
||||
//
|
||||
// return menu;
|
||||
// }
|
||||
//
|
||||
// private static MenuVO getMenuVORedirect(String path, String name, String component,String icon,String title) {
|
||||
// MenuVO menu = new MenuVO();
|
||||
// menu.setPath(path);
|
||||
// menu.setName(name);
|
||||
// menu.setRedirect(component);
|
||||
//
|
||||
// MetaVO meta = new MetaVO();
|
||||
// meta.setIcon(icon);
|
||||
// meta.setTitle(title);
|
||||
// meta.setIsLink("");
|
||||
// meta.setHide(false);
|
||||
// meta.setFull(false);
|
||||
// meta.setAffix(false);
|
||||
// meta.setKeepAlive(true);
|
||||
//
|
||||
// menu.setMeta(meta);
|
||||
//
|
||||
// return menu;
|
||||
// }
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.njcn.gather.system.menu.pojo;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ButtonVO {
|
||||
|
||||
private List<String> useProTable = CollectionUtil.toList("add",
|
||||
"batchAdd",
|
||||
"export",
|
||||
"batchDelete",
|
||||
"status");
|
||||
private List<String> authButton = CollectionUtil.toList( "add",
|
||||
"edit",
|
||||
"delete",
|
||||
"import",
|
||||
"export");
|
||||
}
|
||||
@@ -21,7 +21,8 @@ public enum UserResponseEnum {
|
||||
SUPER_ADMIN_CANNOT_DELETE("A010010", "禁止删除超级管理员用户"),
|
||||
COMPONENT_NOT_BLANK("A010011", "组件地址不能为空"),
|
||||
FUNCTION_PATH_FORMAT_ERROR("A010012", "路由地址格式错误"),
|
||||
SUPER_ADMIN_REPEAT("A010013","超级管理员已存在,请勿重复添加" );
|
||||
SUPER_ADMIN_REPEAT("A010013","超级管理员已存在,请勿重复添加" ),
|
||||
RSA_DECRYT_ERROR("A010014","RSA解密失败" );
|
||||
|
||||
private String code;
|
||||
private String message;
|
||||
|
||||
@@ -10,10 +10,13 @@ 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.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.JwtUtil;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.common.utils.RSAUtil;
|
||||
import com.njcn.gather.user.pojo.constant.UserValidMessage;
|
||||
import com.njcn.gather.user.pojo.enums.UserResponseEnum;
|
||||
import com.njcn.gather.user.user.pojo.param.SysUserParam;
|
||||
import com.njcn.gather.user.user.pojo.po.SysUser;
|
||||
import com.njcn.gather.user.user.pojo.po.Token;
|
||||
@@ -27,6 +30,8 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.security.KeyPair;
|
||||
import java.util.Base64;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -40,6 +45,7 @@ public class AuthController extends BaseController {
|
||||
|
||||
private final ISysUserService sysUserService;
|
||||
private final CustomCacheUtil customCacheUtil;
|
||||
private KeyPair keyPair;
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.AUTHENTICATE)
|
||||
@@ -48,7 +54,16 @@ public class AuthController extends BaseController {
|
||||
public HttpResult<Object> login(@RequestBody SysUserParam.LoginParam param) {
|
||||
String methodDescribe = getMethodDescribe("login");
|
||||
LogUtil.njcnDebug(log, "{},登录参数为:{}", methodDescribe, param);
|
||||
SysUser user = sysUserService.getUserByLoginNameAndPassword(param.getUsername(), param.getPassword());
|
||||
byte[] decode = Base64.getDecoder().decode(param.getUsername());
|
||||
String username = new String(decode);
|
||||
String password = null;
|
||||
try {
|
||||
password = RSAUtil.decrypt(param.getPassword(), keyPair.getPrivate());
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException(UserResponseEnum.RSA_DECRYT_ERROR);
|
||||
}
|
||||
|
||||
SysUser user = sysUserService.getUserByLoginNameAndPassword(username, password);
|
||||
if (ObjectUtil.isNull(user)) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, UserValidMessage.LOGIN_FAILED);
|
||||
} else {
|
||||
@@ -64,6 +79,7 @@ public class AuthController extends BaseController {
|
||||
token.setUserInfo(map);
|
||||
|
||||
customCacheUtil.putWithExpireTime(accessToken, JSON.toJSONString(user), DateUnit.DAY.getMillis() * Integer.MAX_VALUE);
|
||||
sysUserService.updateLoginTime(user.getId());
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, token, methodDescribe);
|
||||
}
|
||||
}
|
||||
@@ -109,4 +125,15 @@ public class AuthController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@ApiOperation("获取RSA公钥")
|
||||
@GetMapping("/getPublicKey")
|
||||
public HttpResult<String> publicKey() throws Exception {
|
||||
String methodDescribe = getMethodDescribe("publicKey");
|
||||
LogUtil.njcnDebug(log, "{},获取RSA公钥", methodDescribe);
|
||||
keyPair = RSAUtil.generateKeyPair();
|
||||
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, RSAUtil.publicKeyToString(keyPair.getPublic()), methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import java.util.List;
|
||||
@Slf4j
|
||||
@Component
|
||||
public class AuthGlobalFilter implements Filter, Ordered {
|
||||
private final static List<String> IGNORE_URI = Arrays.asList("/admin/login", "/report/generateReport");
|
||||
private final static List<String> IGNORE_URI = Arrays.asList("/admin/login","/admin/getPublicKey", "/report/generateReport");
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
|
||||
@@ -24,7 +24,6 @@ public class SysUserParam {
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("部门Id")
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = UserValidMessage.DEPT_ID_FORMAT_ERROR)
|
||||
private String deptId;
|
||||
|
||||
@ApiModelProperty("电话号码")
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.njcn.gather.system.menu.pojo;
|
||||
package com.njcn.gather.user.user.pojo.po;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.njcn.gather.system.menu.pojo;
|
||||
package com.njcn.gather.user.user.pojo.po;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
@@ -117,10 +117,9 @@ public interface ISysUserService extends IService<SysUser> {
|
||||
SysUser getUserByLoginNameAndPassword(String loginName, String password);
|
||||
|
||||
/**
|
||||
* 根据用户ID判断是否是管理员用户
|
||||
* @param userId 用户ID
|
||||
* @return true表示是管理员用户,false表示不是管理员用户
|
||||
* 更新用户登录时间为当前时间
|
||||
*
|
||||
* @param userId
|
||||
*/
|
||||
boolean isAdmin(String userId);
|
||||
|
||||
boolean updateLoginTime(String userId);
|
||||
}
|
||||
|
||||
@@ -63,11 +63,7 @@ public class SysFunctionServiceImpl extends ServiceImpl<SysFunctionMapper, SysFu
|
||||
function.setPids(pidS + "," + functionParam.getPid());
|
||||
}
|
||||
}
|
||||
boolean result = this.save(function);
|
||||
//if (result) {
|
||||
//refreshRolesFunctionsCache();
|
||||
//}
|
||||
return result;
|
||||
return this.save(function);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -84,9 +80,6 @@ public class SysFunctionServiceImpl extends ServiceImpl<SysFunctionMapper, SysFu
|
||||
BeanUtil.copyProperties(param, function);
|
||||
result = this.updateById(function);
|
||||
}
|
||||
// if (result) {
|
||||
// refreshRolesFunctionsCache();
|
||||
// }
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -98,9 +91,6 @@ public class SysFunctionServiceImpl extends ServiceImpl<SysFunctionMapper, SysFu
|
||||
List<SysFunction> childrenList = this.lambdaQuery().eq(SysFunction::getState, DataStateEnum.ENABLE.getCode()).eq(SysFunction::getPid, id).list();
|
||||
if (CollectionUtils.isEmpty(childrenList)) {
|
||||
result1 = this.lambdaUpdate().set(SysFunction::getState, DataStateEnum.DELETED.getCode()).in(SysFunction::getId, id).update();
|
||||
// if (result) {
|
||||
// refreshRolesFunctionsCache();
|
||||
// }
|
||||
} else {
|
||||
throw new BusinessException(UserResponseEnum.EXISTS_CHILDREN_NOT_DELETE);
|
||||
}
|
||||
|
||||
@@ -103,20 +103,6 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
||||
return this.baseMapper.selectList(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public boolean selectRelevance(List<String> ids) {
|
||||
// // 判断角色是否和用户绑定
|
||||
// List<UserRole> userRoleList = this.userRoleMapper.selectUserRole(ids);
|
||||
// // 判断角色是否和资源绑定
|
||||
// List<RoleFunction> roleFunctionList = this.roleFunctionMapper.selectRoleFunction(ids);
|
||||
// // 判断角色是否和组件绑定
|
||||
// List<RoleComponent> roleComponentList = this.roleComponentMapper.selectRoleComponet(ids);
|
||||
// if (!userRoleList.isEmpty() || !roleComponentList.isEmpty() || !roleFunctionList.isEmpty()) {
|
||||
// return true;
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 校验参数,检查是否存在相同名称或编码的角色
|
||||
*/
|
||||
|
||||
@@ -58,7 +58,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
} else {
|
||||
queryWrapper.orderByDesc("sys_user.update_time");
|
||||
}
|
||||
queryWrapper.ne("sys_user.Login_Name", UserConst.SUPER_ADMIN).ne("sys_user.state", UserConst.STATE_DELETE);
|
||||
queryWrapper.ne("sys_user.state", UserConst.STATE_DELETE);
|
||||
Page<SysUser> page = this.baseMapper.selectPage(new Page<>(PageFactory.getPageNum(queryParam), PageFactory.getPageSize(queryParam)), queryWrapper);
|
||||
page.getRecords().forEach(sysUser -> {
|
||||
List<SysRole> sysRoles = sysUserRoleService.listRoleByUserId(sysUser.getId());
|
||||
@@ -126,7 +126,6 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
String secretkey = Sm4Utils.globalSecretKey;
|
||||
Sm4Utils sm4 = new Sm4Utils(secretkey);
|
||||
sysUser.setPassword(sm4.encryptData_ECB(sysUser.getPassword()));
|
||||
// todo 别忘记移除登录时间
|
||||
sysUser.setLoginTime(LocalDateTimeUtil.now());
|
||||
sysUser.setLoginErrorTimes(0);
|
||||
sysUser.setState(UserConst.STATE_ENABLE);
|
||||
@@ -200,17 +199,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAdmin(String userId) {
|
||||
SysUser user = lambdaQuery().ne(SysUser::getState, UserConst.STATE_DELETE).eq(SysUser::getId, userId).one();
|
||||
if (ObjectUtil.isNotNull(user)) {
|
||||
List<SysRole> sysRoles = sysUserRoleService.listRoleByUserId(user.getId());
|
||||
for (SysRole sysRole : sysRoles) {
|
||||
if (sysRole.getType().compareTo(RoleConst.TYPE_ADMINISTRATOR) <= 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
public boolean updateLoginTime(String userId) {
|
||||
return this.lambdaUpdate().eq(SysUser::getId, userId).set(SysUser::getLoginTime, LocalDateTimeUtil.now()).update();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user