Browse Source

Merge remote-tracking branch 'origin/lingshan_master' into lingshan_master

master
yinzuomei 2 years ago
parent
commit
f664a2eb10
  1. 41
      epmet-auth/src/main/java/com/epmet/controller/ThirdLoginController.java
  2. 9
      epmet-auth/src/main/java/com/epmet/service/ThirdLoginService.java
  3. 471
      epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java
  4. 2
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/EpmetThirdApplication.java
  5. 179
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/dingtalk/CallbackController.java
  6. 4
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/tccc/TCCCAuthController.java
  7. 8
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/DingTalkService.java
  8. 61
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/DingTalkServiceImpl.java
  9. 2
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/dao/CustomerProjectParameterDao.java

41
epmet-auth/src/main/java/com/epmet/controller/ThirdLoginController.java

@ -3,7 +3,6 @@ package com.epmet.controller;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.form.*; import com.epmet.dto.form.*;
import com.epmet.dto.result.ResiDingAppLoginResDTO;
import com.epmet.dto.result.StaffOrgsResultDTO; import com.epmet.dto.result.StaffOrgsResultDTO;
import com.epmet.dto.result.UserTokenResultDTO; import com.epmet.dto.result.UserTokenResultDTO;
import com.epmet.service.ThirdLoginService; import com.epmet.service.ThirdLoginService;
@ -159,11 +158,11 @@ public class ThirdLoginController {
* @param formDTO * @param formDTO
* @return * @return
*/ */
@PostMapping("resilogin-ding") // @PostMapping("resilogin-ding")
public Result<ResiDingAppLoginResDTO> resiLoginDing(@RequestBody ResiDingAppLoginFormDTO formDTO) { // public Result<ResiDingAppLoginResDTO> resiLoginDing(@RequestBody ResiDingAppLoginFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO,ResiDingAppLoginFormDTO.InnerMiniApp.class); // ValidatorUtils.validateEntity(formDTO,ResiDingAppLoginFormDTO.InnerMiniApp.class);
return new Result<ResiDingAppLoginResDTO>().ok(thirdLoginService.resiLoginDing(formDTO)); // return new Result<ResiDingAppLoginResDTO>().ok(thirdLoginService.resiLoginDing(formDTO));
} // }
/** /**
* 烟台建立应用授权给我们走企业免登 * 烟台建立应用授权给我们走企业免登
@ -173,11 +172,11 @@ public class ThirdLoginController {
* @param formDTO * @param formDTO
* @return * @return
*/ */
@PostMapping("resilogin-ding-md") // @PostMapping("resilogin-ding-md")
public Result<ResiDingAppLoginResDTO> resiLoginDingMd(@RequestBody DingAppLoginMdFormDTO formDTO) { // public Result<ResiDingAppLoginResDTO> resiLoginDingMd(@RequestBody DingAppLoginMdFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO); // ValidatorUtils.validateEntity(formDTO);
return new Result<ResiDingAppLoginResDTO>().ok(thirdLoginService.resiLoginDingMd(formDTO)); // return new Result<ResiDingAppLoginResDTO>().ok(thirdLoginService.resiLoginDingMd(formDTO));
} // }
/** /**
* 企业内部应用开发不授权了 文档地址https://open.dingtalk.com/document/orgapp-server/enterprise-internal-application-logon-free * 企业内部应用开发不授权了 文档地址https://open.dingtalk.com/document/orgapp-server/enterprise-internal-application-logon-free
@ -200,11 +199,11 @@ public class ThirdLoginController {
* @return * @return
* 目前烟台用的这个 * 目前烟台用的这个
*/ */
@PostMapping("resilogin-internalding") // @PostMapping("resilogin-internalding")
public Result<ResiDingAppLoginResDTO> resiLoginInternalDing(@RequestBody DingAppLoginMdFormDTO formDTO) { // public Result<ResiDingAppLoginResDTO> resiLoginInternalDing(@RequestBody DingAppLoginMdFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO); // ValidatorUtils.validateEntity(formDTO);
return new Result<ResiDingAppLoginResDTO>().ok(thirdLoginService.resiLoginInternalDing(formDTO)); // return new Result<ResiDingAppLoginResDTO>().ok(thirdLoginService.resiLoginInternalDing(formDTO));
} // }
/** /**
* 根据免登授权码, 获取登录用户身份 * 根据免登授权码, 获取登录用户身份
@ -212,11 +211,11 @@ public class ThirdLoginController {
* @param formDTO 免登授权码 * @param formDTO 免登授权码
* @return * @return
*/ */
@PostMapping("govlogin-internalding") // @PostMapping("govlogin-internalding")
public Result<UserTokenResultDTO> login(@RequestBody DingAppLoginMdFormDTO formDTO) { // public Result<UserTokenResultDTO> login(@RequestBody DingAppLoginMdFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO); // ValidatorUtils.validateEntity(formDTO);
return new Result<UserTokenResultDTO>().ok(thirdLoginService.govLoginInternalDing(formDTO)); // return new Result<UserTokenResultDTO>().ok(thirdLoginService.govLoginInternalDing(formDTO));
} // }
/** /**
* 根据免登授权码, 获取登录用户身份 * 根据免登授权码, 获取登录用户身份

9
epmet-auth/src/main/java/com/epmet/service/ThirdLoginService.java

@ -1,7 +1,6 @@
package com.epmet.service; package com.epmet.service;
import com.epmet.dto.form.*; import com.epmet.dto.form.*;
import com.epmet.dto.result.ResiDingAppLoginResDTO;
import com.epmet.dto.result.StaffOrgsResultDTO; import com.epmet.dto.result.StaffOrgsResultDTO;
import com.epmet.dto.result.UserTokenResultDTO; import com.epmet.dto.result.UserTokenResultDTO;
@ -93,7 +92,7 @@ public interface ThirdLoginService {
* @param formDTO * @param formDTO
* @return * @return
*/ */
ResiDingAppLoginResDTO resiLoginDing(ResiDingAppLoginFormDTO formDTO); // ResiDingAppLoginResDTO resiLoginDing(ResiDingAppLoginFormDTO formDTO);
/** /**
* 企业简历内部应用授权给第三方 * 企业简历内部应用授权给第三方
@ -102,21 +101,21 @@ public interface ThirdLoginService {
* @param formDTO * @param formDTO
* @return * @return
*/ */
ResiDingAppLoginResDTO resiLoginDingMd(DingAppLoginMdFormDTO formDTO); // ResiDingAppLoginResDTO resiLoginDingMd(DingAppLoginMdFormDTO formDTO);
/** /**
* 企业内部应用免登 文档地址https://open.dingtalk.com/document/orgapp-server/enterprise-internal-application-logon-free * 企业内部应用免登 文档地址https://open.dingtalk.com/document/orgapp-server/enterprise-internal-application-logon-free
* @param formDTO * @param formDTO
* @return * @return
*/ */
ResiDingAppLoginResDTO resiLoginInternalDing(DingAppLoginMdFormDTO formDTO); // ResiDingAppLoginResDTO resiLoginInternalDing(DingAppLoginMdFormDTO formDTO);
/** /**
* desc:企业内部应用 工作端登录 * desc:企业内部应用 工作端登录
* @param formDTO * @param formDTO
* @return * @return
*/ */
UserTokenResultDTO govLoginInternalDing(DingAppLoginMdFormDTO formDTO); // UserTokenResultDTO govLoginInternalDing(DingAppLoginMdFormDTO formDTO);
/** /**
* desc:烟台sso根据authCode 获取本系统token * desc:烟台sso根据authCode 获取本系统token

471
epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java

@ -5,22 +5,18 @@ import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
import cn.binarywang.wx.miniapp.util.crypt.WxMaCryptUtils; import cn.binarywang.wx.miniapp.util.crypt.WxMaCryptUtils;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.aliyun.dingtalk.module.DingTalkResult;
import com.epmet.auth.constants.AuthOperationConstants; import com.epmet.auth.constants.AuthOperationConstants;
import com.epmet.common.token.constant.LoginConstant; import com.epmet.common.token.constant.LoginConstant;
import com.epmet.commons.rocketmq.messages.LoginMQMsg; import com.epmet.commons.rocketmq.messages.LoginMQMsg;
import com.epmet.commons.tools.constant.AppClientConstant; import com.epmet.commons.tools.constant.AppClientConstant;
import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.enums.EnvEnum; import com.epmet.commons.tools.enums.EnvEnum;
import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.feign.ResultDataResolver; import com.epmet.commons.tools.feign.ResultDataResolver;
import com.epmet.commons.tools.redis.common.CustomerDingDingRedis;
import com.epmet.commons.tools.redis.common.bean.DingMiniInfoCache;
import com.epmet.commons.tools.security.dto.GovTokenDto; import com.epmet.commons.tools.security.dto.GovTokenDto;
import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.security.password.PasswordUtils; import com.epmet.commons.tools.security.password.PasswordUtils;
@ -31,8 +27,6 @@ import com.epmet.commons.tools.validator.PhoneValidatorUtils;
import com.epmet.constant.AuthHttpUrlConstant; import com.epmet.constant.AuthHttpUrlConstant;
import com.epmet.constant.SmsTemplateConstant; import com.epmet.constant.SmsTemplateConstant;
import com.epmet.dto.*; import com.epmet.dto.*;
import com.epmet.dto.dingres.DingUserDetailDTO;
import com.epmet.dto.dingres.V2UserGetuserinfoResDTO;
import com.epmet.dto.form.*; import com.epmet.dto.form.*;
import com.epmet.dto.result.*; import com.epmet.dto.result.*;
import com.epmet.feign.EpmetMessageOpenFeignClient; import com.epmet.feign.EpmetMessageOpenFeignClient;
@ -43,11 +37,6 @@ import com.epmet.jwt.JwtTokenUtils;
import com.epmet.redis.CaptchaRedis; import com.epmet.redis.CaptchaRedis;
import com.epmet.service.GovWebService; import com.epmet.service.GovWebService;
import com.epmet.service.ThirdLoginService; import com.epmet.service.ThirdLoginService;
import com.taobao.api.ApiException;
import com.taobao.dingtalk.client.DingTalkClientToken;
import com.taobao.dingtalk.client.DingTalkClientUser;
import com.taobao.dingtalk.vo.result.AccessTokenResult;
import com.taobao.dingtalk.vo.result.UserBaseInfo;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -87,10 +76,10 @@ public class ThirdLoginServiceImpl implements ThirdLoginService, ResultDataResol
private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient;
@Autowired @Autowired
private EpmetMessageOpenFeignClient messageOpenFeignClient; private EpmetMessageOpenFeignClient messageOpenFeignClient;
@Autowired // @Autowired
private DingTalkClientToken dingTalkClientToken; // private DingTalkClientToken dingTalkClientToken;
@Autowired // @Autowired
private DingTalkClientUser dingTalkClientUser; // private DingTalkClientUser dingTalkClientUser;
@Autowired @Autowired
private GovWebService govWebService; private GovWebService govWebService;
@ -870,54 +859,54 @@ public class ThirdLoginServiceImpl implements ThirdLoginService, ResultDataResol
* @param formDTO * @param formDTO
* @return * @return
*/ */
@Override // @Override
public ResiDingAppLoginResDTO resiLoginDing(ResiDingAppLoginFormDTO formDTO) { // public ResiDingAppLoginResDTO resiLoginDing(ResiDingAppLoginFormDTO formDTO) {
//获取用户手机号 // //获取用户手机号
log.info("1、钉钉居民端应用登录入参:"+ JSON.toJSONString(formDTO)); // log.info("1、钉钉居民端应用登录入参:"+ JSON.toJSONString(formDTO));
ResiDingAppLoginResDTO resDTO= null; // ResiDingAppLoginResDTO resDTO= null;
try { // try {
resDTO = new ResiDingAppLoginResDTO(); // resDTO = new ResiDingAppLoginResDTO();
resDTO.setCustomerId(getCurrentCustomerId()); // resDTO.setCustomerId(getCurrentCustomerId());
//1、获取用户手机号 // //1、获取用户手机号
String miniAppId = formDTO.getMiniAppId(); // String miniAppId = formDTO.getMiniAppId();
DingMiniInfoCache dingMiniInfo = CustomerDingDingRedis.getDingMiniInfo(miniAppId); // DingMiniInfoCache dingMiniInfo = CustomerDingDingRedis.getDingMiniInfo(miniAppId);
DingTalkResult<AccessTokenResult> userAccessToken = dingTalkClientToken.getUserAccessToken(formDTO.getAuthCode(), dingMiniInfo.getSuiteKey(), dingMiniInfo.getSuiteSecret()); // DingTalkResult<AccessTokenResult> userAccessToken = dingTalkClientToken.getUserAccessToken(formDTO.getAuthCode(), dingMiniInfo.getSuiteKey(), dingMiniInfo.getSuiteSecret());
log.info("2、resiLoginDing userAccessToken:{}",JSON.toJSONString(userAccessToken)); // log.info("2、resiLoginDing userAccessToken:{}",JSON.toJSONString(userAccessToken));
if (!userAccessToken.success() || null == userAccessToken.getData()) { // 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()); // 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()); // DingTalkResult<UserBaseInfo> me = dingTalkClientUser.getUserInfo("me", userAccessToken.getData().getAccessToken());
log.info("3、resiLoginDing me:{}",JSON.toJSONString(me)); // log.info("3、resiLoginDing me:{}",JSON.toJSONString(me));
resDTO.setExtInfo(JSON.toJSONString(me.getData())); // resDTO.setExtInfo(JSON.toJSONString(me.getData()));
if (!me.success() || StringUtils.isBlank(me.getData().getMobile())) { // if (!me.success() || StringUtils.isBlank(me.getData().getMobile())) {
log.error("resilogin-ding登录接口报错,入参:" + JSON.toJSONString(formDTO) + ";获取手机号为空, userAccessToken.getData().getAccessToken()=" + userAccessToken.getData().getAccessToken()); // log.error("resilogin-ding登录接口报错,入参:" + JSON.toJSONString(formDTO) + ";获取手机号为空, userAccessToken.getData().getAccessToken()=" + userAccessToken.getData().getAccessToken());
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取手机号为空", "获取手机号为空"); // throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取手机号为空", "获取手机号为空");
} // }
// 2、调用userfeign接口获取userId、注册网格相关信息 todo // // 2、调用userfeign接口获取userId、注册网格相关信息 todo
DingLoginResiFormDTO dingLoginResiFormDTO=ConvertUtils.sourceToTarget(me.getData(),DingLoginResiFormDTO.class); // DingLoginResiFormDTO dingLoginResiFormDTO=ConvertUtils.sourceToTarget(me.getData(),DingLoginResiFormDTO.class);
dingLoginResiFormDTO.setCustomerId(resDTO.getCustomerId()); // dingLoginResiFormDTO.setCustomerId(resDTO.getCustomerId());
Result<DingLoginResiResDTO> loginResiResDTOResult = epmetUserOpenFeignClient.dingResiLogin(dingLoginResiFormDTO); // Result<DingLoginResiResDTO> loginResiResDTOResult = epmetUserOpenFeignClient.dingResiLogin(dingLoginResiFormDTO);
if (!loginResiResDTOResult.success() || null == loginResiResDTOResult.getData()) { // if (!loginResiResDTOResult.success() || null == loginResiResDTOResult.getData()) {
//临时打个日志 // //临时打个日志
log.error(String.format("resilogin-ding获取epmetUserId异常,入参:%s,user服务返参:%s", JSON.toJSONString(formDTO), JSON.toJSONString(loginResiResDTOResult))); // log.error(String.format("resilogin-ding获取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()); // throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取epmetUserId异常:" + JSON.toJSONString(loginResiResDTOResult), EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getMsg());
} // }
DingLoginResiResDTO resiResDTO=loginResiResDTOResult.getData(); // DingLoginResiResDTO resiResDTO=loginResiResDTOResult.getData();
resDTO.setGridId(resiResDTO.getGridId()); // resDTO.setGridId(resiResDTO.getGridId());
resDTO.setGridName(resiResDTO.getGridName()); // resDTO.setGridName(resiResDTO.getGridName());
resDTO.setAgencyId(resiResDTO.getAgencyId()); // resDTO.setAgencyId(resiResDTO.getAgencyId());
resDTO.setEpmetUserId(resiResDTO.getEpmetUserId()); // resDTO.setEpmetUserId(resiResDTO.getEpmetUserId());
resDTO.setRegFlag(resiResDTO.getRegFlag()); // resDTO.setRegFlag(resiResDTO.getRegFlag());
//
//3.生成token,并且存放Redis // //3.生成token,并且存放Redis
String token=this.saveTokenDtoDing(formDTO.getMiniAppId(),AppClientConstant.APP_RESI,AppClientConstant.MINI_DING, resDTO.getEpmetUserId(), resDTO.getCustomerId()); // String token=this.saveTokenDtoDing(formDTO.getMiniAppId(),AppClientConstant.APP_RESI,AppClientConstant.MINI_DING, resDTO.getEpmetUserId(), resDTO.getCustomerId());
resDTO.setAuthorization(token); // resDTO.setAuthorization(token);
//
} catch (ApiException e) { // } catch (ApiException e) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), e.getErrMsg(), EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getMsg()); // throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), e.getErrMsg(), EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getMsg());
} // }
return resDTO; // return resDTO;
} // }
private String saveTokenDtoDing(String miniAppId,String app,String client, String userId,String customerId) { private String saveTokenDtoDing(String miniAppId,String app,String client, String userId,String customerId) {
//生成token串 //生成token串
@ -943,84 +932,84 @@ public class ThirdLoginServiceImpl implements ThirdLoginService, ResultDataResol
return token; return token;
} }
@Override // @Override
public ResiDingAppLoginResDTO resiLoginDingMd(DingAppLoginMdFormDTO formDTO) { // public ResiDingAppLoginResDTO resiLoginDingMd(DingAppLoginMdFormDTO formDTO) {
// 获取用户手机号 // // 获取用户手机号
log.info("1、钉钉居民端应用登录入参:" + JSON.toJSONString(formDTO)); // log.info("1、钉钉居民端应用登录入参:" + JSON.toJSONString(formDTO));
ResiDingAppLoginResDTO resDTO = null; // ResiDingAppLoginResDTO resDTO = null;
resDTO = new ResiDingAppLoginResDTO(); // resDTO = new ResiDingAppLoginResDTO();
resDTO.setCustomerId(getCurrentCustomerId()); // resDTO.setCustomerId(getCurrentCustomerId());
// 1、获取用户手机号 // // 1、获取用户手机号
DingLoginResiFormDTO dingLoginResiFormDTO = getDingLoginResiFormDTOMd(formDTO.getMiniAppId(), formDTO.getAuthCode()); // DingLoginResiFormDTO dingLoginResiFormDTO = getDingLoginResiFormDTOMd(formDTO.getMiniAppId(), formDTO.getAuthCode());
dingLoginResiFormDTO.setCustomerId(resDTO.getCustomerId()); // dingLoginResiFormDTO.setCustomerId(resDTO.getCustomerId());
// 2、调用userfeign接口获取userId、注册网格相关信息 // // 2、调用userfeign接口获取userId、注册网格相关信息
Result<DingLoginResiResDTO> loginResiResDTOResult = epmetUserOpenFeignClient.dingResiLogin(dingLoginResiFormDTO); // Result<DingLoginResiResDTO> loginResiResDTOResult = epmetUserOpenFeignClient.dingResiLogin(dingLoginResiFormDTO);
if (!loginResiResDTOResult.success() || null == loginResiResDTOResult.getData()) { // if (!loginResiResDTOResult.success() || null == loginResiResDTOResult.getData()) {
// 临时打个日志 // // 临时打个日志
log.error(String.format("resiLoginDingMd获取epmetUserId异常,入参:%s,user服务返参:%s", JSON.toJSONString(formDTO), JSON.toJSONString(loginResiResDTOResult))); // 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()); // throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取epmetUserId异常:" + JSON.toJSONString(loginResiResDTOResult), EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getMsg());
} // }
DingLoginResiResDTO resiResDTO = loginResiResDTOResult.getData(); // DingLoginResiResDTO resiResDTO = loginResiResDTOResult.getData();
resDTO.setGridId(resiResDTO.getGridId()); // resDTO.setGridId(resiResDTO.getGridId());
resDTO.setGridName(resiResDTO.getGridName()); // resDTO.setGridName(resiResDTO.getGridName());
resDTO.setAgencyId(resiResDTO.getAgencyId()); // resDTO.setAgencyId(resiResDTO.getAgencyId());
resDTO.setEpmetUserId(resiResDTO.getEpmetUserId()); // resDTO.setEpmetUserId(resiResDTO.getEpmetUserId());
resDTO.setRegFlag(resiResDTO.getRegFlag()); // resDTO.setRegFlag(resiResDTO.getRegFlag());
//
// 3.生成token,并且存放Redis // // 3.生成token,并且存放Redis
String token = this.saveTokenDtoDing(formDTO.getMiniAppId(), AppClientConstant.APP_RESI, AppClientConstant.MINI_DING, resDTO.getEpmetUserId(), resDTO.getCustomerId()); // String token = this.saveTokenDtoDing(formDTO.getMiniAppId(), AppClientConstant.APP_RESI, AppClientConstant.MINI_DING, resDTO.getEpmetUserId(), resDTO.getCustomerId());
resDTO.setAuthorization(token); // resDTO.setAuthorization(token);
//
return resDTO; // return resDTO;
} // }
private DingLoginResiFormDTO getDingLoginResiFormDTOMd(String miniAppId, String authCode) { // private DingLoginResiFormDTO getDingLoginResiFormDTOMd(String miniAppId, String authCode) {
DingMiniInfoCache dingMiniInfo = CustomerDingDingRedis.getDingMiniInfo(miniAppId); // DingMiniInfoCache dingMiniInfo = CustomerDingDingRedis.getDingMiniInfo(miniAppId);
//
// 1、服务商获取第三方应用授权企业的access_token,文档地址:https://open.dingtalk.com/document/orgapp-server/obtains-the-enterprise-authorized-credential // // 1、服务商获取第三方应用授权企业的access_token,文档地址:https://open.dingtalk.com/document/orgapp-server/obtains-the-enterprise-authorized-credential
// 烟台的CorpId: dingaae55cbc47a96845f5bf40eda33b7ba0 // // 烟台的CorpId: dingaae55cbc47a96845f5bf40eda33b7ba0
String yantaiCorpId = "dingaae55cbc47a96845f5bf40eda33b7ba0"; // String yantaiCorpId = "dingaae55cbc47a96845f5bf40eda33b7ba0";
DingTalkResult<String> res = dingTalkClientToken.getThirdAuthCorpAccessToken(dingMiniInfo.getSuiteKey(), dingMiniInfo.getSuiteSecret(), "abc", yantaiCorpId); // DingTalkResult<String> res = dingTalkClientToken.getThirdAuthCorpAccessToken(dingMiniInfo.getSuiteKey(), dingMiniInfo.getSuiteSecret(), "abc", yantaiCorpId);
if (!res.success() || StringUtils.isBlank(res.getData())) { // if (!res.success() || StringUtils.isBlank(res.getData())) {
log.error(String.format("企业内部应用免登服务商获取第三方应用授权企业的access_token失败,customKey:%s,customSecret:%s,corpId:%s", dingMiniInfo.getSuiteSecret(), dingMiniInfo.getSuiteSecret(), yantaiCorpId)); // log.error(String.format("企业内部应用免登服务商获取第三方应用授权企业的access_token失败,customKey:%s,customSecret:%s,corpId:%s", dingMiniInfo.getSuiteSecret(), dingMiniInfo.getSuiteSecret(), yantaiCorpId));
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "服务商获取第三方应用授权企业的access_token", "服务商获取第三方应用授权企业的access_token"); // throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "服务商获取第三方应用授权企业的access_token", "服务商获取第三方应用授权企业的access_token");
} // }
String accessToken = res.getData(); // String accessToken = res.getData();
log.info(String.format("1、服务商获取第三方应用授权企业的access_token返参:%s", accessToken)); // log.info(String.format("1、服务商获取第三方应用授权企业的access_token返参:%s", accessToken));
//
// 2、通过免登码获取用户信息,文档地址:https://open.dingtalk.com/document/orgapp-server/obtain-the-userid-of-a-user-by-using-the-log-free // // 2、通过免登码获取用户信息,文档地址:https://open.dingtalk.com/document/orgapp-server/obtain-the-userid-of-a-user-by-using-the-log-free
DingTalkResult<String> v2UserGetuserinfoRes = dingTalkClientToken.getUserInfo(accessToken, authCode); // DingTalkResult<String> v2UserGetuserinfoRes = dingTalkClientToken.getUserInfo(accessToken, authCode);
if (!v2UserGetuserinfoRes.success() || StringUtils.isBlank(v2UserGetuserinfoRes.getData())) { // if (!v2UserGetuserinfoRes.success() || StringUtils.isBlank(v2UserGetuserinfoRes.getData())) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "通过免登码获取用户信息异常", "通过免登码获取用户信息异常"); // throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "通过免登码获取用户信息异常", "通过免登码获取用户信息异常");
} // }
log.info(String.format("2、通过免登码获取用户信息返参:%s", v2UserGetuserinfoRes.getData())); // log.info(String.format("2、通过免登码获取用户信息返参:%s", v2UserGetuserinfoRes.getData()));
V2UserGetuserinfoResDTO v2UserGetuserinfoResDTO = JSON.parseObject(v2UserGetuserinfoRes.getData(), V2UserGetuserinfoResDTO.class); // V2UserGetuserinfoResDTO v2UserGetuserinfoResDTO = JSON.parseObject(v2UserGetuserinfoRes.getData(), V2UserGetuserinfoResDTO.class);
if (null == v2UserGetuserinfoResDTO || StringUtils.isBlank(v2UserGetuserinfoResDTO.getUserid())) { // if (null == v2UserGetuserinfoResDTO || StringUtils.isBlank(v2UserGetuserinfoResDTO.getUserid())) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取钉钉用户userid为空", "获取钉钉用户userid为空"); // throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取钉钉用户userid为空", "获取钉钉用户userid为空");
} // }
//
//
// 3、查询用户详情,文档地址:https://open.dingtalk.com/document/isvapp-server/query-user-details // // 3、查询用户详情,文档地址:https://open.dingtalk.com/document/isvapp-server/query-user-details
DingTalkResult<String> v2UserGetRes = dingTalkClientToken.getUserDetail(v2UserGetuserinfoResDTO.getUserid(), accessToken); // DingTalkResult<String> v2UserGetRes = dingTalkClientToken.getUserDetail(v2UserGetuserinfoResDTO.getUserid(), accessToken);
if (!v2UserGetRes.success() || StringUtils.isBlank(v2UserGetRes.getData())) { // if (!v2UserGetRes.success() || StringUtils.isBlank(v2UserGetRes.getData())) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "根据userId查询用户详情失败", "根据userId查询用户详情失败"); // throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "根据userId查询用户详情失败", "根据userId查询用户详情失败");
} // }
log.info(String.format("3、查询用户详情:%s", v2UserGetRes.getData())); // log.info(String.format("3、查询用户详情:%s", v2UserGetRes.getData()));
DingUserDetailDTO dingUserDetailDTO = JSON.parseObject(v2UserGetRes.getData(), DingUserDetailDTO.class); // DingUserDetailDTO dingUserDetailDTO = JSON.parseObject(v2UserGetRes.getData(), DingUserDetailDTO.class);
if (null == dingUserDetailDTO || StringUtils.isBlank(dingUserDetailDTO.getMobile())) { // if (null == dingUserDetailDTO || StringUtils.isBlank(dingUserDetailDTO.getMobile())) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取手机号为空", "获取手机号为空"); // throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取手机号为空", "获取手机号为空");
} // }
//
DingLoginResiFormDTO dingLoginResiFormDTO = new DingLoginResiFormDTO(); // DingLoginResiFormDTO dingLoginResiFormDTO = new DingLoginResiFormDTO();
dingLoginResiFormDTO.setAvatarUrl(dingUserDetailDTO.getAvatar()); // dingLoginResiFormDTO.setAvatarUrl(dingUserDetailDTO.getAvatar());
dingLoginResiFormDTO.setEmail(dingUserDetailDTO.getOrg_email()); // dingLoginResiFormDTO.setEmail(dingUserDetailDTO.getOrg_email());
dingLoginResiFormDTO.setMobile(dingUserDetailDTO.getMobile()); // dingLoginResiFormDTO.setMobile(dingUserDetailDTO.getMobile());
dingLoginResiFormDTO.setNick(dingUserDetailDTO.getName()); // dingLoginResiFormDTO.setNick(dingUserDetailDTO.getName());
dingLoginResiFormDTO.setOpenId(StrConstant.EPMETY_STR); // dingLoginResiFormDTO.setOpenId(StrConstant.EPMETY_STR);
dingLoginResiFormDTO.setStateCode(dingUserDetailDTO.getState_code()); // dingLoginResiFormDTO.setStateCode(dingUserDetailDTO.getState_code());
dingLoginResiFormDTO.setUnionId(dingUserDetailDTO.getUnionid()); // dingLoginResiFormDTO.setUnionId(dingUserDetailDTO.getUnionid());
return dingLoginResiFormDTO; // return dingLoginResiFormDTO;
} // }
/** /**
@ -1043,57 +1032,57 @@ public class ThirdLoginServiceImpl implements ThirdLoginService, ResultDataResol
* @param formDTO * @param formDTO
* @return * @return
*/ */
@Override // @Override
public ResiDingAppLoginResDTO resiLoginInternalDing(DingAppLoginMdFormDTO formDTO) { // public ResiDingAppLoginResDTO resiLoginInternalDing(DingAppLoginMdFormDTO formDTO) {
// 获取用户手机号 // // 获取用户手机号
log.info("1、钉钉居民端应用登录入参:" + JSON.toJSONString(formDTO)); // log.info("1、钉钉居民端应用登录入参:" + JSON.toJSONString(formDTO));
ResiDingAppLoginResDTO resDTO = new ResiDingAppLoginResDTO(); // ResiDingAppLoginResDTO resDTO = new ResiDingAppLoginResDTO();
resDTO.setCustomerId(getCurrentCustomerId()); // resDTO.setCustomerId(getCurrentCustomerId());
//
// 1、获取用户手机号 // // 1、获取用户手机号
DingLoginResiFormDTO dingLoginResiFormDTO = getDingLoginResiFormDTOInternal(formDTO.getMiniAppId(), formDTO.getAuthCode()); // DingLoginResiFormDTO dingLoginResiFormDTO = getDingLoginResiFormDTOInternal(formDTO.getMiniAppId(), formDTO.getAuthCode());
dingLoginResiFormDTO.setCustomerId(resDTO.getCustomerId()); // dingLoginResiFormDTO.setCustomerId(resDTO.getCustomerId());
resDTO.setRealName(dingLoginResiFormDTO.getNick()); // resDTO.setRealName(dingLoginResiFormDTO.getNick());
// 2、调用userfeign接口获取userId、注册网格相关信息 // // 2、调用userfeign接口获取userId、注册网格相关信息
Result<DingLoginResiResDTO> loginResiResDTOResult = epmetUserOpenFeignClient.dingResiLogin(dingLoginResiFormDTO); // Result<DingLoginResiResDTO> loginResiResDTOResult = epmetUserOpenFeignClient.dingResiLogin(dingLoginResiFormDTO);
if (!loginResiResDTOResult.success() || null == loginResiResDTOResult.getData()) { // if (!loginResiResDTOResult.success() || null == loginResiResDTOResult.getData()) {
// 临时打个日志 // // 临时打个日志
log.error(String.format("resiLoginInternalDing获取epmetUserId异常,入参:%s", JSON.toJSONString(dingLoginResiFormDTO))); // log.error(String.format("resiLoginInternalDing获取epmetUserId异常,入参:%s", JSON.toJSONString(dingLoginResiFormDTO)));
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取epmetUserId异常:"+ JSON.toJSONString(loginResiResDTOResult), "获取epmetUserId异常"); // throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取epmetUserId异常:"+ JSON.toJSONString(loginResiResDTOResult), "获取epmetUserId异常");
} // }
DingLoginResiResDTO resiResDTO = loginResiResDTOResult.getData(); // DingLoginResiResDTO resiResDTO = loginResiResDTOResult.getData();
resDTO.setGridId(resiResDTO.getGridId()); // resDTO.setGridId(resiResDTO.getGridId());
resDTO.setGridName(resiResDTO.getGridName()); // resDTO.setGridName(resiResDTO.getGridName());
resDTO.setAgencyId(resiResDTO.getAgencyId()); // resDTO.setAgencyId(resiResDTO.getAgencyId());
resDTO.setEpmetUserId(resiResDTO.getEpmetUserId()); // resDTO.setEpmetUserId(resiResDTO.getEpmetUserId());
resDTO.setRegFlag(resiResDTO.getRegFlag()); // resDTO.setRegFlag(resiResDTO.getRegFlag());
//
// 3.生成token,并且存放Redis // // 3.生成token,并且存放Redis
String token = this.saveTokenDtoDing(formDTO.getMiniAppId(), AppClientConstant.APP_RESI, AppClientConstant.MINI_DING, resDTO.getEpmetUserId(), resDTO.getCustomerId()); // String token = this.saveTokenDtoDing(formDTO.getMiniAppId(), AppClientConstant.APP_RESI, AppClientConstant.MINI_DING, resDTO.getEpmetUserId(), resDTO.getCustomerId());
resDTO.setAuthorization(token); // resDTO.setAuthorization(token);
//
return resDTO; // return resDTO;
} // }
@Override // @Override
public UserTokenResultDTO govLoginInternalDing(DingAppLoginMdFormDTO formDTO) { // public UserTokenResultDTO govLoginInternalDing(DingAppLoginMdFormDTO formDTO) {
// 获取用户手机号 // // 获取用户手机号
log.info("1、钉钉居民端应用登录入参:" + JSON.toJSONString(formDTO)); // log.info("1、钉钉居民端应用登录入参:" + JSON.toJSONString(formDTO));
ResiDingAppLoginResDTO resDTO = null; // ResiDingAppLoginResDTO resDTO = null;
resDTO = new ResiDingAppLoginResDTO(); // resDTO = new ResiDingAppLoginResDTO();
resDTO.setCustomerId(getCurrentCustomerId()); // resDTO.setCustomerId(getCurrentCustomerId());
//
// 1、获取用户手机号 // // 1、获取用户手机号
DingLoginResiFormDTO dingLoginResiFormDTO = getDingLoginResiFormDTOInternal(formDTO.getMiniAppId(), formDTO.getAuthCode()); // DingLoginResiFormDTO dingLoginResiFormDTO = getDingLoginResiFormDTOInternal(formDTO.getMiniAppId(), formDTO.getAuthCode());
dingLoginResiFormDTO.setCustomerId(resDTO.getCustomerId()); // dingLoginResiFormDTO.setCustomerId(resDTO.getCustomerId());
//
//
GovWebLoginFormDTO loginGovParam = new GovWebLoginFormDTO(); // GovWebLoginFormDTO loginGovParam = new GovWebLoginFormDTO();
loginGovParam.setCustomerId(dingLoginResiFormDTO.getCustomerId()); // loginGovParam.setCustomerId(dingLoginResiFormDTO.getCustomerId());
loginGovParam.setPhone(dingLoginResiFormDTO.getMobile()); // loginGovParam.setPhone(dingLoginResiFormDTO.getMobile());
//
return govWebService.loginByThirdPlatform(loginGovParam); // return govWebService.loginByThirdPlatform(loginGovParam);
} // }
@Override @Override
public UserTokenResultDTO yanTaiSSOLogin(String authCode) { public UserTokenResultDTO yanTaiSSOLogin(String authCode) {
@ -1115,55 +1104,55 @@ public class ThirdLoginServiceImpl implements ThirdLoginService, ResultDataResol
* @param authCode * @param authCode
* @return * @return
*/ */
private DingLoginResiFormDTO getDingLoginResiFormDTOInternal(String miniAppId, String authCode) { // private DingLoginResiFormDTO getDingLoginResiFormDTOInternal(String miniAppId, String authCode) {
DingMiniInfoCache dingMiniInfo = CustomerDingDingRedis.getDingMiniInfo(miniAppId); // DingMiniInfoCache dingMiniInfo = CustomerDingDingRedis.getDingMiniInfo(miniAppId);
if (dingMiniInfo == null){ // if (dingMiniInfo == null){
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取钉钉应用配置异常", "获取钉钉应用配置异常"); // throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取钉钉应用配置异常", "获取钉钉应用配置异常");
} // }
// 1、获取企业内部应用的accessToken文档地址:https://open.dingtalk.com/document/orgapp-server/obtain-the-access_token-of-an-internal-app // // 1、获取企业内部应用的accessToken文档地址:https://open.dingtalk.com/document/orgapp-server/obtain-the-access_token-of-an-internal-app
String accessToken = ""; // String accessToken = "";
DingTalkResult<String> dingTalkResult = dingTalkClientToken.getAppAccessTokenToken(dingMiniInfo.getSuiteKey(), dingMiniInfo.getSuiteSecret()); // DingTalkResult<String> dingTalkResult = dingTalkClientToken.getAppAccessTokenToken(dingMiniInfo.getSuiteKey(), dingMiniInfo.getSuiteSecret());
if (!dingTalkResult.success() || StringUtils.isBlank(dingTalkResult.getData())) { // if (!dingTalkResult.success() || StringUtils.isBlank(dingTalkResult.getData())) {
log.error(String.format("获取企业内部应用的accessToken失败,customKey:%s,customSecret:%s", dingMiniInfo.getSuiteKey(), dingMiniInfo.getSuiteSecret())); // log.error(String.format("获取企业内部应用的accessToken失败,customKey:%s,customSecret:%s", dingMiniInfo.getSuiteKey(), dingMiniInfo.getSuiteSecret()));
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取企业内部应用的accessToken异常", "获取企业内部应用的accessToken"); // throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取企业内部应用的accessToken异常", "获取企业内部应用的accessToken");
} // }
accessToken = dingTalkResult.getData(); // accessToken = dingTalkResult.getData();
log.info(String.format("1、获取企业内部应用的accessToken返参:%s", accessToken)); // log.info(String.format("1、获取企业内部应用的accessToken返参:%s", accessToken));
//
//
// 2、通过免登码获取用户信息,文档地址:https://open.dingtalk.com/document/orgapp-server/obtain-the-userid-of-a-user-by-using-the-log-free // // 2、通过免登码获取用户信息,文档地址:https://open.dingtalk.com/document/orgapp-server/obtain-the-userid-of-a-user-by-using-the-log-free
DingTalkResult<String> v2UserGetuserinfoRes = dingTalkClientToken.getUserInfo(accessToken, authCode); // DingTalkResult<String> v2UserGetuserinfoRes = dingTalkClientToken.getUserInfo(accessToken, authCode);
if (!v2UserGetuserinfoRes.success() || StringUtils.isBlank(v2UserGetuserinfoRes.getData())) { // if (!v2UserGetuserinfoRes.success() || StringUtils.isBlank(v2UserGetuserinfoRes.getData())) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "通过免登码获取用户信息异常", "通过免登码获取用户信息异常"); // throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "通过免登码获取用户信息异常", "通过免登码获取用户信息异常");
} // }
log.info(String.format("2、通过免登码获取用户信息返参:%s", v2UserGetuserinfoRes.getData())); // log.info(String.format("2、通过免登码获取用户信息返参:%s", v2UserGetuserinfoRes.getData()));
V2UserGetuserinfoResDTO v2UserGetuserinfoResDTO = JSON.parseObject(v2UserGetuserinfoRes.getData(), V2UserGetuserinfoResDTO.class); // V2UserGetuserinfoResDTO v2UserGetuserinfoResDTO = JSON.parseObject(v2UserGetuserinfoRes.getData(), V2UserGetuserinfoResDTO.class);
if (null == v2UserGetuserinfoResDTO || StringUtils.isBlank(v2UserGetuserinfoResDTO.getUserid())) { // if (null == v2UserGetuserinfoResDTO || StringUtils.isBlank(v2UserGetuserinfoResDTO.getUserid())) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取钉钉用户userid为空", "获取钉钉用户userid为空"); // throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取钉钉用户userid为空", "获取钉钉用户userid为空");
} // }
//
//
// 3、查询用户详情,文档地址:https://open.dingtalk.com/document/isvapp-server/query-user-details // // 3、查询用户详情,文档地址:https://open.dingtalk.com/document/isvapp-server/query-user-details
DingTalkResult<String> v2UserGetRes = dingTalkClientToken.getUserDetail(v2UserGetuserinfoResDTO.getUserid(), accessToken); // DingTalkResult<String> v2UserGetRes = dingTalkClientToken.getUserDetail(v2UserGetuserinfoResDTO.getUserid(), accessToken);
if (!v2UserGetRes.success() || StringUtils.isBlank(v2UserGetRes.getData())) { // if (!v2UserGetRes.success() || StringUtils.isBlank(v2UserGetRes.getData())) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "根据userId查询用户详情失败", "根据userId查询用户详情失败"); // throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "根据userId查询用户详情失败", "根据userId查询用户详情失败");
} // }
log.info(String.format("3、查询用户详情:%s", v2UserGetRes.getData())); // log.info(String.format("3、查询用户详情:%s", v2UserGetRes.getData()));
DingUserDetailDTO dingUserDetailDTO = JSON.parseObject(v2UserGetRes.getData(), DingUserDetailDTO.class); // DingUserDetailDTO dingUserDetailDTO = JSON.parseObject(v2UserGetRes.getData(), DingUserDetailDTO.class);
if (null == dingUserDetailDTO || StringUtils.isBlank(dingUserDetailDTO.getMobile())) { // if (null == dingUserDetailDTO || StringUtils.isBlank(dingUserDetailDTO.getMobile())) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取手机号为空", "获取手机号为空"); // throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取手机号为空", "获取手机号为空");
} // }
//
DingLoginResiFormDTO dingLoginResiFormDTO = new DingLoginResiFormDTO(); // DingLoginResiFormDTO dingLoginResiFormDTO = new DingLoginResiFormDTO();
dingLoginResiFormDTO.setAvatarUrl(dingUserDetailDTO.getAvatar()); // dingLoginResiFormDTO.setAvatarUrl(dingUserDetailDTO.getAvatar());
dingLoginResiFormDTO.setEmail(dingUserDetailDTO.getOrg_email()); // dingLoginResiFormDTO.setEmail(dingUserDetailDTO.getOrg_email());
dingLoginResiFormDTO.setMobile(dingUserDetailDTO.getMobile()); // dingLoginResiFormDTO.setMobile(dingUserDetailDTO.getMobile());
dingLoginResiFormDTO.setNick(dingUserDetailDTO.getName()); // dingLoginResiFormDTO.setNick(dingUserDetailDTO.getName());
dingLoginResiFormDTO.setOpenId(StrConstant.EPMETY_STR); // dingLoginResiFormDTO.setOpenId(StrConstant.EPMETY_STR);
dingLoginResiFormDTO.setStateCode(dingUserDetailDTO.getState_code()); // dingLoginResiFormDTO.setStateCode(dingUserDetailDTO.getState_code());
dingLoginResiFormDTO.setUnionId(dingUserDetailDTO.getUnionid()); // dingLoginResiFormDTO.setUnionId(dingUserDetailDTO.getUnionid());
return dingLoginResiFormDTO; // return dingLoginResiFormDTO;
} // }
/** /**
* 客户写死吧 * 客户写死吧

2
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/EpmetThirdApplication.java

@ -1,7 +1,6 @@
package com.epmet; package com.epmet;
import com.epmet.mq.properties.RocketMQProperties; import com.epmet.mq.properties.RocketMQProperties;
import com.taobao.dingtalk.spring.annotations.EnableDingTalk;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
@ -9,7 +8,6 @@ import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.cloud.openfeign.EnableFeignClients;
@EnableDingTalk
@EnableConfigurationProperties(RocketMQProperties.class) @EnableConfigurationProperties(RocketMQProperties.class)
@SpringBootApplication @SpringBootApplication
@EnableDiscoveryClient @EnableDiscoveryClient

179
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/dingtalk/CallbackController.java

@ -1,29 +1,14 @@
package com.epmet.controller.dingtalk; package com.epmet.controller.dingtalk;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.aliyun.dingtalk.util.DingCallbackCrypto;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.dto.form.DingMiniInfoFormDTO;
import com.epmet.commons.tools.redis.common.bean.DingMiniInfoCache;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dao.OpenSyncBizDataDao; import com.epmet.dao.OpenSyncBizDataDao;
import com.epmet.dto.DingMiniInfoDTO;
import com.epmet.dto.form.ExemptLoginUserDetailFormDTO;
import com.epmet.entity.OpenSyncBizDataEntity;
import com.epmet.redis.DingDingCallbackRedis; import com.epmet.redis.DingDingCallbackRedis;
import com.epmet.service.DingTalkService; import com.epmet.service.DingTalkService;
import com.epmet.service.OpenSyncBizDataService; import com.epmet.service.OpenSyncBizDataService;
import org.apache.commons.collections4.CollectionUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/** /**
* ISV 小程序回调信息处理 * ISV 小程序回调信息处理
@ -65,81 +50,81 @@ public class CallbackController {
@Autowired @Autowired
private DingTalkService dingTalkService; private DingTalkService dingTalkService;
@PostMapping(value = "dingCallback") // @PostMapping(value = "dingCallback")
public Object dingCallback( // public Object dingCallback(
@RequestParam(value = "signature") String signature, // @RequestParam(value = "signature") String signature,
@RequestParam(value = "timestamp") Long timestamp, // @RequestParam(value = "timestamp") Long timestamp,
@RequestParam(value = "nonce") String nonce, // @RequestParam(value = "nonce") String nonce,
@RequestParam(value = "suiteKey") String suiteKey, // @RequestParam(value = "suiteKey") String suiteKey,
@RequestBody(required = false) JSONObject body // @RequestBody(required = false) JSONObject body
) { // ) {
String params = "signature:" + signature + " timestamp:" + timestamp + " nonce:" + nonce + " body:" + body + "suiteKey::"+suiteKey; // String params = "signature:" + signature + " timestamp:" + timestamp + " nonce:" + nonce + " body:" + body + "suiteKey::"+suiteKey;
try { // try {
log.info("begin callback:" + params); // log.info("begin callback:" + params);
DingMiniInfoDTO dingMiniInfo = openSyncBizDataDao.getDingMiniInfo(suiteKey); // DingMiniInfoDTO dingMiniInfo = openSyncBizDataDao.getDingMiniInfo(suiteKey);
DingCallbackCrypto dingTalkEncryptor = new DingCallbackCrypto(dingMiniInfo.getToken(), dingMiniInfo.getAesKey(), suiteKey); // DingCallbackCrypto dingTalkEncryptor = new DingCallbackCrypto(dingMiniInfo.getToken(), dingMiniInfo.getAesKey(), suiteKey);
//
// 从post请求的body中获取回调信息的加密数据进行解密处理 // // 从post请求的body中获取回调信息的加密数据进行解密处理
String encrypt = body.getString("encrypt"); // String encrypt = body.getString("encrypt");
String plainText = dingTalkEncryptor.getDecryptMsg(signature, timestamp.toString(), nonce, encrypt); // String plainText = dingTalkEncryptor.getDecryptMsg(signature, timestamp.toString(), nonce, encrypt);
JSONObject callBackContent = JSON.parseObject(plainText); // JSONObject callBackContent = JSON.parseObject(plainText);
//
log.info("推来的消息体:"+plainText); // log.info("推来的消息体:"+plainText);
//
// 根据回调事件类型做不同的业务处理 // // 根据回调事件类型做不同的业务处理
String eventType = callBackContent.getString("EventType"); // String eventType = callBackContent.getString("EventType");
if (EVENT_CHECK_CREATE_SUITE_URL.equals(eventType)) { // if (EVENT_CHECK_CREATE_SUITE_URL.equals(eventType)) {
log.info("验证新创建的回调URL有效性: " + plainText); // log.info("验证新创建的回调URL有效性: " + plainText);
} else if (EVENT_CHECK_UPADTE_SUITE_URL.equals(eventType)) { // } else if (EVENT_CHECK_UPADTE_SUITE_URL.equals(eventType)) {
log.info("验证更新回调URL有效性: " + plainText); // log.info("验证更新回调URL有效性: " + plainText);
} else if (EVENT_SUITE_TICKET.equals(eventType)) { // } else if (EVENT_SUITE_TICKET.equals(eventType)) {
// suite_ticket用于用签名形式生成accessToken(访问钉钉服务端的凭证),需要保存到应用的db。 // // suite_ticket用于用签名形式生成accessToken(访问钉钉服务端的凭证),需要保存到应用的db。
// 钉钉会定期向本callback url推送suite_ticket新值用以提升安全性。 // // 钉钉会定期向本callback url推送suite_ticket新值用以提升安全性。
// 应用在获取到新的时值时,保存db成功后,返回给钉钉success加密串(如本demo的return) // // 应用在获取到新的时值时,保存db成功后,返回给钉钉success加密串(如本demo的return)
log.info("应用suite_ticket数据推送: " + plainText); // log.info("应用suite_ticket数据推送: " + plainText);
} else if (EVENT_TMP_AUTH_CODE.equals(eventType)) { // } else if (EVENT_TMP_AUTH_CODE.equals(eventType)) {
// 本事件应用应该异步进行授权开通企业的初始化,目的是尽最大努力快速返回给钉钉服务端。用以提升企业管理员开通应用体验 // // 本事件应用应该异步进行授权开通企业的初始化,目的是尽最大努力快速返回给钉钉服务端。用以提升企业管理员开通应用体验
// 即使本接口没有收到数据或者收到事件后处理初始化失败都可以后续再用户试用应用时从前端获取到corpId并拉取授权企业信息,进而初始化开通及企业。 // // 即使本接口没有收到数据或者收到事件后处理初始化失败都可以后续再用户试用应用时从前端获取到corpId并拉取授权企业信息,进而初始化开通及企业。
log.info("企业授权开通应用事件: " + plainText); // log.info("企业授权开通应用事件: " + plainText);
} else if (EVENT_SYNC_HTTP_PUSH_HIGH.equals(eventType)){ // } else if (EVENT_SYNC_HTTP_PUSH_HIGH.equals(eventType)){
List<Map<String, Object>> bizData = (List<Map<String, Object>>) callBackContent.get("bizData"); // List<Map<String, Object>> bizData = (List<Map<String, Object>>) callBackContent.get("bizData");
if (CollectionUtils.isNotEmpty(bizData)){ // if (CollectionUtils.isNotEmpty(bizData)){
List<OpenSyncBizDataEntity> list = new ArrayList<>(); // List<OpenSyncBizDataEntity> list = new ArrayList<>();
bizData.forEach(b -> { // bizData.forEach(b -> {
OpenSyncBizDataEntity e = new OpenSyncBizDataEntity(); // OpenSyncBizDataEntity e = new OpenSyncBizDataEntity();
e.setSuiteKey(suiteKey); // e.setSuiteKey(suiteKey);
e.setSubscribeId(b.get("subscribe_id").toString()); // e.setSubscribeId(b.get("subscribe_id").toString());
e.setCorpId(b.get("corp_id").toString()); // e.setCorpId(b.get("corp_id").toString());
e.setBizId(b.get("biz_id").toString()); // e.setBizId(b.get("biz_id").toString());
e.setBizData(b.get("biz_data").toString()); // e.setBizData(b.get("biz_data").toString());
e.setBizType(b.get("biz_type").toString()); // e.setBizType(b.get("biz_type").toString());
list.add(e); // list.add(e);
openSyncBizDataService.delete(e); // openSyncBizDataService.delete(e);
if (e.getBizType().equals(NumConstant.TWO_STR)){ // if (e.getBizType().equals(NumConstant.TWO_STR)){
Map<String,String> ticketMap = JSON.parseObject(e.getBizData(), Map.class); // Map<String,String> ticketMap = JSON.parseObject(e.getBizData(), Map.class);
dingCallbackRedis.set(suiteKey,ticketMap.get("suiteTicket")); // dingCallbackRedis.set(suiteKey,ticketMap.get("suiteTicket"));
} // }
}); // });
openSyncBizDataService.insertBatch(list); // openSyncBizDataService.insertBatch(list);
} // }
} else{ // } else{
// 其他类型事件处理 // // 其他类型事件处理
} // }
//
// 返回success的加密信息表示回调处理成功 // // 返回success的加密信息表示回调处理成功
return dingTalkEncryptor.getEncryptedMap("success", timestamp, nonce); // return dingTalkEncryptor.getEncryptedMap("success", timestamp, nonce);
} catch (Exception e) { // } catch (Exception e) {
//失败的情况,应用的开发者应该通过告警感知,并干预修复 // //失败的情况,应用的开发者应该通过告警感知,并干预修复
log.error("process callback fail." + params, e); // log.error("process callback fail." + params, e);
return "fail"; // return "fail";
} // }
} // }
@PostMapping("getExemptLoginUserDetail") // @PostMapping("getExemptLoginUserDetail")
public Result<Object> getExemptLoginUserDetail(@RequestBody ExemptLoginUserDetailFormDTO formDTO){ // public Result<Object> getExemptLoginUserDetail(@RequestBody ExemptLoginUserDetailFormDTO formDTO){
ValidatorUtils.validateEntity(formDTO, ExemptLoginUserDetailFormDTO.ExemptLoginUserDetailForm.class); // ValidatorUtils.validateEntity(formDTO, ExemptLoginUserDetailFormDTO.ExemptLoginUserDetailForm.class);
return new Result<Object>().ok(dingTalkService.getExemptLoginUserDetail(formDTO)); // return new Result<Object>().ok(dingTalkService.getExemptLoginUserDetail(formDTO));
} // }
/** /**
* Desc: 获取钉钉小程序信息 * Desc: 获取钉钉小程序信息
@ -147,9 +132,9 @@ public class CallbackController {
* @author zxc * @author zxc
* @date 2022/9/15 10:46 * @date 2022/9/15 10:46
*/ */
@PostMapping("getDingMiniInfo") // @PostMapping("getDingMiniInfo")
public Result<DingMiniInfoCache> getDingMiniInfo(@RequestBody DingMiniInfoFormDTO formDTO){ // public Result<DingMiniInfoCache> getDingMiniInfo(@RequestBody DingMiniInfoFormDTO formDTO){
ValidatorUtils.validateEntity(formDTO, DingMiniInfoFormDTO.DingMiniInfoForm.class); // ValidatorUtils.validateEntity(formDTO, DingMiniInfoFormDTO.DingMiniInfoForm.class);
return new Result<DingMiniInfoCache>().ok(dingTalkService.getDingMiniInfo(formDTO)); // return new Result<DingMiniInfoCache>().ok(dingTalkService.getDingMiniInfo(formDTO));
} // }
} }

4
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/tccc/TCCCAuthController.java

@ -1,6 +1,8 @@
package com.epmet.controller.tccc; package com.epmet.controller.tccc;
import com.epmet.commons.tools.utils.net.TCCCClientUtils; import com.epmet.commons.tools.utils.net.TCCCClientUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@ -8,8 +10,10 @@ import org.springframework.web.bind.annotation.RestController;
@Slf4j @Slf4j
@RestController @RestController
@RequestMapping("tccc") @RequestMapping("tccc")
@Api(tags = "获取腾讯呼叫中心URL")
public class TCCCAuthController { public class TCCCAuthController {
@ApiOperation(value = "tccc")
@RequestMapping("getTcccAuth") @RequestMapping("getTcccAuth")
public String getTcccAuth() { public String getTcccAuth() {
try { try {

8
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/DingTalkService.java

@ -1,9 +1,5 @@
package com.epmet.service; package com.epmet.service;
import com.epmet.commons.tools.dto.form.DingMiniInfoFormDTO;
import com.epmet.commons.tools.redis.common.bean.DingMiniInfoCache;
import com.epmet.dto.form.ExemptLoginUserDetailFormDTO;
/** /**
* @Author zxc * @Author zxc
* @DateTime 2022/9/14 14:56 * @DateTime 2022/9/14 14:56
@ -11,7 +7,7 @@ import com.epmet.dto.form.ExemptLoginUserDetailFormDTO;
*/ */
public interface DingTalkService { public interface DingTalkService {
Object getExemptLoginUserDetail(ExemptLoginUserDetailFormDTO formDTO); // Object getExemptLoginUserDetail(ExemptLoginUserDetailFormDTO formDTO);
/** /**
* Desc: 获取钉钉小程序信息 * Desc: 获取钉钉小程序信息
@ -19,6 +15,6 @@ public interface DingTalkService {
* @author zxc * @author zxc
* @date 2022/9/15 10:46 * @date 2022/9/15 10:46
*/ */
DingMiniInfoCache getDingMiniInfo(DingMiniInfoFormDTO formDTO); // DingMiniInfoCache getDingMiniInfo(DingMiniInfoFormDTO formDTO);
} }

61
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/DingTalkServiceImpl.java

@ -1,24 +1,11 @@
package com.epmet.service.impl; package com.epmet.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.aliyun.dingtalk.module.DingTalkResult;
import com.epmet.commons.tools.dto.form.DingMiniInfoFormDTO;
import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.redis.RedisUtils; import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.commons.tools.redis.common.bean.DingMiniInfoCache;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.dao.OpenSyncBizDataDao;
import com.epmet.dto.DingMiniInfoDTO;
import com.epmet.dto.form.ExemptLoginUserDetailFormDTO;
import com.epmet.redis.DingDingCallbackRedis; import com.epmet.redis.DingDingCallbackRedis;
import com.epmet.service.DingTalkService; import com.epmet.service.DingTalkService;
import com.taobao.dingtalk.client.DingTalkClientToken;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.Map;
/** /**
* @Author zxc * @Author zxc
@ -29,21 +16,21 @@ import java.util.Map;
@Slf4j @Slf4j
public class DingTalkServiceImpl implements DingTalkService { public class DingTalkServiceImpl implements DingTalkService {
@Autowired // @Autowired
private DingTalkClientToken dingTalkClientToken; // private DingTalkClientToken dingTalkClientToken;
@Autowired // @Autowired
private OpenSyncBizDataDao openSyncBizDataDao; // private OpenSyncBizDataDao openSyncBizDataDao;
@Autowired @Autowired
private DingDingCallbackRedis dingCallbackRedis; private DingDingCallbackRedis dingCallbackRedis;
@Autowired @Autowired
private RedisUtils redisUtils; private RedisUtils redisUtils;
@Override // @Override
public Object getExemptLoginUserDetail(ExemptLoginUserDetailFormDTO formDTO) { // public Object getExemptLoginUserDetail(ExemptLoginUserDetailFormDTO formDTO) {
DingMiniInfoDTO dingMiniInfo = openSyncBizDataDao.getDingMiniInfoByAppId(formDTO.getMiniAppId()); // DingMiniInfoDTO dingMiniInfo = openSyncBizDataDao.getDingMiniInfoByAppId(formDTO.getMiniAppId());
DingTalkResult<String> exemptLoginUserDetail = dingTalkClientToken.getExemptLoginUserDetail(formDTO.getCorpId(), dingMiniInfo.getSuiteKey(), dingMiniInfo.getSuiteSecret(), dingCallbackRedis.get(dingMiniInfo.getSuiteKey()), formDTO.getCode()); // DingTalkResult<String> exemptLoginUserDetail = dingTalkClientToken.getExemptLoginUserDetail(formDTO.getCorpId(), dingMiniInfo.getSuiteKey(), dingMiniInfo.getSuiteSecret(), dingCallbackRedis.get(dingMiniInfo.getSuiteKey()), formDTO.getCode());
return exemptLoginUserDetail.getData(); // return exemptLoginUserDetail.getData();
} // }
/** /**
* Desc: 获取钉钉小程序信息 * Desc: 获取钉钉小程序信息
@ -51,18 +38,18 @@ public class DingTalkServiceImpl implements DingTalkService {
* @author zxc * @author zxc
* @date 2022/9/15 10:46 * @date 2022/9/15 10:46
*/ */
@Override // @Override
public DingMiniInfoCache getDingMiniInfo(DingMiniInfoFormDTO formDTO) { // public DingMiniInfoCache getDingMiniInfo(DingMiniInfoFormDTO formDTO) {
String key = RedisKeys.getDingMiniInfoKey(formDTO.getMiniAppId()); // String key = RedisKeys.getDingMiniInfoKey(formDTO.getMiniAppId());
Map<String, Object> dingMiniInfoMap = redisUtils.hGetAll(key); // Map<String, Object> dingMiniInfoMap = redisUtils.hGetAll(key);
if (!CollectionUtils.isEmpty(dingMiniInfoMap)) { // if (!CollectionUtils.isEmpty(dingMiniInfoMap)) {
return ConvertUtils.mapToEntity(dingMiniInfoMap,DingMiniInfoCache.class); // return ConvertUtils.mapToEntity(dingMiniInfoMap,DingMiniInfoCache.class);
} // }
DingMiniInfoDTO dingMiniInfo = openSyncBizDataDao.getDingMiniInfoByAppId(formDTO.getMiniAppId()); // DingMiniInfoDTO dingMiniInfo = openSyncBizDataDao.getDingMiniInfoByAppId(formDTO.getMiniAppId());
if (null != dingMiniInfo){ // if (null != dingMiniInfo){
redisUtils.hMSet(key, BeanUtil.beanToMap(dingMiniInfo)); // redisUtils.hMSet(key, BeanUtil.beanToMap(dingMiniInfo));
return ConvertUtils.sourceToTarget(dingMiniInfo,DingMiniInfoCache.class); // return ConvertUtils.sourceToTarget(dingMiniInfo,DingMiniInfoCache.class);
} // }
return null; // return null;
} // }
} }

2
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/dao/CustomerProjectParameterDao.java

@ -87,5 +87,5 @@ public interface CustomerProjectParameterDao extends BaseDao<CustomerProjectPara
* @param key * @param key
* @return java.lang.String * @return java.lang.String
*/ */
String selectValueByKey(@Param("customerId") String customerId, @Param("key") String key); // String selectValueByKey(@Param("customerId") String customerId, @Param("key") String key);
} }

Loading…
Cancel
Save