|
@@ -105,6 +105,8 @@ public class SysUserController extends BaseController
|
|
|
@Autowired
|
|
|
private IMessageUtilsService messageUtilsService;
|
|
|
@Autowired
|
|
|
+ private ISysUserCompanyRelService iSysUserCompanyRelService;
|
|
|
+ @Autowired
|
|
|
private ISysCompanyService sysCompanyService;
|
|
|
@Autowired
|
|
|
private RemoteSystemService remoteSystemService;
|
|
@@ -310,7 +312,7 @@ public class SysUserController extends BaseController
|
|
|
}
|
|
|
//登录错误到达五次就转为冻结
|
|
|
BigDecimal bigDecimal = new BigDecimal(frozenSecond);
|
|
|
- BigDecimal decimal = new BigDecimal("4");
|
|
|
+ BigDecimal decimal = new BigDecimal("5");
|
|
|
if (decimal.compareTo(bigDecimal) == 0) {
|
|
|
SysUser user = new SysUser();
|
|
|
user.setUserId(sysUser.getUserId());
|
|
@@ -339,6 +341,11 @@ public class SysUserController extends BaseController
|
|
|
remoteLogService.saveLogininfor(username, Constants.LOGIN_FAIL, "对不起,您的账号状态异常,请联系管理员",sysUser.getCompanyId());
|
|
|
return R.fail("对不起,您的账号:" + username + " 状态异常,请联系管理员");
|
|
|
}
|
|
|
+ if (UserStatus.DISABLE.getCode().equals(sysUser.getStatus()))
|
|
|
+ {
|
|
|
+ remoteLogService.saveLogininfor(username, Constants.LOGIN_FAIL, "对不起,您的账号状态异常,请联系管理员",sysUser.getCompanyId());
|
|
|
+ return R.fail("对不起,您的账号:" + username + " 状态已停用,请联系管理员");
|
|
|
+ }
|
|
|
// 密码如果不在指定范围内 错误
|
|
|
if (password.length() < UserConstants.PASSWORD_MIN_LENGTH
|
|
|
|| password.length() > UserConstants.PASSWORD_MAX_LENGTH)
|
|
@@ -398,6 +405,7 @@ public class SysUserController extends BaseController
|
|
|
Nullable dtiTime = null;
|
|
|
SysUser suser = new SysUser();
|
|
|
suser.setUserId(sysUser.getUserId());
|
|
|
+ suser.setStatus("0");
|
|
|
suser.setFrozen_second("0");
|
|
|
suser.setFrozen_date((Date) dtiTime);
|
|
|
userService.updateUserLogin(suser);
|
|
@@ -571,28 +579,32 @@ public class SysUserController extends BaseController
|
|
|
* 根据用户编号获取详细信息
|
|
|
*/
|
|
|
@PreAuthorize(hasPermi = "system:user:query")
|
|
|
- @GetMapping(value = { "/", "/{userId}" })
|
|
|
- public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId)
|
|
|
+ @GetMapping(value = { "/", "/{userId}/{scyId}" })
|
|
|
+ public AjaxResult getInfo(
|
|
|
+ @PathVariable(value = "userId", required = false) Long userId,
|
|
|
+ @PathVariable(value = "scyId", required = false) String scyId
|
|
|
+ )
|
|
|
{
|
|
|
//获取当前操作人员
|
|
|
LoginUser userInfo = tokenService.getLoginUser();
|
|
|
- String companyId = userInfo.getSysUser().getCompanyId();
|
|
|
AjaxResult ajax = AjaxResult.success();
|
|
|
+
|
|
|
//角色
|
|
|
SysRole role = new SysRole();
|
|
|
role.setIsAuto("0");
|
|
|
Map map = new HashMap<>();
|
|
|
-// if(!SalaryConstants.OPEX.equals(companyId)){
|
|
|
- map.put("companyId",companyId);
|
|
|
- role.setCompanyId(companyId);
|
|
|
-// }
|
|
|
+ map.put("companyId",scyId);
|
|
|
+ if(CommonUtil.isNotEmpty(scyId)) {
|
|
|
+ role.setCompanyId(scyId);
|
|
|
+ }else {
|
|
|
+ role.setCompanyId(userInfo.getSysUser().getCompanyId());
|
|
|
+ }
|
|
|
List<SysRole> roles = roleService.selectRoleAll(role);
|
|
|
ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin() ).collect(Collectors.toList()));
|
|
|
if (StringUtils.isNotNull(userId))
|
|
|
{
|
|
|
- ajax.put(AjaxResult.DATA_TAG, userService.selectUserById(userId, companyId));
|
|
|
+ ajax.put(AjaxResult.DATA_TAG, userService.selectUserById(userId, scyId));
|
|
|
ajax.put("roleIds", roleService.selectRoleListByUserId(userId));
|
|
|
-
|
|
|
}
|
|
|
return ajax;
|
|
|
}
|
|
@@ -705,14 +717,21 @@ public class SysUserController extends BaseController
|
|
|
@Transactional(rollbackFor=Exception.class)
|
|
|
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
|
|
@PutMapping
|
|
|
- public AjaxResult edit(@Validated @RequestBody SysUser user)
|
|
|
+ public AjaxResult edit(@Validated @RequestBody SysUser user)throws Exception
|
|
|
{
|
|
|
LoginUser userInfo = tokenService.getLoginUser();
|
|
|
SysUser use = userInfo.getSysUser();
|
|
|
String companyId = use.getCompanyId();
|
|
|
+ //当前修改企业
|
|
|
+ String company = user.getCompanyId();
|
|
|
+ //查询之前的deptId
|
|
|
+ LambdaQueryWrapper<SysUserCompanyRel> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(SysUserCompanyRel::getSucrUserId,user.getUserName());
|
|
|
+ queryWrapper.eq(SysUserCompanyRel::getSucrCompanyId,company);
|
|
|
+ List<SysUserCompanyRel> list = iSysUserCompanyRelService.findSysUserCompanyRels(queryWrapper);
|
|
|
+
|
|
|
if(SalaryConstants.OPEX.equals(companyId)) {
|
|
|
- String com = user.getCompanyId();
|
|
|
- if (CommonUtil.isEmpty(com)) {
|
|
|
+ if (CommonUtil.isEmpty(company)) {
|
|
|
return AjaxResult.error("修改用户'" + user.getNickName() + "'失败,请选择公司");
|
|
|
}
|
|
|
userService.checkUserAllowed(user);
|
|
@@ -733,7 +752,22 @@ public class SysUserController extends BaseController
|
|
|
}
|
|
|
user.setUpdateBy(CommonUtil.objToString(SecurityUtils.getUserId()));
|
|
|
}
|
|
|
- return toAjax(userService.updateUser(user));
|
|
|
+ userService.updateUser(user);
|
|
|
+ // 审批表删除部门分组数据()
|
|
|
+ if(list.size() > 0){
|
|
|
+ String deptId = CommonUtil.objToString(list.get(0).getSucrDeptId());
|
|
|
+ Map<String, Object> flowableRes = flowableService.deleteFlowableUserGroup(String.valueOf(user.getUserId()), deptId);
|
|
|
+ if (!"200".equals(flowableRes.get("code"))) {
|
|
|
+ throw new Exception("审批数据新增失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //审批表增加部门分组数据
|
|
|
+ SysDept dept = deptMapper.selectDeptById(user.getDeptId());
|
|
|
+ Map<String, Object> flowableRes = flowableService.addFlowableUser(String.valueOf(user.getUserId()), user.getNickName(), dept.getAlternateNumber());
|
|
|
+ if (!"200".equals(flowableRes.get("code"))) {
|
|
|
+ throw new Exception("审批数据新增失败!");
|
|
|
+ }
|
|
|
+ return AjaxResult.success();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -755,11 +789,11 @@ public class SysUserController extends BaseController
|
|
|
@PutMapping("/resetPwd")
|
|
|
public AjaxResult resetPwd(@RequestBody SysUser user)
|
|
|
{
|
|
|
- String regEx = "[\u4e00-\u9fa5]";
|
|
|
+ String regEx = "^(?![0-9]+$)(?![a-z]+$)(?![A-Z]+$)(?!([^(0-9a-zA-Z)])+$).{6,20}$";
|
|
|
Pattern p = Pattern.compile(regEx);
|
|
|
Matcher m = p.matcher(user.getPassword());
|
|
|
if(m.find()){
|
|
|
- return AjaxResult.error("请输入字母、数字、特殊符号格式编码");
|
|
|
+ return AjaxResult.error("密码请包含数字,英文,字符中的两种以上,长度6-20位");
|
|
|
}
|
|
|
userService.checkUserAllowed(user);
|
|
|
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|