|
|
@ -79,13 +79,13 @@ public class GovLoginServiceImpl implements GovLoginService { |
|
|
|
public void sendSmsCode(SendSmsCodeFormDTO formDTO) { |
|
|
|
//1、校验手机号是否符合规范
|
|
|
|
if (!PhoneValidatorUtils.isMobile(formDTO.getMobile())) { |
|
|
|
logger.error(String.format(SEND_SMS_CODE_ERROR, formDTO.getMobile(), EpmetErrorCode.ERROR_PHONE.getCode(), EpmetErrorCode.ERROR_PHONE.getMsg())); |
|
|
|
logger.warn(String.format(SEND_SMS_CODE_ERROR, formDTO.getMobile(), EpmetErrorCode.ERROR_PHONE.getCode(), EpmetErrorCode.ERROR_PHONE.getMsg())); |
|
|
|
throw new RenException(EpmetErrorCode.ERROR_PHONE.getCode()); |
|
|
|
} |
|
|
|
//2、根据手机号校验用户是否存在
|
|
|
|
Result<List<CustomerStaffDTO>> customerStaffResult = epmetUserFeignClient.checkCustomerStaff(formDTO.getMobile()); |
|
|
|
if (!customerStaffResult.success()) { |
|
|
|
logger.error(String.format(SEND_SMS_CODE_ERROR, formDTO.getMobile(), customerStaffResult.getCode(), customerStaffResult.getMsg())); |
|
|
|
logger.warn(String.format(SEND_SMS_CODE_ERROR, formDTO.getMobile(), customerStaffResult.getCode(), customerStaffResult.getMsg())); |
|
|
|
throw new RenException(customerStaffResult.getCode()); |
|
|
|
} |
|
|
|
//3、发送短信验证码
|
|
|
@ -94,7 +94,7 @@ public class GovLoginServiceImpl implements GovLoginService { |
|
|
|
sendVerificationCodeFormDTO.setAliyunTemplateCode(SmsTemplateConstant.LGOIN_CONFIRM); |
|
|
|
Result<SendVerificationCodeResultDTO> smsCodeResult=epmetMessageOpenFeignClient.sendVerificationCode(sendVerificationCodeFormDTO); |
|
|
|
if (!smsCodeResult.success()) { |
|
|
|
logger.error(String.format(SEND_SMS_CODE_ERROR, formDTO.getMobile(), smsCodeResult.getCode(), smsCodeResult.getMsg())); |
|
|
|
logger.warn(String.format(SEND_SMS_CODE_ERROR, formDTO.getMobile(), smsCodeResult.getCode(), smsCodeResult.getMsg())); |
|
|
|
throw new RenException(smsCodeResult.getCode()); |
|
|
|
} |
|
|
|
//4、保存短信验证码(删除现有短信验证码、将新的短信验证码存入Redis)
|
|
|
@ -114,13 +114,13 @@ public class GovLoginServiceImpl implements GovLoginService { |
|
|
|
//1、根据手机号查询到用户信息
|
|
|
|
Result<List<CustomerStaffDTO>> customerStaffResult = epmetUserFeignClient.checkCustomerStaff(formDTO.getMobile()); |
|
|
|
if (!customerStaffResult.success()) { |
|
|
|
logger.error(String.format("手机验证码登录异常,手机号[%s],code[%s],msg[%s]", formDTO.getMobile(), customerStaffResult.getCode(), customerStaffResult.getMsg())); |
|
|
|
logger.warn(String.format("手机验证码登录异常,手机号[%s],code[%s],msg[%s]", formDTO.getMobile(), customerStaffResult.getCode(), customerStaffResult.getMsg())); |
|
|
|
throw new RenException(customerStaffResult.getCode()); |
|
|
|
} |
|
|
|
//2、验证码是否正确
|
|
|
|
String rightSmsCode = captchaRedis.getSmsCode(formDTO.getMobile()); |
|
|
|
if (!formDTO.getSmsCode().equals(rightSmsCode)) { |
|
|
|
logger.error(String.format("验证码错误code[%s],msg[%s]",EpmetErrorCode.MOBILE_CODE_ERROR.getCode(),EpmetErrorCode.MOBILE_CODE_ERROR.getMsg())); |
|
|
|
logger.warn(String.format("验证码错误code[%s],msg[%s]",EpmetErrorCode.MOBILE_CODE_ERROR.getCode(),EpmetErrorCode.MOBILE_CODE_ERROR.getMsg())); |
|
|
|
throw new RenException(EpmetErrorCode.MOBILE_CODE_ERROR.getCode()); |
|
|
|
} |
|
|
|
//3、查询用户所有的组织信息
|
|
|
@ -134,7 +134,7 @@ public class GovLoginServiceImpl implements GovLoginService { |
|
|
|
if(result.success()&&null!=result.getData()){ |
|
|
|
return result.getData(); |
|
|
|
} |
|
|
|
logger.error(String .format("手机验证码获取组织,调用%s服务失败,入参手机号%s,验证码%s,返回错误码%s,错误提示信息%s", ServiceConstant.GOV_ORG_SERVER,formDTO.getMobile(),formDTO.getSmsCode(),result.getCode(),result.getMsg())); |
|
|
|
logger.warn(String .format("手机验证码获取组织,调用%s服务失败,入参手机号%s,验证码%s,返回错误码%s,错误提示信息%s", ServiceConstant.GOV_ORG_SERVER,formDTO.getMobile(),formDTO.getSmsCode(),result.getCode(),result.getMsg())); |
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
|
|
|
|
@ -147,7 +147,7 @@ public class GovLoginServiceImpl implements GovLoginService { |
|
|
|
} |
|
|
|
Result<StaffLatestAgencyResultDTO> latestStaffWechat = epmetUserFeignClient.getLatestStaffWechatLoginRecord(wxMaJscode2SessionResult.getOpenid()); |
|
|
|
if (!latestStaffWechat.success() || null == latestStaffWechat.getData()) { |
|
|
|
logger.error(String.format("没有获取到用户最近一次登录账户信息,code[%s],msg[%s]", EpmetErrorCode.PLEASE_LOGIN.getCode(), EpmetErrorCode.PLEASE_LOGIN.getMsg())); |
|
|
|
logger.warn(String.format("没有获取到用户最近一次登录账户信息,code[%s],msg[%s]", EpmetErrorCode.PLEASE_LOGIN.getCode(), EpmetErrorCode.PLEASE_LOGIN.getMsg())); |
|
|
|
throw new RenException(EpmetErrorCode.PLEASE_LOGIN.getCode()); |
|
|
|
} |
|
|
|
StaffLatestAgencyResultDTO staffLatestAgencyResultDTO = latestStaffWechat.getData(); |
|
|
@ -222,7 +222,7 @@ public class GovLoginServiceImpl implements GovLoginService { |
|
|
|
public Set<String> getGridIdList(String staffId) { |
|
|
|
Result<List<GridByStaffResultDTO>> result = govOrgFeignClient.listGridsbystaffid(staffId); |
|
|
|
if (!result.success()) { |
|
|
|
logger.error("登录:查询网格列表,远程调用返回错误:{}", result.getMsg()); |
|
|
|
logger.warn("登录:查询网格列表,远程调用返回错误:{}", result.getMsg()); |
|
|
|
return null; |
|
|
|
} else { |
|
|
|
List<GridByStaffResultDTO> grids = result.getData(); |
|
|
@ -239,11 +239,11 @@ public class GovLoginServiceImpl implements GovLoginService { |
|
|
|
return deptIdLists; |
|
|
|
} |
|
|
|
} else { |
|
|
|
logger.error("登录:查询部门列表,远程调用返回错误:{}", deptListResult.getMsg()); |
|
|
|
logger.warn("登录:查询部门列表,远程调用返回错误:{}", deptListResult.getMsg()); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
String errorStackTrace = ExceptionUtils.getErrorStackTrace(e); |
|
|
|
logger.error("登录:查询部门列表异常:{}", errorStackTrace); |
|
|
|
logger.warn("登录:查询部门列表异常:{}", errorStackTrace); |
|
|
|
} |
|
|
|
return null; |
|
|
|
} |
|
|
@ -268,7 +268,7 @@ public class GovLoginServiceImpl implements GovLoginService { |
|
|
|
customerStaffFormDTO.setMobile(formDTO.getMobile()); |
|
|
|
Result<CustomerStaffDTO> customerStaffDTOResult = epmetUserFeignClient.getCustomerStaffInfo(customerStaffFormDTO); |
|
|
|
if (!customerStaffDTOResult.success() || null == customerStaffDTOResult.getData()) { |
|
|
|
logger.error(String.format("获取工作人员信息失败,手机号[%s],客户id:[%s],code[%s],msg[%s]", formDTO.getMobile(), formDTO.getCustomerId(), customerStaffDTOResult.getCode(), customerStaffDTOResult.getMsg())); |
|
|
|
logger.warn(String.format("获取工作人员信息失败,手机号[%s],客户id:[%s],code[%s],msg[%s]", formDTO.getMobile(), formDTO.getCustomerId(), customerStaffDTOResult.getCode(), customerStaffDTOResult.getMsg())); |
|
|
|
throw new RenException(customerStaffDTOResult.getCode()); |
|
|
|
} |
|
|
|
CustomerStaffDTO customerStaff = customerStaffDTOResult.getData(); |
|
|
@ -291,7 +291,7 @@ public class GovLoginServiceImpl implements GovLoginService { |
|
|
|
@Override |
|
|
|
public void loginOut(TokenDto tokenDto) { |
|
|
|
if(null == tokenDto){ |
|
|
|
logger.error("token解析失败,直接跳转重新登录即可"); |
|
|
|
logger.warn("token解析失败,直接跳转重新登录即可"); |
|
|
|
throw new RenException("当前用户信息获取失败"); |
|
|
|
} |
|
|
|
cpUserDetailRedis.logout(tokenDto.getApp() , tokenDto.getClient() , tokenDto.getUserId()); |
|
|
@ -328,7 +328,7 @@ public class GovLoginServiceImpl implements GovLoginService { |
|
|
|
//1、根据手机号查询到用户信息
|
|
|
|
Result<List<CustomerStaffDTO>> customerStaffResult = epmetUserFeignClient.checkCustomerStaff(formDTO.getMobile()); |
|
|
|
if (!customerStaffResult.success()) { |
|
|
|
logger.error(String.format("手机密码登录异常,手机号[%s],code[%s],msg[%s]", formDTO.getMobile(), customerStaffResult.getCode(), customerStaffResult.getMsg())); |
|
|
|
logger.warn(String.format("手机密码登录异常,手机号[%s],code[%s],msg[%s]", formDTO.getMobile(), customerStaffResult.getCode(), customerStaffResult.getMsg())); |
|
|
|
throw new RenException(customerStaffResult.getCode()); |
|
|
|
} |
|
|
|
//2、密码是否正确
|
|
|
@ -357,7 +357,7 @@ public class GovLoginServiceImpl implements GovLoginService { |
|
|
|
} |
|
|
|
//根据手机号查出来所有用户,密码都为空,表明用户未激活账户,未设置密码
|
|
|
|
if(!havePasswordFlag){ |
|
|
|
logger.error(String.format("当前手机号(%s)下所有账户都未设置密码,请先使用验证码登录激活账户",formDTO.getMobile())); |
|
|
|
logger.warn(String.format("当前手机号(%s)下所有账户都未设置密码,请先使用验证码登录激活账户",formDTO.getMobile())); |
|
|
|
throw new RenException(EpmetErrorCode.PASSWORD_ERROR.getCode()); |
|
|
|
} |
|
|
|
//密码错误
|
|
|
@ -371,7 +371,7 @@ public class GovLoginServiceImpl implements GovLoginService { |
|
|
|
if(result.success()&&null!=result.getData()){ |
|
|
|
return result.getData(); |
|
|
|
} |
|
|
|
logger.error(String .format("手机验证码获取组织,调用%s服务失败,入参手机号%s,密码%s,返回错误码%s,错误提示信息%s", |
|
|
|
logger.warn(String .format("手机验证码获取组织,调用%s服务失败,入参手机号%s,密码%s,返回错误码%s,错误提示信息%s", |
|
|
|
ServiceConstant.GOV_ORG_SERVER, |
|
|
|
formDTO.getMobile(), |
|
|
|
formDTO.getPassword(), |
|
|
@ -466,7 +466,7 @@ public class GovLoginServiceImpl implements GovLoginService { |
|
|
|
public String getOrgIdPath(String staffId) { |
|
|
|
Result<CustomerAgencyDTO> result = govOrgFeignClient.getAgencyByStaff(staffId); |
|
|
|
if (!result.success()) { |
|
|
|
logger.error("登录:查询登录人所属的机关OrgIdPath失败:{}", result.getMsg()); |
|
|
|
logger.warn("登录:查询登录人所属的机关OrgIdPath失败:{}", result.getMsg()); |
|
|
|
return null; |
|
|
|
} |
|
|
|
CustomerAgencyDTO agency = result.getData(); |
|
|
@ -484,7 +484,7 @@ public class GovLoginServiceImpl implements GovLoginService { |
|
|
|
public CustomerAgencyDTO getAgencyByStaffId(String staffId) { |
|
|
|
Result<CustomerAgencyDTO> result = govOrgFeignClient.getAgencyByStaff(staffId); |
|
|
|
if (!result.success()) { |
|
|
|
logger.error("登录:查询登录人所属的机关OrgIdPath失败:{}", result.getMsg()); |
|
|
|
logger.warn("登录:查询登录人所属的机关OrgIdPath失败:{}", result.getMsg()); |
|
|
|
return null; |
|
|
|
} |
|
|
|
return result.getData(); |
|
|
|