|
|
@ -11,7 +11,6 @@ import com.epmet.common.token.constant.LoginConstant; |
|
|
|
import com.epmet.commons.rocketmq.messages.LoginMQMsg; |
|
|
|
import com.epmet.commons.tools.constant.AppClientConstant; |
|
|
|
import com.epmet.commons.tools.constant.ServiceConstant; |
|
|
|
import com.epmet.commons.tools.enums.DingMiniAppEnum; |
|
|
|
import com.epmet.commons.tools.enums.EnvEnum; |
|
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
|
import com.epmet.commons.tools.exception.EpmetException; |
|
|
@ -800,56 +799,63 @@ public class ThirdLoginServiceImpl implements ThirdLoginService, ResultDataResol |
|
|
|
return token; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public ResiDingAppLoginResDTO resiLoginDingTemp(ResiDingAppLoginFormDTO formDTO) { |
|
|
|
//获取用户手机号
|
|
|
|
log.info("钉钉居民端应用登录入参:"+ JSON.toJSONString(formDTO)); |
|
|
|
ResiDingAppLoginResDTO resDTO= null; |
|
|
|
try { |
|
|
|
resDTO = new ResiDingAppLoginResDTO(); |
|
|
|
EnvEnum currentEnv = EnvEnum.getCurrentEnv(); |
|
|
|
if (EnvEnum.PROD.getCode().equals(currentEnv.getCode())) { |
|
|
|
//烟台的客户id
|
|
|
|
resDTO.setCustomerId("1535072605621841922"); |
|
|
|
}else if(EnvEnum.TEST.getCode().equals(currentEnv.getCode())){ |
|
|
|
//最美琴岛
|
|
|
|
resDTO.setCustomerId("0c41b272ee9ee95ac6f184ad548a30eb"); |
|
|
|
resDTO.setGridId("f896b59f3cddf1f54280546d79803652"); |
|
|
|
resDTO.setGridName("抚顺社区-抚顺第一网格"); |
|
|
|
resDTO.setAgencyId("f6e183d8e6687020074e6d8061926bfa"); |
|
|
|
resDTO.setEpmetUserId("f838614e67cf8ae0edaefe562b6660e5"); |
|
|
|
resDTO.setRegFlag(true); |
|
|
|
}else if(EnvEnum.LOCAL.getCode().equals(currentEnv.getCode())||EnvEnum.DEV.getCode().equals(currentEnv.getCode())){ |
|
|
|
//其余统一走开发环境
|
|
|
|
resDTO.setCustomerId("45687aa479955f9d06204d415238f7cc"); |
|
|
|
resDTO.setGridId("763d6e09b9081d63195d53da84b3ae3a"); |
|
|
|
resDTO.setGridName("抚顺社区-抚顺第二网格"); |
|
|
|
resDTO.setAgencyId("f6e183d8e6687020074e6d8061926bfa"); |
|
|
|
resDTO.setEpmetUserId("f838614e67cf8ae0edaefe562b6660e5"); |
|
|
|
resDTO.setRegFlag(true); |
|
|
|
} |
|
|
|
public ResiDingAppLoginResDTO resiLoginDingMd(ResiDingAppLoginMdFormDTO formDTO) { |
|
|
|
// 获取用户手机号
|
|
|
|
log.info("1、钉钉居民端应用登录入参:" + JSON.toJSONString(formDTO)); |
|
|
|
ResiDingAppLoginResDTO resDTO = null; |
|
|
|
resDTO = new ResiDingAppLoginResDTO(); |
|
|
|
EnvEnum currentEnv = EnvEnum.getCurrentEnv(); |
|
|
|
if (EnvEnum.PROD.getCode().equals(currentEnv.getCode())) { |
|
|
|
// 烟台的客户id
|
|
|
|
resDTO.setCustomerId("1535072605621841922"); |
|
|
|
} else if (EnvEnum.TEST.getCode().equals(currentEnv.getCode())) { |
|
|
|
// 最美琴岛
|
|
|
|
resDTO.setCustomerId("0c41b272ee9ee95ac6f184ad548a30eb"); |
|
|
|
} else { |
|
|
|
// 其余统一走开发环境
|
|
|
|
resDTO.setCustomerId("45687aa479955f9d06204d415238f7cc"); |
|
|
|
} |
|
|
|
|
|
|
|
//1、获取用户手机号 todo 这里暂时没改为miniappId
|
|
|
|
String clientId = formDTO.getMiniAppId(); |
|
|
|
DingTalkResult<AccessTokenResult> userAccessToken = dingTalkClientToken.getUserAccessToken(formDTO.getAuthCode(), clientId, DingMiniAppEnum.getEnum(clientId).getSuiteSecret()); |
|
|
|
log.info("resiLoginDing userAccessToken:{}",JSON.toJSONString(userAccessToken)); |
|
|
|
if (!userAccessToken.success() || null == userAccessToken.getData()) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "调用微信api异常:" + JSON.toJSONString(userAccessToken), EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getMsg()); |
|
|
|
} |
|
|
|
DingTalkResult<UserBaseInfo> me = dingTalkClientUser.getUserInfo("me", userAccessToken.getData().getAccessToken()); |
|
|
|
log.info("resiLoginDing me:{}",JSON.toJSONString(me)); |
|
|
|
resDTO.setExtInfo(JSON.toJSONString(me.getData())); |
|
|
|
// 1、获取用户手机号
|
|
|
|
DingLoginResiFormDTO dingLoginResiFormDTO = getDingLoginResiFormDTOMd(formDTO.getMiniAppId(), formDTO.getAuthCode()); |
|
|
|
dingLoginResiFormDTO.setCustomerId(resDTO.getCustomerId()); |
|
|
|
// 2、调用userfeign接口获取userId、注册网格相关信息
|
|
|
|
Result<DingLoginResiResDTO> loginResiResDTOResult = epmetUserOpenFeignClient.dingResiLogin(dingLoginResiFormDTO); |
|
|
|
if (!loginResiResDTOResult.success() || null == loginResiResDTOResult.getData()) { |
|
|
|
// 临时打个日志
|
|
|
|
log.error(String.format("resiLoginDingMd获取epmetUserId异常,入参:%s,user服务返参:%s", JSON.toJSONString(formDTO), JSON.toJSONString(loginResiResDTOResult))); |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取epmetUserId异常:" + JSON.toJSONString(loginResiResDTOResult), EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getMsg()); |
|
|
|
} |
|
|
|
DingLoginResiResDTO resiResDTO = loginResiResDTOResult.getData(); |
|
|
|
resDTO.setGridId(resiResDTO.getGridId()); |
|
|
|
resDTO.setGridName(resiResDTO.getGridName()); |
|
|
|
resDTO.setAgencyId(resiResDTO.getAgencyId()); |
|
|
|
resDTO.setEpmetUserId(resiResDTO.getEpmetUserId()); |
|
|
|
resDTO.setRegFlag(resiResDTO.getRegFlag()); |
|
|
|
|
|
|
|
// 2、调用userfeign接口获取userId、注册网格相关信息 todo
|
|
|
|
// 3.生成token,并且存放Redis
|
|
|
|
String token = this.saveTokenDtoDing(formDTO.getMiniAppId(), AppClientConstant.APP_RESI, AppClientConstant.MINI_DING, resDTO.getEpmetUserId(), resDTO.getCustomerId()); |
|
|
|
resDTO.setAuthorization(token); |
|
|
|
|
|
|
|
//3.生成token,并且存放Redis
|
|
|
|
String token=this.saveTokenDtoDing(clientId,AppClientConstant.APP_RESI,AppClientConstant.MINI_DING, resDTO.getEpmetUserId(), resDTO.getCustomerId()); |
|
|
|
resDTO.setAuthorization(token); |
|
|
|
return resDTO; |
|
|
|
} |
|
|
|
|
|
|
|
} catch (ApiException e) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), e.getErrMsg(), EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getMsg()); |
|
|
|
private DingLoginResiFormDTO getDingLoginResiFormDTOMd(String miniAppId, String authCode) { |
|
|
|
DingMiniInfoCache dingMiniInfo = CustomerDingDingRedis.getDingMiniInfo(miniAppId); |
|
|
|
// 1、服务商获取第三方应用授权企业的access_token,文档地址:https://open.dingtalk.com/document/orgapp-server/obtains-the-enterprise-authorized-credential
|
|
|
|
// 烟台的CorpId: dingaae55cbc47a96845f5bf40eda33b7ba0
|
|
|
|
DingTalkResult<String> res = dingTalkClientToken.getThirdAuthCorpAccessToken(dingMiniInfo.getSuiteKey(), dingMiniInfo.getSuiteSecret(), "abc", "dingaae55cbc47a96845f5bf40eda33b7ba0"); |
|
|
|
if (!res.success() || StringUtils.isBlank(res.getData())) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "服务商获取第三方应用授权企业的access_token", "服务商获取第三方应用授权企业的access_token"); |
|
|
|
} |
|
|
|
return resDTO; |
|
|
|
// 2、通过免登码获取用户信息,文档地址:https://open.dingtalk.com/document/orgapp-server/obtain-the-userid-of-a-user-by-using-the-log-free
|
|
|
|
// dingTalkClientToken.getTodo();
|
|
|
|
// 3、查询用户详情,文档地址:https://open.dingtalk.com/document/isvapp-server/query-user-details
|
|
|
|
// dingTalkClientToken.getTodo();
|
|
|
|
DingLoginResiFormDTO dingLoginResiFormDTO = new DingLoginResiFormDTO(); |
|
|
|
return dingLoginResiFormDTO; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|