提交 b4376a07 authored 作者: taojinlong's avatar taojinlong

feat: license 提醒: 无license,不提醒;过期以及无效,提醒

上级 688a59d5
...@@ -41,18 +41,6 @@ public class DefaultLicenseService { ...@@ -41,18 +41,6 @@ public class DefaultLicenseService {
f2CLicenseResponse.setMessage("The license is unavailable for this product."); f2CLicenseResponse.setMessage("The license is unavailable for this product.");
return f2CLicenseResponse; return f2CLicenseResponse;
} }
// 检查每个模块的PLU限制
// if(!Arrays.asList(NO_PLU_LIMIT_MODULES).contains(moduleId)){
// AuthorizationUnit authorizationUnit= CommonBeanFactory.getBean(AuthorizationUnit.class);
// try{
// authorizationUnit.calculateAssets(f2CLicenseResponse.getLicense().getCount());
// return f2CLicenseResponse;
// }catch (Exception e){
// f2CLicenseResponse.setStatus(F2CLicenseResponse.Status.invalid);
// f2CLicenseResponse.setMessage(e.getMessage());
// }
// }
return f2CLicenseResponse; return f2CLicenseResponse;
}catch (Exception e){ }catch (Exception e){
return F2CLicenseResponse.invalid(e.getMessage()); return F2CLicenseResponse.invalid(e.getMessage());
...@@ -79,16 +67,10 @@ public class DefaultLicenseService { ...@@ -79,16 +67,10 @@ public class DefaultLicenseService {
License license = readLicense(); License license = readLicense();
return validateLicense(product, license.getLicense()); return validateLicense(product, license.getLicense());
} catch (Exception e) { } catch (Exception e) {
return F2CLicenseResponse.invalid(e.getMessage()); return F2CLicenseResponse.noRecord();
} }
} }
public void validateF2cLicense(){
License license = readLicense();
F2CLicenseResponse f2CLicenseResponse = validateLicense(product, license.getLicense());
writeLicense(license.getLicense(), f2CLicenseResponse);
}
public F2CLicenseResponse updateLicense(String product, String licenseKey) { public F2CLicenseResponse updateLicense(String product, String licenseKey) {
// 验证license // 验证license
F2CLicenseResponse response = validateLicense(product, licenseKey); F2CLicenseResponse response = validateLicense(product, licenseKey);
...@@ -104,12 +86,10 @@ public class DefaultLicenseService { ...@@ -104,12 +86,10 @@ public class DefaultLicenseService {
public License readLicense() { public License readLicense() {
License license = innerLicenseService.getLicense(LICENSE_ID); License license = innerLicenseService.getLicense(LICENSE_ID);
if (license == null) { if (license == null) {
/*DEException.throwException(Translator.get("i18n_no_license_record"));*/
DEException.throwException("i18n_no_license_record"); DEException.throwException("i18n_no_license_record");
} }
if (StringUtils.isBlank(license.getLicense())) { if (StringUtils.isBlank(license.getLicense())) {
DEException.throwException("i18n_license_is_empty"); DEException.throwException("i18n_license_is_empty");
//F2CException.throwException(Translator.get("i18n_license_is_empty"));
} }
return license; return license;
} }
...@@ -117,9 +97,7 @@ public class DefaultLicenseService { ...@@ -117,9 +97,7 @@ public class DefaultLicenseService {
// 创建或更新License // 创建或更新License
private void writeLicense(String licenseKey, F2CLicenseResponse response) { private void writeLicense(String licenseKey, F2CLicenseResponse response) {
if (StringUtils.isBlank(licenseKey)) { if (StringUtils.isBlank(licenseKey)) {
DEException.throwException("i18n_license_is_empty"); DEException.throwException("i18n_license_is_empty");
} }
License license = new License(); License license = new License();
license.setId(LICENSE_ID); license.setId(LICENSE_ID);
......
...@@ -31,6 +31,7 @@ public class F2CLicenseResponse { ...@@ -31,6 +31,7 @@ public class F2CLicenseResponse {
} }
public static enum Status { public static enum Status {
no_record,
valid, valid,
invalid, invalid,
expired; expired;
...@@ -43,4 +44,12 @@ public class F2CLicenseResponse { ...@@ -43,4 +44,12 @@ public class F2CLicenseResponse {
f2CLicenseResponse.setMessage(a); f2CLicenseResponse.setMessage(a);
return f2CLicenseResponse; return f2CLicenseResponse;
} }
public static F2CLicenseResponse noRecord() {
F2CLicenseResponse f2CLicenseResponse = new F2CLicenseResponse();
f2CLicenseResponse.setStatus(Status.no_record);
f2CLicenseResponse.setLicense(null);
f2CLicenseResponse.setMessage("No license record");
return f2CLicenseResponse;
}
} }
...@@ -2,6 +2,7 @@ package io.dataease.controller; ...@@ -2,6 +2,7 @@ package io.dataease.controller;
import com.google.gson.Gson;
import io.dataease.commons.license.DefaultLicenseService; import io.dataease.commons.license.DefaultLicenseService;
import io.dataease.commons.license.F2CLicenseResponse; import io.dataease.commons.license.F2CLicenseResponse;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
...@@ -22,16 +23,14 @@ public class LicenseController { ...@@ -22,16 +23,14 @@ public class LicenseController {
@GetMapping(value = "anonymous/license/validate") @GetMapping(value = "anonymous/license/validate")
public ResultHolder validateLicense() throws Exception { public ResultHolder validateLicense() throws Exception {
if (!need_validate_lic) { // if (!need_validate_lic) {
return ResultHolder.success(null); // return ResultHolder.success(null);
} // }
/* License license = defaultLicenseService.readLicense();
if(StringUtils.isEmpty(license.getF2cLicense())){
throw new Exception("Invalid License.");
}
F2CLicenseResponse f2CLicenseResponse = new Gson().fromJson(license.getF2cLicense(), F2CLicenseResponse.class);*/
F2CLicenseResponse f2CLicenseResponse = defaultLicenseService.validateLicense(); F2CLicenseResponse f2CLicenseResponse = defaultLicenseService.validateLicense();
System.out.println(new Gson().toJson(f2CLicenseResponse));
switch (f2CLicenseResponse.getStatus()) { switch (f2CLicenseResponse.getStatus()) {
case no_record:
return ResultHolder.success(f2CLicenseResponse);
case valid: case valid:
return ResultHolder.success(null); return ResultHolder.success(null);
case expired: case expired:
......
...@@ -32,7 +32,6 @@ const actions = { ...@@ -32,7 +32,6 @@ const actions = {
}) })
}) })
} }
} }
export default { export default {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论