|
@@ -5,6 +5,10 @@ import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.aliyun.dingtalkcontact_1_0.Client;
|
|
|
import com.aliyun.dingtalkcontact_1_0.models.GetUserHeaders;
|
|
|
+import com.aliyun.dingtalkoauth2_1_0.models.GetAuthInfoHeaders;
|
|
|
+import com.aliyun.dingtalkoauth2_1_0.models.GetAuthInfoRequest;
|
|
|
+import com.aliyun.dingtalkoauth2_1_0.models.GetAuthInfoResponse;
|
|
|
+import com.aliyun.dingtalkoauth2_1_0.models.GetAuthInfoResponseBody;
|
|
|
import com.aliyun.tea.TeaConverter;
|
|
|
import com.aliyun.tea.TeaException;
|
|
|
import com.aliyun.tea.TeaPair;
|
|
@@ -958,7 +962,6 @@ public class DingDingServiceImpl implements DingDingService {
|
|
|
User upUser = new User();
|
|
|
upUser.setId(oldUser.getId());
|
|
|
boolean changed = false;
|
|
|
-
|
|
|
if (dingding.getContactNeedTranslate() == 0 && duser.getName() != null && (oldUser.getName() == null || !oldUser.getName().equals(duser.getName()))) {
|
|
|
upUser.setName(duser.getName());
|
|
|
changed = true;
|
|
@@ -2660,6 +2663,56 @@ public class DingDingServiceImpl implements DingDingService {
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
+ public static com.aliyun.dingtalkoauth2_1_0.Client createAuthClient() throws Exception {
|
|
|
+ Config config = new Config();
|
|
|
+ config.protocol = "https";
|
|
|
+ config.regionId = "central";
|
|
|
+ return new com.aliyun.dingtalkoauth2_1_0.Client(config);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg getAuthInfo(String corpid) throws Exception {
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
+// java.util.List<String> args = java.util.Arrays.asList(args_);
|
|
|
+ com.aliyun.dingtalkoauth2_1_0.Client client = createAuthClient();
|
|
|
+ GetAuthInfoHeaders getAuthInfoHeaders = new GetAuthInfoHeaders();
|
|
|
+ getAuthInfoHeaders.xAcsDingtalkAccessToken = getDDSuiteAccessToken();
|
|
|
+ GetAuthInfoRequest getAuthInfoRequest = new GetAuthInfoRequest()
|
|
|
+ .setAuthCorpId(corpid);
|
|
|
+ try {
|
|
|
+ GetAuthInfoResponse authInfoWithOptions = client.getAuthInfoWithOptions(getAuthInfoRequest, getAuthInfoHeaders, new RuntimeOptions());
|
|
|
+ GetAuthInfoResponseBody body = authInfoWithOptions.body;
|
|
|
+ System.out.println("获取授权信息body=========="+body);
|
|
|
+ String authUserId = body.getAuthUserInfo().getUserId();
|
|
|
+ try {
|
|
|
+ String corpName = body.getAuthCorpInfo().corpName;
|
|
|
+
|
|
|
+ body.getAuthAppInfo().getAgentList().stream().filter(agent -> agent.agentName.equals("工时管家")).forEach(agent -> {
|
|
|
+ try {
|
|
|
+ corpAuth(corpid, corpName, authUserId, agent.agentId);
|
|
|
+ } catch (ApiException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ msg.setError(e.getMessage());
|
|
|
+ }
|
|
|
+ } catch (TeaException err) {
|
|
|
+ if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
|
|
|
+ // err 中含有 code 和 message 属性,可帮助开发定位问题
|
|
|
+ msg.setError(err.code+": " +err.message);
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception _err) {
|
|
|
+ TeaException err = new TeaException(_err.getMessage(), _err);
|
|
|
+ if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
|
|
|
+ // err 中含有 code 和 message 属性,可帮助开发定位问题
|
|
|
+ msg.setError(err.code+": " +err.message);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
|
|
|
private boolean judgeIsLeader(String userId) {
|
|
|
int cnt = projectAuditorMapper.selectCount(new QueryWrapper<ProjectAuditor>().eq("auditor_id", userId));
|