|
@@ -9,16 +9,15 @@ import com.qmth.teachcloud.common.bean.dto.AuthOrgInfoDto;
|
|
|
import com.qmth.teachcloud.common.config.DictionaryConfig;
|
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
|
import com.qmth.teachcloud.common.entity.BasicSchool;
|
|
|
+import com.qmth.teachcloud.common.entity.SysOrg;
|
|
|
import com.qmth.teachcloud.common.entity.TSAuth;
|
|
|
import com.qmth.teachcloud.common.enums.AuthEnum;
|
|
|
import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
|
import com.qmth.teachcloud.common.enums.UploadFileEnum;
|
|
|
import com.qmth.teachcloud.common.mapper.BasicSchoolMapper;
|
|
|
+import com.qmth.teachcloud.common.mapper.SysOrgMapper;
|
|
|
import com.qmth.teachcloud.common.mapper.TSAuthMapper;
|
|
|
-import com.qmth.teachcloud.common.service.AuthInfoService;
|
|
|
-import com.qmth.teachcloud.common.service.BasicSchoolService;
|
|
|
-import com.qmth.teachcloud.common.service.CommonCacheService;
|
|
|
-import com.qmth.teachcloud.common.service.TSAuthService;
|
|
|
+import com.qmth.teachcloud.common.service.*;
|
|
|
import com.qmth.teachcloud.common.util.FileStoreUtil;
|
|
|
import org.apache.commons.codec.digest.DigestUtils;
|
|
|
import org.slf4j.Logger;
|
|
@@ -74,6 +73,12 @@ public class AuthInfoServiceImpl implements AuthInfoService {
|
|
|
@Resource
|
|
|
AuthInfoService authInfoService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ SysOrgService sysOrgService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ SysOrgMapper sysOrgMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 授权信息初始化
|
|
|
*
|
|
@@ -171,10 +176,12 @@ public class AuthInfoServiceImpl implements AuthInfoService {
|
|
|
List<TSAuth> tsAuthList = null;
|
|
|
Set<Long> orgIdsSet = null;
|
|
|
Set<BasicSchool> basicSchoolSet = null;
|
|
|
+ Set<SysOrg> sysOrgSet = null;
|
|
|
if (!CollectionUtils.isEmpty(orgInfoList)) {
|
|
|
tsAuthList = new ArrayList<>();
|
|
|
orgIdsSet = new HashSet<>();
|
|
|
basicSchoolSet = new HashSet<>();
|
|
|
+ sysOrgSet = new HashSet<>();
|
|
|
}
|
|
|
boolean oss = dictionaryConfig.sysDomain().isOss();
|
|
|
for (OrgInfo o : orgInfoList) {
|
|
@@ -192,9 +199,9 @@ public class AuthInfoServiceImpl implements AuthInfoService {
|
|
|
|
|
|
QueryWrapper<BasicSchool> basicSchoolQueryWrapper = new QueryWrapper<>();
|
|
|
basicSchoolQueryWrapper.lambda().eq(BasicSchool::getCode, o.getCode());
|
|
|
- int count = basicSchoolService.count(basicSchoolQueryWrapper);
|
|
|
- if (count == 0) {//不存在则创建学校
|
|
|
- BasicSchool basicSchool = new BasicSchool(o.getCode(), o.getName(), o.getAccessKey(), o.getAccessSecret());
|
|
|
+ BasicSchool basicSchool = basicSchoolService.getOne(basicSchoolQueryWrapper);
|
|
|
+ if (Objects.isNull(basicSchool)) {//不存在则创建学校
|
|
|
+ basicSchool = new BasicSchool(o.getCode(), o.getName(), o.getAccessKey(), o.getAccessSecret());
|
|
|
if (Objects.nonNull(o.getLogo()) && (!o.getLogo().startsWith("https:") || !o.getLogo().startsWith("http"))) {
|
|
|
String filePath = SystemConstant.TEMP_FILES_DIR + File.separator + SystemConstant.getUuid() + ".jpg";
|
|
|
File logoFile = new File(filePath);
|
|
@@ -224,7 +231,15 @@ public class AuthInfoServiceImpl implements AuthInfoService {
|
|
|
}
|
|
|
basicSchoolSet.add(basicSchool);
|
|
|
}
|
|
|
+
|
|
|
+ QueryWrapper<SysOrg> sysOrgQueryWrapper = new QueryWrapper<>();
|
|
|
+ sysOrgQueryWrapper.lambda().eq(SysOrg::getSchoolId, basicSchool.getId());
|
|
|
+ int count = sysOrgService.count(sysOrgQueryWrapper);
|
|
|
+ if (count == 0) {
|
|
|
+ sysOrgSet.add(new SysOrg(basicSchool.getId(), basicSchool.getName()));
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
if (!CollectionUtils.isEmpty(tsAuthList) && !CollectionUtils.isEmpty(orgIdsSet)) {
|
|
|
QueryWrapper<TSAuth> tsAuthQueryWrapper = new QueryWrapper<>();
|
|
|
tsAuthQueryWrapper.lambda().in(TSAuth::getSchoolId, orgIdsSet);
|
|
@@ -234,6 +249,10 @@ public class AuthInfoServiceImpl implements AuthInfoService {
|
|
|
if (!CollectionUtils.isEmpty(basicSchoolSet)) {
|
|
|
basicSchoolMapper.insertBatch(basicSchoolSet);
|
|
|
}
|
|
|
+
|
|
|
+ if (!CollectionUtils.isEmpty(sysOrgSet)) {
|
|
|
+ sysOrgMapper.insertBatch(sysOrgSet);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|