|
@@ -194,15 +194,7 @@ public class DingAuthServiceInfoImpl implements DingAuthServiceInfo {
|
|
|
String corp_id = null;
|
|
|
JSONObject biz_data = null;
|
|
|
Integer bizType = 0;
|
|
|
- for (Object bizDatum : bizData) {
|
|
|
- JSONObject bizDataJson = (JSONObject) bizDatum;
|
|
|
- log.info("[callback] 获取到授权bizDataJson:" + bizDataJson);
|
|
|
- String biz_data_str = bizDataJson.getString("biz_data");
|
|
|
- biz_data = JSONObject.parseObject(biz_data_str);
|
|
|
- bizType = bizDataJson.getInteger("biz_type");
|
|
|
- log.info("[callback] 获取到bizType:" + bizType);
|
|
|
- corp_id = bizDataJson.getString("corp_id");
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
switch (eventType) {
|
|
|
case SUITE_TICKET_CALLBACK_URL_VALIDATE:
|
|
@@ -246,12 +238,20 @@ public class DingAuthServiceInfoImpl implements DingAuthServiceInfo {
|
|
|
break;
|
|
|
case SYNC_HTTP_PUSH_HIGH:
|
|
|
log.info("[callback] 套件票据事件:" + plainNode);
|
|
|
- log.info("[callback] 套件票据事件123:" + bizData);
|
|
|
+ for (Object bizDatum : bizData) {
|
|
|
+ JSONObject bizDataJson = (JSONObject) bizDatum;
|
|
|
+ log.info("[callback] 获取到授权bizDataJson:" + bizDataJson);
|
|
|
+ String biz_data_str = bizDataJson.getString("biz_data");
|
|
|
+ biz_data = JSONObject.parseObject(biz_data_str);
|
|
|
+ bizType = bizDataJson.getInteger("biz_type");
|
|
|
+ log.info("[callback] 获取到bizType:" + bizType);
|
|
|
+ corp_id = bizDataJson.getString("corp_id");
|
|
|
+ }
|
|
|
+ log.info("[callback] 获取到套件票据corp_id:{}", corp_id);
|
|
|
//套件票据
|
|
|
if (bizType == 2 && biz_data != null && corp_id != null) {
|
|
|
String suiteTicket = biz_data.getString("suiteTicket");
|
|
|
String redisKeyPrefix = Constants.DAILY_DING_AUTH + corp_id + ":";
|
|
|
- log.info("[callback] 获取到套件票据corp_id:{}", corp_id);
|
|
|
redisCache.setCacheObject(redisKeyPrefix + Constants.DAILY_DING_SUITE_TICKET, suiteTicket, 5, TimeUnit.HOURS);
|
|
|
}
|
|
|
//套件票据授权
|
|
@@ -263,13 +263,13 @@ public class DingAuthServiceInfoImpl implements DingAuthServiceInfo {
|
|
|
//企业授权信息
|
|
|
String syncAction = biz_data.getString("syncAction");
|
|
|
if ("org_suite_auth".equals(syncAction)) {
|
|
|
+ log.info("[callback] 企业授权第三方企业应用:{}",corp_id);
|
|
|
updateCompanyInfo(biz_data,corp_id);
|
|
|
} else if ("org_suite_change".equals(syncAction)) {
|
|
|
-
|
|
|
+ log.info("[callback] 表示企业变更授权范围:{}",corp_id);
|
|
|
} else if ("org_suite_relieve".equals(syncAction)) {
|
|
|
-
|
|
|
+ log.info("[callback] 表示企业解除授权:{}",corp_id);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
resultMap = encryptText(CALLBACK_RETURN_SUCCESS);
|
|
|
break;
|
|
@@ -308,7 +308,8 @@ public class DingAuthServiceInfoImpl implements DingAuthServiceInfo {
|
|
|
|
|
|
return sb.toString();
|
|
|
}
|
|
|
- public void updateCompanyInfo(JSONObject biz_data, String corp_id){
|
|
|
+
|
|
|
+ public void updateCompanyInfo(JSONObject biz_data, String corp_id) {
|
|
|
String authCorpInfo_str = biz_data.getString("auth_corp_info");//授权方企业信息。
|
|
|
String auth_info_str = biz_data.getString("auth_info");//授权信息。
|
|
|
String auth_user_info_str = biz_data.getString("auth_user_info");//授权方管理员信息
|
|
@@ -317,7 +318,7 @@ public class DingAuthServiceInfoImpl implements DingAuthServiceInfo {
|
|
|
JSONArray agentArray = authInfo.getJSONArray("agent");
|
|
|
JSONObject agent = JSONObject.parseObject(agentArray.get(0).toString());
|
|
|
JSONObject authUserInfo = JSONObject.parseObject(auth_user_info_str);
|
|
|
- String accessToken = dingThirdTokenService.getCorpAccessToken(corp_id);
|
|
|
+// String accessToken = dingThirdTokenService.getCorpAccessToken(corp_id);
|
|
|
String manager_userid = authUserInfo.getString("userId");
|
|
|
TCompanyUser po = new TCompanyUser();
|
|
|
po.setUserId(manager_userid);
|
|
@@ -325,21 +326,22 @@ public class DingAuthServiceInfoImpl implements DingAuthServiceInfo {
|
|
|
//企业管理员
|
|
|
List<TCompanyUser> poList = tCompanyUserService.selectTCompanyUserList(po);
|
|
|
//用户详细信息
|
|
|
- OapiV2UserGetResponse authUser = dingThirdTokenService.getAuthUser(accessToken, manager_userid);
|
|
|
- OapiV2UserGetResponse.UserGetResponse result = authUser.getResult();
|
|
|
+// OapiV2UserGetResponse authUser = dingThirdTokenService.getAuthUser(accessToken, manager_userid);
|
|
|
+// OapiV2UserGetResponse.UserGetResponse result = authUser.getResult();
|
|
|
if (CollUtil.isEmpty(poList)) {
|
|
|
tCompanyUserService.insertTCompanyUser(po);
|
|
|
// 插入用户
|
|
|
SysUser user = new SysUser();
|
|
|
- user.setDeptIdList(result.getDeptIdList());
|
|
|
- user.setNickName(result.getName());
|
|
|
+// user.setDeptIdList(result.getDeptIdList());
|
|
|
+// user.setNickName(result.getName());
|
|
|
user.setUserName(manager_userid);
|
|
|
- user.setEmail(result.getEmail());
|
|
|
- user.setPhonenumber(result.getMobile());
|
|
|
- user.setAvatar(result.getAvatar());
|
|
|
+// user.setEmail(result.getEmail());
|
|
|
+// user.setPhonenumber(result.getMobile());
|
|
|
+// user.setAvatar(result.getAvatar());
|
|
|
user.setStatus("0");
|
|
|
- user.setEmployNo(result.getJobNumber());
|
|
|
+// user.setEmployNo(result.getJobNumber());
|
|
|
user.setCorpId(corp_id);
|
|
|
+ user.setCreateBy("1");
|
|
|
sysUserMapper.insertUser(user);
|
|
|
// 插入用户角色 赋予租户管理员
|
|
|
SysRole role = sysRoleService.selectRoleByKey("tentant_admin");
|
|
@@ -352,16 +354,40 @@ public class DingAuthServiceInfoImpl implements DingAuthServiceInfo {
|
|
|
}
|
|
|
// 查询企业信息
|
|
|
TEnterpriseCompany tEnterpriseCompany = tEnterpriseCompanyService.selectTEnterpriseCompanyByCorpId(authCorpInfo.getString("corpid"));
|
|
|
- if(null != tEnterpriseCompany){
|
|
|
- TEnterpriseCompany other = JSON.toJavaObject(authCorpInfo, TEnterpriseCompany.class);
|
|
|
- other.setAgentid(agent.getString("agentid"));
|
|
|
- other.setName(agent.getString("agent_name"));
|
|
|
- other.setLogoUrl(agent.getString("logo_url"));
|
|
|
- tEnterpriseCompany.copyFrom(other,true);
|
|
|
+
|
|
|
+ if (null != tEnterpriseCompany) {
|
|
|
+ tEnterpriseCompany.setName(authCorpInfo.getString("corp_name"));
|
|
|
+ tEnterpriseCompany.setLogoUrl(authCorpInfo.getString("corp_logo_url"));
|
|
|
+ tEnterpriseCompany.setCorpid(authCorpInfo.getString("corpid"));
|
|
|
+ tEnterpriseCompany.setInviteCode(authCorpInfo.getString("invite_code"));
|
|
|
+ tEnterpriseCompany.setIndustry(authCorpInfo.getString("industry"));
|
|
|
+ tEnterpriseCompany.setCorpName(authCorpInfo.getString("corp_name"));
|
|
|
+ tEnterpriseCompany.setLicenseCode(authCorpInfo.getString("license_code"));
|
|
|
+ tEnterpriseCompany.setAuthChannel(authCorpInfo.getString("auth_channel"));
|
|
|
+ tEnterpriseCompany.setAuthChannelType(authCorpInfo.getString("auth_channel_type"));
|
|
|
+ tEnterpriseCompany.setIsAuthenticated(authCorpInfo.get("is_authenticated").toString());
|
|
|
+ tEnterpriseCompany.setAuthLevel(authUserInfo.getString("auth_level"));
|
|
|
+ tEnterpriseCompany.setInviteUrl(authUserInfo.getString("invite_url"));
|
|
|
+ tEnterpriseCompany.setCorpLogoUrl(authUserInfo.getString("corp_logo_url"));
|
|
|
+ tEnterpriseCompany.setAgentid(agent.getString("agentid"));
|
|
|
+ tEnterpriseCompany.setName(agent.getString("agent_name"));
|
|
|
+ tEnterpriseCompany.setLogoUrl(agent.getString("logo_url"));
|
|
|
tEnterpriseCompanyService.updateTEnterpriseCompany(tEnterpriseCompany);
|
|
|
} else {
|
|
|
- // 转换JSONObject为TEnterpriseCompany对象
|
|
|
- tEnterpriseCompany = JSON.toJavaObject(authCorpInfo, TEnterpriseCompany.class);
|
|
|
+ tEnterpriseCompany = new TEnterpriseCompany();
|
|
|
+ tEnterpriseCompany.setName(authCorpInfo.getString("corp_name"));
|
|
|
+ tEnterpriseCompany.setLogoUrl(authCorpInfo.getString("corp_logo_url"));
|
|
|
+ tEnterpriseCompany.setCorpid(authCorpInfo.getString("corpid"));
|
|
|
+ tEnterpriseCompany.setInviteCode(authCorpInfo.getString("invite_code"));
|
|
|
+ tEnterpriseCompany.setIndustry(authCorpInfo.getString("industry"));
|
|
|
+ tEnterpriseCompany.setCorpName(authCorpInfo.getString("corp_name"));
|
|
|
+ tEnterpriseCompany.setLicenseCode(authCorpInfo.getString("license_code"));
|
|
|
+ tEnterpriseCompany.setAuthChannel(authCorpInfo.getString("auth_channel"));
|
|
|
+ tEnterpriseCompany.setAuthChannelType(authCorpInfo.getString("auth_channel_type"));
|
|
|
+ tEnterpriseCompany.setIsAuthenticated(authCorpInfo.get("is_authenticated").toString());
|
|
|
+ tEnterpriseCompany.setAuthLevel(authUserInfo.getString("auth_level"));
|
|
|
+ tEnterpriseCompany.setInviteUrl(authUserInfo.getString("invite_url"));
|
|
|
+ tEnterpriseCompany.setCorpLogoUrl(authUserInfo.getString("corp_logo_url"));
|
|
|
tEnterpriseCompany.setAgentid(agent.getString("agentid"));
|
|
|
tEnterpriseCompany.setName(agent.getString("agent_name"));
|
|
|
tEnterpriseCompany.setLogoUrl(agent.getString("logo_url"));
|