|
@@ -5,6 +5,7 @@ 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.teachcloud.common.bean.result.AppInfoResult;
|
|
import com.qmth.teachcloud.common.config.DictionaryConfig;
|
|
import com.qmth.teachcloud.common.config.DictionaryConfig;
|
|
import com.qmth.teachcloud.common.contant.SpringContextHolder;
|
|
import com.qmth.teachcloud.common.contant.SpringContextHolder;
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
@@ -86,15 +87,15 @@ public class AuthInfoServiceImpl implements AuthInfoService {
|
|
&& !Objects.equals(solarProperties.getAccessSecret().trim(), "")) {//在线激活
|
|
&& !Objects.equals(solarProperties.getAccessSecret().trim(), "")) {//在线激活
|
|
// this.authError("不支持在线激活,请联系系统管理员!");
|
|
// this.authError("不支持在线激活,请联系系统管理员!");
|
|
log.error("不支持在线激活,请联系系统管理员!");
|
|
log.error("不支持在线激活,请联系系统管理员!");
|
|
- licenseForDb();
|
|
|
|
|
|
+ licenseForDb(AuthEnum.OFF_LINE);
|
|
} else if (Objects.nonNull(solarProperties.getLicense())
|
|
} else if (Objects.nonNull(solarProperties.getLicense())
|
|
&& !Objects.equals(solarProperties.getLicense().trim(), "")) {//离线激活
|
|
&& !Objects.equals(solarProperties.getLicense().trim(), "")) {//离线激活
|
|
// this.authError("不支持离线激活,请联系系统管理员!");
|
|
// this.authError("不支持离线激活,请联系系统管理员!");
|
|
log.error("不支持离线激活,请联系系统管理员!");
|
|
log.error("不支持离线激活,请联系系统管理员!");
|
|
- licenseForDb();
|
|
|
|
|
|
+ licenseForDb(AuthEnum.OFF_LINE);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- licenseForDb();
|
|
|
|
|
|
+ licenseForDb(AuthEnum.OFF_LINE);
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.error(SystemConstant.LOG_ERROR, e);
|
|
log.error(SystemConstant.LOG_ERROR, e);
|
|
@@ -102,6 +103,21 @@ public class AuthInfoServiceImpl implements AuthInfoService {
|
|
return appInfo;
|
|
return appInfo;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 授权信息初始化
|
|
|
|
+ *
|
|
|
|
+ * @param appInfo
|
|
|
|
+ * @param accessKey
|
|
|
|
+ * @param accessSecret
|
|
|
|
+ * @return
|
|
|
|
+ * @throws Exception
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public AppInfo appInfoInit(AppInfo appInfo, String accessKey, String accessSecret) throws Exception {
|
|
|
|
+ authInfoService.saveAuthInfo(appInfo, AuthEnum.ON_LINE, null);
|
|
|
|
+ return appInfo;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* app是否过期
|
|
* app是否过期
|
|
*
|
|
*
|
|
@@ -138,13 +154,19 @@ public class AuthInfoServiceImpl implements AuthInfoService {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public Long selectAuthInfo() {
|
|
|
|
|
|
+ public AppInfoResult selectAuthInfo() {
|
|
Long expireTime = null;
|
|
Long expireTime = null;
|
|
AppInfo appInfo = solarService.getAppInfo();
|
|
AppInfo appInfo = solarService.getAppInfo();
|
|
if (Objects.nonNull(appInfo) && Objects.nonNull(appInfo.getControl())) {
|
|
if (Objects.nonNull(appInfo) && Objects.nonNull(appInfo.getControl())) {
|
|
expireTime = Objects.nonNull(appInfo.getControl().getExpireTime()) ? appInfo.getControl().getExpireTime() : -1;
|
|
expireTime = Objects.nonNull(appInfo.getControl().getExpireTime()) ? appInfo.getControl().getExpireTime() : -1;
|
|
}
|
|
}
|
|
- return expireTime;
|
|
|
|
|
|
+ String accessKey = solarProperties.getAccessKey();
|
|
|
|
+ String accessSecret = solarProperties.getAccessSecret();
|
|
|
|
+ AuthEnum authEnum = AuthEnum.OFF_LINE;
|
|
|
|
+ if (Objects.nonNull(accessKey) && Objects.nonNull(accessSecret)) {
|
|
|
|
+ authEnum = AuthEnum.ON_LINE;
|
|
|
|
+ }
|
|
|
|
+ return new AppInfoResult(expireTime, accessKey, accessSecret, authEnum);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -294,16 +316,27 @@ public class AuthInfoServiceImpl implements AuthInfoService {
|
|
/**
|
|
/**
|
|
* 强制从db更新激活信息
|
|
* 强制从db更新激活信息
|
|
*
|
|
*
|
|
|
|
+ * @param authEnum
|
|
* @throws Exception
|
|
* @throws Exception
|
|
*/
|
|
*/
|
|
- public void licenseForDb() throws Exception {
|
|
|
|
|
|
+ public void licenseForDb(AuthEnum authEnum) throws Exception {
|
|
QueryWrapper<TSAuth> tsAuthQueryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<TSAuth> tsAuthQueryWrapper = new QueryWrapper<>();
|
|
tsAuthQueryWrapper.lambda().isNotNull(TSAuth::getFile);
|
|
tsAuthQueryWrapper.lambda().isNotNull(TSAuth::getFile);
|
|
List<TSAuth> tsAuthList = tsAuthService.list(tsAuthQueryWrapper);
|
|
List<TSAuth> tsAuthList = tsAuthService.list(tsAuthQueryWrapper);
|
|
if (!CollectionUtils.isEmpty(tsAuthList)) {
|
|
if (!CollectionUtils.isEmpty(tsAuthList)) {
|
|
for (TSAuth t : tsAuthList) {
|
|
for (TSAuth t : tsAuthList) {
|
|
AppInfo appInfo = solarService.update(t.getFile());
|
|
AppInfo appInfo = solarService.update(t.getFile());
|
|
- authInfoService.saveAuthInfo(appInfo, AuthEnum.OFF_LINE, t.getFile());
|
|
|
|
|
|
+ authInfoService.saveAuthInfo(appInfo, authEnum, t.getFile());
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ tsAuthQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ tsAuthQueryWrapper.lambda().isNotNull(TSAuth::getAccessKey).isNotNull(TSAuth::getAccessSecret);
|
|
|
|
+ tsAuthList = tsAuthService.list(tsAuthQueryWrapper);
|
|
|
|
+ if (!CollectionUtils.isEmpty(tsAuthList)) {
|
|
|
|
+ for (TSAuth t : tsAuthList) {
|
|
|
|
+ AppInfo appInfo = solarService.update(t.getAccessKey(), t.getAccessSecret());
|
|
|
|
+ authInfoService.saveAuthInfo(appInfo, AuthEnum.ON_LINE, null);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|