|
@@ -5,10 +5,8 @@ import com.qmth.boot.core.solar.config.SolarProperties;
|
|
import com.qmth.boot.core.solar.model.AppInfo;
|
|
import com.qmth.boot.core.solar.model.AppInfo;
|
|
import com.qmth.boot.core.solar.model.OrgInfo;
|
|
import com.qmth.boot.core.solar.model.OrgInfo;
|
|
import com.qmth.boot.core.solar.service.SolarService;
|
|
import com.qmth.boot.core.solar.service.SolarService;
|
|
|
|
+import com.qmth.themis.business.constant.SpringContextHolder;
|
|
import com.qmth.themis.business.constant.SystemConstant;
|
|
import com.qmth.themis.business.constant.SystemConstant;
|
|
-import com.qmth.themis.business.dao.TBOrgMapper;
|
|
|
|
-import com.qmth.themis.business.dao.TSAuthMapper;
|
|
|
|
-import com.qmth.themis.business.dto.AuthOrgInfoDto;
|
|
|
|
import com.qmth.themis.business.entity.TBOrg;
|
|
import com.qmth.themis.business.entity.TBOrg;
|
|
import com.qmth.themis.business.entity.TSAuth;
|
|
import com.qmth.themis.business.entity.TSAuth;
|
|
import com.qmth.themis.business.enums.AuthEnum;
|
|
import com.qmth.themis.business.enums.AuthEnum;
|
|
@@ -52,18 +50,12 @@ public class AuthInfoServiceImpl implements AuthInfoService {
|
|
@Resource
|
|
@Resource
|
|
TSAuthService tsAuthService;
|
|
TSAuthService tsAuthService;
|
|
|
|
|
|
- @Resource
|
|
|
|
- TSAuthMapper tsAuthMapper;
|
|
|
|
-
|
|
|
|
@Resource
|
|
@Resource
|
|
CacheService cacheService;
|
|
CacheService cacheService;
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
TBOrgService tbOrgService;
|
|
TBOrgService tbOrgService;
|
|
|
|
|
|
- @Resource
|
|
|
|
- TBOrgMapper tbOrgMapper;
|
|
|
|
-
|
|
|
|
@Resource
|
|
@Resource
|
|
QrCodeUtil qrCodeUtil;
|
|
QrCodeUtil qrCodeUtil;
|
|
|
|
|
|
@@ -118,11 +110,11 @@ public class AuthInfoServiceImpl implements AuthInfoService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public void appHasExpired(String code) {
|
|
public void appHasExpired(String code) {
|
|
- if (Objects.nonNull(code)) {
|
|
|
|
- AuthOrgInfoDto authOrgInfoDto = cacheService.authInfoCache(code);
|
|
|
|
- if (Objects.isNull(authOrgInfoDto) || (Objects.nonNull(authOrgInfoDto) && authOrgInfoDto.getControl().hasExpired())) {
|
|
|
|
- throw new BusinessException(ExceptionResultEnum.AUTH_INFO_ERROR);
|
|
|
|
- }
|
|
|
|
|
|
+ TBOrg tbOrg = cacheService.addOrgCodeCache(code);
|
|
|
|
+ if ((Objects.nonNull(tbOrg) && Objects.nonNull(tbOrg.getEnable()) && tbOrg.getEnable().intValue() == 0)
|
|
|
|
+ || (Objects.isNull(solarService.getAppInfo()) || solarService.getAppInfo().getControl().hasExpired())
|
|
|
|
+ || (Objects.isNull(solarService.getAppControl()) || solarService.getAppControl().hasExpired())) {
|
|
|
|
+ throw new BusinessException(ExceptionResultEnum.AUTH_INFO_ERROR);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -168,16 +160,16 @@ public class AuthInfoServiceImpl implements AuthInfoService {
|
|
public void saveAuthInfo(AppInfo appInfo, AuthEnum authEnum, byte[] file) throws Exception {
|
|
public void saveAuthInfo(AppInfo appInfo, AuthEnum authEnum, byte[] file) throws Exception {
|
|
List<OrgInfo> orgInfoList = solarService.getOrgList();
|
|
List<OrgInfo> orgInfoList = solarService.getOrgList();
|
|
List<TSAuth> tsAuthList = null;
|
|
List<TSAuth> tsAuthList = null;
|
|
- Set<Long> orgIdsSet = null;
|
|
|
|
|
|
+ Map<String, String> orgCodesMap = null;
|
|
Set<TBOrg> tbOrgSet = null;
|
|
Set<TBOrg> tbOrgSet = null;
|
|
if (!CollectionUtils.isEmpty(orgInfoList)) {
|
|
if (!CollectionUtils.isEmpty(orgInfoList)) {
|
|
tsAuthList = new ArrayList<>();
|
|
tsAuthList = new ArrayList<>();
|
|
- orgIdsSet = new HashSet<>();
|
|
|
|
tbOrgSet = new HashSet<>();
|
|
tbOrgSet = new HashSet<>();
|
|
|
|
+ orgCodesMap = new HashMap<>();
|
|
}
|
|
}
|
|
boolean oss = qrCodeUtil.getSysDomain().isOss();
|
|
boolean oss = qrCodeUtil.getSysDomain().isOss();
|
|
for (OrgInfo o : orgInfoList) {
|
|
for (OrgInfo o : orgInfoList) {
|
|
- orgIdsSet.add(o.getId());
|
|
|
|
|
|
+ orgCodesMap.put(o.getCode(), o.getCode());
|
|
if (authEnum == AuthEnum.OFF_LINE) {
|
|
if (authEnum == AuthEnum.OFF_LINE) {
|
|
if (Objects.isNull(file)) {
|
|
if (Objects.isNull(file)) {
|
|
tsAuthList.add(new TSAuth(o.getId(), solarProperties.getLicense(), authEnum, appInfo.getControl().getExpireTime()));
|
|
tsAuthList.add(new TSAuth(o.getId(), solarProperties.getLicense(), authEnum, appInfo.getControl().getExpireTime()));
|
|
@@ -187,7 +179,6 @@ public class AuthInfoServiceImpl implements AuthInfoService {
|
|
} else {
|
|
} else {
|
|
tsAuthList.add(new TSAuth(o.getId(), solarProperties.getAccessKey(), solarProperties.getAccessSecret(), authEnum, appInfo.getControl().getExpireTime()));
|
|
tsAuthList.add(new TSAuth(o.getId(), solarProperties.getAccessKey(), solarProperties.getAccessSecret(), authEnum, appInfo.getControl().getExpireTime()));
|
|
}
|
|
}
|
|
- cacheService.removeAuthInfoCache(o.getCode());
|
|
|
|
|
|
|
|
QueryWrapper<TBOrg> tbOrgQueryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<TBOrg> tbOrgQueryWrapper = new QueryWrapper<>();
|
|
tbOrgQueryWrapper.lambda().eq(TBOrg::getCode, o.getCode());
|
|
tbOrgQueryWrapper.lambda().eq(TBOrg::getCode, o.getCode());
|
|
@@ -225,24 +216,44 @@ public class AuthInfoServiceImpl implements AuthInfoService {
|
|
} else {
|
|
} else {
|
|
tbOrg.setAccessKey(o.getAccessKey());
|
|
tbOrg.setAccessKey(o.getAccessKey());
|
|
tbOrg.setAccessSecret(o.getAccessSecret());
|
|
tbOrg.setAccessSecret(o.getAccessSecret());
|
|
- tbOrg.setLogo(o.getLogoUrl());
|
|
|
|
- tbOrgService.saveOrUpdate(tbOrg);
|
|
|
|
- cacheService.updateOrgCache(tbOrg.getId());
|
|
|
|
- cacheService.updateOrgCodeCache(tbOrg.getCode());
|
|
|
|
|
|
+ tbOrg.setLogo(Objects.nonNull(o.getLogoUrl()) ? o.getLogoUrl() : tbOrg.getLogo());
|
|
|
|
+ tbOrgSet.add(tbOrg);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if (!CollectionUtils.isEmpty(tsAuthList) && !CollectionUtils.isEmpty(orgIdsSet)) {
|
|
|
|
- QueryWrapper<TSAuth> tsAuthQueryWrapper = new QueryWrapper<>();
|
|
|
|
- tsAuthQueryWrapper.lambda().in(TSAuth::getSchoolId, orgIdsSet);
|
|
|
|
- tsAuthService.remove(tsAuthQueryWrapper);
|
|
|
|
- tsAuthMapper.insertBatch(tsAuthList);
|
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(tsAuthList) && !CollectionUtils.isEmpty(orgCodesMap)) {
|
|
|
|
+ tsAuthService.remove(new QueryWrapper<TSAuth>().lambda().ge(TSAuth::getId, 0L));
|
|
|
|
+ tsAuthService.saveOrUpdateBatch(tsAuthList);
|
|
|
|
|
|
if (!CollectionUtils.isEmpty(tbOrgSet)) {
|
|
if (!CollectionUtils.isEmpty(tbOrgSet)) {
|
|
|
|
+ tbOrgService.saveOrUpdateBatch(tbOrgSet);
|
|
cacheService.removeOrgIdCache();
|
|
cacheService.removeOrgIdCache();
|
|
cacheService.removeOrgCodeCache();
|
|
cacheService.removeOrgCodeCache();
|
|
- tbOrgMapper.insertBatch(tbOrgSet);
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ AuthInfoService authInfoService = SpringContextHolder.getBean(AuthInfoService.class);
|
|
|
|
+ authInfoService.updateSchoolEnable(orgCodesMap);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 更新学校启用/禁用
|
|
|
|
+ *
|
|
|
|
+ * @param orgCodesMap
|
|
|
|
+ */
|
|
|
|
+ public void updateSchoolEnable(Map<String, String> orgCodesMap) {
|
|
|
|
+ List<TBOrg> tbOrgList = tbOrgService.list();
|
|
|
|
+ if (!CollectionUtils.isEmpty(tbOrgList)) {
|
|
|
|
+ for (TBOrg t : tbOrgList) {
|
|
|
|
+ if (orgCodesMap.containsKey(t.getCode())) {
|
|
|
|
+ t.setEnable(1);
|
|
|
|
+ } else {
|
|
|
|
+ t.setEnable(0);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ tbOrgService.saveOrUpdateBatch(tbOrgList);
|
|
|
|
+ cacheService.removeOrgIdCache();
|
|
|
|
+ cacheService.removeOrgCodeCache();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|