diff --git a/backend/src/main/java/io/dataease/commons/license/DefaultLicenseService.java b/backend/src/main/java/io/dataease/commons/license/DefaultLicenseService.java index 8f96a8463b..07a651d3b3 100644 --- a/backend/src/main/java/io/dataease/commons/license/DefaultLicenseService.java +++ b/backend/src/main/java/io/dataease/commons/license/DefaultLicenseService.java @@ -41,18 +41,6 @@ public class DefaultLicenseService { f2CLicenseResponse.setMessage("The license is unavailable for this product."); 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; }catch (Exception e){ return F2CLicenseResponse.invalid(e.getMessage()); @@ -79,16 +67,10 @@ public class DefaultLicenseService { License license = readLicense(); return validateLicense(product, license.getLicense()); } 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) { // 验证license F2CLicenseResponse response = validateLicense(product, licenseKey); @@ -104,12 +86,10 @@ public class DefaultLicenseService { public License readLicense() { License license = innerLicenseService.getLicense(LICENSE_ID); if (license == null) { - /*DEException.throwException(Translator.get("i18n_no_license_record"));*/ DEException.throwException("i18n_no_license_record"); } if (StringUtils.isBlank(license.getLicense())) { DEException.throwException("i18n_license_is_empty"); - //F2CException.throwException(Translator.get("i18n_license_is_empty")); } return license; } @@ -117,9 +97,7 @@ public class DefaultLicenseService { // 创建或更新License private void writeLicense(String licenseKey, F2CLicenseResponse response) { if (StringUtils.isBlank(licenseKey)) { - DEException.throwException("i18n_license_is_empty"); - } License license = new License(); license.setId(LICENSE_ID); diff --git a/backend/src/main/java/io/dataease/commons/license/F2CLicenseResponse.java b/backend/src/main/java/io/dataease/commons/license/F2CLicenseResponse.java index 529c97d609..632a9bfcc3 100644 --- a/backend/src/main/java/io/dataease/commons/license/F2CLicenseResponse.java +++ b/backend/src/main/java/io/dataease/commons/license/F2CLicenseResponse.java @@ -31,6 +31,7 @@ public class F2CLicenseResponse { } public static enum Status { + no_record, valid, invalid, expired; @@ -43,4 +44,12 @@ public class F2CLicenseResponse { f2CLicenseResponse.setMessage(a); 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; + } } diff --git a/backend/src/main/java/io/dataease/controller/LicenseController.java b/backend/src/main/java/io/dataease/controller/LicenseController.java index f56e19d51c..4071f6b811 100644 --- a/backend/src/main/java/io/dataease/controller/LicenseController.java +++ b/backend/src/main/java/io/dataease/controller/LicenseController.java @@ -2,6 +2,7 @@ package io.dataease.controller; +import com.google.gson.Gson; import io.dataease.commons.license.DefaultLicenseService; import io.dataease.commons.license.F2CLicenseResponse; import org.springframework.beans.factory.annotation.Value; @@ -22,16 +23,14 @@ public class LicenseController { @GetMapping(value = "anonymous/license/validate") public ResultHolder validateLicense() throws Exception { - if (!need_validate_lic) { - 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);*/ +// if (!need_validate_lic) { +// return ResultHolder.success(null); +// } F2CLicenseResponse f2CLicenseResponse = defaultLicenseService.validateLicense(); + System.out.println(new Gson().toJson(f2CLicenseResponse)); switch (f2CLicenseResponse.getStatus()) { + case no_record: + return ResultHolder.success(f2CLicenseResponse); case valid: return ResultHolder.success(null); case expired: diff --git a/frontend/src/store/modules/lic.js b/frontend/src/store/modules/lic.js index 64f5ee8254..e3380eb4ba 100644 --- a/frontend/src/store/modules/lic.js +++ b/frontend/src/store/modules/lic.js @@ -32,7 +32,6 @@ const actions = { }) }) } - } export default {