|
|
@@ -28,6 +28,7 @@ import com.tianhu.system.common.IMessageUtilsService;
|
|
|
import com.tianhu.system.common.ValidateCodeService;
|
|
|
import com.tianhu.system.domain.*;
|
|
|
import com.tianhu.system.domain.vo.TreeSelect;
|
|
|
+import com.tianhu.system.mapper.OwnSysUserMapper;
|
|
|
import com.tianhu.system.mapper.SysDeptMapper;
|
|
|
import com.tianhu.system.mapper.SysUserMapper;
|
|
|
import com.tianhu.system.mapper.SysUserRoleMapper;
|
|
|
@@ -114,6 +115,8 @@ public class SysUserController extends BaseController
|
|
|
private RemoteLogService remoteLogService;
|
|
|
@Autowired
|
|
|
private RemoteUserService remoteUserService;
|
|
|
+ @Autowired
|
|
|
+ private OwnSysUserMapper ownSysUserMapper;
|
|
|
/**
|
|
|
* 用户注册成功
|
|
|
*/
|
|
|
@@ -171,30 +174,39 @@ public class SysUserController extends BaseController
|
|
|
validateCodeService.checkCapcha(code, uuid, true);
|
|
|
|
|
|
SysUser sysUser = userService.selectUserByUserName(username);
|
|
|
- // 短信验证码登陆 或者 验证码注册
|
|
|
+ // 短信验证码登陆 或者 验证码注册 或扫码
|
|
|
if ("1".equals(type) || "2".equals(type)) {
|
|
|
//当前时间
|
|
|
Date nowDate = DateUtils.getNowDate();
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
String dateTime = simpleDateFormat.format(nowDate);
|
|
|
- //冻结时间
|
|
|
- Date time = sysUser.getFrozen_date();
|
|
|
- if(time != null) {
|
|
|
- Calendar c = Calendar.getInstance();
|
|
|
- c.setTime(time);
|
|
|
- c.add(Calendar.DAY_OF_MONTH, 1);
|
|
|
- Date nomalDate = c.getTime();
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
- String endDate = sdf.format(time);
|
|
|
- //冻结结束时间
|
|
|
- String nomalDates = sdf.format(nomalDate);
|
|
|
- //时间比较
|
|
|
- int compareTo = endDate.compareTo(dateTime);
|
|
|
- if (compareTo == 0 && UserStatus.DELETED.getCode().equals(sysUser.getStatus())) {
|
|
|
- remoteLogService.saveLogininfor(username, Constants.LOGIN_FAIL, "对不起,您的账号已冻结,请" + nomalDates + "尝试登陆", sysUser.getCompanyId());
|
|
|
- return R.fail("对不起,您的账号:" + username + " 已冻结,请" + nomalDates + "尝试登陆");
|
|
|
+
|
|
|
+ if (sysUser != null) {
|
|
|
+ //冻结时间
|
|
|
+ Date time = sysUser.getFrozen_date();
|
|
|
+ if(time != null) {
|
|
|
+ Calendar c = Calendar.getInstance();
|
|
|
+ c.setTime(time);
|
|
|
+ c.add(Calendar.DAY_OF_MONTH, 1);
|
|
|
+ Date nomalDate = c.getTime();
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ String endDate = sdf.format(time);
|
|
|
+ //冻结结束时间
|
|
|
+ String nomalDates = sdf.format(nomalDate);
|
|
|
+ //时间比较
|
|
|
+ int compareTo = endDate.compareTo(dateTime);
|
|
|
+ if (compareTo == 0 && UserStatus.DELETED.getCode().equals(sysUser.getStatus())) {
|
|
|
+ if ("1".equals(type)) {
|
|
|
+ remoteLogService.saveLogininfor(username, Constants.LOGIN_FAIL, "对不起,您的账号已冻结,请于" + nomalDates + "尝试登陆", sysUser.getCompanyId());
|
|
|
+ return R.fail("对不起,您的账号:" + username + " 已冻结,请于" + nomalDates + "尝试登陆");
|
|
|
+ } else {
|
|
|
+ remoteLogService.saveLogininfor(username, Constants.LOGIN_FAIL, "对不起,您的账号已冻结,请于" + nomalDates + "尝试扫码绑定", sysUser.getCompanyId());
|
|
|
+ return R.fail("对不起,您的账号:" + username + " 已冻结,请于" + nomalDates + "尝试扫码绑定");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
// 验证短信验证码
|
|
|
if(CommonUtil.isNotEmpty(shortMessageCode)){
|
|
|
LambdaQueryWrapper<PubVerifyCode> pubVerifyCode = new LambdaQueryWrapper<>();
|
|
|
@@ -323,8 +335,8 @@ public class SysUserController extends BaseController
|
|
|
suser.setFrozen_date(DateUtils.getNowDate());
|
|
|
userService.updateUserLogin(suser);
|
|
|
}else if (compareTo == 0 && UserStatus.DELETED.getCode().equals(sysUser.getStatus())) {
|
|
|
- remoteLogService.saveLogininfor(username, Constants.LOGIN_FAIL, "对不起,您的账号已冻结,请"+ nomalDates +"尝试登陆",sysUser.getCompanyId());
|
|
|
- return R.fail("对不起,您的账号:" + username + " 已冻结,请"+ nomalDates +"尝试登陆");
|
|
|
+ remoteLogService.saveLogininfor(username, Constants.LOGIN_FAIL, "对不起,您的账号已冻结,请于"+ nomalDates +"尝试登陆",sysUser.getCompanyId());
|
|
|
+ return R.fail("对不起,您的账号:" + username + " 已冻结,请于"+ nomalDates +"尝试登陆");
|
|
|
}
|
|
|
}
|
|
|
//登录错误到达五次就转为冻结
|
|
|
@@ -345,8 +357,8 @@ public class SysUserController extends BaseController
|
|
|
Date nomalDate = c.getTime();
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
nomalDates = sdf.format(nomalDate);
|
|
|
- remoteLogService.saveLogininfor(username, Constants.LOGIN_FAIL, "对不起,您的账号已冻结,请"+ nomalDates +"尝试登陆",sysUser.getCompanyId());
|
|
|
- return R.fail("对不起,您的账号:" + username + " 已冻结,请"+ nomalDates +"尝试登陆");
|
|
|
+ remoteLogService.saveLogininfor(username, Constants.LOGIN_FAIL, "对不起,您的账号已冻结,请于"+ nomalDates +"尝试登陆",sysUser.getCompanyId());
|
|
|
+ return R.fail("对不起,您的账号:" + username + " 已冻结,请于"+ nomalDates +"尝试登陆");
|
|
|
}
|
|
|
if (StringUtils.isAnyBlank(username, password))
|
|
|
{
|
|
|
@@ -544,6 +556,29 @@ public class SysUserController extends BaseController
|
|
|
return R.ok(loginUser);
|
|
|
}
|
|
|
|
|
|
+ @PostMapping("/checkLogin")
|
|
|
+ public R checkLogin(@RequestParam(value = "token") String token) {
|
|
|
+ String singleLogin = configService.selectConfigByKey("singleLogin");
|
|
|
+ if ("1".equals(singleLogin)) {
|
|
|
+ Long userId = tokenService.getLoginUser(token).getSysUser().getUserId();
|
|
|
+
|
|
|
+ Map<String, Object> param = new HashMap<>();
|
|
|
+ param.put("userId", userId);
|
|
|
+ param.put("token", token);
|
|
|
+
|
|
|
+ String lastToken = ownSysUserMapper.getLoginToken(param);
|
|
|
+ LoginUser lastLoginUser = tokenService.getLoginUser(lastToken);
|
|
|
+
|
|
|
+ if (lastLoginUser != null) {
|
|
|
+ lastLoginUser.setSingle("1");
|
|
|
+ tokenService.setLoginUser(lastLoginUser);
|
|
|
+ }
|
|
|
+
|
|
|
+ ownSysUserMapper.updateLoginToken(param);
|
|
|
+ }
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取用户信息
|
|
|
*
|