diff --git a/backend/src/main/java/io/dataease/auth/server/AuthServer.java b/backend/src/main/java/io/dataease/auth/server/AuthServer.java index 56211cab1d..f340ba381c 100644 --- a/backend/src/main/java/io/dataease/auth/server/AuthServer.java +++ b/backend/src/main/java/io/dataease/auth/server/AuthServer.java @@ -13,6 +13,9 @@ import io.dataease.auth.util.RsaUtil; import io.dataease.commons.utils.BeanUtils; import io.dataease.commons.utils.CodingUtil; import io.dataease.commons.utils.ServletUtils; +/*import io.dataease.plugins.config.SpringContextUtil; +import io.dataease.plugins.xpack.dto.response.SysSettingDto; +import io.dataease.plugins.xpack.service.DePluginXpackService;*/ import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.apache.shiro.SecurityUtils; @@ -105,6 +108,14 @@ public class AuthServer implements AuthApi { SysUserEntity userById = authUserService.getUserById(4L); String nickName = userById.getNickName(); System.out.println(nickName); + /* Map beansOfType = SpringContextUtil.getApplicationContext().getBeansOfType(DePluginXpackService.class); + for (Map.Entry entry : beansOfType.entrySet()) { + Object key = entry.getKey(); + DePluginXpackService value = (DePluginXpackService)entry.getValue(); + List sysSettingDtos = value.systemSettings(); + String name = entry.getValue().getClass().getName(); + System.out.println("key: "+ key + ", value: "+ name); + }*/ return "apple"; } } diff --git a/backend/src/main/java/io/dataease/auth/service/impl/ShiroServiceImpl.java b/backend/src/main/java/io/dataease/auth/service/impl/ShiroServiceImpl.java index 88f361fe18..97df62a17d 100644 --- a/backend/src/main/java/io/dataease/auth/service/impl/ShiroServiceImpl.java +++ b/backend/src/main/java/io/dataease/auth/service/impl/ShiroServiceImpl.java @@ -46,7 +46,12 @@ public class ShiroServiceImpl implements ShiroService { filterChainDefinitionMap.put("/chart/view/getData/**", ANON); + filterChainDefinitionMap.put("/system/ui/**", ANON); + filterChainDefinitionMap.put("/PluginDemo.js", ANON); + filterChainDefinitionMap.put("/DeXPack.js", ANON); + filterChainDefinitionMap.put("/api/auth/test", ANON); + filterChainDefinitionMap.put("/api/xpack/test", ANON); filterChainDefinitionMap.put("/api/auth/login", ANON); filterChainDefinitionMap.put("/api/auth/validateName", ANON); diff --git a/backend/src/main/java/io/dataease/base/domain/MyPlugin.java b/backend/src/main/java/io/dataease/base/domain/MyPlugin.java new file mode 100644 index 0000000000..2dd3204176 --- /dev/null +++ b/backend/src/main/java/io/dataease/base/domain/MyPlugin.java @@ -0,0 +1,35 @@ +package io.dataease.base.domain; + +import java.io.Serializable; +import lombok.Data; + +@Data +public class MyPlugin implements Serializable { + private Long pluginId; + + private String name; + + private Boolean free; + + private Integer cost; + + private String descript; + + private String version; + + private Integer installType; + + private String creator; + + private Long releaseTime; + + private Long installTime; + + private String moduleName; + + private String beanName; + + private String icon; + + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/backend/src/main/java/io/dataease/base/domain/MyPluginExample.java b/backend/src/main/java/io/dataease/base/domain/MyPluginExample.java new file mode 100644 index 0000000000..c723bbeee0 --- /dev/null +++ b/backend/src/main/java/io/dataease/base/domain/MyPluginExample.java @@ -0,0 +1,1050 @@ +package io.dataease.base.domain; + +import java.util.ArrayList; +import java.util.List; + +public class MyPluginExample { + protected String orderByClause; + + protected boolean distinct; + + protected List oredCriteria; + + public MyPluginExample() { + oredCriteria = new ArrayList(); + } + + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + public String getOrderByClause() { + return orderByClause; + } + + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + public boolean isDistinct() { + return distinct; + } + + public List getOredCriteria() { + return oredCriteria; + } + + public void or(Criteria criteria) { + oredCriteria.add(criteria); + } + + public Criteria or() { + Criteria criteria = createCriteriaInternal(); + oredCriteria.add(criteria); + return criteria; + } + + public Criteria createCriteria() { + Criteria criteria = createCriteriaInternal(); + if (oredCriteria.size() == 0) { + oredCriteria.add(criteria); + } + return criteria; + } + + protected Criteria createCriteriaInternal() { + Criteria criteria = new Criteria(); + return criteria; + } + + public void clear() { + oredCriteria.clear(); + orderByClause = null; + distinct = false; + } + + protected abstract static class GeneratedCriteria { + protected List criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List getCriteria() { + return criteria; + } + + protected void addCriterion(String condition) { + if (condition == null) { + throw new RuntimeException("Value for condition cannot be null"); + } + criteria.add(new Criterion(condition)); + } + + protected void addCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value)); + } + + protected void addCriterion(String condition, Object value1, Object value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value1, value2)); + } + + public Criteria andPluginIdIsNull() { + addCriterion("plugin_id is null"); + return (Criteria) this; + } + + public Criteria andPluginIdIsNotNull() { + addCriterion("plugin_id is not null"); + return (Criteria) this; + } + + public Criteria andPluginIdEqualTo(Long value) { + addCriterion("plugin_id =", value, "pluginId"); + return (Criteria) this; + } + + public Criteria andPluginIdNotEqualTo(Long value) { + addCriterion("plugin_id <>", value, "pluginId"); + return (Criteria) this; + } + + public Criteria andPluginIdGreaterThan(Long value) { + addCriterion("plugin_id >", value, "pluginId"); + return (Criteria) this; + } + + public Criteria andPluginIdGreaterThanOrEqualTo(Long value) { + addCriterion("plugin_id >=", value, "pluginId"); + return (Criteria) this; + } + + public Criteria andPluginIdLessThan(Long value) { + addCriterion("plugin_id <", value, "pluginId"); + return (Criteria) this; + } + + public Criteria andPluginIdLessThanOrEqualTo(Long value) { + addCriterion("plugin_id <=", value, "pluginId"); + return (Criteria) this; + } + + public Criteria andPluginIdIn(List values) { + addCriterion("plugin_id in", values, "pluginId"); + return (Criteria) this; + } + + public Criteria andPluginIdNotIn(List values) { + addCriterion("plugin_id not in", values, "pluginId"); + return (Criteria) this; + } + + public Criteria andPluginIdBetween(Long value1, Long value2) { + addCriterion("plugin_id between", value1, value2, "pluginId"); + return (Criteria) this; + } + + public Criteria andPluginIdNotBetween(Long value1, Long value2) { + addCriterion("plugin_id not between", value1, value2, "pluginId"); + return (Criteria) this; + } + + public Criteria andNameIsNull() { + addCriterion("`name` is null"); + return (Criteria) this; + } + + public Criteria andNameIsNotNull() { + addCriterion("`name` is not null"); + return (Criteria) this; + } + + public Criteria andNameEqualTo(String value) { + addCriterion("`name` =", value, "name"); + return (Criteria) this; + } + + public Criteria andNameNotEqualTo(String value) { + addCriterion("`name` <>", value, "name"); + return (Criteria) this; + } + + public Criteria andNameGreaterThan(String value) { + addCriterion("`name` >", value, "name"); + return (Criteria) this; + } + + public Criteria andNameGreaterThanOrEqualTo(String value) { + addCriterion("`name` >=", value, "name"); + return (Criteria) this; + } + + public Criteria andNameLessThan(String value) { + addCriterion("`name` <", value, "name"); + return (Criteria) this; + } + + public Criteria andNameLessThanOrEqualTo(String value) { + addCriterion("`name` <=", value, "name"); + return (Criteria) this; + } + + public Criteria andNameLike(String value) { + addCriterion("`name` like", value, "name"); + return (Criteria) this; + } + + public Criteria andNameNotLike(String value) { + addCriterion("`name` not like", value, "name"); + return (Criteria) this; + } + + public Criteria andNameIn(List values) { + addCriterion("`name` in", values, "name"); + return (Criteria) this; + } + + public Criteria andNameNotIn(List values) { + addCriterion("`name` not in", values, "name"); + return (Criteria) this; + } + + public Criteria andNameBetween(String value1, String value2) { + addCriterion("`name` between", value1, value2, "name"); + return (Criteria) this; + } + + public Criteria andNameNotBetween(String value1, String value2) { + addCriterion("`name` not between", value1, value2, "name"); + return (Criteria) this; + } + + public Criteria andFreeIsNull() { + addCriterion("`free` is null"); + return (Criteria) this; + } + + public Criteria andFreeIsNotNull() { + addCriterion("`free` is not null"); + return (Criteria) this; + } + + public Criteria andFreeEqualTo(Boolean value) { + addCriterion("`free` =", value, "free"); + return (Criteria) this; + } + + public Criteria andFreeNotEqualTo(Boolean value) { + addCriterion("`free` <>", value, "free"); + return (Criteria) this; + } + + public Criteria andFreeGreaterThan(Boolean value) { + addCriterion("`free` >", value, "free"); + return (Criteria) this; + } + + public Criteria andFreeGreaterThanOrEqualTo(Boolean value) { + addCriterion("`free` >=", value, "free"); + return (Criteria) this; + } + + public Criteria andFreeLessThan(Boolean value) { + addCriterion("`free` <", value, "free"); + return (Criteria) this; + } + + public Criteria andFreeLessThanOrEqualTo(Boolean value) { + addCriterion("`free` <=", value, "free"); + return (Criteria) this; + } + + public Criteria andFreeIn(List values) { + addCriterion("`free` in", values, "free"); + return (Criteria) this; + } + + public Criteria andFreeNotIn(List values) { + addCriterion("`free` not in", values, "free"); + return (Criteria) this; + } + + public Criteria andFreeBetween(Boolean value1, Boolean value2) { + addCriterion("`free` between", value1, value2, "free"); + return (Criteria) this; + } + + public Criteria andFreeNotBetween(Boolean value1, Boolean value2) { + addCriterion("`free` not between", value1, value2, "free"); + return (Criteria) this; + } + + public Criteria andCostIsNull() { + addCriterion("cost is null"); + return (Criteria) this; + } + + public Criteria andCostIsNotNull() { + addCriterion("cost is not null"); + return (Criteria) this; + } + + public Criteria andCostEqualTo(Integer value) { + addCriterion("cost =", value, "cost"); + return (Criteria) this; + } + + public Criteria andCostNotEqualTo(Integer value) { + addCriterion("cost <>", value, "cost"); + return (Criteria) this; + } + + public Criteria andCostGreaterThan(Integer value) { + addCriterion("cost >", value, "cost"); + return (Criteria) this; + } + + public Criteria andCostGreaterThanOrEqualTo(Integer value) { + addCriterion("cost >=", value, "cost"); + return (Criteria) this; + } + + public Criteria andCostLessThan(Integer value) { + addCriterion("cost <", value, "cost"); + return (Criteria) this; + } + + public Criteria andCostLessThanOrEqualTo(Integer value) { + addCriterion("cost <=", value, "cost"); + return (Criteria) this; + } + + public Criteria andCostIn(List values) { + addCriterion("cost in", values, "cost"); + return (Criteria) this; + } + + public Criteria andCostNotIn(List values) { + addCriterion("cost not in", values, "cost"); + return (Criteria) this; + } + + public Criteria andCostBetween(Integer value1, Integer value2) { + addCriterion("cost between", value1, value2, "cost"); + return (Criteria) this; + } + + public Criteria andCostNotBetween(Integer value1, Integer value2) { + addCriterion("cost not between", value1, value2, "cost"); + return (Criteria) this; + } + + public Criteria andDescriptIsNull() { + addCriterion("descript is null"); + return (Criteria) this; + } + + public Criteria andDescriptIsNotNull() { + addCriterion("descript is not null"); + return (Criteria) this; + } + + public Criteria andDescriptEqualTo(String value) { + addCriterion("descript =", value, "descript"); + return (Criteria) this; + } + + public Criteria andDescriptNotEqualTo(String value) { + addCriterion("descript <>", value, "descript"); + return (Criteria) this; + } + + public Criteria andDescriptGreaterThan(String value) { + addCriterion("descript >", value, "descript"); + return (Criteria) this; + } + + public Criteria andDescriptGreaterThanOrEqualTo(String value) { + addCriterion("descript >=", value, "descript"); + return (Criteria) this; + } + + public Criteria andDescriptLessThan(String value) { + addCriterion("descript <", value, "descript"); + return (Criteria) this; + } + + public Criteria andDescriptLessThanOrEqualTo(String value) { + addCriterion("descript <=", value, "descript"); + return (Criteria) this; + } + + public Criteria andDescriptLike(String value) { + addCriterion("descript like", value, "descript"); + return (Criteria) this; + } + + public Criteria andDescriptNotLike(String value) { + addCriterion("descript not like", value, "descript"); + return (Criteria) this; + } + + public Criteria andDescriptIn(List values) { + addCriterion("descript in", values, "descript"); + return (Criteria) this; + } + + public Criteria andDescriptNotIn(List values) { + addCriterion("descript not in", values, "descript"); + return (Criteria) this; + } + + public Criteria andDescriptBetween(String value1, String value2) { + addCriterion("descript between", value1, value2, "descript"); + return (Criteria) this; + } + + public Criteria andDescriptNotBetween(String value1, String value2) { + addCriterion("descript not between", value1, value2, "descript"); + return (Criteria) this; + } + + public Criteria andVersionIsNull() { + addCriterion("version is null"); + return (Criteria) this; + } + + public Criteria andVersionIsNotNull() { + addCriterion("version is not null"); + return (Criteria) this; + } + + public Criteria andVersionEqualTo(String value) { + addCriterion("version =", value, "version"); + return (Criteria) this; + } + + public Criteria andVersionNotEqualTo(String value) { + addCriterion("version <>", value, "version"); + return (Criteria) this; + } + + public Criteria andVersionGreaterThan(String value) { + addCriterion("version >", value, "version"); + return (Criteria) this; + } + + public Criteria andVersionGreaterThanOrEqualTo(String value) { + addCriterion("version >=", value, "version"); + return (Criteria) this; + } + + public Criteria andVersionLessThan(String value) { + addCriterion("version <", value, "version"); + return (Criteria) this; + } + + public Criteria andVersionLessThanOrEqualTo(String value) { + addCriterion("version <=", value, "version"); + return (Criteria) this; + } + + public Criteria andVersionLike(String value) { + addCriterion("version like", value, "version"); + return (Criteria) this; + } + + public Criteria andVersionNotLike(String value) { + addCriterion("version not like", value, "version"); + return (Criteria) this; + } + + public Criteria andVersionIn(List values) { + addCriterion("version in", values, "version"); + return (Criteria) this; + } + + public Criteria andVersionNotIn(List values) { + addCriterion("version not in", values, "version"); + return (Criteria) this; + } + + public Criteria andVersionBetween(String value1, String value2) { + addCriterion("version between", value1, value2, "version"); + return (Criteria) this; + } + + public Criteria andVersionNotBetween(String value1, String value2) { + addCriterion("version not between", value1, value2, "version"); + return (Criteria) this; + } + + public Criteria andInstallTypeIsNull() { + addCriterion("install_type is null"); + return (Criteria) this; + } + + public Criteria andInstallTypeIsNotNull() { + addCriterion("install_type is not null"); + return (Criteria) this; + } + + public Criteria andInstallTypeEqualTo(Integer value) { + addCriterion("install_type =", value, "installType"); + return (Criteria) this; + } + + public Criteria andInstallTypeNotEqualTo(Integer value) { + addCriterion("install_type <>", value, "installType"); + return (Criteria) this; + } + + public Criteria andInstallTypeGreaterThan(Integer value) { + addCriterion("install_type >", value, "installType"); + return (Criteria) this; + } + + public Criteria andInstallTypeGreaterThanOrEqualTo(Integer value) { + addCriterion("install_type >=", value, "installType"); + return (Criteria) this; + } + + public Criteria andInstallTypeLessThan(Integer value) { + addCriterion("install_type <", value, "installType"); + return (Criteria) this; + } + + public Criteria andInstallTypeLessThanOrEqualTo(Integer value) { + addCriterion("install_type <=", value, "installType"); + return (Criteria) this; + } + + public Criteria andInstallTypeIn(List values) { + addCriterion("install_type in", values, "installType"); + return (Criteria) this; + } + + public Criteria andInstallTypeNotIn(List values) { + addCriterion("install_type not in", values, "installType"); + return (Criteria) this; + } + + public Criteria andInstallTypeBetween(Integer value1, Integer value2) { + addCriterion("install_type between", value1, value2, "installType"); + return (Criteria) this; + } + + public Criteria andInstallTypeNotBetween(Integer value1, Integer value2) { + addCriterion("install_type not between", value1, value2, "installType"); + return (Criteria) this; + } + + public Criteria andCreatorIsNull() { + addCriterion("creator is null"); + return (Criteria) this; + } + + public Criteria andCreatorIsNotNull() { + addCriterion("creator is not null"); + return (Criteria) this; + } + + public Criteria andCreatorEqualTo(String value) { + addCriterion("creator =", value, "creator"); + return (Criteria) this; + } + + public Criteria andCreatorNotEqualTo(String value) { + addCriterion("creator <>", value, "creator"); + return (Criteria) this; + } + + public Criteria andCreatorGreaterThan(String value) { + addCriterion("creator >", value, "creator"); + return (Criteria) this; + } + + public Criteria andCreatorGreaterThanOrEqualTo(String value) { + addCriterion("creator >=", value, "creator"); + return (Criteria) this; + } + + public Criteria andCreatorLessThan(String value) { + addCriterion("creator <", value, "creator"); + return (Criteria) this; + } + + public Criteria andCreatorLessThanOrEqualTo(String value) { + addCriterion("creator <=", value, "creator"); + return (Criteria) this; + } + + public Criteria andCreatorLike(String value) { + addCriterion("creator like", value, "creator"); + return (Criteria) this; + } + + public Criteria andCreatorNotLike(String value) { + addCriterion("creator not like", value, "creator"); + return (Criteria) this; + } + + public Criteria andCreatorIn(List values) { + addCriterion("creator in", values, "creator"); + return (Criteria) this; + } + + public Criteria andCreatorNotIn(List values) { + addCriterion("creator not in", values, "creator"); + return (Criteria) this; + } + + public Criteria andCreatorBetween(String value1, String value2) { + addCriterion("creator between", value1, value2, "creator"); + return (Criteria) this; + } + + public Criteria andCreatorNotBetween(String value1, String value2) { + addCriterion("creator not between", value1, value2, "creator"); + return (Criteria) this; + } + + public Criteria andReleaseTimeIsNull() { + addCriterion("release_time is null"); + return (Criteria) this; + } + + public Criteria andReleaseTimeIsNotNull() { + addCriterion("release_time is not null"); + return (Criteria) this; + } + + public Criteria andReleaseTimeEqualTo(Long value) { + addCriterion("release_time =", value, "releaseTime"); + return (Criteria) this; + } + + public Criteria andReleaseTimeNotEqualTo(Long value) { + addCriterion("release_time <>", value, "releaseTime"); + return (Criteria) this; + } + + public Criteria andReleaseTimeGreaterThan(Long value) { + addCriterion("release_time >", value, "releaseTime"); + return (Criteria) this; + } + + public Criteria andReleaseTimeGreaterThanOrEqualTo(Long value) { + addCriterion("release_time >=", value, "releaseTime"); + return (Criteria) this; + } + + public Criteria andReleaseTimeLessThan(Long value) { + addCriterion("release_time <", value, "releaseTime"); + return (Criteria) this; + } + + public Criteria andReleaseTimeLessThanOrEqualTo(Long value) { + addCriterion("release_time <=", value, "releaseTime"); + return (Criteria) this; + } + + public Criteria andReleaseTimeIn(List values) { + addCriterion("release_time in", values, "releaseTime"); + return (Criteria) this; + } + + public Criteria andReleaseTimeNotIn(List values) { + addCriterion("release_time not in", values, "releaseTime"); + return (Criteria) this; + } + + public Criteria andReleaseTimeBetween(Long value1, Long value2) { + addCriterion("release_time between", value1, value2, "releaseTime"); + return (Criteria) this; + } + + public Criteria andReleaseTimeNotBetween(Long value1, Long value2) { + addCriterion("release_time not between", value1, value2, "releaseTime"); + return (Criteria) this; + } + + public Criteria andInstallTimeIsNull() { + addCriterion("install_time is null"); + return (Criteria) this; + } + + public Criteria andInstallTimeIsNotNull() { + addCriterion("install_time is not null"); + return (Criteria) this; + } + + public Criteria andInstallTimeEqualTo(Long value) { + addCriterion("install_time =", value, "installTime"); + return (Criteria) this; + } + + public Criteria andInstallTimeNotEqualTo(Long value) { + addCriterion("install_time <>", value, "installTime"); + return (Criteria) this; + } + + public Criteria andInstallTimeGreaterThan(Long value) { + addCriterion("install_time >", value, "installTime"); + return (Criteria) this; + } + + public Criteria andInstallTimeGreaterThanOrEqualTo(Long value) { + addCriterion("install_time >=", value, "installTime"); + return (Criteria) this; + } + + public Criteria andInstallTimeLessThan(Long value) { + addCriterion("install_time <", value, "installTime"); + return (Criteria) this; + } + + public Criteria andInstallTimeLessThanOrEqualTo(Long value) { + addCriterion("install_time <=", value, "installTime"); + return (Criteria) this; + } + + public Criteria andInstallTimeIn(List values) { + addCriterion("install_time in", values, "installTime"); + return (Criteria) this; + } + + public Criteria andInstallTimeNotIn(List values) { + addCriterion("install_time not in", values, "installTime"); + return (Criteria) this; + } + + public Criteria andInstallTimeBetween(Long value1, Long value2) { + addCriterion("install_time between", value1, value2, "installTime"); + return (Criteria) this; + } + + public Criteria andInstallTimeNotBetween(Long value1, Long value2) { + addCriterion("install_time not between", value1, value2, "installTime"); + return (Criteria) this; + } + + public Criteria andModuleNameIsNull() { + addCriterion("module_name is null"); + return (Criteria) this; + } + + public Criteria andModuleNameIsNotNull() { + addCriterion("module_name is not null"); + return (Criteria) this; + } + + public Criteria andModuleNameEqualTo(String value) { + addCriterion("module_name =", value, "moduleName"); + return (Criteria) this; + } + + public Criteria andModuleNameNotEqualTo(String value) { + addCriterion("module_name <>", value, "moduleName"); + return (Criteria) this; + } + + public Criteria andModuleNameGreaterThan(String value) { + addCriterion("module_name >", value, "moduleName"); + return (Criteria) this; + } + + public Criteria andModuleNameGreaterThanOrEqualTo(String value) { + addCriterion("module_name >=", value, "moduleName"); + return (Criteria) this; + } + + public Criteria andModuleNameLessThan(String value) { + addCriterion("module_name <", value, "moduleName"); + return (Criteria) this; + } + + public Criteria andModuleNameLessThanOrEqualTo(String value) { + addCriterion("module_name <=", value, "moduleName"); + return (Criteria) this; + } + + public Criteria andModuleNameLike(String value) { + addCriterion("module_name like", value, "moduleName"); + return (Criteria) this; + } + + public Criteria andModuleNameNotLike(String value) { + addCriterion("module_name not like", value, "moduleName"); + return (Criteria) this; + } + + public Criteria andModuleNameIn(List values) { + addCriterion("module_name in", values, "moduleName"); + return (Criteria) this; + } + + public Criteria andModuleNameNotIn(List values) { + addCriterion("module_name not in", values, "moduleName"); + return (Criteria) this; + } + + public Criteria andModuleNameBetween(String value1, String value2) { + addCriterion("module_name between", value1, value2, "moduleName"); + return (Criteria) this; + } + + public Criteria andModuleNameNotBetween(String value1, String value2) { + addCriterion("module_name not between", value1, value2, "moduleName"); + return (Criteria) this; + } + + public Criteria andBeanNameIsNull() { + addCriterion("bean_name is null"); + return (Criteria) this; + } + + public Criteria andBeanNameIsNotNull() { + addCriterion("bean_name is not null"); + return (Criteria) this; + } + + public Criteria andBeanNameEqualTo(String value) { + addCriterion("bean_name =", value, "beanName"); + return (Criteria) this; + } + + public Criteria andBeanNameNotEqualTo(String value) { + addCriterion("bean_name <>", value, "beanName"); + return (Criteria) this; + } + + public Criteria andBeanNameGreaterThan(String value) { + addCriterion("bean_name >", value, "beanName"); + return (Criteria) this; + } + + public Criteria andBeanNameGreaterThanOrEqualTo(String value) { + addCriterion("bean_name >=", value, "beanName"); + return (Criteria) this; + } + + public Criteria andBeanNameLessThan(String value) { + addCriterion("bean_name <", value, "beanName"); + return (Criteria) this; + } + + public Criteria andBeanNameLessThanOrEqualTo(String value) { + addCriterion("bean_name <=", value, "beanName"); + return (Criteria) this; + } + + public Criteria andBeanNameLike(String value) { + addCriterion("bean_name like", value, "beanName"); + return (Criteria) this; + } + + public Criteria andBeanNameNotLike(String value) { + addCriterion("bean_name not like", value, "beanName"); + return (Criteria) this; + } + + public Criteria andBeanNameIn(List values) { + addCriterion("bean_name in", values, "beanName"); + return (Criteria) this; + } + + public Criteria andBeanNameNotIn(List values) { + addCriterion("bean_name not in", values, "beanName"); + return (Criteria) this; + } + + public Criteria andBeanNameBetween(String value1, String value2) { + addCriterion("bean_name between", value1, value2, "beanName"); + return (Criteria) this; + } + + public Criteria andBeanNameNotBetween(String value1, String value2) { + addCriterion("bean_name not between", value1, value2, "beanName"); + return (Criteria) this; + } + + public Criteria andIconIsNull() { + addCriterion("icon is null"); + return (Criteria) this; + } + + public Criteria andIconIsNotNull() { + addCriterion("icon is not null"); + return (Criteria) this; + } + + public Criteria andIconEqualTo(String value) { + addCriterion("icon =", value, "icon"); + return (Criteria) this; + } + + public Criteria andIconNotEqualTo(String value) { + addCriterion("icon <>", value, "icon"); + return (Criteria) this; + } + + public Criteria andIconGreaterThan(String value) { + addCriterion("icon >", value, "icon"); + return (Criteria) this; + } + + public Criteria andIconGreaterThanOrEqualTo(String value) { + addCriterion("icon >=", value, "icon"); + return (Criteria) this; + } + + public Criteria andIconLessThan(String value) { + addCriterion("icon <", value, "icon"); + return (Criteria) this; + } + + public Criteria andIconLessThanOrEqualTo(String value) { + addCriterion("icon <=", value, "icon"); + return (Criteria) this; + } + + public Criteria andIconLike(String value) { + addCriterion("icon like", value, "icon"); + return (Criteria) this; + } + + public Criteria andIconNotLike(String value) { + addCriterion("icon not like", value, "icon"); + return (Criteria) this; + } + + public Criteria andIconIn(List values) { + addCriterion("icon in", values, "icon"); + return (Criteria) this; + } + + public Criteria andIconNotIn(List values) { + addCriterion("icon not in", values, "icon"); + return (Criteria) this; + } + + public Criteria andIconBetween(String value1, String value2) { + addCriterion("icon between", value1, value2, "icon"); + return (Criteria) this; + } + + public Criteria andIconNotBetween(String value1, String value2) { + addCriterion("icon not between", value1, value2, "icon"); + return (Criteria) this; + } + } + + public static class Criteria extends GeneratedCriteria { + + protected Criteria() { + super(); + } + } + + public static class Criterion { + private String condition; + + private Object value; + + private Object secondValue; + + private boolean noValue; + + private boolean singleValue; + + private boolean betweenValue; + + private boolean listValue; + + private String typeHandler; + + public String getCondition() { + return condition; + } + + public Object getValue() { + return value; + } + + public Object getSecondValue() { + return secondValue; + } + + public boolean isNoValue() { + return noValue; + } + + public boolean isSingleValue() { + return singleValue; + } + + public boolean isBetweenValue() { + return betweenValue; + } + + public boolean isListValue() { + return listValue; + } + + public String getTypeHandler() { + return typeHandler; + } + + protected Criterion(String condition) { + super(); + this.condition = condition; + this.typeHandler = null; + this.noValue = true; + } + + protected Criterion(String condition, Object value, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.typeHandler = typeHandler; + if (value instanceof List) { + this.listValue = true; + } else { + this.singleValue = true; + } + } + + protected Criterion(String condition, Object value) { + this(condition, value, null); + } + + protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.secondValue = secondValue; + this.typeHandler = typeHandler; + this.betweenValue = true; + } + + protected Criterion(String condition, Object value, Object secondValue) { + this(condition, value, secondValue, null); + } + } +} \ No newline at end of file diff --git a/backend/src/main/java/io/dataease/base/mapper/MyPluginMapper.java b/backend/src/main/java/io/dataease/base/mapper/MyPluginMapper.java new file mode 100644 index 0000000000..3d14695717 --- /dev/null +++ b/backend/src/main/java/io/dataease/base/mapper/MyPluginMapper.java @@ -0,0 +1,30 @@ +package io.dataease.base.mapper; + +import io.dataease.base.domain.MyPlugin; +import io.dataease.base.domain.MyPluginExample; +import java.util.List; +import org.apache.ibatis.annotations.Param; + +public interface MyPluginMapper { + long countByExample(MyPluginExample example); + + int deleteByExample(MyPluginExample example); + + int deleteByPrimaryKey(Long pluginId); + + int insert(MyPlugin record); + + int insertSelective(MyPlugin record); + + List selectByExample(MyPluginExample example); + + MyPlugin selectByPrimaryKey(Long pluginId); + + int updateByExampleSelective(@Param("record") MyPlugin record, @Param("example") MyPluginExample example); + + int updateByExample(@Param("record") MyPlugin record, @Param("example") MyPluginExample example); + + int updateByPrimaryKeySelective(MyPlugin record); + + int updateByPrimaryKey(MyPlugin record); +} \ No newline at end of file diff --git a/backend/src/main/java/io/dataease/base/mapper/MyPluginMapper.xml b/backend/src/main/java/io/dataease/base/mapper/MyPluginMapper.xml new file mode 100644 index 0000000000..7381c8fb44 --- /dev/null +++ b/backend/src/main/java/io/dataease/base/mapper/MyPluginMapper.xml @@ -0,0 +1,338 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + plugin_id, `name`, `free`, cost, descript, version, install_type, creator, release_time, + install_time, module_name, bean_name, icon + + + + + delete from my_plugin + where plugin_id = #{pluginId,jdbcType=BIGINT} + + + delete from my_plugin + + + + + + insert into my_plugin (plugin_id, `name`, `free`, + cost, descript, version, + install_type, creator, release_time, + install_time, module_name, bean_name, + icon) + values (#{pluginId,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{free,jdbcType=BIT}, + #{cost,jdbcType=INTEGER}, #{descript,jdbcType=VARCHAR}, #{version,jdbcType=VARCHAR}, + #{installType,jdbcType=INTEGER}, #{creator,jdbcType=VARCHAR}, #{releaseTime,jdbcType=BIGINT}, + #{installTime,jdbcType=BIGINT}, #{moduleName,jdbcType=VARCHAR}, #{beanName,jdbcType=VARCHAR}, + #{icon,jdbcType=VARCHAR}) + + + insert into my_plugin + + + plugin_id, + + + `name`, + + + `free`, + + + cost, + + + descript, + + + version, + + + install_type, + + + creator, + + + release_time, + + + install_time, + + + module_name, + + + bean_name, + + + icon, + + + + + #{pluginId,jdbcType=BIGINT}, + + + #{name,jdbcType=VARCHAR}, + + + #{free,jdbcType=BIT}, + + + #{cost,jdbcType=INTEGER}, + + + #{descript,jdbcType=VARCHAR}, + + + #{version,jdbcType=VARCHAR}, + + + #{installType,jdbcType=INTEGER}, + + + #{creator,jdbcType=VARCHAR}, + + + #{releaseTime,jdbcType=BIGINT}, + + + #{installTime,jdbcType=BIGINT}, + + + #{moduleName,jdbcType=VARCHAR}, + + + #{beanName,jdbcType=VARCHAR}, + + + #{icon,jdbcType=VARCHAR}, + + + + + + update my_plugin + + + plugin_id = #{record.pluginId,jdbcType=BIGINT}, + + + `name` = #{record.name,jdbcType=VARCHAR}, + + + `free` = #{record.free,jdbcType=BIT}, + + + cost = #{record.cost,jdbcType=INTEGER}, + + + descript = #{record.descript,jdbcType=VARCHAR}, + + + version = #{record.version,jdbcType=VARCHAR}, + + + install_type = #{record.installType,jdbcType=INTEGER}, + + + creator = #{record.creator,jdbcType=VARCHAR}, + + + release_time = #{record.releaseTime,jdbcType=BIGINT}, + + + install_time = #{record.installTime,jdbcType=BIGINT}, + + + module_name = #{record.moduleName,jdbcType=VARCHAR}, + + + bean_name = #{record.beanName,jdbcType=VARCHAR}, + + + icon = #{record.icon,jdbcType=VARCHAR}, + + + + + + + + update my_plugin + set plugin_id = #{record.pluginId,jdbcType=BIGINT}, + `name` = #{record.name,jdbcType=VARCHAR}, + `free` = #{record.free,jdbcType=BIT}, + cost = #{record.cost,jdbcType=INTEGER}, + descript = #{record.descript,jdbcType=VARCHAR}, + version = #{record.version,jdbcType=VARCHAR}, + install_type = #{record.installType,jdbcType=INTEGER}, + creator = #{record.creator,jdbcType=VARCHAR}, + release_time = #{record.releaseTime,jdbcType=BIGINT}, + install_time = #{record.installTime,jdbcType=BIGINT}, + module_name = #{record.moduleName,jdbcType=VARCHAR}, + bean_name = #{record.beanName,jdbcType=VARCHAR}, + icon = #{record.icon,jdbcType=VARCHAR} + + + + + + update my_plugin + + + `name` = #{name,jdbcType=VARCHAR}, + + + `free` = #{free,jdbcType=BIT}, + + + cost = #{cost,jdbcType=INTEGER}, + + + descript = #{descript,jdbcType=VARCHAR}, + + + version = #{version,jdbcType=VARCHAR}, + + + install_type = #{installType,jdbcType=INTEGER}, + + + creator = #{creator,jdbcType=VARCHAR}, + + + release_time = #{releaseTime,jdbcType=BIGINT}, + + + install_time = #{installTime,jdbcType=BIGINT}, + + + module_name = #{moduleName,jdbcType=VARCHAR}, + + + bean_name = #{beanName,jdbcType=VARCHAR}, + + + icon = #{icon,jdbcType=VARCHAR}, + + + where plugin_id = #{pluginId,jdbcType=BIGINT} + + + update my_plugin + set `name` = #{name,jdbcType=VARCHAR}, + `free` = #{free,jdbcType=BIT}, + cost = #{cost,jdbcType=INTEGER}, + descript = #{descript,jdbcType=VARCHAR}, + version = #{version,jdbcType=VARCHAR}, + install_type = #{installType,jdbcType=INTEGER}, + creator = #{creator,jdbcType=VARCHAR}, + release_time = #{releaseTime,jdbcType=BIGINT}, + install_time = #{installTime,jdbcType=BIGINT}, + module_name = #{moduleName,jdbcType=VARCHAR}, + bean_name = #{beanName,jdbcType=VARCHAR}, + icon = #{icon,jdbcType=VARCHAR} + where plugin_id = #{pluginId,jdbcType=BIGINT} + + \ No newline at end of file diff --git a/backend/src/main/java/io/dataease/base/mapper/ext/ExtSysPluginMapper.java b/backend/src/main/java/io/dataease/base/mapper/ext/ExtSysPluginMapper.java new file mode 100644 index 0000000000..886f5ddf07 --- /dev/null +++ b/backend/src/main/java/io/dataease/base/mapper/ext/ExtSysPluginMapper.java @@ -0,0 +1,11 @@ +package io.dataease.base.mapper.ext; + +import io.dataease.base.domain.MyPlugin; +import io.dataease.base.mapper.ext.query.GridExample; + +import java.util.List; + +public interface ExtSysPluginMapper { + + List query(GridExample example); +} diff --git a/backend/src/main/java/io/dataease/base/mapper/ext/ExtSysPluginMapper.xml b/backend/src/main/java/io/dataease/base/mapper/ext/ExtSysPluginMapper.xml new file mode 100644 index 0000000000..488a2ad96e --- /dev/null +++ b/backend/src/main/java/io/dataease/base/mapper/ext/ExtSysPluginMapper.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + diff --git a/backend/src/main/java/io/dataease/commons/utils/DeFileUtils.java b/backend/src/main/java/io/dataease/commons/utils/DeFileUtils.java new file mode 100644 index 0000000000..3e67f8caec --- /dev/null +++ b/backend/src/main/java/io/dataease/commons/utils/DeFileUtils.java @@ -0,0 +1,115 @@ +package io.dataease.commons.utils; + +import org.springframework.web.multipart.MultipartFile; + +import java.io.*; +import java.nio.channels.FileChannel; + +public class DeFileUtils { + + + + /** + * Java文件操作 获取不带扩展名的文件名 + */ + public static String getFileNameNoEx(String filename) { + if ((filename != null) && (filename.length() > 0)) { + int dot = filename.lastIndexOf('.'); + if ((dot > -1) && (dot < (filename.length()))) { + return filename.substring(0, dot); + } + } + return filename; + } + + /** + * 获取文件扩展名,不带 . + */ + public static String getExtensionName(String filename) { + if ((filename != null) && (filename.length() > 0)) { + int dot = filename.lastIndexOf('.'); + if ((dot > -1) && (dot < (filename.length() - 1))) { + return filename.substring(dot + 1); + } + } + return filename; + } + /** + * 将文件名解析成文件的上传路径 + */ + public static File upload(MultipartFile file, String filePath) { + String name = getFileNameNoEx(file.getOriginalFilename()); + String suffix = getExtensionName(file.getOriginalFilename()); + try { + String fileName = name + "." + suffix; + String path = filePath + fileName; + // getCanonicalFile 可解析正确各种路径 + File dest = new File(path).getCanonicalFile(); + // 检测是否存在目录 + if (!dest.getParentFile().exists()) { + if (!dest.getParentFile().mkdirs()) { + System.out.println("was not successful."); + } + } + // 文件写入 + // file.transferTo(dest); + FileOutputStream fileOutputStream = new FileOutputStream(dest); + fileOutputStream.write(file.getBytes()); + fileOutputStream.flush(); + fileOutputStream.close(); + return dest; + } catch (Exception e) { + LogUtil.error(e.getMessage(), e); + } + return null; + } + + public static String copy(File source, String targetDir) throws IOException{ + String name = source.getName(); + String destPath = null; + if (targetDir.endsWith("/") || targetDir.endsWith("\\")){ + destPath = targetDir + name; + }else{ + destPath = targetDir + "/" + name; + } + File DestFile = new File(destPath); + if (!DestFile.getParentFile().exists()) { + DestFile.getParentFile().mkdirs(); + } + copyFileUsingFileChannels(source, DestFile); + return destPath; + } + + private static void copyFileUsingFileChannels(File source, File dest) throws IOException { + FileChannel inputChannel = null; + FileChannel outputChannel = null; + try { + inputChannel = new FileInputStream(source).getChannel(); + outputChannel = new FileOutputStream(dest).getChannel(); + outputChannel.transferFrom(inputChannel, 0, inputChannel.size()); + } finally { + inputChannel.close(); + outputChannel.close(); + } + } + + public static String readJson(File file) { + String str = null; + try { + FileReader fileReader = new FileReader(file); + Reader reader = new InputStreamReader(new FileInputStream(file), "utf-8"); + int ch=0; + StringBuffer sb = new StringBuffer(); + while ((ch = reader.read()) != -1) { + sb.append((char) ch); + } + fileReader.close(); + reader.close(); + str = sb.toString(); + return str; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } +} diff --git a/backend/src/main/java/io/dataease/commons/utils/ZipUtils.java b/backend/src/main/java/io/dataease/commons/utils/ZipUtils.java new file mode 100644 index 0000000000..153c50767e --- /dev/null +++ b/backend/src/main/java/io/dataease/commons/utils/ZipUtils.java @@ -0,0 +1,141 @@ +package io.dataease.commons.utils; + +import java.io.*; +import java.util.Enumeration; +import java.util.zip.ZipEntry; +import java.util.zip.ZipException; +import java.util.zip.ZipFile; +import java.util.zip.ZipInputStream; + +public class ZipUtils { + + + /** + * 解压文件 + * + * @param zipFilePath 解压文件路径 + * @param outputFolder 输出解压文件路径 + */ + public static void unZipIt(String zipFilePath, String outputFolder) { + byte[] buffer = new byte[1024]; + + File folder = new File(outputFolder); + if (!folder.exists()) { + folder.mkdir(); + } + try { + //get the zip file content + ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFilePath)); + ZipEntry ze = zis.getNextEntry(); + while (ze != null) { + String fileName = ze.getName(); + File newFile = new File(outputFolder + File.separator + fileName); + System.out.println("file unzip : " + newFile.getAbsoluteFile()); + //大部分网络上的源码,这里没有判断子目录 + if (ze.isDirectory()) { + if (!newFile.mkdirs()) { + System.out.println("was not successful."); + } + } else { + if (!new File(newFile.getParent()).mkdirs()) { + System.out.println("was not successful."); + } + FileOutputStream fos = new FileOutputStream(newFile); + int len; + while ((len = zis.read(buffer)) != -1) { + fos.write(buffer, 0, len); + } + fos.close(); + } + ze = zis.getNextEntry(); + } + zis.closeEntry(); + zis.close(); + System.out.println("Done"); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public static void unzip(File source, String out) throws IOException { + try (ZipInputStream zis = new ZipInputStream(new FileInputStream(source))) { + + ZipEntry entry = zis.getNextEntry(); + + while (entry != null) { + + File file = new File(out, entry.getName()); + + if (entry.isDirectory()) { + if (!file.mkdirs()) { + System.out.println("was not successful."); + } + } else { + File parent = file.getParentFile(); + + if (!parent.exists()) { + if (!parent.mkdirs()) { + System.out.println("was not successful."); + } + } + + try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file))) { + + byte[] buffer = new byte[Math.toIntExact(entry.getSize())]; + + int location; + + while ((location = zis.read(buffer)) != -1) { + bos.write(buffer, 0, location); + } + } + } + entry = zis.getNextEntry(); + } + } + } + + /** + * 把所有文件都直接解压到指定目录(忽略子文件夹) + * + * @param zipFile + * @param folderPath + * @throws ZipException + * @throws IOException + */ + public static void upZipFile(File zipFile, String folderPath) throws ZipException, IOException { + File desDir = new File(folderPath); + if (!desDir.exists()) { + if (!desDir.mkdirs()) { + System.out.println("was not successful."); + } + } + ZipFile zf = new ZipFile(zipFile); + for (Enumeration entries = zf.entries(); entries.hasMoreElements(); ) { + ZipEntry entry = ((ZipEntry) entries.nextElement()); + InputStream in = zf.getInputStream(entry); + File desFile = new File(folderPath, java.net.URLEncoder.encode(entry.getName(), "UTF-8")); + + if (!desFile.exists()) { + File fileParentDir = desFile.getParentFile(); + if (!fileParentDir.exists()) { + if (!fileParentDir.mkdirs()) { + System.out.println("was not successful."); + } + } + } + + OutputStream out = new FileOutputStream(desFile); + byte[] buffer = new byte[1024 * 1024]; + int realLength = in.read(buffer); + while (realLength != -1) { + out.write(buffer, 0, realLength); + realLength = in.read(buffer); + } + + out.close(); + in.close(); + + } + } +} diff --git a/backend/src/main/java/io/dataease/controller/sys/SysPluginController.java b/backend/src/main/java/io/dataease/controller/sys/SysPluginController.java new file mode 100644 index 0000000000..9ad21f438f --- /dev/null +++ b/backend/src/main/java/io/dataease/controller/sys/SysPluginController.java @@ -0,0 +1,39 @@ +package io.dataease.controller.sys; + +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import io.dataease.base.domain.MyPlugin; +import io.dataease.commons.utils.PageUtils; +import io.dataease.commons.utils.Pager; +import io.dataease.controller.sys.base.BaseGridRequest; +import io.dataease.service.sys.PluginService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import java.util.List; +import java.util.Map; + + +@RestController +@Api(tags = "系统:插件管理") +@RequestMapping("/api/plugin") +public class SysPluginController { + + @Autowired + private PluginService pluginService; + + @ApiOperation("查询已安装插件") + @PostMapping("/pluginGrid/{goPage}/{pageSize}") + public Pager> pluginGrid(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody BaseGridRequest request) { + Page page = PageHelper.startPage(goPage, pageSize, true); + return PageUtils.setPageInfo(page, pluginService.query(request)); + } + + @PostMapping("upload") + public Map localUpload(@RequestParam("file") MultipartFile file) throws Exception { + return pluginService.localInstall(file); + } +} diff --git a/backend/src/main/java/io/dataease/dto/chart/ChartViewFieldDTO.java b/backend/src/main/java/io/dataease/dto/chart/ChartViewFieldDTO.java index e4a7127d77..a3aab7eedf 100644 --- a/backend/src/main/java/io/dataease/dto/chart/ChartViewFieldDTO.java +++ b/backend/src/main/java/io/dataease/dto/chart/ChartViewFieldDTO.java @@ -17,6 +17,8 @@ public class ChartViewFieldDTO implements Serializable { private String originName; + private String dataeaseName; + private String name; private String type; diff --git a/backend/src/main/java/io/dataease/plugins/config/LoadjarUtil.java b/backend/src/main/java/io/dataease/plugins/config/LoadjarUtil.java new file mode 100644 index 0000000000..e5a0811c3e --- /dev/null +++ b/backend/src/main/java/io/dataease/plugins/config/LoadjarUtil.java @@ -0,0 +1,51 @@ +package io.dataease.plugins.config; + +import io.dataease.plugins.loader.ClassloaderResponsity; +import io.dataease.plugins.loader.ModuleClassLoader; +import org.springframework.stereotype.Component; + +import java.io.File; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URL; +import java.util.List; +import java.util.Map; + +@Component +public class LoadjarUtil { + + public List loadJar(String jarPath){ + File jar = new File(jarPath); + URI uri = jar.toURI(); + String moduleName = jarPath.substring(jarPath.lastIndexOf("/")+1,jarPath.lastIndexOf(".")); + try { + + if(ClassloaderResponsity.getInstance().containsClassLoader(moduleName)){ + ClassloaderResponsity.getInstance().removeClassLoader(moduleName); + } + + ModuleClassLoader classLoader = new ModuleClassLoader(new URL[]{uri.toURL()}, Thread.currentThread().getContextClassLoader()); + SpringContextUtil.getBeanFactory().setBeanClassLoader(classLoader); + Thread.currentThread().setContextClassLoader(classLoader); + classLoader.initBean(); + ClassloaderResponsity.getInstance().addClassLoader(moduleName,classLoader); + + } catch (MalformedURLException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + return SpringContextUtil.getAllBean(); + } + + public List> deleteModule(String moduleName){ + if(ClassloaderResponsity.getInstance().containsClassLoader(moduleName)){ + ClassloaderResponsity.getInstance().removeClassLoader(moduleName); + } + return beans(); + } + public List> beans(){ + return SpringContextUtil.getAllBean(); + } +} diff --git a/backend/src/main/java/io/dataease/plugins/config/SpringContextUtil.java b/backend/src/main/java/io/dataease/plugins/config/SpringContextUtil.java new file mode 100644 index 0000000000..cd9bb49691 --- /dev/null +++ b/backend/src/main/java/io/dataease/plugins/config/SpringContextUtil.java @@ -0,0 +1,85 @@ +package io.dataease.plugins.config; + +import org.springframework.beans.BeansException; +import org.springframework.beans.factory.support.DefaultListableBeanFactory; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Component +public class SpringContextUtil implements ApplicationContextAware { + + //获取bean工厂,用来实现动态注入bean + //不能使用其他类加载器加载bean + //否则会出现异常:类未找到,类未定义 + public static DefaultListableBeanFactory getBeanFactory(){ + return (DefaultListableBeanFactory) getApplicationContext().getAutowireCapableBeanFactory(); + } + + + + public static List> getAllBean() { + + + List> list = new ArrayList<>(); + + + String[] beans = getApplicationContext() + .getBeanDefinitionNames(); + + for (String beanName : beans) { + Class beanType = getApplicationContext() + .getType(beanName); + + Map map = new HashMap<>(); + + map.put("BeanName", beanName); + map.put("beanType", beanType); + map.put("package", beanType.getPackage()); + list.add(map); + + } + + return list; + } + + + + + /** + * 上下文对象实例 + */ + private static ApplicationContext applicationContext; + + + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { + this.applicationContext = applicationContext; + } + + /** + * 获取applicationContext + * + * @return + */ + public static ApplicationContext getApplicationContext() { + return applicationContext; + } + + + public static Object getBean(String name) { + return getApplicationContext().getBean(name); + } + + public static T getBean(Class clazz) { + return getApplicationContext().getBean(clazz); + } + + public static T getBean(String name, Class clazz) { + return getApplicationContext().getBean(name, clazz); + } +} diff --git a/backend/src/main/java/io/dataease/plugins/loader/ClassloaderResponsity.java b/backend/src/main/java/io/dataease/plugins/loader/ClassloaderResponsity.java new file mode 100644 index 0000000000..1ed8e86bb8 --- /dev/null +++ b/backend/src/main/java/io/dataease/plugins/loader/ClassloaderResponsity.java @@ -0,0 +1,65 @@ +package io.dataease.plugins.loader; + +import io.dataease.plugins.config.SpringContextUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +public class ClassloaderResponsity { + + + private static Logger logger = LoggerFactory.getLogger(ClassloaderResponsity.class); + + private ClassloaderResponsity(){} + + + private Map responsityMap = new ConcurrentHashMap<>(); + + + + public void addClassLoader(String moduleName,ModuleClassLoader moduleClassLoader){ + responsityMap.put(moduleName,moduleClassLoader); + } + + public boolean containsClassLoader(String key){ + return responsityMap.containsKey(key); + } + + public ModuleClassLoader getClassLoader(String key){ + return responsityMap.get(key); + } + + public void removeClassLoader(String moduleName){ + ModuleClassLoader moduleClassLoader = responsityMap.get(moduleName); + try { + List registeredBean = moduleClassLoader.getRegisteredBean(); + + for (String beanName : registeredBean) { + logger.info("删除bean:"+beanName); + SpringContextUtil.getBeanFactory().removeBeanDefinition(beanName); + } + + moduleClassLoader.close(); + responsityMap.remove(moduleName); + + } catch (IOException e) { + logger.error("删除"+moduleName+"模块发生错误"); + } + } + + + + + + private static class ClassloaderResponsityHodler{ + private static ClassloaderResponsity instamce = new ClassloaderResponsity(); + } + + public static ClassloaderResponsity getInstance(){ + return ClassloaderResponsityHodler.instamce; + } +} diff --git a/backend/src/main/java/io/dataease/plugins/loader/ModuleClassLoader.java b/backend/src/main/java/io/dataease/plugins/loader/ModuleClassLoader.java new file mode 100644 index 0000000000..9005a29230 --- /dev/null +++ b/backend/src/main/java/io/dataease/plugins/loader/ModuleClassLoader.java @@ -0,0 +1,189 @@ +package io.dataease.plugins.loader; + +import io.dataease.plugins.config.SpringContextUtil; +import org.springframework.beans.factory.config.BeanDefinition; +import org.springframework.beans.factory.support.BeanDefinitionBuilder; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Repository; +import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.lang.reflect.Modifier; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.*; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; + +public class ModuleClassLoader extends URLClassLoader { + + //属于本类加载器加载的jar包 + private JarFile jarFile; + + //保存已经加载过的Class对象 + private Map cacheClassMap = new HashMap<>(); + + //保存本类加载器加载的class字节码 + private Map classBytesMap = new HashMap<>(); + + //需要注册的spring bean的name集合 + private List registeredBean = new ArrayList<>(); + + + //构造 + public ModuleClassLoader(URL[] urls, ClassLoader parent) { + super(urls, parent); + URL url = urls[0]; + String path = url.getPath(); + try { + jarFile = new JarFile(path); + } catch (IOException e) { + e.printStackTrace(); + } + //初始化类加载器执行类加载 + init(); + } + + + + //重写loadClass方法 + //改写loadClass方式 + @Override + public Class loadClass(String name) throws ClassNotFoundException { + if(findLoadedClass(name)==null){ + return super.loadClass(name); + }else{ + return cacheClassMap.get(name); + } + + } + + + + /** + * 方法描述 初始化类加载器,保存字节码 + * @method init + */ + private void init() { + + //解析jar包每一项 + Enumeration en = jarFile.entries(); + InputStream input = null; + try{ + while (en.hasMoreElements()) { + JarEntry je = en.nextElement(); + String name = je.getName(); + //这里添加了路径扫描限制 + if (name.endsWith(".class")) { + String className = name.replace(".class", "").replaceAll("/", "."); + input = jarFile.getInputStream(je); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + int bufferSize = 4096; + byte[] buffer = new byte[bufferSize]; + int bytesNumRead = 0; + while ((bytesNumRead = input.read(buffer)) != -1) { + baos.write(buffer, 0, bytesNumRead); + } + byte[] classBytes = baos.toByteArray(); + classBytesMap.put(className,classBytes); + } + } + } catch (IOException e) { + e.printStackTrace(); + } finally { + if(input!=null){ + try { + input.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + + //将jar中的每一个class字节码进行Class载入 + for (Map.Entry entry : classBytesMap.entrySet()) { + String key = entry.getKey(); + Class aClass = null; + try { + aClass = loadClass(key); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } + cacheClassMap.put(key,aClass); + } + + } + + /** + * 方法描述 初始化spring bean + * @method initBean + */ + public void initBean(){ + for (Map.Entry entry : cacheClassMap.entrySet()) { + String className = entry.getKey(); + Class cla = entry.getValue(); + if(isSpringBeanClass(cla)){ + BeanDefinitionBuilder beanDefinitionBuilder = BeanDefinitionBuilder.genericBeanDefinition(cla); + BeanDefinition beanDefinition = beanDefinitionBuilder.getRawBeanDefinition(); + //设置当前bean定义对象是单利的 + beanDefinition.setScope("singleton"); + + //将变量首字母置小写 + String beanName = StringUtils.uncapitalize(className); + + beanName = beanName.substring(beanName.lastIndexOf(".")+1); + beanName = StringUtils.uncapitalize(beanName); + + SpringContextUtil.getBeanFactory().registerBeanDefinition(beanName,beanDefinition); + registeredBean.add(beanName); + System.out.println("注册bean:"+beanName); + } + + } + } + + + //获取当前类加载器注册的bean + //在移除当前类加载器的时候需要手动删除这些注册的bean + public List getRegisteredBean() { + return registeredBean; + } + + + /** + * 方法描述 判断class对象是否带有spring的注解 + * @method isSpringBeanClass + * @param cla jar中的每一个class + * @return true 是spring bean false 不是spring bean + */ + public boolean isSpringBeanClass(Class cla){ + if(cla==null){ + return false; + } + //是否是接口 + if(cla.isInterface()){ + return false; + } + + //是否是抽象类 + if( Modifier.isAbstract(cla.getModifiers())){ + return false; + } + + if(cla.getAnnotation(Component.class)!=null){ + return true; + } + if(cla.getAnnotation(Repository.class)!=null){ + return true; + } + if(cla.getAnnotation(Service.class)!=null){ + return true; + } + + return false; + } + +} diff --git a/backend/src/main/java/io/dataease/service/chart/ChartViewService.java b/backend/src/main/java/io/dataease/service/chart/ChartViewService.java index bf150b46a7..da4b832be8 100644 --- a/backend/src/main/java/io/dataease/service/chart/ChartViewService.java +++ b/backend/src/main/java/io/dataease/service/chart/ChartViewService.java @@ -150,7 +150,7 @@ public class ChartViewService { // data = sparkCalc.getData(table.getId(), fields, xAxis, yAxis, "tmp_" + view.getId().split("-")[0], extFilterList); // 连接doris,构建doris数据源查询 - Datasource ds = (Datasource) CommonBeanFactory.getBean("DorisDatasource"); + Datasource ds = (Datasource) CommonBeanFactory.getBean("DorisDatasource"); DatasourceProvider datasourceProvider = ProviderFactory.getProvider(ds.getType()); DatasourceRequest datasourceRequest = new DatasourceRequest(); datasourceRequest.setDatasource(ds); @@ -199,9 +199,9 @@ public class ChartViewService { for (int i = 0; i < fields.size(); i++) { ChartViewFieldDTO chartViewFieldDTO = fields.get(i); if (chartViewFieldDTO.getDeType() == 0 || chartViewFieldDTO.getDeType() == 1) { - d.put(fields.get(i).getOriginName(), ele[i]); + d.put(fields.get(i).getDataeaseName(), ele[i]); } else if (chartViewFieldDTO.getDeType() == 2 || chartViewFieldDTO.getDeType() == 3) { - d.put(fields.get(i).getOriginName(), new BigDecimal(ele[i]).setScale(2, RoundingMode.HALF_UP)); + d.put(fields.get(i).getDataeaseName(), new BigDecimal(ele[i]).setScale(2, RoundingMode.HALF_UP)); } } tableRow.add(d); @@ -231,7 +231,7 @@ public class ChartViewService { } DatasetTableField field = request.getDatasetTableField(); filter.append(" AND ") - .append(field.getOriginName()) + .append(field.getDataeaseName()) .append(" ") .append(transMysqlFilterTerm(request.getOperator())) .append(" "); @@ -259,12 +259,12 @@ public class ChartViewService { public String transMysqlSQL(String table, List xAxis, List yAxis, List extFilterRequestList) { // 字段汇总 排序等 - String[] field = yAxis.stream().map(y -> "CAST(" + y.getSummary() + "(" + y.getOriginName() + ") AS DECIMAL(20,2)) AS _" + y.getSummary() + "_" + (StringUtils.equalsIgnoreCase(y.getOriginName(), "*") ? "" : y.getOriginName())).toArray(String[]::new); - String[] group = xAxis.stream().map(ChartViewFieldDTO::getOriginName).toArray(String[]::new); + String[] field = yAxis.stream().map(y -> "CAST(" + y.getSummary() + "(" + y.getDataeaseName() + ") AS " + (y.getDeType() == 2 ? "DECIMAL(20,0)" : "DECIMAL(20,2)") + ") AS _" + y.getSummary() + "_" + (StringUtils.equalsIgnoreCase(y.getDataeaseName(), "*") ? "" : y.getDataeaseName())).toArray(String[]::new); + String[] group = xAxis.stream().map(ChartViewFieldDTO::getDataeaseName).toArray(String[]::new); String[] xOrder = xAxis.stream().filter(f -> StringUtils.isNotEmpty(f.getSort()) && !StringUtils.equalsIgnoreCase(f.getSort(), "none")) - .map(f -> f.getOriginName() + " " + f.getSort()).toArray(String[]::new); + .map(f -> f.getDataeaseName() + " " + f.getSort()).toArray(String[]::new); String[] yOrder = yAxis.stream().filter(f -> StringUtils.isNotEmpty(f.getSort()) && !StringUtils.equalsIgnoreCase(f.getSort(), "none")) - .map(f -> "_" + f.getSummary() + "_" + (StringUtils.equalsIgnoreCase(f.getOriginName(), "*") ? "" : f.getOriginName()) + " " + f.getSort()).toArray(String[]::new); + .map(f -> "_" + f.getSummary() + "_" + (StringUtils.equalsIgnoreCase(f.getDataeaseName(), "*") ? "" : f.getDataeaseName()) + " " + f.getSort()).toArray(String[]::new); String[] order = Arrays.copyOf(xOrder, xOrder.length + yOrder.length); System.arraycopy(yOrder, 0, order, xOrder.length, yOrder.length); @@ -272,7 +272,7 @@ public class ChartViewService { .map(x -> { String[] s = x.getFilter().stream().map(f -> { StringBuilder filter = new StringBuilder(); - filter.append(" AND ").append(x.getOriginName()).append(transMysqlFilterTerm(f.getTerm())); + filter.append(" AND ").append(x.getDataeaseName()).append(transMysqlFilterTerm(f.getTerm())); if (StringUtils.containsIgnoreCase(f.getTerm(), "null")) { } else if (StringUtils.containsIgnoreCase(f.getTerm(), "in")) { filter.append("('").append(StringUtils.join(f.getValue(), "','")).append("')"); @@ -301,7 +301,7 @@ public class ChartViewService { .map(y -> { String[] s = y.getFilter().stream().map(f -> { StringBuilder filter = new StringBuilder(); - filter.append(" AND _").append(y.getSummary()).append("_").append(StringUtils.equalsIgnoreCase(y.getOriginName(), "*") ? "" : y.getOriginName()).append(transMysqlFilterTerm(f.getTerm())); + filter.append(" AND _").append(y.getSummary()).append("_").append(StringUtils.equalsIgnoreCase(y.getDataeaseName(), "*") ? "" : y.getDataeaseName()).append(transMysqlFilterTerm(f.getTerm())); if (StringUtils.containsIgnoreCase(f.getTerm(), "null")) { } else if (StringUtils.containsIgnoreCase(f.getTerm(), "in")) { filter.append("('").append(StringUtils.join(f.getValue(), "','")).append("')"); diff --git a/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java b/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java index 40cc45087e..a1f69fe642 100644 --- a/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java +++ b/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java @@ -74,6 +74,11 @@ public class DataSetTableService { public DatasetTable save(DatasetTable datasetTable) throws Exception { checkName(datasetTable); + if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "sql")) { + DataSetTableRequest dataSetTableRequest = new DataSetTableRequest(); + BeanUtils.copyBean(dataSetTableRequest, datasetTable); + getSQLPreview(dataSetTableRequest); + } if (StringUtils.isEmpty(datasetTable.getId())) { datasetTable.setId(UUID.randomUUID().toString()); datasetTable.setCreateBy(AuthUtils.getUser().getUsername()); @@ -163,6 +168,7 @@ public class DataSetTableService { .tableId(dataSetTableRequest.getId()) .originName("*") .name("记录数*") + .dataeaseName("*") .type("INT") .checked(true) .columnIndex(999) @@ -221,7 +227,7 @@ public class DataSetTableService { String table = dataTableInfoDTO.getTable(); datasourceRequest.setQuery(createQuerySQL(ds.getType(), table, fieldArray) + " LIMIT " + (page - 1) * pageSize + "," + realSize); - + LogUtil.info(datasourceRequest.getQuery()); try { data.addAll(datasourceProvider.getData(datasourceRequest)); } catch (Exception e) { @@ -241,7 +247,7 @@ public class DataSetTableService { String sql = dataTableInfoDTO.getSql(); datasourceRequest.setQuery(createQuerySQL(ds.getType(), " (" + sql + ") AS tmp ", fieldArray) + " LIMIT " + (page - 1) * pageSize + "," + realSize); - + LogUtil.info(datasourceRequest.getQuery()); try { data.addAll(datasourceProvider.getData(datasourceRequest)); } catch (Exception e) { @@ -260,7 +266,7 @@ public class DataSetTableService { datasourceRequest.setDatasource(ds); String table = DorisTableUtils.dorisName(dataSetTableRequest.getId()); datasourceRequest.setQuery(createQuerySQL(ds.getType(), table, fieldArray) + " LIMIT " + (page - 1) * pageSize + "," + realSize); - + LogUtil.info(datasourceRequest.getQuery()); try { data.addAll(jdbcProvider.getData(datasourceRequest)); } catch (Exception e) { @@ -280,7 +286,7 @@ public class DataSetTableService { datasourceRequest.setDatasource(ds); String table = DorisTableUtils.dorisName(dataSetTableRequest.getId()); datasourceRequest.setQuery(createQuerySQL(ds.getType(), table, fieldArray) + " LIMIT " + (page - 1) * pageSize + "," + realSize); - + LogUtil.info(datasourceRequest.getQuery()); try { data.addAll(jdbcProvider.getData(datasourceRequest)); } catch (Exception e) { @@ -320,7 +326,11 @@ public class DataSetTableService { DatasourceRequest datasourceRequest = new DatasourceRequest(); datasourceRequest.setDatasource(ds); String sql = new Gson().fromJson(dataSetTableRequest.getInfo(), DataTableInfoDTO.class).getSql(); - datasourceRequest.setQuery("SELECT * FROM (" + sql + ") AS tmp LIMIT 0,1000"); + // 使用输入的sql先预执行一次,并拿到所有字段 + datasourceRequest.setQuery(sql); + List previewFields = datasourceProvider.fetchResultField(datasourceRequest); + // 正式执行 + datasourceRequest.setQuery("SELECT * FROM (" + sql + ") AS tmp ORDER BY " + previewFields.get(0).getFieldName() + " LIMIT 0,1000"); Map result = datasourceProvider.fetchResultAndField(datasourceRequest); List data = result.get("dataList"); List fields = result.get("fieldList"); @@ -353,8 +363,12 @@ public class DataSetTableService { DataTableInfoDTO dataTableInfoDTO = new Gson().fromJson(dataSetTableRequest.getInfo(), DataTableInfoDTO.class); List list = dataSetTableUnionService.listByTableId(dataTableInfoDTO.getList().get(0).getTableId()); + String sql = getCustomSQL(dataTableInfoDTO, list); + // 使用输入的sql先预执行一次,并拿到所有字段 + datasourceRequest.setQuery(sql); + List previewFields = jdbcProvider.fetchResultField(datasourceRequest); - datasourceRequest.setQuery(getCustomSQL(dataTableInfoDTO, list)); + datasourceRequest.setQuery("SELECT * FROM (" + sql + ") AS tmp ORDER BY " + previewFields.get(0).getFieldName() + " LIMIT 0,1000"); Map result = jdbcProvider.fetchResultAndField(datasourceRequest); List data = result.get("dataList"); List fields = result.get("fieldList"); @@ -543,11 +557,11 @@ public class DataSetTableService { DatasourceTypes datasourceType = DatasourceTypes.valueOf(type); switch (datasourceType) { case mysql: - return MessageFormat.format("SELECT {0} FROM {1}", StringUtils.join(fields, ","), table); + return MessageFormat.format("SELECT {0} FROM {1} ORDER BY " + (fields.length > 0 ? fields[0] : "null"), StringUtils.join(fields, ","), table); case sqlServer: - return MessageFormat.format("SELECT {0} FROM {1}", StringUtils.join(fields, ","), table); + return MessageFormat.format("SELECT {0} FROM {1} ORDER BY " + (fields.length > 0 ? fields[0] : "null"), StringUtils.join(fields, ","), table); default: - return MessageFormat.format("SELECT {0} FROM {1}", StringUtils.join(fields, ","), table); + return MessageFormat.format("SELECT {0} FROM {1} ORDER BY " + (fields.length > 0 ? fields[0] : "null"), StringUtils.join(fields, ","), table); } } diff --git a/backend/src/main/java/io/dataease/service/sys/PluginService.java b/backend/src/main/java/io/dataease/service/sys/PluginService.java new file mode 100644 index 0000000000..4b5f2abbf5 --- /dev/null +++ b/backend/src/main/java/io/dataease/service/sys/PluginService.java @@ -0,0 +1,134 @@ +package io.dataease.service.sys; + +import com.google.gson.Gson; +import io.dataease.base.domain.MyPlugin; +import io.dataease.base.mapper.MyPluginMapper; +import io.dataease.base.mapper.ext.ExtSysPluginMapper; +import io.dataease.base.mapper.ext.query.GridExample; +import io.dataease.commons.utils.BeanUtils; +import io.dataease.commons.utils.DeFileUtils; +import io.dataease.commons.utils.ZipUtils; +import io.dataease.controller.sys.base.BaseGridRequest; +import io.dataease.plugins.config.LoadjarUtil; +import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; +import java.io.File; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.util.List; +import java.util.Map; + + +@Service +public class PluginService { + + @Value("${dataease.plugin.dir:/opt/dataease/plugins/}") + private String pluginDir; + + private final static String pluginJsonName = "plugin.json"; + + @Resource + private ExtSysPluginMapper extSysPluginMapper; + + @Resource + private MyPluginMapper myPluginMapper; + + @Resource + private LoadjarUtil loadjarUtil; + + public List query(BaseGridRequest request) { + GridExample gridExample = request.convertExample(); + List results = extSysPluginMapper.query(gridExample); + return results; + } + + /** + * 从本地安装处插件 + * @param file + * @return + */ + public Map localInstall(MultipartFile file) { + //1.上传文件到服务器pluginDir目录下 + File dest = DeFileUtils.upload(file, pluginDir+"temp/"); + //2.解压目标文件dest 得到plugin.json和jar + String folder = pluginDir+"folder/"; + try { + ZipUtils.upZipFile(dest, folder); + } catch (IOException e) { + // 需要删除文件 + e.printStackTrace(); + } + //3.解析plugin.json 失败则 直接返回错误 删除文件 + File folderFile = new File(folder); + File[] jsonFiles = folderFile.listFiles(this::isPluginJson); + if (ArrayUtils.isEmpty(jsonFiles)) { + throw new RuntimeException("缺少插件描述文件"); + } + MyPlugin myPlugin = formatJsonFile(jsonFiles[0]); + //4.加载jar包 失败则 直接返回错误 删除文件 + File[] jarFiles = folderFile.listFiles(this::isPluginJar); + if (ArrayUtils.isEmpty(jarFiles)) { + throw new RuntimeException("缺少插件jar文件"); + } + File jarFile = jarFiles[0]; + String jarRoot = pluginDir+"jar/"; + String jarPath = null; + try { + jarPath = DeFileUtils.copy(jarFile, jarRoot); + } catch (IOException e) { + e.printStackTrace(); + } + loadjarUtil.loadJar(jarPath); + //5.写表到my_plugin + myPlugin.setPluginId(0L); + myPluginMapper.insert(myPlugin); + return null; + } + + //判断当前文件是否实插件描述文件 + //文件名称必须plugin.json + private boolean isPluginJson(File file) { + return StringUtils.equals(file.getName(), pluginJsonName); + } + + private boolean isPluginJar(File file) { + String name = file.getName(); + return StringUtils.equals(DeFileUtils.getExtensionName(name), "jar"); + } + + /** + * 从plugin.json文件反序列化为MyPlugin实例对象 + * @return + */ + private MyPlugin formatJsonFile(File file) { + String str = DeFileUtils.readJson(file); + Gson gson = new Gson(); + Map myPlugin = gson.fromJson(str, Map.class); + myPlugin.put("free", (Double)myPlugin.get("free") > 0.0); + MyPlugin result = new MyPlugin(); + try { + org.apache.commons.beanutils.BeanUtils.populate(result, myPlugin); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } + //BeanUtils.copyBean(result, myPlugin); + return result; + } + + /** + * 从插件商城远程安装插件 + * 2.0版本实现 + * @param params + * @return + */ + public Map remoteInstall(Map params) { + return null; + } +} diff --git a/backend/src/main/resources/db/migration/V8__system.sql b/backend/src/main/resources/db/migration/V8__system.sql index 1a96439e1e..f7c72f8cff 100644 --- a/backend/src/main/resources/db/migration/V8__system.sql +++ b/backend/src/main/resources/db/migration/V8__system.sql @@ -239,3 +239,35 @@ INSERT INTO `sys_users_roles` VALUES (19, 4); COMMIT; SET FOREIGN_KEY_CHECKS = 1; + +SET NAMES utf8mb4; +SET FOREIGN_KEY_CHECKS = 0; + +-- ---------------------------- +-- Table structure for my_plugin +-- ---------------------------- +DROP TABLE IF EXISTS `my_plugin`; +CREATE TABLE `my_plugin` ( + `plugin_id` bigint(20) NOT NULL COMMENT '主键', + `name` varchar(255) DEFAULT NULL COMMENT '插件名称', + `free` tinyint(1) DEFAULT NULL COMMENT '是否免费', + `cost` int(10) DEFAULT NULL COMMENT '费用', + `descript` varchar(255) DEFAULT NULL COMMENT '描述', + `version` varchar(255) DEFAULT NULL COMMENT '版本号', + `install_type` int(4) DEFAULT NULL COMMENT '安装类型', + `creator` varchar(255) DEFAULT NULL COMMENT '开发者', + `release_time` bigint(13) DEFAULT NULL COMMENT '发布时间', + `install_time` bigint(13) DEFAULT NULL COMMENT '安装时间', + `module_name` varchar(255) DEFAULT NULL COMMENT 'jar包名称', + `bean_name` varchar(40) DEFAULT NULL COMMENT 'bean名称', + `icon` varchar(255) DEFAULT NULL COMMENT '图标', + PRIMARY KEY (`plugin_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- ---------------------------- +-- Records of my_plugin +-- ---------------------------- +BEGIN; +COMMIT; + +SET FOREIGN_KEY_CHECKS = 1; diff --git a/backend/src/main/resources/generatorConfig.xml b/backend/src/main/resources/generatorConfig.xml index 6aa551a59a..7bf112a3c0 100644 --- a/backend/src/main/resources/generatorConfig.xml +++ b/backend/src/main/resources/generatorConfig.xml @@ -67,7 +67,7 @@ - +
diff --git a/frontend/package.json b/frontend/package.json index 65c1a2ba34..595b2d4646 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -35,6 +35,7 @@ "umy-ui": "^1.1.6", "vcolorpicker": "^1.1.0", "vue": "2.6.10", + "vue-axios": "3.2.4", "vue-clipboard2": "0.3.1", "vue-codemirror": "^4.0.6", "vue-i18n": "7.3.2", diff --git a/frontend/public/index.html b/frontend/public/index.html index acf03654a4..9562e7af22 100644 --- a/frontend/public/index.html +++ b/frontend/public/index.html @@ -4,7 +4,8 @@ - + + <%= webpackConfig.name %> diff --git a/frontend/src/api/system/plugin.js b/frontend/src/api/system/plugin.js new file mode 100644 index 0000000000..cc22401f55 --- /dev/null +++ b/frontend/src/api/system/plugin.js @@ -0,0 +1,13 @@ +import request from '@/utils/request' +const pathMap = { + queryPath: '/api/plugin/pluginGrid/' +} +export function pluginLists(page, size, data) { + return request({ + url: pathMap.queryPath + page + '/' + size, + method: 'post', + data, + loading: true + }) +} + diff --git a/frontend/src/components/AsyncComponent/index.vue b/frontend/src/components/AsyncComponent/index.vue new file mode 100644 index 0000000000..08eae71e02 --- /dev/null +++ b/frontend/src/components/AsyncComponent/index.vue @@ -0,0 +1,53 @@ + + + diff --git a/frontend/src/lang/zh.js b/frontend/src/lang/zh.js index 655f5732c0..bc118254a5 100644 --- a/frontend/src/lang/zh.js +++ b/frontend/src/lang/zh.js @@ -812,9 +812,10 @@ export default { target_field: '被关联字段', union_relation: '关联关系', pls_setting_union_success: '请正确设置关联关系', - invalid_dataset:'Kettle未运行,无效数据集', + invalid_dataset: 'Kettle未运行,无效数据集', check_all: '全选', - can_not_union_self: '被关联表不能与关联表相同' + can_not_union_self: '被关联表不能与关联表相同', + float: '小数' }, datasource: { datasource: '数据源', @@ -887,5 +888,20 @@ export default { back: '返回', view: '视图', edit: '编辑' + }, + plugin: { + local_install: '本地安装', + remote_install: '远程安装', + name: '插件名称', + free: '是否免费', + cost: '费用', + descript: '描述', + version: '版本', + creator: '作者', + install_time: '安装时间', + release_time: '时间', + un_install: '卸载', + uninstall_confirm: '确定卸载该插件', + uninstall_cancel: '取消卸载插件' } } diff --git a/frontend/src/main.js b/frontend/src/main.js index 9da6c562bc..ef5ab39f23 100644 --- a/frontend/src/main.js +++ b/frontend/src/main.js @@ -3,7 +3,8 @@ import Cookies from 'js-cookie' import '@/styles/index.scss' // global css import ElementUI from 'element-ui' import Fit2CloudUI from 'fit2cloud-ui' - +import axios from 'axios' +import VueAxios from 'vue-axios' import i18n from './lang' // internationalization import App from './App' import store from './store' @@ -59,6 +60,7 @@ Vue.use(ElementUI, { Vue.use(Fit2CloudUI, { i18n: (key, value) => i18n.t(key, value) }) +Vue.use(VueAxios, axios) Vue.use(filter) Vue.use(directives) Vue.use(message) diff --git a/frontend/src/router/index.js b/frontend/src/router/index.js index c4eaca82c6..9f61116aaf 100644 --- a/frontend/src/router/index.js +++ b/frontend/src/router/index.js @@ -85,7 +85,7 @@ export const constantRoutes = [ { path: '/', component: Layout, - redirect: '/panel', + redirect: '/panel/index', hidden: true } diff --git a/frontend/src/views/dataset/add/AddCustom.vue b/frontend/src/views/dataset/add/AddCustom.vue index 3e300be0bf..2633e4c420 100644 --- a/frontend/src/views/dataset/add/AddCustom.vue +++ b/frontend/src/views/dataset/add/AddCustom.vue @@ -28,24 +28,34 @@ - - - - + + +
+ {{ $t('dataset.data_preview') }} +
+ + + + + {{ $t('dataset.preview_show') }} + 1000 + {{ $t('dataset.preview_item') }} + +
@@ -101,7 +111,7 @@ export default { const that = this setTimeout(function() { const currentHeight = document.documentElement.clientHeight - that.height = currentHeight - 56 - 15 - 26 - 25 - 43 - 15 + that.height = currentHeight - 56 - 15 - 26 - 25 - 43 - 16 - 37 - 20 - 10 }, 10) }, @@ -207,6 +217,14 @@ export default { margin-left: 0; } + .dataPreview>>>.el-card__header{ + padding: 6px 8px; + } + + .dataPreview>>>.el-card__body{ + padding:10px; + } + span{ font-size: 14px; } @@ -214,4 +232,11 @@ export default { .panel-height{ height: calc(100vh - 56px - 15px - 26px - 25px - 43px); } + + .span-number{ + color: #f18126; + } + .table-count{ + color: #606266; + } diff --git a/frontend/src/views/dataset/common/DatasetTableData.vue b/frontend/src/views/dataset/common/DatasetTableData.vue index 1839633ac3..7bdb288c37 100644 --- a/frontend/src/views/dataset/common/DatasetTableData.vue +++ b/frontend/src/views/dataset/common/DatasetTableData.vue @@ -11,9 +11,9 @@ > diff --git a/frontend/src/views/dataset/data/FieldEdit.vue b/frontend/src/views/dataset/data/FieldEdit.vue index 3a03192151..d3be80d2f7 100644 --- a/frontend/src/views/dataset/data/FieldEdit.vue +++ b/frontend/src/views/dataset/data/FieldEdit.vue @@ -12,19 +12,37 @@ - + @@ -58,7 +76,13 @@ export default { data() { return { maxHeight: 'auto', - tableFields: [] + tableFields: [], + fields: [ + { label: this.$t('dataset.text'), value: 0 }, + { label: this.$t('dataset.time'), value: 1 }, + { label: this.$t('dataset.value'), value: 2 }, + { label: this.$t('dataset.value') + '(' + this.$t('dataset.float') + ')', value: 3 } + ] } }, watch: { @@ -108,4 +132,10 @@ export default { .field-class{ font-size: 12px !important; } + .el-select>>>input{ + padding-right: 10px; + } + .el-select>>>.el-input__suffix{ + right: 0; + } diff --git a/frontend/src/views/dataset/data/ViewTable.vue b/frontend/src/views/dataset/data/ViewTable.vue index 0f759300f5..f7f45a95d7 100644 --- a/frontend/src/views/dataset/data/ViewTable.vue +++ b/frontend/src/views/dataset/data/ViewTable.vue @@ -31,7 +31,7 @@ - + diff --git a/frontend/src/views/system/plugin/index.vue b/frontend/src/views/system/plugin/index.vue new file mode 100644 index 0000000000..90feda6ea2 --- /dev/null +++ b/frontend/src/views/system/plugin/index.vue @@ -0,0 +1,162 @@ + + + + + diff --git a/frontend/src/views/system/systemParamSettings/index.vue b/frontend/src/views/system/systemParamSettings/index.vue index b0966c88d0..b789b650c7 100644 --- a/frontend/src/views/system/systemParamSettings/index.vue +++ b/frontend/src/views/system/systemParamSettings/index.vue @@ -1,34 +1,41 @@