forked from github/dataease
feat: license 提醒: 无license,不提醒;过期以及无效,提醒
This commit is contained in:
parent
688a59d597
commit
b4376a079e
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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:
|
||||
|
@ -32,7 +32,6 @@ const actions = {
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default {
|
||||
|
Loading…
Reference in New Issue
Block a user