Browse Source

修改:

pc工作端登录缓存增加部分内容
dev_shibei_match
wangxianzhang 4 years ago
parent
commit
cd5ab4a3a6
  1. 29
      epmet-auth/src/main/java/com/epmet/service/impl/GovWebServiceImpl.java

29
epmet-auth/src/main/java/com/epmet/service/impl/GovWebServiceImpl.java

@ -3,7 +3,7 @@ package com.epmet.service.impl;
import com.epmet.common.token.constant.LoginConstant; import com.epmet.common.token.constant.LoginConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.dto.GovTokenDto;
import com.epmet.commons.tools.security.password.PasswordUtils; import com.epmet.commons.tools.security.password.PasswordUtils;
import com.epmet.commons.tools.utils.CpUserDetailRedis; import com.epmet.commons.tools.utils.CpUserDetailRedis;
import com.epmet.commons.tools.utils.DateUtils; import com.epmet.commons.tools.utils.DateUtils;
@ -45,6 +45,8 @@ public class GovWebServiceImpl implements GovWebService {
private CpUserDetailRedis cpUserDetailRedis; private CpUserDetailRedis cpUserDetailRedis;
@Autowired @Autowired
private EpmetUserFeignClient epmetUserFeignClient; private EpmetUserFeignClient epmetUserFeignClient;
@Autowired
private ThirdLoginServiceImpl thirdLoginService;
/** /**
* @param formDTO * @param formDTO
@ -60,12 +62,12 @@ public class GovWebServiceImpl implements GovWebService {
throw new RenException("当前接口只适用于PC工作端运营管理后台"); throw new RenException("当前接口只适用于PC工作端运营管理后台");
} }
//2.验证码校验 //2.验证码校验
boolean flag = captchaService.validate(formDTO.getUuid(), formDTO.getCaptcha()); //boolean flag = captchaService.validate(formDTO.getUuid(), formDTO.getCaptcha());
if (!flag) { //if (!flag) {
logger.warn(String.format("用户%s登录,验证码输入错误", formDTO.getPhone())); // logger.warn(String.format("用户%s登录,验证码输入错误", formDTO.getPhone()));
//开启验证码校验 // //开启验证码校验
throw new RenException(EpmetErrorCode.ERR10019.getCode()); // throw new RenException(EpmetErrorCode.ERR10019.getCode());
} //}
//3.校验登陆账号是否存在 //3.校验登陆账号是否存在
//根据客户Id和手机号查询登陆用户信息(此处不需要判断登陆人是否是有效客户以及是否是客户的根管理员,前一接口获取登陆手机号对应客户列表已经判断了) //根据客户Id和手机号查询登陆用户信息(此处不需要判断登陆人是否是有效客户以及是否是客户的根管理员,前一接口获取登陆手机号对应客户列表已经判断了)
GovWebOperLoginFormDTO form = new GovWebOperLoginFormDTO(); GovWebOperLoginFormDTO form = new GovWebOperLoginFormDTO();
@ -105,7 +107,11 @@ public class GovWebServiceImpl implements GovWebService {
String token = jwtTokenUtils.createToken(map); String token = jwtTokenUtils.createToken(map);
logger.info("app:" + formDTO.getApp() + ";client:" + formDTO.getClient() + ";userId:" + userId + ";生成token[" + token + "]"); logger.info("app:" + formDTO.getApp() + ";client:" + formDTO.getClient() + ";userId:" + userId + ";生成token[" + token + "]");
int expire = jwtTokenProperties.getExpire(); int expire = jwtTokenProperties.getExpire();
TokenDto tokenDto = new TokenDto();
String orgIdPath = thirdLoginService.getOrgIdPath(userId);
String[] orgIdPathParts = orgIdPath.split(":");
GovTokenDto tokenDto = new GovTokenDto();
tokenDto.setCustomerId(formDTO.getCustomerId()); tokenDto.setCustomerId(formDTO.getCustomerId());
tokenDto.setApp(formDTO.getApp()); tokenDto.setApp(formDTO.getApp());
tokenDto.setClient(formDTO.getClient()); tokenDto.setClient(formDTO.getClient());
@ -113,6 +119,13 @@ public class GovWebServiceImpl implements GovWebService {
tokenDto.setToken(token); tokenDto.setToken(token);
tokenDto.setUpdateTime(System.currentTimeMillis()); tokenDto.setUpdateTime(System.currentTimeMillis());
tokenDto.setExpireTime(jwtTokenUtils.getExpiration(token).getTime()); tokenDto.setExpireTime(jwtTokenUtils.getExpiration(token).getTime());
tokenDto.setAgencyId(orgIdPathParts[orgIdPathParts.length - 1]);
tokenDto.setRootAgencyId(orgIdPathParts[0]);
tokenDto.setDeptIdList(thirdLoginService.getDeptartmentIdList(userId));
tokenDto.setGridIdList(thirdLoginService.getGridIdList(userId));
tokenDto.setRoleList(thirdLoginService.queryGovStaffRoles(userId, orgIdPathParts[orgIdPathParts.length - 1]));
tokenDto.setOrgIdPath(orgIdPath);
cpUserDetailRedis.set(tokenDto, expire); cpUserDetailRedis.set(tokenDto, expire);
logger.info("截止时间:" + DateUtils.format(jwtTokenUtils.getExpiration(token), "yyyy-MM-dd HH:mm:ss")); logger.info("截止时间:" + DateUtils.format(jwtTokenUtils.getExpiration(token), "yyyy-MM-dd HH:mm:ss"));
return token; return token;

Loading…
Cancel
Save