().ok(thirdLoginService.resiLoginInternalDing(formDTO));
+ }
}
diff --git a/epmet-auth/src/main/java/com/epmet/dto/dingres/DingUserDetailDTO.java b/epmet-auth/src/main/java/com/epmet/dto/dingres/DingUserDetailDTO.java
new file mode 100644
index 0000000000..4a46922590
--- /dev/null
+++ b/epmet-auth/src/main/java/com/epmet/dto/dingres/DingUserDetailDTO.java
@@ -0,0 +1,73 @@
+package com.epmet.dto.dingres;
+
+import lombok.Data;
+
+/**
+ * @Description
+ * @Author yzm
+ * @Date 2022/9/22 14:16
+ */
+@Data
+public class DingUserDetailDTO {
+ // 接口文档:https://open.dingtalk.com/document/isvapp-server/query-user-details
+ /**
+ * 员工的userId。
+ */
+ private String userid;
+
+ /**
+ * 员工在当前开发者企业账号范围内的唯一标识。
+ */
+ private String unionid;
+
+ /**
+ * 员工姓名。
+ */
+ private String name;
+ /**
+ * 头像。
+ *
+ * 说明 员工使用默认头像,不返回该字段,手动设置头像会返回
+ */
+ private String avatar;
+ /**
+ * 国际电话区号。
+ *
+ * 说明 第三方企业应用不返回该字段;如需获取state_code,可以使用钉钉统一授权套件方式获取。
+ */
+ private String state_code;
+ /**
+ * 手机号码。
+ *
+ * 说明
+ * 企业内部应用,只有应用开通通讯录邮箱等个人信息权限,才会返回该字段。
+ * 第三方企业应用不返回该字段,如需获取mobile,可以使用钉钉统一授权套件方式获取。
+ */
+ private String mobile;
+ /**
+ * 是否号码隐藏:
+ *
+ * true:隐藏
+ *
+ * false:不隐藏
+ *
+ * 说明 隐藏手机号后,手机号在个人资料页隐藏,但仍可对其发DING、发起钉钉免费商务电话。
+ */
+ private String hide_mobile;
+ /**
+ * 分机号。
+ *
+ * 说明 第三方企业应用不返回该参数。
+ */
+ private String telephone;
+
+ /**
+ * 员工的企业邮箱。
+ *
+ * 如果员工的企业邮箱没有开通,返回信息中不包含该数据。
+ *
+ * 说明 第三方企业应用不返回该参数。
+ */
+ private String org_email;
+}
+
diff --git a/epmet-auth/src/main/java/com/epmet/dto/dingres/V2UserGetuserinfoResDTO.java b/epmet-auth/src/main/java/com/epmet/dto/dingres/V2UserGetuserinfoResDTO.java
new file mode 100644
index 0000000000..ea9eb3b46b
--- /dev/null
+++ b/epmet-auth/src/main/java/com/epmet/dto/dingres/V2UserGetuserinfoResDTO.java
@@ -0,0 +1,54 @@
+package com.epmet.dto.dingres;
+
+import lombok.Data;
+
+/**
+ * @Description
+ * @Author yzm
+ * @Date 2022/9/22 14:08
+ */
+@Data
+public class V2UserGetuserinfoResDTO {
+ // 接口返参:https://open.dingtalk.com/document/orgapp-server/obtain-the-userid-of-a-user-by-using-the-log-free
+ /**
+ * 用户的userid。
+ */
+ private String userid;
+ /**
+ * 设备ID。
+ */
+ private String device_id;
+ /**
+ * 是否是管理员。
+ *
+ * true:是
+ *
+ * false:不是
+ */
+ private Boolean sys;
+ /**
+ * 级别。
+ *
+ * 1:主管理员
+ *
+ * 2:子管理员
+ *
+ * 100:老板
+ *
+ * 0:其他(如普通员工)
+ */
+ private Number sys_level;
+ /**
+ * 用户关联的unionId。
+ */
+ private String associated_unionid;
+ /**
+ * 用户unionId。
+ */
+ private String unionid;
+ /**
+ * 用户名字。
+ */
+ private String name;
+}
+
diff --git a/epmet-auth/src/main/java/com/epmet/dto/form/ResiDingAppLoginFormDTO.java b/epmet-auth/src/main/java/com/epmet/dto/form/ResiDingAppLoginFormDTO.java
new file mode 100644
index 0000000000..b18e95478a
--- /dev/null
+++ b/epmet-auth/src/main/java/com/epmet/dto/form/ResiDingAppLoginFormDTO.java
@@ -0,0 +1,41 @@
+package com.epmet.dto.form;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+
+/**
+ * @Description
+ * @Author yzm
+ * @Date 2022/9/14 17:11
+ */
+@Data
+public class ResiDingAppLoginFormDTO {
+ public interface InnerMiniApp {}
+ public interface ThirdMiniApp {}
+ /**
+ * 授权统一后的authCode
+ */
+ @NotBlank(message = "authCode不能为空",groups = InnerMiniApp.class)
+ private String authCode;
+// /**
+// * 第三方企业应用传应用的SuiteKey
+// */
+// @NotBlank(message = "clientId不能为空")
+// private String clientId;
+ /**
+ * 第三方企业应用传应用的SuiteKey
+ */
+ @NotBlank(message = "miniAppId不能为空",groups = InnerMiniApp.class)
+ private String miniAppId;
+
+ // @NotBlank(message = "当前访问用户的企业corpId不能为空")
+ // private String corpId;
+
+ /**
+ * third:第三方应用
+ * company_customize:企业定制应用
+ */
+ private String appType="company_customize";
+}
+
diff --git a/epmet-auth/src/main/java/com/epmet/dto/form/ResiDingAppLoginMdFormDTO.java b/epmet-auth/src/main/java/com/epmet/dto/form/ResiDingAppLoginMdFormDTO.java
new file mode 100644
index 0000000000..0b3b9ae0f8
--- /dev/null
+++ b/epmet-auth/src/main/java/com/epmet/dto/form/ResiDingAppLoginMdFormDTO.java
@@ -0,0 +1,23 @@
+package com.epmet.dto.form;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+
+/**
+ * @Description
+ * @Author yzm
+ * @Date 2022/9/22 10:42
+ */
+@Data
+public class ResiDingAppLoginMdFormDTO {
+ @NotBlank(message = "authCode不能为空")
+ private String authCode;
+ /**
+ * 第三方企业应用传应用的SuiteKey
+ */
+ @NotBlank(message = "miniAppId不能为空")
+ private String miniAppId;
+
+}
+
diff --git a/epmet-auth/src/main/java/com/epmet/dto/result/ResiDingAppLoginResDTO.java b/epmet-auth/src/main/java/com/epmet/dto/result/ResiDingAppLoginResDTO.java
new file mode 100644
index 0000000000..7a0517574a
--- /dev/null
+++ b/epmet-auth/src/main/java/com/epmet/dto/result/ResiDingAppLoginResDTO.java
@@ -0,0 +1,42 @@
+package com.epmet.dto.result;
+
+import lombok.Data;
+
+/**
+ * @Description
+ * @Author yzm
+ * @Date 2022/9/14 17:20
+ */
+@Data
+public class ResiDingAppLoginResDTO {
+ private String authorization;
+ private String customerId;
+ private String gridId;
+ /**
+ * 网格名
+ */
+ private String gridName;
+ /**
+ * 网格所属的组织id
+ */
+ private String agencyId;
+ /**
+ * 居民端用户id
+ */
+ private String epmetUserId;
+
+ /**
+ * 5.获取用户手机号。使用用户个人access_token调用获取用户通讯录个人信息接口获取
+ * 返参信息
+ * 接口文档:https://open.dingtalk.com/document/isvapp-server/dingtalk-retrieve-user-information
+ */
+ private String extInfo;
+
+ /**
+ * 是否注册居民
+ * true:已注册
+ * false:未注册
+ */
+ private Boolean regFlag;
+}
+
diff --git a/epmet-auth/src/main/java/com/epmet/service/ThirdLoginService.java b/epmet-auth/src/main/java/com/epmet/service/ThirdLoginService.java
index 69d13bf926..70bcc92338 100644
--- a/epmet-auth/src/main/java/com/epmet/service/ThirdLoginService.java
+++ b/epmet-auth/src/main/java/com/epmet/service/ThirdLoginService.java
@@ -1,6 +1,7 @@
package com.epmet.service;
import com.epmet.dto.form.*;
+import com.epmet.dto.result.ResiDingAppLoginResDTO;
import com.epmet.dto.result.StaffOrgsResultDTO;
import com.epmet.dto.result.UserTokenResultDTO;
@@ -84,4 +85,29 @@ public interface ThirdLoginService {
* @description 单客户-工作端微信小程序登录-发送验证码
**/
void sendSmsCode(ThirdSendSmsCodeFormDTO formDTO);
+
+ /**
+ * 钉钉应用的登录-居民端
+ * 产品服务商建立第三方企业应用
+ * 参考文档:https://open.dingtalk.com/document/isvapp-server/unified-authorization-suite-access-process
+ * @param formDTO
+ * @return
+ */
+ ResiDingAppLoginResDTO resiLoginDing(ResiDingAppLoginFormDTO formDTO);
+
+ /**
+ * 企业简历内部应用授权给第三方
+ * 可参考文档: 获取第三方应用授权企业的accessToken https://open.dingtalk.com/document/orgapp-server/obtain-the-access_token-of-the-authorized-enterprise
+ * https://open.dingtalk.com/document/orgapp-server/enterprise-internal-application-logon-free
+ * @param formDTO
+ * @return
+ */
+ ResiDingAppLoginResDTO resiLoginDingMd(ResiDingAppLoginMdFormDTO formDTO);
+
+ /**
+ * 企业内部应用免登 文档地址:https://open.dingtalk.com/document/orgapp-server/enterprise-internal-application-logon-free
+ * @param formDTO
+ * @return
+ */
+ ResiDingAppLoginResDTO resiLoginInternalDing(ResiDingAppLoginMdFormDTO formDTO);
}
diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java
index cd1495ddb2..91812aaeda 100644
--- a/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java
+++ b/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java
@@ -5,15 +5,21 @@ import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
import cn.binarywang.wx.miniapp.util.crypt.WxMaCryptUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
+import com.aliyun.dingtalk.module.DingTalkResult;
import com.epmet.auth.constants.AuthOperationConstants;
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.constant.StrConstant;
+import com.epmet.commons.tools.enums.EnvEnum;
import com.epmet.commons.tools.exception.EpmetErrorCode;
+import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.exception.RenException;
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.TokenDto;
import com.epmet.commons.tools.security.password.PasswordUtils;
@@ -23,6 +29,8 @@ import com.epmet.commons.tools.validator.PhoneValidatorUtils;
import com.epmet.constant.AuthHttpUrlConstant;
import com.epmet.constant.SmsTemplateConstant;
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.result.*;
import com.epmet.feign.EpmetMessageOpenFeignClient;
@@ -32,6 +40,11 @@ import com.epmet.jwt.JwtTokenProperties;
import com.epmet.jwt.JwtTokenUtils;
import com.epmet.redis.CaptchaRedis;
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 org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
@@ -73,6 +86,10 @@ public class ThirdLoginServiceImpl implements ThirdLoginService, ResultDataResol
private EpmetMessageOpenFeignClient messageOpenFeignClient;
@Autowired
private LoginUserUtil loginUserUtil;
+ @Autowired
+ private DingTalkClientToken dingTalkClientToken;
+ @Autowired
+ private DingTalkClientUser dingTalkClientUser;
/**
* @param formDTO
@@ -815,4 +832,297 @@ public class ThirdLoginServiceImpl implements ThirdLoginService, ResultDataResol
//getResultDataOrThrowsException(result, ServiceConstant.EPMET_MESSAGE_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "调用Message服务,发送登录事件到MQ失败");
}
+// 接入流程:https://open.dingtalk.com/document/isvapp-server/unified-authorization-suite-access-process
+// 1、获取个人用户token:https://open.dingtalk.com/document/isvapp-server/obtain-user-token
+// 2、获取用户通讯录个人信息:https://open.dingtalk.com/document/isvapp-server/dingtalk-retrieve-user-information
+// 接口逻辑:
+// (1)根据clientId去XXX表找到customerId
+// (2)通过1、2拿到手机号之后,根据mobile+customerId去user_base_info表找userId,
+// 是否注册居民:register_relation
+// (3)没有则生成user、user_Base_info表记录
+ /**
+ * 钉钉应用的登录-居民端
+ *
+ * @param formDTO
+ * @return
+ */
+ @Override
+ public ResiDingAppLoginResDTO resiLoginDing(ResiDingAppLoginFormDTO formDTO) {
+ //获取用户手机号
+ log.info("1、钉钉居民端应用登录入参:"+ JSON.toJSONString(formDTO));
+ ResiDingAppLoginResDTO resDTO= null;
+ try {
+ resDTO = new ResiDingAppLoginResDTO();
+ resDTO.setCustomerId(getCurrentCustomerId());
+ //1、获取用户手机号
+ String miniAppId = formDTO.getMiniAppId();
+ DingMiniInfoCache dingMiniInfo = CustomerDingDingRedis.getDingMiniInfo(miniAppId);
+ DingTalkResult userAccessToken = dingTalkClientToken.getUserAccessToken(formDTO.getAuthCode(), dingMiniInfo.getSuiteKey(), dingMiniInfo.getSuiteSecret());
+ log.info("2、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 me = dingTalkClientUser.getUserInfo("me", userAccessToken.getData().getAccessToken());
+ log.info("3、resiLoginDing me:{}",JSON.toJSONString(me));
+ resDTO.setExtInfo(JSON.toJSONString(me.getData()));
+ if (!me.success() || StringUtils.isBlank(me.getData().getMobile())) {
+ log.error("resilogin-ding登录接口报错,入参:" + JSON.toJSONString(formDTO) + ";获取手机号为空, userAccessToken.getData().getAccessToken()=" + userAccessToken.getData().getAccessToken());
+ throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取手机号为空", "获取手机号为空");
+ }
+ // 2、调用userfeign接口获取userId、注册网格相关信息 todo
+ DingLoginResiFormDTO dingLoginResiFormDTO=ConvertUtils.sourceToTarget(me.getData(),DingLoginResiFormDTO.class);
+ dingLoginResiFormDTO.setCustomerId(resDTO.getCustomerId());
+ Result loginResiResDTOResult = epmetUserOpenFeignClient.dingResiLogin(dingLoginResiFormDTO);
+ if (!loginResiResDTOResult.success() || null == loginResiResDTOResult.getData()) {
+ //临时打个日志
+ 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());
+ }
+ DingLoginResiResDTO resiResDTO=loginResiResDTOResult.getData();
+ resDTO.setGridId(resiResDTO.getGridId());
+ resDTO.setGridName(resiResDTO.getGridName());
+ resDTO.setAgencyId(resiResDTO.getAgencyId());
+ resDTO.setEpmetUserId(resiResDTO.getEpmetUserId());
+ resDTO.setRegFlag(resiResDTO.getRegFlag());
+
+ //3.生成token,并且存放Redis
+ String token=this.saveTokenDtoDing(formDTO.getMiniAppId(),AppClientConstant.APP_RESI,AppClientConstant.MINI_DING, resDTO.getEpmetUserId(), resDTO.getCustomerId());
+ resDTO.setAuthorization(token);
+
+ } catch (ApiException e) {
+ throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), e.getErrMsg(), EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getMsg());
+ }
+ return resDTO;
+ }
+
+ private String saveTokenDtoDing(String miniAppId,String app,String client, String userId,String customerId) {
+ //生成token串
+ Map map = new HashMap<>();
+ map.put(AppClientConstant.APP, app);
+ // map.put(AppClientConstant.CLIENT, client);
+ // 第三方企业应用传应用的SuiteKey 作为client
+ map.put(AppClientConstant.CLIENT, client.concat(miniAppId));
+ map.put("userId", userId);
+ String token = jwtTokenUtils.createToken(map);
+ int expire = jwtTokenProperties.getExpire();
+ TokenDto tokenDto = new TokenDto();
+ tokenDto.setCustomerId(customerId);
+ tokenDto.setApp(app);
+ tokenDto.setClient(client.concat(miniAppId));
+ tokenDto.setUserId(userId);
+ tokenDto.setToken(token);
+ tokenDto.setUpdateTime(System.currentTimeMillis());
+ tokenDto.setExpireTime(jwtTokenUtils.getExpiration(token).getTime());
+ cpUserDetailRedis.set(tokenDto, expire);
+ // cpUserDetailRedis.setForDingApp(miniAppId,tokenDto, expire);
+ logger.info("截止时间:" + DateUtils.format(jwtTokenUtils.getExpiration(token), "yyyy-MM-dd HH:mm:ss"));
+ return token;
+ }
+
+ @Override
+ public ResiDingAppLoginResDTO resiLoginDingMd(ResiDingAppLoginMdFormDTO formDTO) {
+ // 获取用户手机号
+ log.info("1、钉钉居民端应用登录入参:" + JSON.toJSONString(formDTO));
+ ResiDingAppLoginResDTO resDTO = null;
+ resDTO = new ResiDingAppLoginResDTO();
+ resDTO.setCustomerId(getCurrentCustomerId());
+ // 1、获取用户手机号
+ DingLoginResiFormDTO dingLoginResiFormDTO = getDingLoginResiFormDTOMd(formDTO.getMiniAppId(), formDTO.getAuthCode());
+ dingLoginResiFormDTO.setCustomerId(resDTO.getCustomerId());
+ // 2、调用userfeign接口获取userId、注册网格相关信息
+ Result 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());
+
+ // 3.生成token,并且存放Redis
+ String token = this.saveTokenDtoDing(formDTO.getMiniAppId(), AppClientConstant.APP_RESI, AppClientConstant.MINI_DING, resDTO.getEpmetUserId(), resDTO.getCustomerId());
+ resDTO.setAuthorization(token);
+
+ return resDTO;
+ }
+
+ 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
+ String yantaiCorpId = "dingaae55cbc47a96845f5bf40eda33b7ba0";
+ DingTalkResult res = dingTalkClientToken.getThirdAuthCorpAccessToken(dingMiniInfo.getSuiteKey(), dingMiniInfo.getSuiteSecret(), "abc", yantaiCorpId);
+ if (!res.success() || StringUtils.isBlank(res.getData())) {
+ 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");
+ }
+ String accessToken = res.getData();
+ 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
+ DingTalkResult v2UserGetuserinfoRes = dingTalkClientToken.getUserInfo(accessToken, authCode);
+ if (!v2UserGetuserinfoRes.success() || StringUtils.isBlank(v2UserGetuserinfoRes.getData())) {
+ throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "通过免登码获取用户信息异常", "通过免登码获取用户信息异常");
+ }
+ log.info(String.format("2、通过免登码获取用户信息返参:%s", v2UserGetuserinfoRes.getData()));
+ V2UserGetuserinfoResDTO v2UserGetuserinfoResDTO = JSON.parseObject(v2UserGetuserinfoRes.getData(), V2UserGetuserinfoResDTO.class);
+ if (null == v2UserGetuserinfoResDTO || StringUtils.isBlank(v2UserGetuserinfoResDTO.getUserid())) {
+ throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取钉钉用户userid为空", "获取钉钉用户userid为空");
+ }
+
+
+ // 3、查询用户详情,文档地址:https://open.dingtalk.com/document/isvapp-server/query-user-details
+ DingTalkResult v2UserGetRes = dingTalkClientToken.getUserDetail(v2UserGetuserinfoResDTO.getUserid(), accessToken);
+ if (!v2UserGetRes.success() || StringUtils.isBlank(v2UserGetRes.getData())) {
+ throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "根据userId查询用户详情失败", "根据userId查询用户详情失败");
+ }
+ log.info(String.format("3、查询用户详情:%s", v2UserGetRes.getData()));
+ DingUserDetailDTO dingUserDetailDTO = JSON.parseObject(v2UserGetRes.getData(), DingUserDetailDTO.class);
+ if (null == dingUserDetailDTO || StringUtils.isBlank(dingUserDetailDTO.getMobile())) {
+ throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取手机号为空", "获取手机号为空");
+ }
+
+ DingLoginResiFormDTO dingLoginResiFormDTO = new DingLoginResiFormDTO();
+ dingLoginResiFormDTO.setAvatarUrl(dingUserDetailDTO.getAvatar());
+ dingLoginResiFormDTO.setEmail(dingUserDetailDTO.getOrg_email());
+ dingLoginResiFormDTO.setMobile(dingUserDetailDTO.getMobile());
+ dingLoginResiFormDTO.setNick(dingUserDetailDTO.getName());
+ dingLoginResiFormDTO.setOpenId(StrConstant.EPMETY_STR);
+ dingLoginResiFormDTO.setStateCode(dingUserDetailDTO.getState_code());
+ dingLoginResiFormDTO.setUnionId(dingUserDetailDTO.getUnionid());
+ return dingLoginResiFormDTO;
+ }
+
+
+ /**
+ * 企业内部应用开发,不授权了
+ * https://open.dingtalk.com/document/orgapp-server/enterprise-internal-application-logon-free
+ * 建议用户信息保存在前端缓存中(dd.setStorage)或者cookie中,避免每次进入应用都调用钉钉接口进行免登。
+ *
+ * 获取免登授权码。
+ * 小程序免登
+ * 微应用免登
+ * 获取AccessToken。
+ * 调用接口获取access_token,详情请参考获取企业内部应用的access_token。
+ *
+ * 获取userid。
+ * 调用接口获取用户的userid,详情请参考通过免登码获取用户信息。
+ *
+ * 获取用户详情。
+ * 调用接口获取用户详细信息,详情请参考根据userId获取用户详情。
+ *
+ * @param formDTO
+ * @return
+ */
+ @Override
+ public ResiDingAppLoginResDTO resiLoginInternalDing(ResiDingAppLoginMdFormDTO formDTO) {
+ // 获取用户手机号
+ log.info("1、钉钉居民端应用登录入参:" + JSON.toJSONString(formDTO));
+ ResiDingAppLoginResDTO resDTO = null;
+ resDTO = new ResiDingAppLoginResDTO();
+ resDTO.setCustomerId(getCurrentCustomerId());
+
+ // 1、获取用户手机号
+ DingLoginResiFormDTO dingLoginResiFormDTO = getDingLoginResiFormDTOInternal(formDTO.getMiniAppId(), formDTO.getAuthCode());
+ dingLoginResiFormDTO.setCustomerId(resDTO.getCustomerId());
+
+ // 2、调用userfeign接口获取userId、注册网格相关信息
+ Result loginResiResDTOResult = epmetUserOpenFeignClient.dingResiLogin(dingLoginResiFormDTO);
+ if (!loginResiResDTOResult.success() || null == loginResiResDTOResult.getData()) {
+ // 临时打个日志
+ log.error(String.format("resiLoginInternalDing获取epmetUserId异常,入参:%s", JSON.toJSONString(dingLoginResiFormDTO)));
+ throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取epmetUserId异常:"+ JSON.toJSONString(loginResiResDTOResult), "获取epmetUserId异常");
+ }
+ DingLoginResiResDTO resiResDTO = loginResiResDTOResult.getData();
+ resDTO.setGridId(resiResDTO.getGridId());
+ resDTO.setGridName(resiResDTO.getGridName());
+ resDTO.setAgencyId(resiResDTO.getAgencyId());
+ resDTO.setEpmetUserId(resiResDTO.getEpmetUserId());
+ resDTO.setRegFlag(resiResDTO.getRegFlag());
+
+ // 3.生成token,并且存放Redis
+ String token = this.saveTokenDtoDing(formDTO.getMiniAppId(), AppClientConstant.APP_RESI, AppClientConstant.MINI_DING, resDTO.getEpmetUserId(), resDTO.getCustomerId());
+ resDTO.setAuthorization(token);
+
+ return resDTO;
+ }
+
+ /**
+ * 最原始的企业内部应用开发,不授权给产品服务商
+ * @param miniAppId
+ * @param authCode
+ * @return
+ */
+ private DingLoginResiFormDTO getDingLoginResiFormDTOInternal(String miniAppId, String authCode) {
+ DingMiniInfoCache dingMiniInfo = CustomerDingDingRedis.getDingMiniInfo(miniAppId);
+
+ // 1、获取企业内部应用的accessToken文档地址:https://open.dingtalk.com/document/orgapp-server/obtain-the-access_token-of-an-internal-app
+ String accessToken = "";
+ DingTalkResult dingTalkResult = dingTalkClientToken.getAppAccessTokenToken(dingMiniInfo.getSuiteKey(), dingMiniInfo.getSuiteSecret());
+ if (!dingTalkResult.success() || StringUtils.isBlank(dingTalkResult.getData())) {
+ log.error(String.format("获取企业内部应用的accessToken失败,customKey:%s,customSecret:%s", dingMiniInfo.getSuiteSecret(), dingMiniInfo.getSuiteSecret()));
+ throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取企业内部应用的accessToken异常", "获取企业内部应用的accessToken");
+ }
+ accessToken = dingTalkResult.getData();
+ 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
+ DingTalkResult v2UserGetuserinfoRes = dingTalkClientToken.getUserInfo(accessToken, authCode);
+ if (!v2UserGetuserinfoRes.success() || StringUtils.isBlank(v2UserGetuserinfoRes.getData())) {
+ throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "通过免登码获取用户信息异常", "通过免登码获取用户信息异常");
+ }
+ log.info(String.format("2、通过免登码获取用户信息返参:%s", v2UserGetuserinfoRes.getData()));
+ V2UserGetuserinfoResDTO v2UserGetuserinfoResDTO = JSON.parseObject(v2UserGetuserinfoRes.getData(), V2UserGetuserinfoResDTO.class);
+ if (null == v2UserGetuserinfoResDTO || StringUtils.isBlank(v2UserGetuserinfoResDTO.getUserid())) {
+ throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取钉钉用户userid为空", "获取钉钉用户userid为空");
+ }
+
+
+ // 3、查询用户详情,文档地址:https://open.dingtalk.com/document/isvapp-server/query-user-details
+ DingTalkResult v2UserGetRes = dingTalkClientToken.getUserDetail(v2UserGetuserinfoResDTO.getUserid(), accessToken);
+ if (!v2UserGetRes.success() || StringUtils.isBlank(v2UserGetRes.getData())) {
+ throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "根据userId查询用户详情失败", "根据userId查询用户详情失败");
+ }
+ log.info(String.format("3、查询用户详情:%s", v2UserGetRes.getData()));
+ DingUserDetailDTO dingUserDetailDTO = JSON.parseObject(v2UserGetRes.getData(), DingUserDetailDTO.class);
+ if (null == dingUserDetailDTO || StringUtils.isBlank(dingUserDetailDTO.getMobile())) {
+ throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取手机号为空", "获取手机号为空");
+ }
+
+ DingLoginResiFormDTO dingLoginResiFormDTO = new DingLoginResiFormDTO();
+ dingLoginResiFormDTO.setAvatarUrl(dingUserDetailDTO.getAvatar());
+ dingLoginResiFormDTO.setEmail(dingUserDetailDTO.getOrg_email());
+ dingLoginResiFormDTO.setMobile(dingUserDetailDTO.getMobile());
+ dingLoginResiFormDTO.setNick(dingUserDetailDTO.getName());
+ dingLoginResiFormDTO.setOpenId(StrConstant.EPMETY_STR);
+ dingLoginResiFormDTO.setStateCode(dingUserDetailDTO.getState_code());
+ dingLoginResiFormDTO.setUnionId(dingUserDetailDTO.getUnionid());
+ return dingLoginResiFormDTO;
+ }
+
+ /**
+ * 客户写死吧
+ * @return
+ */
+ private String getCurrentCustomerId() {
+ String customerId="";
+ EnvEnum currentEnv = EnvEnum.getCurrentEnv();
+ if (EnvEnum.PROD.getCode().equals(currentEnv.getCode())) {
+ // 烟台的客户id
+ customerId="1535072605621841922";
+ } else if (EnvEnum.TEST.getCode().equals(currentEnv.getCode())) {
+ // 最美琴岛
+ customerId="0c41b272ee9ee95ac6f184ad548a30eb";
+ } else {
+ // 其余统一走开发环境
+ customerId="45687aa479955f9d06204d415238f7cc";
+ }
+ return customerId;
+ }
}
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/AppClientConstant.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/AppClientConstant.java
index 0b42461f6e..049f335aa4 100644
--- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/AppClientConstant.java
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/AppClientConstant.java
@@ -32,6 +32,11 @@ public interface AppClientConstant {
*/
String CLIENT_WXMP = "wxmp";
+ /**
+ * 钉钉小程序
+ */
+ String MINI_DING = "mini_ding";
+
/**
* 客户来源App
* */
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/DingMiniInfoFormDTO.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/DingMiniInfoFormDTO.java
new file mode 100644
index 0000000000..bd36526985
--- /dev/null
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/DingMiniInfoFormDTO.java
@@ -0,0 +1,26 @@
+package com.epmet.commons.tools.dto.form;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import javax.validation.constraints.NotBlank;
+import java.io.Serializable;
+
+/**
+ * @Author zxc
+ * @DateTime 2022/9/15 10:25
+ * @DESC
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class DingMiniInfoFormDTO implements Serializable {
+
+ private static final long serialVersionUID = 2661531490851265637L;
+
+ public interface DingMiniInfoForm{}
+
+ @NotBlank(message = "miniAppId不能为空",groups = DingMiniInfoForm.class)
+ private String miniAppId;
+}
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/DingMiniAppEnum.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/DingMiniAppEnum.java
new file mode 100644
index 0000000000..b0c0054ebb
--- /dev/null
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/DingMiniAppEnum.java
@@ -0,0 +1,79 @@
+package com.epmet.commons.tools.enums;
+
+/**
+ * @Description
+ * @Author yzm
+ * @Date 2022/9/14 19:11
+ */
+public enum DingMiniAppEnum {
+ // 亿联云盘CorpId:dingd1e19e397c754c7735c2f4657eb6378f
+ //
+ // //各应用秘钥
+ // 随手拍
+ // SuiteId:27501006
+ // AppId:119450
+ // MiniAppId:5000000002934668
+ // SuiteKey:suitew6ccvkquinmrghqy
+ // SuiteSecret:TooAxiegdsE5BPP6xo1AxK1LdmaUoMpPMyomOcGcBSXtnsxRc8dEfyOlG56oSmEB
+ //
+ // 随时讲
+ // SuiteId:27564007
+ // AppId:119451
+ // MiniAppId:5000000002934374
+ // SuiteKey:suitezhyj12glsrp8em0f
+ // SuiteSecret:-z5Q_lvMP6l7fTzlArEzUT8D_-5pvqBQaJMuTGHoXnz0nuiqGQMZ8aeya_cxTsN-
+ //
+ // 我的报事
+ // SuiteId:27569006
+ // AppId:119452
+ // MiniAppId:5000000002934456
+ // SuiteKey:suite5yxliro6wawv514w
+ // SuiteSecret:aQxiPi7DwJSUa9HlbUU_L7Q4wGCLEDmgf__Ffx75cTn3jZwuHy9vdl-9Iv5FeyJU
+ //
+ // 实时动态
+ // SuiteId:27458011
+ // AppId:119453
+ // MiniAppId:5000000002934488
+ // SuiteKey:suitemcestnonr6y0xigc
+ // SuiteSecret:kKCNCkfDhmLoVnl_wuAiScyDG4776mkTevuSBuiYhHg-Bvz1-vhb_4IA-Km7nK2I
+ SSP("suitew6ccvkquinmrghqy", "随手拍", "TooAxiegdsE5BPP6xo1AxK1LdmaUoMpPMyomOcGcBSXtnsxRc8dEfyOlG56oSmEB"),
+ SSJ("suitezhyj12glsrp8em0f", "随时讲", "-z5Q_lvMP6l7fTzlArEzUT8D_-5pvqBQaJMuTGHoXnz0nuiqGQMZ8aeya_cxTsN-"),
+ MY_REPORT_EVENT("suite5yxliro6wawv514w", "我的报事", "aQxiPi7DwJSUa9HlbUU_L7Q4wGCLEDmgf__Ffx75cTn3jZwuHy9vdl-9Iv5FeyJU"),
+ SSDT("suitemcestnonr6y0xigc", "实时动态", "kKCNCkfDhmLoVnl_wuAiScyDG4776mkTevuSBuiYhHg-Bvz1-vhb_4IA-Km7nK2I");
+
+ private String suiteKey;
+ private String name;
+ private String suiteSecret;
+
+
+ DingMiniAppEnum(String suiteKey, String name, String suiteSecret) {
+ this.suiteKey = suiteKey;
+ this.name = name;
+ this.suiteSecret = suiteSecret;
+ }
+
+ public static DingMiniAppEnum getEnum(String suiteKey) {
+ DingMiniAppEnum[] values = DingMiniAppEnum.values();
+ for (DingMiniAppEnum value : values) {
+ if (value.getSuiteKey().equals(suiteKey)) {
+ return value;
+ }
+ }
+ return null;
+ }
+
+
+ public String getSuiteKey() {
+ return suiteKey;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getSuiteSecret() {
+ return suiteSecret;
+ }
+
+}
+
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/CommonThirdFeignClient.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/CommonThirdFeignClient.java
new file mode 100644
index 0000000000..6bc986aca0
--- /dev/null
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/CommonThirdFeignClient.java
@@ -0,0 +1,24 @@
+package com.epmet.commons.tools.feign;
+
+import com.epmet.commons.tools.constant.ServiceConstant;
+import com.epmet.commons.tools.dto.form.DingMiniInfoFormDTO;
+import com.epmet.commons.tools.feign.fallback.CommonThirdFeignClientFallBackFactory;
+import com.epmet.commons.tools.redis.common.bean.DingMiniInfoCache;
+import com.epmet.commons.tools.utils.Result;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+
+
+/**
+ * @Description
+ * @Author zxc
+ */
+@FeignClient(name = ServiceConstant.EPMET_THIRD_SERVER, fallbackFactory = CommonThirdFeignClientFallBackFactory.class)
+// @FeignClient(name = ServiceConstant.EPMET_THIRD_SERVER, fallbackFactory = CommonAggFeignClientFallBackFactory.class,url = "localhost:8110")
+public interface CommonThirdFeignClient {
+
+ @PostMapping("/third/dingTalk/getDingMiniInfo")
+ Result getDingMiniInfo(@RequestBody DingMiniInfoFormDTO formDTO);
+
+}
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonThirdFeignClientFallBackFactory.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonThirdFeignClientFallBackFactory.java
new file mode 100644
index 0000000000..4a43935086
--- /dev/null
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonThirdFeignClientFallBackFactory.java
@@ -0,0 +1,20 @@
+package com.epmet.commons.tools.feign.fallback;
+
+import com.epmet.commons.tools.exception.ExceptionUtils;
+import com.epmet.commons.tools.feign.CommonThirdFeignClient;
+import feign.hystrix.FallbackFactory;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+@Component
+@Slf4j
+public class CommonThirdFeignClientFallBackFactory implements FallbackFactory {
+
+ private CommonThirdFeignClientFallback fallback = new CommonThirdFeignClientFallback();
+
+ @Override
+ public CommonThirdFeignClient create(Throwable cause) {
+ log.error(String.format("FeignClient调用发生异常,异常信息:%s", ExceptionUtils.getThrowableErrorStackTrace(cause)));
+ return fallback;
+ }
+}
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonThirdFeignClientFallback.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonThirdFeignClientFallback.java
new file mode 100644
index 0000000000..47e278f846
--- /dev/null
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonThirdFeignClientFallback.java
@@ -0,0 +1,24 @@
+package com.epmet.commons.tools.feign.fallback;
+
+import com.epmet.commons.tools.constant.ServiceConstant;
+import com.epmet.commons.tools.dto.form.DingMiniInfoFormDTO;
+import com.epmet.commons.tools.feign.CommonThirdFeignClient;
+import com.epmet.commons.tools.redis.common.bean.DingMiniInfoCache;
+import com.epmet.commons.tools.utils.ModuleUtils;
+import com.epmet.commons.tools.utils.Result;
+import org.springframework.stereotype.Component;
+
+/**
+ *
+ * @Author zxc
+ * @Description
+ * @Date
+ **/
+@Component
+public class CommonThirdFeignClientFallback implements CommonThirdFeignClient {
+
+ @Override
+ public Result getDingMiniInfo(DingMiniInfoFormDTO formDTO) {
+ return ModuleUtils.feignConError(ServiceConstant.EPMET_THIRD_SERVER, "getDingMiniInfo", formDTO);
+ }
+}
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java
index bb7edb3e2a..ac55205beb 100644
--- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java
@@ -104,6 +104,10 @@ public class RedisKeys {
return rootPrefix.concat("sys:security:user:").concat(app).concat(StrConstant.COLON).concat(client).concat(StrConstant.COLON).concat(userId);
}
+ public static String getCpUserKeyForDingApp(String suiteKey,String app, String client, String userId) {
+ return rootPrefix.concat("sys:security:user:").concat(app).concat(StrConstant.COLON).concat(client).concat(StrConstant.COLON).concat(suiteKey).concat(StrConstant.COLON).concat(userId);
+ }
+
/**
* 拼接手机验证码key---后面需要改!!!
*
@@ -871,4 +875,18 @@ public class RedisKeys {
public static String getDhToken() {
return rootPrefix.concat("dh:token");
}
+
+ /**
+ * Desc: 票据
+ * @param suiteKey
+ * @author zxc
+ * @date 2022/9/14 10:46
+ */
+ public static String getSuiteTicketKey(String suiteKey) {
+ return rootPrefix.concat("ding:suiteTicket:" + suiteKey);
+ }
+
+ public static String getDingMiniInfoKey(String suiteKey) {
+ return rootPrefix.concat("ding:miniInfo:" + suiteKey);
+ }
}
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/CustomerDingDingRedis.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/CustomerDingDingRedis.java
new file mode 100644
index 0000000000..8a57fb1ca7
--- /dev/null
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/CustomerDingDingRedis.java
@@ -0,0 +1,58 @@
+package com.epmet.commons.tools.redis.common;
+
+import com.epmet.commons.tools.dto.form.DingMiniInfoFormDTO;
+import com.epmet.commons.tools.exception.EpmetException;
+import com.epmet.commons.tools.feign.CommonThirdFeignClient;
+import com.epmet.commons.tools.redis.RedisKeys;
+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.commons.tools.utils.Result;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.util.CollectionUtils;
+
+import javax.annotation.PostConstruct;
+import java.util.Map;
+
+/**
+ * @Author zxc
+ * @DateTime 2022/9/15 10:01
+ * @DESC
+ */
+@Slf4j
+@Component
+public class CustomerDingDingRedis {
+
+ @Autowired
+ private CommonThirdFeignClient thirdFeignClient;
+ @Autowired
+ private RedisUtils redisUtils;
+
+ private static CustomerDingDingRedis customerDingDingRedis;
+
+ @PostConstruct
+ public void init() {
+ customerDingDingRedis = this;
+ customerDingDingRedis.thirdFeignClient = this.thirdFeignClient;
+ customerDingDingRedis.redisUtils = this.redisUtils;
+ }
+
+ public static DingMiniInfoCache getDingMiniInfo(String miniAppId){
+ String key = RedisKeys.getDingMiniInfoKey(miniAppId);
+ Map miniInfoMap = customerDingDingRedis.redisUtils.hGetAll(key);
+ if (!CollectionUtils.isEmpty(miniInfoMap)){
+ return ConvertUtils.mapToEntity(miniInfoMap,DingMiniInfoCache.class);
+ }
+ Result dingMiniInfoResult = customerDingDingRedis.thirdFeignClient.getDingMiniInfo(new DingMiniInfoFormDTO(miniAppId));
+ if (!dingMiniInfoResult.success()){
+ throw new EpmetException("查询dingMiniInfo失败...");
+ }
+ if (null == dingMiniInfoResult.getData()){
+ return null;
+ }
+ return dingMiniInfoResult.getData();
+ }
+
+}
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/DingMiniInfoCache.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/DingMiniInfoCache.java
new file mode 100644
index 0000000000..bd656c9a7e
--- /dev/null
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/DingMiniInfoCache.java
@@ -0,0 +1,52 @@
+package com.epmet.commons.tools.redis.common.bean;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @Author zxc
+ * @DateTime 2022/9/15 10:11
+ * @DESC
+ */
+@Data
+public class DingMiniInfoCache implements Serializable {
+
+ private static final long serialVersionUID = -6956910978074595334L;
+
+ private String id;
+
+ /**
+ *
+ */
+ private String suiteId;
+
+ /**
+ *
+ */
+ private String appId;
+
+ /**
+ *
+ */
+ private String miniAppId;
+
+ /**
+ *
+ */
+ private String suiteName;
+
+ /**
+ *
+ */
+ private String suiteKey;
+
+ /**
+ *
+ */
+ private String suiteSecret;
+
+ private String token;
+
+ private String aesKey;
+}
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/CpUserDetailRedis.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/CpUserDetailRedis.java
index 4c0845fc6c..856cb6449d 100644
--- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/CpUserDetailRedis.java
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/CpUserDetailRedis.java
@@ -41,6 +41,15 @@ public class CpUserDetailRedis {
redisUtils.hMSet(key, map, expire);
}
+ public void setForDingApp(String suiteKey,TokenDto user, long expire) {
+ if (user == null) {
+ return;
+ }
+ String key = RedisKeys.getCpUserKeyForDingApp(suiteKey,user.getApp(), user.getClient(), user.getUserId());
+ //bean to map
+ Map map = BeanUtil.beanToMap(user, false, true);
+ redisUtils.hMSet(key, map, expire);
+ }
/**
* 获取token信息
*
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/NameUtils.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/NameUtils.java
new file mode 100644
index 0000000000..8dec710c4a
--- /dev/null
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/NameUtils.java
@@ -0,0 +1,89 @@
+package com.epmet.commons.tools.utils;
+
+import com.epmet.commons.tools.constant.NumConstant;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @Description
+ * @Author zhaoqifeng
+ * @Date 2022/9/14 14:40
+ */
+public class NameUtils {
+ /**
+ * 复姓(两字),国内现存81个。末尾添加三字以上的部分满姓
+ */
+ private static final String[] SURNAME_NOW = {"百里", "北堂", "北野", "北宫", "辟闾", "孛尔", "淳于", "成公", "陈生", "褚师",
+ "端木", "东方", "东郭", "东野", "东门", "第五", "大狐", "段干", "段阳", "带曰", "第二", "东宫", "公孙", "公冶", "公羊",
+ "公良", "公西", "公孟", "高堂", "高阳", "公析", "公肩", "公坚", "郭公", "谷梁", "毌将", "公乘", "毌丘", "公户", "公广",
+ "公仪", "公祖", "皇甫", "黄龙", "胡母", "何阳", "夹谷", "九方", "即墨", "梁丘", "闾丘", "洛阳", "陵尹", "冷富", "龙丘",
+ "令狐", "林彭", "南宫", "南郭", "女娲", "南伯", "南容", "南门", "南野", "欧阳", "欧侯", "濮阳", "青阳", "漆雕", "亓官",
+ "渠丘", "壤驷", "上官", "少室", "少叔", "司徒", "司马", "司空", "司寇", "士孙", "申屠", "申徒", "申鲜", "申叔", "夙沙",
+ "叔先", "叔仲", "侍其", "叔孙", "澹台", "太史", "太叔", "太公", "屠岸", "唐古", "闻人", "巫马", "微生", "王孙", "无庸",
+ "夏侯", "西门", "信平", "鲜于", "轩辕", "相里", "新垣", "徐离", "羊舌", "羊角", "延陵", "於陵", "伊祁", "吾丘", "乐正",
+ "只斤", "诸葛", "颛孙", "仲孙", "仲长", "钟离", "宗政", "主父", "中叔", "左人", "左丘", "宰父", "长儿", "仉督", "单于",
+ "叱干", "叱利", "车非", "车公", "车侯", "车长", "车绵", "独孤", "大野", "独吉", "达奚", "达官", "达仲", "达品", "哥舒",
+ "哥夜", "哥翰", "哥汗", "赫连", "呼延", "贺兰", "黑齿", "斛律", "斛粟", "贺若", "贺奴", "贺远", "贺元", "夹谷", "吉胡",
+ "吉利", "吉家", "可频", "慕容", "万俟", "万红", "万中", "抹捻", "纳兰", "纳西", "纳吉", "纳罕", "纳塞", "纳博", "纳称",
+ "纳勉", "普周", "仆固", "仆散", "蒲察", "屈突", "屈卢", "钳耳", "是云", "索卢", "厍狄", "拓跋", "同蹄", "秃发", "完颜",
+ "完明", "完忠", "宇文", "尉迟", "耶律", "耶红", "也先", "耶鲜", "耶闻", "长孙", "长南", "长北", "长西", "长红", "长元",
+ "长秋", "长寸", "长李", "长云", "萨嘛喇","赫舍里","萨克达","钮祜禄","他塔喇","喜塔腊","库雅喇","瓜尔佳","舒穆禄","索绰络",
+ "叶赫那拉","依尔觉罗","额尔德特","讷殷富察","叶赫那兰","爱新觉罗","依尔根觉罗"};
+
+ /**
+ * 获取复姓,非单字姓氏。未匹配上则依旧返回单字姓氏
+ * @param name
+ * @return
+ */
+ public static String getSurNameComplex(String name){
+ for (String s : SURNAME_NOW) {
+ if (name.startsWith(s)) {
+ return name.substring(0, s.length());
+ }
+ }
+ return name.substring(0,1);
+ }
+
+ /**
+ * 获取复姓名,去除姓氏后名
+ * @param name
+ * @return
+ */
+ public static String getNameComplex(String name){
+ for (String s : SURNAME_NOW) {
+ if (name.startsWith(s)) {
+ return name.substring(s.length());
+ }
+ }
+ return name.substring(1);
+ }
+
+ /**
+ * 获取姓氏与姓名
+ * 姓名在两字时,首字为姓。
+ * 姓名大于两字时,优先匹配复姓。
+ * 姓氏未匹配且姓名多于5字时,姓与名均在姓氏中,名为空;少于5字时则采用第一个字为姓。
+ * @param name 姓名
+ * @return map类型数据,姓氏为key值“X”,名字为value值“M”
+ */
+ public static Map getSurName(String name) {
+ Map mapData = new HashMap<>(NumConstant.TWO);
+ if (name.length() > NumConstant.ZERO && name.length() <= NumConstant.TWO){
+ mapData.put("X", name.substring(NumConstant.ZERO, NumConstant.ONE));
+ mapData.put("M", name.substring(NumConstant.ONE));
+ } else if (name.length() > NumConstant.TWO) {
+ for (String s : SURNAME_NOW) {//遍历复姓数组
+ if (name.startsWith(s)) {
+ mapData.put("X", s);
+ mapData.put("M", name.substring(s.length()));
+ return mapData;
+ }
+ }
+ //姓氏没有匹配时采用第一个字为姓
+ mapData.put("X", name.substring(NumConstant.ZERO, NumConstant.ONE));
+ mapData.put("M", name.substring(NumConstant.ONE));
+ }
+ return mapData;
+ }
+}
diff --git a/epmet-gateway/src/main/resources/bootstrap.yml b/epmet-gateway/src/main/resources/bootstrap.yml
index b0b2492d33..bfc3d86130 100644
--- a/epmet-gateway/src/main/resources/bootstrap.yml
+++ b/epmet-gateway/src/main/resources/bootstrap.yml
@@ -498,6 +498,7 @@ epmet:
- /resi/voice/**
- /point/**
- /heart/**
+ - /oss/**
# 内部认证url白名单(在白名单中的,就不会再校验登录了)
internalAuthUrlsWhiteList:
diff --git a/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java b/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java
index 8946e7e73a..49160b176d 100644
--- a/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java
+++ b/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java
@@ -10,6 +10,7 @@ package com.epmet.controller;
import com.epmet.cloud.CloudStorageConfig;
import com.epmet.cloud.OssFactory;
+import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode;
@@ -17,6 +18,7 @@ import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.redis.RedisUtils;
+import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.commons.tools.validator.group.AliyunGroup;
@@ -404,8 +406,10 @@ public class OssController {
* @date 2021.08.03 16:23
*/
@PostMapping("upload-resi-event-file")
- public Result uploadResiEventFile(@RequestPart(value = "file") MultipartFile file, @RequestParam("customerId") String customerId) {
-
+ public Result uploadResiEventFile(@LoginUser TokenDto tokenDto, @RequestPart(value = "file") MultipartFile file, @RequestParam(value = "customerId",required = false) String customerId) {
+ if (StringUtils.isBlank(customerId)){
+ customerId = tokenDto.getCustomerId();
+ }
// 体积限制
int sizeMb = 10;
int sizeThreshold = sizeMb * 1024 * 1024; // 大小限制10m
diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/DingMiniInfoDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/DingMiniInfoDTO.java
new file mode 100644
index 0000000000..19ebfacdd9
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/DingMiniInfoDTO.java
@@ -0,0 +1,89 @@
+package com.epmet.dto;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+
+/**
+ * 钉钉小程序信息
+ *
+ * @author generator generator@elink-cn.com
+ * @since v1.0.0 2022-09-14
+ */
+@Data
+public class DingMiniInfoDTO implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * ID
+ */
+ private String id;
+
+ /**
+ *
+ */
+ private String suiteId;
+
+ /**
+ *
+ */
+ private String appId;
+
+ /**
+ *
+ */
+ private String miniAppId;
+
+ /**
+ *
+ */
+ private String suiteName;
+
+ /**
+ *
+ */
+ private String suiteKey;
+
+ /**
+ *
+ */
+ private String suiteSecret;
+
+ private String token;
+
+ private String aesKey;
+
+ /**
+ *
+ */
+ private Integer delFlag;
+
+ /**
+ * 乐观锁
+ */
+ private Integer revision;
+
+ /**
+ * 创建人
+ */
+ private String createdBy;
+
+ /**
+ * 创建时间
+ */
+ private Date createdTime;
+
+ /**
+ * 更新人
+ */
+ private String updatedBy;
+
+ /**
+ * 更新时间
+ */
+ private Date updatedTime;
+
+}
\ No newline at end of file
diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/OpenSyncBizDataDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/OpenSyncBizDataDTO.java
new file mode 100644
index 0000000000..12dac445f0
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/OpenSyncBizDataDTO.java
@@ -0,0 +1,99 @@
+package com.epmet.dto;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+
+/**
+ *
+ *
+ * @author generator generator@elink-cn.com
+ * @since v1.0.0 2022-09-14
+ */
+@Data
+public class OpenSyncBizDataDTO implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ *
+ */
+ private String id;
+
+ /**
+ * 第三方企业应用的suiteid加下划线0
+ */
+ private String subscribeId;
+
+ private String suiteKey;
+
+ /**
+ * 第三方企业应用的corpid
+ */
+ private String corpId;
+
+ /**
+ * 第三方企业应用的suiteid
+ */
+ private String bizId;
+
+ /**
+ * 数据为Json格式
+ */
+ private String bizData;
+
+ /**
+ * 2:第三方企业应用票据;
+4:企业授权变更,包含授权、解除授权、授权变更;
+7:第三方企业应用变更,包含停用、启用、删除(删除保留授权);
+13:企业用户变更,包含用户添加、修改、删除;
+14:企业部门变更,包含部门添加、修改、删除;
+15:企业角色变更,包含角色添加、修改、删除;
+16:企业变更,包含企业修改、删除;
+17:市场订单;
+20:企业外部联系人变更,包含添加、修改、删除;
+22:ISV自定义审批;
+25:家校通讯录1.0(Deprecated)信息变更。家校通讯录升级,请查看家校通讯录2.0数据推送;
+32:智能硬件绑定类型;
+37:因订单到期或者用户退款等导致的服务关闭,目前仅推送因退款等导致的服务关闭;
+50:家校通讯录2.0,部门信息变更;
+51:家校通讯录2.0,人员信息变更;
+63:应用试用记录回调信息;
+66:工作台组件变更回调事件;
+67:钉钉假期相关回调事件;
+133:CRM客户动态相关数据回调事件;
+137:人事平台员工异动V2相关数据回调事件;
+139:异步转译通讯录id任务完成通知;
+165:人事平台员工档案变动事件相关数据的回调事件;
+175:人事解决方案变更事件;
+ */
+ private String bizType;
+
+ /**
+ *
+ */
+ private Integer delFlag;
+
+ /**
+ *
+ */
+ private Date createdTime;
+
+ /**
+ *
+ */
+ private String createdBy;
+
+ /**
+ *
+ */
+ private Date updatedTime;
+
+ /**
+ *
+ */
+ private String updatedBy;
+
+}
\ No newline at end of file
diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/ExemptLoginUserDetailFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/ExemptLoginUserDetailFormDTO.java
new file mode 100644
index 0000000000..7e84993d2f
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/ExemptLoginUserDetailFormDTO.java
@@ -0,0 +1,28 @@
+package com.epmet.dto.form;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import java.io.Serializable;
+
+/**
+ * @Author zxc
+ * @DateTime 2022/9/14 14:52
+ * @DESC
+ */
+@Data
+public class ExemptLoginUserDetailFormDTO implements Serializable {
+
+ private static final long serialVersionUID = -4333806195203619201L;
+
+ public interface ExemptLoginUserDetailForm{}
+
+ @NotBlank(message = "code不能为空",groups = ExemptLoginUserDetailForm.class)
+ private String code;
+
+ @NotBlank(message = "corpId不能为空",groups = ExemptLoginUserDetailForm.class)
+ private String corpId;
+
+ @NotBlank(message = "miniAppId不能为空",groups = ExemptLoginUserDetailForm.class)
+ private String miniAppId;
+}
diff --git a/epmet-module/epmet-third/epmet-third-server/pom.xml b/epmet-module/epmet-third/epmet-third-server/pom.xml
index e991b981f3..a70d2ac789 100644
--- a/epmet-module/epmet-third/epmet-third-server/pom.xml
+++ b/epmet-module/epmet-third/epmet-third-server/pom.xml
@@ -157,7 +157,16 @@
rocketmq-acl
4.9.2
-
+
+ dingtalk-spring-boot-starter
+ com.taobao
+ 1.0.0
+
+
+ commons-codec
+ commons-codec
+ 1.15
+
@@ -229,7 +238,7 @@
SECfcc020bdc83bb17a2c00f39977b1fbc409ef4188c7beaea11c5caa90eeaf87fd
-
+
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/EpmetThirdApplication.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/EpmetThirdApplication.java
index 3efd642c87..21c518e033 100644
--- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/EpmetThirdApplication.java
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/EpmetThirdApplication.java
@@ -1,6 +1,7 @@
package com.epmet;
import com.epmet.mq.properties.RocketMQProperties;
+import com.taobao.dingtalk.spring.annotations.EnableDingTalk;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
@@ -8,6 +9,7 @@ import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
+@EnableDingTalk
@EnableConfigurationProperties(RocketMQProperties.class)
@SpringBootApplication
@EnableDiscoveryClient
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/dingtalk/CallbackController.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/dingtalk/CallbackController.java
new file mode 100644
index 0000000000..8164c4cdbe
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/dingtalk/CallbackController.java
@@ -0,0 +1,155 @@
+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.dto.DingMiniInfoDTO;
+import com.epmet.dto.form.ExemptLoginUserDetailFormDTO;
+import com.epmet.entity.OpenSyncBizDataEntity;
+import com.epmet.redis.DingDingCallbackRedis;
+import com.epmet.service.DingTalkService;
+import com.epmet.service.OpenSyncBizDataService;
+import org.apache.commons.collections4.CollectionUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * ISV 小程序回调信息处理
+ */
+@RestController
+@RequestMapping("/dingTalk")
+public class CallbackController {
+
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
+ /**
+ * 创建应用,验证回调URL创建有效事件(第一次保存回调URL之前)
+ */
+ private static final String EVENT_CHECK_CREATE_SUITE_URL = "check_create_suite_url";
+
+ /**
+ * 创建应用,验证回调URL变更有效事件(第一次保存回调URL之后)
+ */
+ private static final String EVENT_CHECK_UPADTE_SUITE_URL = "check_update_suite_url";
+
+ /**
+ * suite_ticket推送事件
+ */
+ private static final String EVENT_SUITE_TICKET = "suite_ticket";
+
+ /**
+ * 企业授权开通应用事件
+ */
+ private static final String EVENT_TMP_AUTH_CODE = "tmp_auth_code";
+
+ private static final String EVENT_SYNC_HTTP_PUSH_HIGH = "SYNC_HTTP_PUSH_HIGH";
+
+ @Autowired
+ private OpenSyncBizDataService openSyncBizDataService;
+ @Autowired
+ private OpenSyncBizDataDao openSyncBizDataDao;
+ @Autowired
+ private DingDingCallbackRedis dingCallbackRedis;
+ @Autowired
+ private DingTalkService dingTalkService;
+
+ @PostMapping(value = "dingCallback")
+ public Object dingCallback(
+ @RequestParam(value = "signature") String signature,
+ @RequestParam(value = "timestamp") Long timestamp,
+ @RequestParam(value = "nonce") String nonce,
+ @RequestParam(value = "suiteKey") String suiteKey,
+ @RequestBody(required = false) JSONObject body
+ ) {
+ String params = "signature:" + signature + " timestamp:" + timestamp + " nonce:" + nonce + " body:" + body + "suiteKey::"+suiteKey;
+ try {
+ log.info("begin callback:" + params);
+ DingMiniInfoDTO dingMiniInfo = openSyncBizDataDao.getDingMiniInfo(suiteKey);
+ DingCallbackCrypto dingTalkEncryptor = new DingCallbackCrypto(dingMiniInfo.getToken(), dingMiniInfo.getAesKey(), suiteKey);
+
+ // 从post请求的body中获取回调信息的加密数据进行解密处理
+ String encrypt = body.getString("encrypt");
+ String plainText = dingTalkEncryptor.getDecryptMsg(signature, timestamp.toString(), nonce, encrypt);
+ JSONObject callBackContent = JSON.parseObject(plainText);
+
+ log.info("推来的消息体:"+plainText);
+
+ // 根据回调事件类型做不同的业务处理
+ String eventType = callBackContent.getString("EventType");
+ if (EVENT_CHECK_CREATE_SUITE_URL.equals(eventType)) {
+ log.info("验证新创建的回调URL有效性: " + plainText);
+ } else if (EVENT_CHECK_UPADTE_SUITE_URL.equals(eventType)) {
+ log.info("验证更新回调URL有效性: " + plainText);
+ } else if (EVENT_SUITE_TICKET.equals(eventType)) {
+ // suite_ticket用于用签名形式生成accessToken(访问钉钉服务端的凭证),需要保存到应用的db。
+ // 钉钉会定期向本callback url推送suite_ticket新值用以提升安全性。
+ // 应用在获取到新的时值时,保存db成功后,返回给钉钉success加密串(如本demo的return)
+ log.info("应用suite_ticket数据推送: " + plainText);
+ } else if (EVENT_TMP_AUTH_CODE.equals(eventType)) {
+ // 本事件应用应该异步进行授权开通企业的初始化,目的是尽最大努力快速返回给钉钉服务端。用以提升企业管理员开通应用体验
+ // 即使本接口没有收到数据或者收到事件后处理初始化失败都可以后续再用户试用应用时从前端获取到corpId并拉取授权企业信息,进而初始化开通及企业。
+ log.info("企业授权开通应用事件: " + plainText);
+ } else if (EVENT_SYNC_HTTP_PUSH_HIGH.equals(eventType)){
+ List