|
|
@ -9,6 +9,7 @@ import com.epmet.commons.tools.exception.ExceptionUtils; |
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.security.dto.GovTokenDto; |
|
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
|
import com.epmet.commons.tools.security.password.PasswordUtils; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.CpUserDetailRedis; |
|
|
|
import com.epmet.commons.tools.utils.DateUtils; |
|
|
@ -29,6 +30,7 @@ import com.epmet.jwt.JwtTokenUtils; |
|
|
|
import com.epmet.redis.CaptchaRedis; |
|
|
|
import com.epmet.service.GovLoginService; |
|
|
|
import com.epmet.service.LoginService; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
@ -270,6 +272,9 @@ public class GovLoginServiceImpl implements GovLoginService { |
|
|
|
throw new RenException(customerStaffDTOResult.getCode()); |
|
|
|
} |
|
|
|
CustomerStaffDTO customerStaff = customerStaffDTOResult.getData(); |
|
|
|
if(null==customerStaff.getPassword()||"".equals(customerStaff.getPassword().trim())){ |
|
|
|
throw new RenException(EpmetErrorCode.PLEASE_ACTIVATE_CURRENT_CUSTOMER_ACCOUNT.getCode()); |
|
|
|
} |
|
|
|
//2、解析微信用户
|
|
|
|
WxMaJscode2SessionResult wxMaJscode2SessionResult = loginService.getWxMaUser(LoginConstant.APP_GOV, formDTO.getWxCode()); |
|
|
|
//3、记录staff_wechat,并记录用户激活状态,激活时间
|
|
|
@ -320,6 +325,60 @@ public class GovLoginServiceImpl implements GovLoginService { |
|
|
|
cpUserDetailRedis.set(userDetails, jwtTokenProperties.getExpire()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<StaffOrgsResultDTO> getMyOrgByPassword(StaffOrgsFormDTO formDTO) { |
|
|
|
//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())); |
|
|
|
throw new RenException(customerStaffResult.getCode()); |
|
|
|
} |
|
|
|
//2、密码是否正确
|
|
|
|
List<CustomerStaffDTO> customerStaffList=customerStaffResult.getData(); |
|
|
|
//3、查询用户所有的组织信息
|
|
|
|
List<String> customerIdList = new ArrayList<>(); |
|
|
|
//是否设置过密码
|
|
|
|
boolean havePasswordFlag=false; |
|
|
|
//密码是否正确
|
|
|
|
boolean passwordRightFlag=false; |
|
|
|
for (CustomerStaffDTO customerStaffDTO : customerStaffList) { |
|
|
|
if(StringUtils.isNotBlank(customerStaffDTO.getPassword())){ |
|
|
|
havePasswordFlag=true; |
|
|
|
}else{ |
|
|
|
logger.warn(String.format("当前用户:手机号%s,客户Id%s下未设置密码.",formDTO.getMobile(),customerStaffDTO.getCustomerId())); |
|
|
|
} |
|
|
|
if (!PasswordUtils.matches(formDTO.getPassword(), customerStaffDTO.getPassword())) { |
|
|
|
logger.warn(String.format("当前用户:手机号%s,客户Id%s密码输入错误.",formDTO.getMobile(),customerStaffDTO.getCustomerId())); |
|
|
|
|
|
|
|
}else{ |
|
|
|
logger.warn(String.format("当前用户:手机号%s,客户Id%s密码匹配正确.",formDTO.getMobile(),customerStaffDTO.getCustomerId())); |
|
|
|
passwordRightFlag=true; |
|
|
|
} |
|
|
|
customerIdList.add(customerStaffDTO.getCustomerId()); |
|
|
|
} |
|
|
|
//根据手机号查出来所有用户,密码都为空,表明用户未激活账户,未设置密码
|
|
|
|
if(!havePasswordFlag){ |
|
|
|
throw new RenException(EpmetErrorCode.PLEASE_ACTIVATE_ACCOUNT.getCode()); |
|
|
|
} |
|
|
|
//密码错误
|
|
|
|
if(!passwordRightFlag){ |
|
|
|
throw new RenException(EpmetErrorCode.PASSWORD_ERROR.getCode()); |
|
|
|
} |
|
|
|
StaffOrgFormDTO staffOrgFormDTO = new StaffOrgFormDTO(); |
|
|
|
staffOrgFormDTO.setCustomerIdList(customerIdList); |
|
|
|
Result<List<StaffOrgsResultDTO>> result = govOrgFeignClient.getStaffOrgList(staffOrgFormDTO); |
|
|
|
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.getPassword(), |
|
|
|
result.getCode(), |
|
|
|
result.getMsg())); |
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
|
|
|
|
|
//保存登录日志
|
|
|
|
private Result saveStaffLoginRecord(GovWxmpEnteOrgFormDTO formDTO, String staffId, String openId) { |
|
|
|
StaffLoginAgencyRecordFormDTO staffLoginAgencyRecordFormDTO = new StaffLoginAgencyRecordFormDTO(); |
|
|
|