|
@@ -1,6 +1,6 @@
|
|
|
-package com.rongwei.zhsw.code.service.impl;
|
|
|
+package com.rongwei.sfcommon.sys.service.impl;
|
|
|
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.rongwei.commonservice.service.RedisService;
|
|
|
|
|
|
import com.rongwei.rwadmincommon.system.domain.SysUserDo;
|
|
@@ -10,12 +10,13 @@ import com.rongwei.rwadmincommon.system.service.SysUserService;
|
|
|
import com.rongwei.rwadmincommon.system.vo.JwtAuthenticationRequest;
|
|
|
import com.rongwei.rwadmincommon.system.vo.SysUserVo;
|
|
|
import com.rongwei.rwcommon.base.R;
|
|
|
+import com.rongwei.rwcommon.base.exception.CustomException;
|
|
|
import com.rongwei.rwcommon.utils.Constants;
|
|
|
import com.rongwei.rwcommon.utils.SecurityUtil;
|
|
|
import com.rongwei.rwcommonentity.commonservers.domain.TenantDo;
|
|
|
-import com.rongwei.zhsw.code.dao.TenantDao;
|
|
|
-import com.rongwei.zhsw.code.fegin.LoginAuth;
|
|
|
-import com.rongwei.zhsw.code.service.LoginLogicService;
|
|
|
+import com.rongwei.sfcommon.sys.dao.TenantDao;
|
|
|
+import com.rongwei.sfcommon.fegin.LoginAuth;
|
|
|
+import com.rongwei.sfcommon.sys.service.LoginLogicService;
|
|
|
import lombok.SneakyThrows;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
@@ -128,7 +129,7 @@ public class LoginLogicServiceImpl implements LoginLogicService {
|
|
|
@SneakyThrows
|
|
|
@Override
|
|
|
public R accountLogin(UserLoginVo userLogin) {
|
|
|
- Map<String, List<SysUserDo>> allTenantUsers = (Map<String, List<SysUserDo>>) redisService.getRedisCatchObj("allTenantUsers");
|
|
|
+ // Map<String, List<SysUserDo>> allTenantUsers = (Map<String, List<SysUserDo>>) redisService.getRedisCatchObj("allTenantUsers");
|
|
|
// 是否为融公社管理员登录
|
|
|
// if (userLogin.isCheckPrimaryLibrary()) {
|
|
|
// // 校验当前账号是否属于 主库
|
|
@@ -159,20 +160,18 @@ public class LoginLogicServiceImpl implements LoginLogicService {
|
|
|
loginUtilService.saasLoginToken(userLogin);
|
|
|
// }
|
|
|
// 校验用户名正确性
|
|
|
- SysUserDo sysUser = new SysUserDo();
|
|
|
- sysUser.setAccount(userLogin.getUsername());
|
|
|
- SysUserDo sysUserDo = sysUserService.getOne(new QueryWrapper(sysUser));
|
|
|
- if (sysUserDo == null || com.rongwei.rwcommon.utils.StringUtils.isEmpty(sysUserDo.getId())) {
|
|
|
+ SysUserDo sysUserDo = sysUserService.getOne(new LambdaQueryWrapper<SysUserDo>().eq(SysUserDo::getAccount,userLogin.getUsername()),true);
|
|
|
+ if (sysUserDo == null || StringUtils.isBlank(sysUserDo.getId())) {
|
|
|
// 防攻击,模糊提醒
|
|
|
- throw new RuntimeException("用户名密码不正确");
|
|
|
+ throw new CustomException("用户名密码不正确");
|
|
|
}
|
|
|
if ("1".equals(sysUserDo.getEnabled())) {
|
|
|
- throw new RuntimeException("此用户不可用,请联系管理员");
|
|
|
+ throw new CustomException("此用户不可用,请联系管理员");
|
|
|
}
|
|
|
// 校验登录密码正确性
|
|
|
String secPas = SecurityUtil.getSaltMd5AndSha(userLogin.getPassword(), sysUserDo.getId());
|
|
|
if (!secPas.equals(sysUserDo.getPassword())) {
|
|
|
- throw new RuntimeException("用户名密码不正确");
|
|
|
+ throw new CustomException("用户名密码不正确");
|
|
|
}
|
|
|
// token生成
|
|
|
JwtAuthenticationRequest jwtAuthenticationRequest = new JwtAuthenticationRequest(sysUserDo.getId(), sysUserDo.getAccount(), sysUserDo.getName());
|
|
@@ -182,7 +181,7 @@ public class LoginLogicServiceImpl implements LoginLogicService {
|
|
|
Map<String, Object> tokenmap = loginAuth.getTokenInfo(jwtAuthenticationRequest);
|
|
|
String token = (String) tokenmap.get("token");
|
|
|
if ("ServerAbnormal".equals(token)) {
|
|
|
- throw new RuntimeException("认证服务异常");
|
|
|
+ throw new CustomException("认证服务异常");
|
|
|
}
|
|
|
// 组织返回给前端的用户信息
|
|
|
SysUserVo sysUserVo = new SysUserVo();
|