|
@@ -1,10 +1,7 @@
|
|
-package com.rongwei.zhsw.sys.service.impl;
|
|
|
|
|
|
+package com.rongwei.zhsw.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
-import com.rongwe.zhsw.vo.WeChatLoginReturnVo;
|
|
|
|
-import com.rongwe.zhsw.vo.WeChatLoginVo;
|
|
|
|
import com.rongwei.commonservice.service.RedisService;
|
|
import com.rongwei.commonservice.service.RedisService;
|
|
-
|
|
|
|
import com.rongwei.rwadmincommon.system.domain.SysUserDo;
|
|
import com.rongwei.rwadmincommon.system.domain.SysUserDo;
|
|
import com.rongwei.rwadmincommon.system.domain.UserLoginVo;
|
|
import com.rongwei.rwadmincommon.system.domain.UserLoginVo;
|
|
import com.rongwei.rwadmincommon.system.service.LoginUtilService;
|
|
import com.rongwei.rwadmincommon.system.service.LoginUtilService;
|
|
@@ -13,27 +10,20 @@ import com.rongwei.rwadmincommon.system.vo.JwtAuthenticationRequest;
|
|
import com.rongwei.rwadmincommon.system.vo.SysUserVo;
|
|
import com.rongwei.rwadmincommon.system.vo.SysUserVo;
|
|
import com.rongwei.rwcommon.base.R;
|
|
import com.rongwei.rwcommon.base.R;
|
|
import com.rongwei.rwcommon.base.exception.CustomException;
|
|
import com.rongwei.rwcommon.base.exception.CustomException;
|
|
-import com.rongwei.rwcommon.utils.Constants;
|
|
|
|
import com.rongwei.rwcommon.utils.SecurityUtil;
|
|
import com.rongwei.rwcommon.utils.SecurityUtil;
|
|
-import com.rongwei.rwcommonentity.commonservers.domain.TenantDo;
|
|
|
|
-import com.rongwei.zhsw.sys.dao.CommonBusinessDao;
|
|
|
|
import com.rongwei.zhsw.fegin.LoginAuth;
|
|
import com.rongwei.zhsw.fegin.LoginAuth;
|
|
-import com.rongwei.zhsw.sys.service.LoginLogicService;
|
|
|
|
-import com.rongwei.zhsw.utils.WeChatUtils;
|
|
|
|
|
|
+import com.rongwei.zhsw.service.LoginLogicService;
|
|
import lombok.SneakyThrows;
|
|
import lombok.SneakyThrows;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
-import org.springframework.web.context.request.RequestContextHolder;
|
|
|
|
-import org.springframework.web.context.request.ServletRequestAttributes;
|
|
|
|
|
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
|
-import java.util.*;
|
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
/**
|
|
* LoginLogicServiceImpl class
|
|
* LoginLogicServiceImpl class
|
|
@@ -53,48 +43,20 @@ public class LoginLogicServiceImpl implements LoginLogicService {
|
|
@Autowired
|
|
@Autowired
|
|
private LoginAuth loginAuth;
|
|
private LoginAuth loginAuth;
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 账号密码登录逻辑
|
|
* 账号密码登录逻辑
|
|
|
|
+ *
|
|
* @param userLogin
|
|
* @param userLogin
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@SneakyThrows
|
|
@SneakyThrows
|
|
@Override
|
|
@Override
|
|
public R accountLogin(UserLoginVo userLogin) {
|
|
public R accountLogin(UserLoginVo userLogin) {
|
|
- // Map<String, List<SysUserDo>> allTenantUsers = (Map<String, List<SysUserDo>>) redisService.getRedisCatchObj("allTenantUsers");
|
|
|
|
- // 是否为融公社管理员登录
|
|
|
|
-// if (userLogin.isCheckPrimaryLibrary()) {
|
|
|
|
-// // 校验当前账号是否属于 主库
|
|
|
|
-// // 获取主库中的用户信息
|
|
|
|
-// List<SysUserDo> sysUserDos = allTenantUsers == null ? new ArrayList<>() : allTenantUsers.getOrDefault(primarySchemaId, new ArrayList<>());
|
|
|
|
-// // 校验当前登录账号是否穿在
|
|
|
|
-// boolean hasUser = sysUserDos.stream().anyMatch(user -> userLogin.getUsername().equals(user.getAccount()));
|
|
|
|
-// // 不存在提示错误信息
|
|
|
|
-// if (!hasUser) {
|
|
|
|
-// log.error("当前登录账号:{} 在主库中不存在", userLogin.getUsername());
|
|
|
|
-// throw new RuntimeException("账号或密码错误");
|
|
|
|
-// }
|
|
|
|
-// if (!allTenantUsers.containsKey(primarySchemaId)) {
|
|
|
|
-// log.error("无法获取主库信息");
|
|
|
|
-// throw new RuntimeException("无法获取主库信息!请联系系统管理员");
|
|
|
|
-// }
|
|
|
|
-// // 获取租户信息
|
|
|
|
-// List<TenantDo> tenantDoList = tenantDao.getTenantDosById(Arrays.asList(primarySchemaId.split(",")));// (List<TenantDo>) redisService.getRedisCatchObj("allTenants");
|
|
|
|
-// if (tenantDoList.isEmpty()) {
|
|
|
|
-// log.error("无法通过id:{},获取到租户信息.", primarySchemaId);
|
|
|
|
-// throw new RuntimeException("无法获取租户信息,请联系管理员!");
|
|
|
|
-// }
|
|
|
|
-// ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
|
|
|
-// HttpServletRequest srequest = attributes.getRequest();
|
|
|
|
-// srequest.setAttribute(Constants.SAAS_LOGIN_TOKEN, tenantDoList.get(0).getDskey());
|
|
|
|
-// } else {
|
|
|
|
- // 设置对应的Schema
|
|
|
|
- loginUtilService.saasLoginToken(userLogin);
|
|
|
|
- // }
|
|
|
|
|
|
+ Map<String, List<SysUserDo>> allTenantUsers = (Map<String, List<SysUserDo>>) redisService.getRedisCatchObj("allTenantUsers");
|
|
|
|
+ // 设置对应的Schema
|
|
|
|
+ loginUtilService.saasLoginToken(userLogin);
|
|
// 校验用户名正确性
|
|
// 校验用户名正确性
|
|
- SysUserDo sysUserDo = sysUserService.getOne(new LambdaQueryWrapper<SysUserDo>().eq(SysUserDo::getAccount,userLogin.getUsername()),true);
|
|
|
|
|
|
+ SysUserDo sysUserDo = sysUserService.getOne(new LambdaQueryWrapper<SysUserDo>().eq(SysUserDo::getAccount, userLogin.getUsername()), true);
|
|
if (sysUserDo == null || StringUtils.isBlank(sysUserDo.getId())) {
|
|
if (sysUserDo == null || StringUtils.isBlank(sysUserDo.getId())) {
|
|
// 防攻击,模糊提醒
|
|
// 防攻击,模糊提醒
|
|
throw new CustomException("用户名密码不正确");
|
|
throw new CustomException("用户名密码不正确");
|
|
@@ -132,11 +94,4 @@ public class LoginLogicServiceImpl implements LoginLogicService {
|
|
return R.ok(map);
|
|
return R.ok(map);
|
|
}
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
|
- public R wechatLogin(WeChatLoginVo weChatLoginVo) {
|
|
|
|
- log.info("微信用户登录");
|
|
|
|
- WeChatLoginReturnVo login = WeChatUtils.login(weChatLoginVo.getWxCode());
|
|
|
|
- return R.ok(login);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
}
|
|
}
|