Ver Fonte

正式环境密码

24282 há 2 anos atrás
pai
commit
ea38ed46a2

+ 4 - 3
hx-dingding/src/main/java/com/fjhx/dingding/service/impl/DingServiceImpl.java

@@ -105,6 +105,10 @@ public class DingServiceImpl implements DingService {
             TenantInfo tenantInfo = tenantInfoService.getOne(Wrappers.<TenantInfo>lambdaQuery()
                     .eq(TenantInfo::getCorpid, dto.getCorpId()));
 
+            if (tenantInfo == null) {
+                throw new ServiceException("未知corpId");
+            }
+
             sysUser = new SysUser();
             OapiV2UserGetResponse.UserGetResponse userDetail = DingUtil.getUserDetail(dto.getCorpId(), userid);
             List<Long> deptIdList = userDetail.getDeptIdList();
@@ -225,14 +229,11 @@ public class DingServiceImpl implements DingService {
         List<String> tenantIdList = list.stream().map(TenantInfo::getTenantId).collect(Collectors.toList());
 
         if (list.size() > 0) {
-
             String tempTenantId;
             do {
                 tempTenantId = tenantId + "-" + RandomUtil.randomString(3);
             } while (!tenantIdList.contains(tempTenantId));
-
             tenantId = tempTenantId;
-
         }
 
         // 创建租户

+ 5 - 2
hx-dingding/src/main/java/com/fjhx/dingding/utils/DingUtil.java

@@ -107,7 +107,11 @@ public class DingUtil {
             req.setCode(code);
             String corpAccessToken = getCorpAccessToken(corpId);
             OapiV2UserGetuserinfoResponse rsp = client.execute(req, corpAccessToken);
-            return rsp.getResult();
+            OapiV2UserGetuserinfoResponse.UserGetByCodeResponse result = rsp.getResult();
+            if (result == null) {
+                throw new ServiceException(rsp.getErrmsg());
+            }
+            return result;
         } catch (Exception e) {
             log.error("通过免登码获取用户信息失败", e);
             throw new ServiceException("通过免登码获取用户信息失败");
@@ -128,7 +132,6 @@ public class DingUtil {
         }
     }
 
-
     public static List<OapiV2DepartmentListsubResponse.DeptBaseResponse> getDeptList(String corpId, Long deptId) {
         try {
             DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/department/listsub");