|
@@ -58,10 +58,20 @@ public class AuthInfoServiceImpl implements AuthInfoService {
|
|
|
&& !Objects.equals(solarProperties.getAccessKey().trim(), "")
|
|
|
&& Objects.nonNull(solarProperties.getAccessSecret())
|
|
|
&& !Objects.equals(solarProperties.getAccessSecret().trim(), "")) {//在线激活
|
|
|
- saveAuthInfo(appInfo, AuthEnum.ON_LINE);
|
|
|
+ saveAuthInfo(appInfo, AuthEnum.ON_LINE, null);
|
|
|
} else if (Objects.nonNull(solarProperties.getLicense())
|
|
|
&& !Objects.equals(solarProperties.getLicense().trim(), "")) {//离线激活
|
|
|
- saveAuthInfo(appInfo, AuthEnum.OFF_LINE);
|
|
|
+ saveAuthInfo(appInfo, AuthEnum.OFF_LINE, null);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ QueryWrapper<TSAuth> tsAuthQueryWrapper = new QueryWrapper<>();
|
|
|
+ tsAuthQueryWrapper.lambda().isNotNull(TSAuth::getFile);
|
|
|
+ List<TSAuth> tsAuthList = tsAuthService.list(tsAuthQueryWrapper);
|
|
|
+ if (Objects.nonNull(tsAuthList) && tsAuthList.size() > 0) {
|
|
|
+ for (TSAuth t : tsAuthList) {
|
|
|
+ appInfo = solarService.update(t.getFile());
|
|
|
+ saveAuthInfo(appInfo, AuthEnum.OFF_LINE, t.getFile());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
@@ -73,19 +83,33 @@ public class AuthInfoServiceImpl implements AuthInfoService {
|
|
|
/**
|
|
|
* app是否过期
|
|
|
*
|
|
|
- * @param schoolId
|
|
|
+ * @param code
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public void appHasExpired(Long schoolId) {
|
|
|
- if (Objects.nonNull(schoolId)) {
|
|
|
- AuthOrgInfoDto authOrgInfoDto = commonCacheService.authInfoCache(schoolId);
|
|
|
+ public void appHasExpired(String code) {
|
|
|
+ if (Objects.nonNull(code)) {
|
|
|
+ AuthOrgInfoDto authOrgInfoDto = commonCacheService.authInfoCache(code);
|
|
|
if (Objects.isNull(authOrgInfoDto) || (Objects.nonNull(authOrgInfoDto) && authOrgInfoDto.getControl().hasExpired())) {
|
|
|
throw ExceptionResultEnum.AUTH_INFO_ERROR.exception();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 离线激活
|
|
|
+ *
|
|
|
+ * @param licenseData
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void updateLicense(byte[] licenseData) {
|
|
|
+ AppInfo appInfo = solarService.update(licenseData);
|
|
|
+ if (Objects.isNull(appInfo)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("激活失败");
|
|
|
+ }
|
|
|
+ saveAuthInfo(appInfo, AuthEnum.OFF_LINE, licenseData);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 保存鉴权信息
|
|
|
*
|
|
@@ -93,7 +117,7 @@ public class AuthInfoServiceImpl implements AuthInfoService {
|
|
|
* @param authEnum
|
|
|
*/
|
|
|
@Transactional
|
|
|
- protected void saveAuthInfo(AppInfo appInfo, AuthEnum authEnum) {
|
|
|
+ protected void saveAuthInfo(AppInfo appInfo, AuthEnum authEnum, byte[] file) {
|
|
|
List<OrgInfo> orgInfoList = solarService.getOrgList();
|
|
|
List<TSAuth> tsAuthList = null;
|
|
|
Set<Long> orgIdsSet = null;
|
|
@@ -104,11 +128,15 @@ public class AuthInfoServiceImpl implements AuthInfoService {
|
|
|
for (OrgInfo o : orgInfoList) {
|
|
|
orgIdsSet.add(o.getId());
|
|
|
if (authEnum == AuthEnum.OFF_LINE) {
|
|
|
- tsAuthList.add(new TSAuth(o.getId(), solarProperties.getLicense(), authEnum, appInfo.getControl().getExpireTime()));
|
|
|
+ if (Objects.isNull(file)) {
|
|
|
+ tsAuthList.add(new TSAuth(o.getId(), solarProperties.getLicense(), authEnum, appInfo.getControl().getExpireTime()));
|
|
|
+ } else {
|
|
|
+ tsAuthList.add(new TSAuth(o.getId(), file, authEnum, appInfo.getControl().getExpireTime()));
|
|
|
+ }
|
|
|
} else {
|
|
|
tsAuthList.add(new TSAuth(o.getId(), solarProperties.getAccessKey(), solarProperties.getAccessSecret(), authEnum, appInfo.getControl().getExpireTime()));
|
|
|
}
|
|
|
- commonCacheService.updateAuthInfoCache(o.getId());
|
|
|
+ commonCacheService.updateAuthInfoCache(o.getCode());
|
|
|
}
|
|
|
if (Objects.nonNull(tsAuthList) && tsAuthList.size() > 0 && Objects.nonNull(orgIdsSet) && orgIdsSet.size() > 0) {
|
|
|
QueryWrapper<TSAuth> tsAuthQueryWrapper = new QueryWrapper<>();
|