diff --git a/backend/src/main/java/io/dataease/controller/LicenseController.java b/backend/src/main/java/io/dataease/controller/LicenseController.java index 4071f6b811..160dc80d1b 100644 --- a/backend/src/main/java/io/dataease/controller/LicenseController.java +++ b/backend/src/main/java/io/dataease/controller/LicenseController.java @@ -23,9 +23,9 @@ public class LicenseController { @GetMapping(value = "anonymous/license/validate") public ResultHolder validateLicense() throws Exception { -// if (!need_validate_lic) { -// return ResultHolder.success(null); -// } + if (!need_validate_lic) { + return ResultHolder.success(null); + } F2CLicenseResponse f2CLicenseResponse = defaultLicenseService.validateLicense(); System.out.println(new Gson().toJson(f2CLicenseResponse)); switch (f2CLicenseResponse.getStatus()) { diff --git a/backend/src/main/java/io/dataease/plugins/loader/MyScanner.java b/backend/src/main/java/io/dataease/plugins/loader/MyScanner.java index 8fbeada3fb..fa099f7f27 100644 --- a/backend/src/main/java/io/dataease/plugins/loader/MyScanner.java +++ b/backend/src/main/java/io/dataease/plugins/loader/MyScanner.java @@ -8,20 +8,16 @@ import org.springframework.beans.factory.support.BeanDefinitionRegistry; import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor; import org.springframework.stereotype.Component; -import javax.annotation.Resource; - @Component public class MyScanner implements BeanDefinitionRegistryPostProcessor { - @Resource - private MapperScannerConfigurer mapperScannerConfigurer; + private BeanDefinitionRegistry beanDefinitionRegistry; @Override public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry beanDefinitionRegistry) throws BeansException { this.beanDefinitionRegistry = beanDefinitionRegistry; - System.out.println("-----"); } @Override @@ -30,9 +26,7 @@ public class MyScanner implements BeanDefinitionRegistryPostProcessor { } public void scanner() { - if (null == mapperScannerConfigurer){ - mapperScannerConfigurer = SpringContextUtil.getBean(MapperScannerConfigurer.class); - } + MapperScannerConfigurer mapperScannerConfigurer = SpringContextUtil.getBean(MapperScannerConfigurer.class); mapperScannerConfigurer.postProcessBeanDefinitionRegistry(this.beanDefinitionRegistry); } diff --git a/backend/src/main/java/io/dataease/plugins/util/PluginUtils.java b/backend/src/main/java/io/dataease/plugins/util/PluginUtils.java index b8bcb043a7..52c422b870 100644 --- a/backend/src/main/java/io/dataease/plugins/util/PluginUtils.java +++ b/backend/src/main/java/io/dataease/plugins/util/PluginUtils.java @@ -1,21 +1,51 @@ package io.dataease.plugins.util; +import io.dataease.commons.license.DefaultLicenseService; +import io.dataease.commons.license.F2CLicenseResponse; import io.dataease.plugins.common.dto.PluginSysMenu; import io.dataease.plugins.common.service.PluginMenuService; import io.dataease.plugins.config.SpringContextUtil; - +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Component; +import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.stream.Collectors; +@Component public class PluginUtils { + + + private static DefaultLicenseService defaultLicenseService; + + @Autowired + public void setDefaultLicenseService(DefaultLicenseService defaultLicenseService) { + PluginUtils.defaultLicenseService = defaultLicenseService; + } + public static List pluginMenus() { + F2CLicenseResponse f2CLicenseResponse = currentLic(); + if (f2CLicenseResponse.getStatus() != F2CLicenseResponse.Status.valid) + return new ArrayList<>(); Map pluginMenuServiceMap = SpringContextUtil.getApplicationContext().getBeansOfType(PluginMenuService.class); List menus = pluginMenuServiceMap.values().stream().flatMap(item -> item.menus().stream()).collect(Collectors.toList()); return menus; } + public static F2CLicenseResponse currentLic() { + Environment environment = SpringContextUtil.getBean(Environment.class); + Boolean need_validate_lic = environment.getProperty("dataease.need_validate_lic", Boolean.class, true); + if (!need_validate_lic) { + F2CLicenseResponse f2CLicenseResponse = new F2CLicenseResponse(); + f2CLicenseResponse.setStatus(F2CLicenseResponse.Status.valid); + return f2CLicenseResponse; + } + F2CLicenseResponse f2CLicenseResponse = defaultLicenseService.validateLicense(); + return f2CLicenseResponse; + } + diff --git a/frontend/src/layout/components/Licbar.vue b/frontend/src/layout/components/Licbar.vue index e18e473f6a..96ffb1873c 100644 --- a/frontend/src/layout/components/Licbar.vue +++ b/frontend/src/layout/components/Licbar.vue @@ -1,5 +1,5 @@ @@ -20,9 +20,12 @@ export default { theme() { return this.$store.state.settings.theme }, - licstatus() { + licValidate() { return this.$store.state.lic.validate }, + licStatus() { + return this.$store.state.lic.licStatus || '' + }, licMsg() { return this.$store.state.lic.licMsg ? ('license.' + this.$store.state.lic.licMsg) : null } diff --git a/frontend/src/permission.js b/frontend/src/permission.js index 309e89e800..2fae911066 100644 --- a/frontend/src/permission.js +++ b/frontend/src/permission.js @@ -152,12 +152,8 @@ const hasPermission = (router, user_permissions) => { } return true } -const xpackMenuNames = ['system-param', 'system-plugin'] const filterLic = (router) => { - if (xpackMenuNames.some(name => name === router.name) && !store.getters.validate) { - return false - } - return true + return !router.isPlugin || store.getters.validate } router.afterEach(() => { // finish progress bar diff --git a/frontend/src/store/modules/lic.js b/frontend/src/store/modules/lic.js index e3380eb4ba..96aaa420d0 100644 --- a/frontend/src/store/modules/lic.js +++ b/frontend/src/store/modules/lic.js @@ -1,6 +1,7 @@ import { validateLic } from '@/api/system/lic' const state = { validate: true, + licStatus: null, licMsg: null } @@ -10,6 +11,9 @@ const mutations = { }, SET_LIC_MSG: (state, msg) => { state.licMsg = msg + }, + SET_LIC_STATUS: (state, data) => { + state.licStatus = data } } @@ -22,8 +26,15 @@ const actions = { return new Promise((resolve, reject) => { validateLic().then(response => { const { data } = response - commit('SET_VALIDATE', true) - commit('SET_LIC_MSG', null) + if (data && data.status && data.status === 'no_record') { + commit('SET_VALIDATE', false) + commit('SET_LIC_MSG', data.message) + commit('SET_LIC_STATUS', data.status) + } else { + commit('SET_VALIDATE', true) + commit('SET_LIC_MSG', null) + } + resolve(data) }).catch(error => { commit('SET_VALIDATE', false)