diff --git a/Dockerfile b/Dockerfile index ae8731a389..209a5a99b1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,26 +1,11 @@ FROM registry.cn-qingdao.aliyuncs.com/dataease/fabric8-java-alpine-openjdk8-jre:edge-chromium -# RUN echo -e 'https://dl-cdn.alpinelinux.org/alpine/edge/main/\nhttps://dl-cdn.alpinelinux.org/alpine/edge/community/' > /etc/apk/repositories - -# RUN apk add chromium chromium-chromedriver fontconfig --no-cache --allow-untrusted - -# ADD simsun.ttc /usr/share/fonts/ - -# RUN cd /usr/share/fonts/ \ -# && mkfontscale \ -# && mkfontdir \ -# && fc-cache -fv - ARG IMAGE_TAG -RUN mkdir -p /opt/apps - -RUN mkdir -p /opt/dataease/data/feature/full +RUN mkdir -p /opt/apps /opt/dataease/data/feature/full /opt/dataease/drivers ADD mapFiles/* /opt/dataease/data/feature/full/ -RUN mkdir -p /opt/dataease/drivers - ADD drivers/* /opt/dataease/drivers/ ADD backend/target/backend-$IMAGE_TAG.jar /opt/apps diff --git a/backend/pom.xml b/backend/pom.xml index 1049621672..7d1e213fc0 100644 --- a/backend/pom.xml +++ b/backend/pom.xml @@ -106,6 +106,7 @@ mysql mysql-connector-java + 8.0.28 runtime @@ -279,6 +280,16 @@ json-path 2.4.0 + + + org.springframework.boot + spring-boot-starter-data-redis + + + + org.apache.commons + commons-pool2 + @@ -403,7 +414,7 @@ mysql mysql-connector-java - 8.0.16 + 8.0.28 com.itfsw diff --git a/backend/src/main/java/io/dataease/auth/entity/SysUserEntity.java b/backend/src/main/java/io/dataease/auth/entity/SysUserEntity.java index 99ae03a2e2..cd0c12fff2 100644 --- a/backend/src/main/java/io/dataease/auth/entity/SysUserEntity.java +++ b/backend/src/main/java/io/dataease/auth/entity/SysUserEntity.java @@ -1,6 +1,5 @@ package io.dataease.auth.entity; - import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -39,4 +38,7 @@ public class SysUserEntity implements Serializable { @ApiModelProperty(hidden = true) private Boolean isAdmin; + + @ApiModelProperty(hidden = true) + private Integer from; } 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 a5748dc71a..9bea8f4a0e 100644 --- a/backend/src/main/java/io/dataease/auth/server/AuthServer.java +++ b/backend/src/main/java/io/dataease/auth/server/AuthServer.java @@ -141,7 +141,7 @@ public class AuthServer implements AuthApi { @Override public Boolean useInitPwd() { CurrentUserDto user = AuthUtils.getUser(); - if (null == user) { + if (null == user || 0 != user.getFrom()) { return false; } String md5 = CodingUtil.md5(DEFAULT_PWD); diff --git a/backend/src/main/java/io/dataease/base/domain/ChartView.java b/backend/src/main/java/io/dataease/base/domain/ChartView.java index 569746859c..dd6a16307b 100644 --- a/backend/src/main/java/io/dataease/base/domain/ChartView.java +++ b/backend/src/main/java/io/dataease/base/domain/ChartView.java @@ -1,39 +1,42 @@ package io.dataease.base.domain; import java.io.Serializable; + +import io.swagger.annotations.ApiModelProperty; import lombok.Data; @Data public class ChartView implements Serializable { + @ApiModelProperty("ID") private String id; - + @ApiModelProperty("名称") private String name; - - private String title; - - private String sceneId; - + @ApiModelProperty("数据集ID") private String tableId; - + @ApiModelProperty("图表类型") private String type; - + @ApiModelProperty("渲染方式") private String render; - + @ApiModelProperty("展示结果数量") private Integer resultCount; - + @ApiModelProperty("展示结果") private String resultMode; - + @ApiModelProperty("标题") + private String title; + @ApiModelProperty("场景ID") + private String sceneId; + @ApiModelProperty("创建人") private String createBy; - + @ApiModelProperty("创建时间") private Long createTime; - + @ApiModelProperty("更新时间") private Long updateTime; - + @ApiModelProperty("样式优先级") private String stylePriority; - + @ApiModelProperty("public or private") private String chartType; - + @ApiModelProperty("是否插件") private Boolean isPlugin; private static final long serialVersionUID = 1L; -} \ No newline at end of file +} diff --git a/backend/src/main/java/io/dataease/base/domain/ChartViewExample.java b/backend/src/main/java/io/dataease/base/domain/ChartViewExample.java index 51a45711b1..f4d44ca52a 100644 --- a/backend/src/main/java/io/dataease/base/domain/ChartViewExample.java +++ b/backend/src/main/java/io/dataease/base/domain/ChartViewExample.java @@ -244,146 +244,6 @@ public class ChartViewExample { return (Criteria) this; } - public Criteria andTitleIsNull() { - addCriterion("title is null"); - return (Criteria) this; - } - - public Criteria andTitleIsNotNull() { - addCriterion("title is not null"); - return (Criteria) this; - } - - public Criteria andTitleEqualTo(String value) { - addCriterion("title =", value, "title"); - return (Criteria) this; - } - - public Criteria andTitleNotEqualTo(String value) { - addCriterion("title <>", value, "title"); - return (Criteria) this; - } - - public Criteria andTitleGreaterThan(String value) { - addCriterion("title >", value, "title"); - return (Criteria) this; - } - - public Criteria andTitleGreaterThanOrEqualTo(String value) { - addCriterion("title >=", value, "title"); - return (Criteria) this; - } - - public Criteria andTitleLessThan(String value) { - addCriterion("title <", value, "title"); - return (Criteria) this; - } - - public Criteria andTitleLessThanOrEqualTo(String value) { - addCriterion("title <=", value, "title"); - return (Criteria) this; - } - - public Criteria andTitleLike(String value) { - addCriterion("title like", value, "title"); - return (Criteria) this; - } - - public Criteria andTitleNotLike(String value) { - addCriterion("title not like", value, "title"); - return (Criteria) this; - } - - public Criteria andTitleIn(List values) { - addCriterion("title in", values, "title"); - return (Criteria) this; - } - - public Criteria andTitleNotIn(List values) { - addCriterion("title not in", values, "title"); - return (Criteria) this; - } - - public Criteria andTitleBetween(String value1, String value2) { - addCriterion("title between", value1, value2, "title"); - return (Criteria) this; - } - - public Criteria andTitleNotBetween(String value1, String value2) { - addCriterion("title not between", value1, value2, "title"); - return (Criteria) this; - } - - public Criteria andSceneIdIsNull() { - addCriterion("scene_id is null"); - return (Criteria) this; - } - - public Criteria andSceneIdIsNotNull() { - addCriterion("scene_id is not null"); - return (Criteria) this; - } - - public Criteria andSceneIdEqualTo(String value) { - addCriterion("scene_id =", value, "sceneId"); - return (Criteria) this; - } - - public Criteria andSceneIdNotEqualTo(String value) { - addCriterion("scene_id <>", value, "sceneId"); - return (Criteria) this; - } - - public Criteria andSceneIdGreaterThan(String value) { - addCriterion("scene_id >", value, "sceneId"); - return (Criteria) this; - } - - public Criteria andSceneIdGreaterThanOrEqualTo(String value) { - addCriterion("scene_id >=", value, "sceneId"); - return (Criteria) this; - } - - public Criteria andSceneIdLessThan(String value) { - addCriterion("scene_id <", value, "sceneId"); - return (Criteria) this; - } - - public Criteria andSceneIdLessThanOrEqualTo(String value) { - addCriterion("scene_id <=", value, "sceneId"); - return (Criteria) this; - } - - public Criteria andSceneIdLike(String value) { - addCriterion("scene_id like", value, "sceneId"); - return (Criteria) this; - } - - public Criteria andSceneIdNotLike(String value) { - addCriterion("scene_id not like", value, "sceneId"); - return (Criteria) this; - } - - public Criteria andSceneIdIn(List values) { - addCriterion("scene_id in", values, "sceneId"); - return (Criteria) this; - } - - public Criteria andSceneIdNotIn(List values) { - addCriterion("scene_id not in", values, "sceneId"); - return (Criteria) this; - } - - public Criteria andSceneIdBetween(String value1, String value2) { - addCriterion("scene_id between", value1, value2, "sceneId"); - return (Criteria) this; - } - - public Criteria andSceneIdNotBetween(String value1, String value2) { - addCriterion("scene_id not between", value1, value2, "sceneId"); - return (Criteria) this; - } - public Criteria andTableIdIsNull() { addCriterion("table_id is null"); return (Criteria) this; @@ -724,6 +584,146 @@ public class ChartViewExample { return (Criteria) this; } + public Criteria andTitleIsNull() { + addCriterion("title is null"); + return (Criteria) this; + } + + public Criteria andTitleIsNotNull() { + addCriterion("title is not null"); + return (Criteria) this; + } + + public Criteria andTitleEqualTo(String value) { + addCriterion("title =", value, "title"); + return (Criteria) this; + } + + public Criteria andTitleNotEqualTo(String value) { + addCriterion("title <>", value, "title"); + return (Criteria) this; + } + + public Criteria andTitleGreaterThan(String value) { + addCriterion("title >", value, "title"); + return (Criteria) this; + } + + public Criteria andTitleGreaterThanOrEqualTo(String value) { + addCriterion("title >=", value, "title"); + return (Criteria) this; + } + + public Criteria andTitleLessThan(String value) { + addCriterion("title <", value, "title"); + return (Criteria) this; + } + + public Criteria andTitleLessThanOrEqualTo(String value) { + addCriterion("title <=", value, "title"); + return (Criteria) this; + } + + public Criteria andTitleLike(String value) { + addCriterion("title like", value, "title"); + return (Criteria) this; + } + + public Criteria andTitleNotLike(String value) { + addCriterion("title not like", value, "title"); + return (Criteria) this; + } + + public Criteria andTitleIn(List values) { + addCriterion("title in", values, "title"); + return (Criteria) this; + } + + public Criteria andTitleNotIn(List values) { + addCriterion("title not in", values, "title"); + return (Criteria) this; + } + + public Criteria andTitleBetween(String value1, String value2) { + addCriterion("title between", value1, value2, "title"); + return (Criteria) this; + } + + public Criteria andTitleNotBetween(String value1, String value2) { + addCriterion("title not between", value1, value2, "title"); + return (Criteria) this; + } + + public Criteria andSceneIdIsNull() { + addCriterion("scene_id is null"); + return (Criteria) this; + } + + public Criteria andSceneIdIsNotNull() { + addCriterion("scene_id is not null"); + return (Criteria) this; + } + + public Criteria andSceneIdEqualTo(String value) { + addCriterion("scene_id =", value, "sceneId"); + return (Criteria) this; + } + + public Criteria andSceneIdNotEqualTo(String value) { + addCriterion("scene_id <>", value, "sceneId"); + return (Criteria) this; + } + + public Criteria andSceneIdGreaterThan(String value) { + addCriterion("scene_id >", value, "sceneId"); + return (Criteria) this; + } + + public Criteria andSceneIdGreaterThanOrEqualTo(String value) { + addCriterion("scene_id >=", value, "sceneId"); + return (Criteria) this; + } + + public Criteria andSceneIdLessThan(String value) { + addCriterion("scene_id <", value, "sceneId"); + return (Criteria) this; + } + + public Criteria andSceneIdLessThanOrEqualTo(String value) { + addCriterion("scene_id <=", value, "sceneId"); + return (Criteria) this; + } + + public Criteria andSceneIdLike(String value) { + addCriterion("scene_id like", value, "sceneId"); + return (Criteria) this; + } + + public Criteria andSceneIdNotLike(String value) { + addCriterion("scene_id not like", value, "sceneId"); + return (Criteria) this; + } + + public Criteria andSceneIdIn(List values) { + addCriterion("scene_id in", values, "sceneId"); + return (Criteria) this; + } + + public Criteria andSceneIdNotIn(List values) { + addCriterion("scene_id not in", values, "sceneId"); + return (Criteria) this; + } + + public Criteria andSceneIdBetween(String value1, String value2) { + addCriterion("scene_id between", value1, value2, "sceneId"); + return (Criteria) this; + } + + public Criteria andSceneIdNotBetween(String value1, String value2) { + addCriterion("scene_id not between", value1, value2, "sceneId"); + return (Criteria) this; + } + public Criteria andCreateByIsNull() { addCriterion("create_by is null"); return (Criteria) this; @@ -1207,4 +1207,4 @@ public class ChartViewExample { this(condition, value, secondValue, null); } } -} \ No newline at end of file +} diff --git a/backend/src/main/java/io/dataease/base/domain/ChartViewWithBLOBs.java b/backend/src/main/java/io/dataease/base/domain/ChartViewWithBLOBs.java index d928332ac5..f0492a42d3 100644 --- a/backend/src/main/java/io/dataease/base/domain/ChartViewWithBLOBs.java +++ b/backend/src/main/java/io/dataease/base/domain/ChartViewWithBLOBs.java @@ -1,6 +1,8 @@ package io.dataease.base.domain; import java.io.Serializable; + +import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; @@ -9,27 +11,30 @@ import lombok.ToString; @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) public class ChartViewWithBLOBs extends ChartView implements Serializable { + @ApiModelProperty("x轴") private String xAxis; - + @ApiModelProperty("x副轴") private String xAxisExt; - + @ApiModelProperty("y轴") private String yAxis; - + @ApiModelProperty("y副轴") private String yAxisExt; - + @ApiModelProperty("堆叠字段") private String extStack; - + @ApiModelProperty("气泡大小字段") private String extBubble; - + @ApiModelProperty("图形属性") private String customAttr; - + @ApiModelProperty("组件样式") private String customStyle; - + @ApiModelProperty("过滤器字段") private String customFilter; - + @ApiModelProperty("下钻字段") private String drillFields; - + @ApiModelProperty("高级设置") + private String senior; + @ApiModelProperty("视图截图快照") private String snapshot; private static final long serialVersionUID = 1L; -} \ No newline at end of file +} diff --git a/backend/src/main/java/io/dataease/base/mapper/ChartViewMapper.xml b/backend/src/main/java/io/dataease/base/mapper/ChartViewMapper.xml index d7e9404ad0..c8d1f5c55f 100644 --- a/backend/src/main/java/io/dataease/base/mapper/ChartViewMapper.xml +++ b/backend/src/main/java/io/dataease/base/mapper/ChartViewMapper.xml @@ -4,13 +4,13 @@ - - + + @@ -29,6 +29,7 @@ + @@ -90,12 +91,12 @@ - id, `name`, title, scene_id, table_id, `type`, render, result_count, result_mode, + id, `name`, table_id, `type`, render, result_count, result_mode, title, scene_id, create_by, create_time, update_time, style_priority, chart_type, is_plugin - x_axis, x_axis_ext, y_axis, y_axis_ext, ext_stack, ext_bubble, custom_attr, custom_style, - custom_filter, drill_fields, snapshot + x_axis, x_axis_ext, y_axis, y_axis_ext, ext_stack, ext_bubble, custom_attr, custom_style, + custom_filter, drill_fields, senior, snapshot - select user_id, username,nick_name, dept_id, password, enabled,email, phone, language,is_admin from sys_user where user_id = #{userId} + select user_id, username,nick_name, dept_id, password, enabled,email, phone, language,is_admin, `from` from sys_user where user_id = #{userId} - select - chart_view.* - from chart_view where id = #{id} + select chart_view.* + from chart_view + where id = #{id} - INSERT INTO chart_view ( - `id`, - `name`, - `scene_id`, - `table_id`, - `type`, - `title`, - `x_axis`, - `x_axis_ext`, - `y_axis`, - `custom_attr`, - `custom_style`, - `custom_filter`, - `drill_fields`, - `create_by`, - `create_time`, - `update_time`, - `snapshot`, - `style_priority`, - `ext_stack`, - `ext_bubble`, - `y_axis_ext`, - `render`, - `result_count`, - `result_mode`, - `chart_type` - ) SELECT - #{newChartId}, - GET_CHART_VIEW_COPY_NAME ( #{oldChartId} ), - #{panelId}, - `table_id`, - `type`, - GET_CHART_VIEW_COPY_NAME ( #{oldChartId} ), - `x_axis`, - `x_axis_ext`, - `y_axis`, - `custom_attr`, - `custom_style`, - `custom_filter`, - `drill_fields`, - `create_by`, - `create_time`, - `update_time`, - `snapshot`, - `style_priority`, - `ext_stack`, - `ext_bubble`, - `y_axis_ext`, - `render`, - `result_count`, - `result_mode`, - 'private' - FROM - chart_view - WHERE - id = #{oldChartId} + INSERT INTO chart_view (`id`, + `name`, + `scene_id`, + `table_id`, + `type`, + `title`, + `x_axis`, + `x_axis_ext`, + `y_axis`, + `custom_attr`, + `custom_style`, + `custom_filter`, + `drill_fields`, + `create_by`, + `create_time`, + `update_time`, + `snapshot`, + `style_priority`, + `ext_stack`, + `ext_bubble`, + `y_axis_ext`, + `render`, + `result_count`, + `result_mode`, + `chart_type`, + `senior`) + SELECT #{newChartId}, + GET_CHART_VIEW_COPY_NAME(#{oldChartId}), + #{panelId}, + `table_id`, + `type`, + GET_CHART_VIEW_COPY_NAME(#{oldChartId}), + `x_axis`, + `x_axis_ext`, + `y_axis`, + `custom_attr`, + `custom_style`, + `custom_filter`, + `drill_fields`, + `create_by`, + `create_time`, + `update_time`, + `snapshot`, + `style_priority`, + `ext_stack`, + `ext_bubble`, + `y_axis_ext`, + `render`, + `result_count`, + `result_mode`, + 'private', + `senior` + FROM chart_view + WHERE id = #{oldChartId} - - INSERT INTO chart_view ( - id, - `name`, - title, - scene_id, - table_id, - `type`, - render, - result_count, - result_mode, - create_by, - create_time, - update_time, - style_priority, - chart_type, - is_plugin, - x_axis, - x_axis_ext, - y_axis, - y_axis_ext, - ext_stack, - ext_bubble, - custom_attr, - custom_style, - custom_filter, - drill_fields, - SNAPSHOT - ) SELECT - pv_copy.chart_view_id AS id, - `name`, - title, - pv_copy.panel_id AS scene_id, - table_id, - `type`, - render, - result_count, - result_mode, - create_by, - create_time, - update_time, - style_priority, - chart_type, - is_plugin, - x_axis, - x_axis_ext, - y_axis, - y_axis_ext, - ext_stack, - ext_bubble, - custom_attr, - custom_style, - custom_filter, - drill_fields, - SNAPSHOT - FROM - ( - SELECT - panel_id, - copy_from_view, - chart_view_id - FROM - panel_view - WHERE - copy_id = #{copyId} - ) pv_copy - LEFT JOIN chart_view ON chart_view.id = pv_copy.copy_from_view + + INSERT INTO chart_view (id, + `name`, + title, + scene_id, + table_id, + `type`, + render, + result_count, + result_mode, + create_by, + create_time, + update_time, + style_priority, + chart_type, + is_plugin, + x_axis, + x_axis_ext, + y_axis, + y_axis_ext, + ext_stack, + ext_bubble, + custom_attr, + custom_style, + custom_filter, + drill_fields, + SNAPSHOT) + SELECT pv_copy.chart_view_id AS id, + `name`, + title, + pv_copy.panel_id AS scene_id, + table_id, + `type`, + render, + result_count, + result_mode, + create_by, + create_time, + update_time, + style_priority, + chart_type, + is_plugin, + x_axis, + x_axis_ext, + y_axis, + y_axis_ext, + ext_stack, + ext_bubble, + custom_attr, + custom_style, + custom_filter, + drill_fields, + SNAPSHOT + FROM ( + SELECT panel_id, + copy_from_view, + chart_view_id + FROM panel_view + WHERE copy_id = #{copyId} + ) pv_copy + LEFT JOIN chart_view ON chart_view.id = pv_copy.copy_from_view - delete chart_view from (select GET_CHART_GROUP_WITH_CHILDREN(#{pid}) cids) t,chart_view where FIND_IN_SET(chart_view.id,cids) and chart_type='public' + delete + chart_view from (select GET_CHART_GROUP_WITH_CHILDREN( + #{pid} + ) + cids + ) + t, + chart_view + where + FIND_IN_SET + ( + chart_view + . + id, + cids + ) + and + chart_type + = + 'public' - delete chart_group from (select GET_CHART_GROUP_WITH_CHILDREN(#{pid}) cids) t,chart_group where FIND_IN_SET(chart_group.id,cids) + delete + chart_group from (select GET_CHART_GROUP_WITH_CHILDREN( + #{pid} + ) + cids + ) + t, + chart_group + where + FIND_IN_SET + ( + chart_group + . + id, + cids + ) diff --git a/backend/src/main/java/io/dataease/commons/condition/RedisStatusCondition.java b/backend/src/main/java/io/dataease/commons/condition/RedisStatusCondition.java new file mode 100644 index 0000000000..ad23200b57 --- /dev/null +++ b/backend/src/main/java/io/dataease/commons/condition/RedisStatusCondition.java @@ -0,0 +1,23 @@ +package io.dataease.commons.condition; + +import io.dataease.commons.utils.CommonBeanFactory; +import org.apache.commons.lang3.StringUtils; +import org.springframework.context.annotation.Condition; +import org.springframework.context.annotation.ConditionContext; +import org.springframework.core.env.Environment; +import org.springframework.core.type.AnnotatedTypeMetadata; + +public class RedisStatusCondition implements Condition { + + private static final String DEFAULT_TYPE = "ehcache"; + private static final String TARGET_TYPE = "redis"; + private static final String TYPE_KEY = "spring.cache.type"; + + @Override + public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) { + Environment environment = context.getEnvironment(); + String ehcacheType = environment.getProperty(TYPE_KEY, String.class, DEFAULT_TYPE); + + return StringUtils.equals(TARGET_TYPE, ehcacheType); + } +} diff --git a/backend/src/main/java/io/dataease/config/RedisConfig.java b/backend/src/main/java/io/dataease/config/RedisConfig.java new file mode 100644 index 0000000000..c3778545bc --- /dev/null +++ b/backend/src/main/java/io/dataease/config/RedisConfig.java @@ -0,0 +1,27 @@ +package io.dataease.config; + + +import io.dataease.commons.condition.RedisStatusCondition; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Conditional; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.redis.connection.RedisConnectionFactory; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; + + + +@Configuration +public class RedisConfig { + + @Conditional({RedisStatusCondition.class}) + @Bean + public RedisTemplate redisTemplate(RedisConnectionFactory factory) { + RedisTemplate redisTemplate = new RedisTemplate<>(); + redisTemplate.setConnectionFactory(factory); + Jackson2JsonRedisSerializer serializer = new Jackson2JsonRedisSerializer(Object.class); + redisTemplate.setDefaultSerializer(serializer); + return redisTemplate; + } + +} diff --git a/backend/src/main/java/io/dataease/controller/dataset/DataSetTableUnionController.java b/backend/src/main/java/io/dataease/controller/dataset/DataSetTableUnionController.java index fd981b1fc1..c9f401e47f 100644 --- a/backend/src/main/java/io/dataease/controller/dataset/DataSetTableUnionController.java +++ b/backend/src/main/java/io/dataease/controller/dataset/DataSetTableUnionController.java @@ -26,17 +26,18 @@ public class DataSetTableUnionController { @Resource private DataSetTableUnionService dataSetTableUnionService; + @DePermission(type = DePermissionType.DATASET, value = "sourceTableId", level = ResourceAuthLevel.DATASET_LEVEL_MANAGE) @ApiOperation("保存") @PostMapping("save") public DatasetTableUnion save(@RequestBody DatasetTableUnion datasetTableUnion) { return dataSetTableUnionService.save(datasetTableUnion); } - @DePermission(type = DePermissionType.DATASET, level = ResourceAuthLevel.DATASET_LEVEL_MANAGE) + @DePermission(type = DePermissionType.DATASET, value = "sourceTableId", level = ResourceAuthLevel.DATASET_LEVEL_MANAGE) @ApiOperation("删除") - @PostMapping("delete/{id}") - public void delete(@PathVariable String id) { - dataSetTableUnionService.delete(id); + @PostMapping("delete") + public void delete(@RequestBody DatasetTableUnion datasetTableUnion) { + dataSetTableUnionService.delete(datasetTableUnion.getId()); } @DePermission(type = DePermissionType.DATASET) diff --git a/backend/src/main/java/io/dataease/listener/util/CacheUtils.java b/backend/src/main/java/io/dataease/listener/util/CacheUtils.java index 443a9dc3fd..913fa42bb4 100644 --- a/backend/src/main/java/io/dataease/listener/util/CacheUtils.java +++ b/backend/src/main/java/io/dataease/listener/util/CacheUtils.java @@ -1,30 +1,46 @@ package io.dataease.listener.util; +import io.dataease.commons.utils.CommonBeanFactory; import net.sf.ehcache.Cache; import net.sf.ehcache.Element; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cache.CacheManager; import org.springframework.cache.ehcache.EhCacheCacheManager; -import org.springframework.context.annotation.Configuration; -import java.util.Date; +import org.springframework.data.redis.cache.RedisCacheManager; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.core.ValueOperations; + +import java.util.Date; +import java.util.concurrent.TimeUnit; -@Configuration public class CacheUtils { - private static CacheManager manager; + private static CacheManager cacheManager; - @Autowired - public void setManager(CacheManager manager) { - CacheUtils.manager = manager; + + private static CacheManager getCacheManager() { + if (cacheManager == null) + cacheManager = CommonBeanFactory.getBean(CacheManager.class); + return cacheManager; } public static Object get(String cacheName, Object key) { + if (getCacheManager() instanceof RedisCacheManager) { + org.springframework.cache.Cache cache = getCacheManager().getCache(cacheName); + if (null == cache) return null; + return cache.get(key); + } Element element = cache(cacheName).get(key); if (null == element) return null; return element.getObjectValue(); } public static void put(String cacheName, Object key, Object value, Integer ttl, Integer tti) { + if (getCacheManager() instanceof RedisCacheManager) { + RedisTemplate redisTemplate = (RedisTemplate) CommonBeanFactory.getBean("redisTemplate"); + ValueOperations valueOperations = redisTemplate.opsForValue(); + valueOperations.setIfPresent(cacheName + "::" + key , value ); + return; + } Element e = new Element(key, value); //不设置则使用xml配置 if (ttl != null) { @@ -33,19 +49,35 @@ public class CacheUtils { } if (tti != null) e.setTimeToIdle(tti); - cache(cacheName).put(e); + Cache cache = cache(cacheName); + if (null != cache) + cache.put(e); } public static boolean remove(String cacheName, Object key) { + if (getCacheManager() instanceof RedisCacheManager) { + org.springframework.cache.Cache cache = getCacheManager().getCache(cacheName); + if (null == cache) return false; + return cache.evictIfPresent(key); + } return cache(cacheName).remove(key); } public static void removeAll(String cacheName) { + if (getCacheManager() instanceof RedisCacheManager) { + org.springframework.cache.Cache cache = getCacheManager().getCache(cacheName); + if (null == cache) return; + cache.clear(); + return; + } cache(cacheName).removeAll(); } private static Cache cache(String cacheName) { - net.sf.ehcache.CacheManager cacheManager = ((EhCacheCacheManager) manager).getCacheManager(); + if (getCacheManager() instanceof RedisCacheManager) { + return null; + } + net.sf.ehcache.CacheManager cacheManager = ((EhCacheCacheManager) getCacheManager()).getCacheManager(); if (!cacheManager.cacheExists(cacheName)) cacheManager.addCache(cacheName); Cache cacheManagerCache = cacheManager.getCache(cacheName); @@ -57,6 +89,12 @@ public class CacheUtils { long exp = (time - System.currentTimeMillis()) / 1000; int intExp = (int)exp; removeAll("lic_info"); + if (getCacheManager() instanceof RedisCacheManager) { + RedisTemplate redisTemplate = (RedisTemplate) CommonBeanFactory.getBean("redisTemplate"); + ValueOperations valueOperations = redisTemplate.opsForValue(); + valueOperations.set("lic_info::lic", "lic", exp, TimeUnit.SECONDS); + return; + } put("lic_info", "lic", "lic", intExp, intExp); } } 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 c8b81bb235..e95faa427a 100644 --- a/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java +++ b/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java @@ -3,7 +3,6 @@ package io.dataease.service.dataset; import com.google.gson.Gson; import io.dataease.auth.annotation.DeCleaner; import io.dataease.auth.api.dto.CurrentUserDto; -import io.dataease.auth.entity.SysUserEntity; import io.dataease.base.domain.*; import io.dataease.base.mapper.*; import io.dataease.base.mapper.ext.ExtDataSetGroupMapper; @@ -51,9 +50,10 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; -import java.io.*; +import java.io.File; +import java.io.FileOutputStream; +import java.io.InputStream; import java.math.BigDecimal; -import java.nio.charset.StandardCharsets; import java.text.MessageFormat; import java.text.NumberFormat; import java.text.SimpleDateFormat; @@ -1181,6 +1181,14 @@ public class DataSetTableService { DEException.throwException( Translator.get("i18n_custom_ds_delete") + String.format(":table id [%s]", tableId)); } + CurrentUserDto user = AuthUtils.getUser(); + if (user != null && !user.getIsAdmin()) { + DataSetTableDTO withPermission = getWithPermission(datasetTable.getId(), user.getUserId()); + if (ObjectUtils.isEmpty(withPermission.getPrivileges()) || !withPermission.getPrivileges().contains("use")) { + DEException.throwException( + Translator.get("i18n_dataset_no_permission") + String.format(":table name [%s]", withPermission.getName())); + } + } List fields = dataSetTableFieldsService.getListByIdsEach(unionDTO.getCurrentDsField()); String[] array = fields.stream() @@ -1309,6 +1317,14 @@ public class DataSetTableService { DEException.throwException( Translator.get("i18n_custom_ds_delete") + String.format(":table id [%s]", tableId)); } + CurrentUserDto user = AuthUtils.getUser(); + if (user != null && !user.getIsAdmin()) { + DataSetTableDTO withPermission = getWithPermission(datasetTable.getId(), user.getUserId()); + if (ObjectUtils.isEmpty(withPermission.getPrivileges()) || !withPermission.getPrivileges().contains("use")) { + DEException.throwException( + Translator.get("i18n_dataset_no_permission") + String.format(":table name [%s]", withPermission.getName())); + } + } List fields = dataSetTableFieldsService.getListByIdsEach(unionDTO.getCurrentDsField()); String[] array = fields.stream() diff --git a/backend/src/main/java/io/dataease/service/dataset/ExtractDataService.java b/backend/src/main/java/io/dataease/service/dataset/ExtractDataService.java index 6afd148af2..ebf6e5bb9e 100644 --- a/backend/src/main/java/io/dataease/service/dataset/ExtractDataService.java +++ b/backend/src/main/java/io/dataease/service/dataset/ExtractDataService.java @@ -119,9 +119,9 @@ public class ExtractDataService { private static final String dropTableSql = "DROP TABLE IF EXISTS TABLE_NAME;"; private static final String shellScript = "result=`curl --location-trusted -u %s:%s -H \"label:%s\" -H \"column_separator:%s\" -H \"columns:%s\" -H \"merge_type: %s\" -T %s -XPUT http://%s:%s/api/%s/%s/_stream_load`\n" + - "if [ $? == 0 ] ; then\n" + + "if [ $? -eq 0 ] ; then\n" + " failstatus=$(echo $result | grep '\"Status\": \"Fail\"')\n" + - " if [[ \"$failstatus\" != \"\" ]]; then\n" + + " if [ \"x${failstatus}\" != \"x\" ];then" + " echo $result\n" + " exit 1\n" + " fi\n" + @@ -342,34 +342,26 @@ public class ExtractDataService { try { if(datasource.getType().equalsIgnoreCase(DatasourceTypes.api.name())){ extractData(datasetTable, datasource, datasetTableFields, "incremental_add", null); - return; - } - DatasetTableIncrementalConfig datasetTableIncrementalConfig = dataSetTableService.incrementalConfig(datasetTableId); - if (datasetTableIncrementalConfig == null || StringUtils.isEmpty(datasetTableIncrementalConfig.getTableId())) { - updateTableStatus(datasetTableId, datasetTable, JobStatus.Completed, null); - return; - } - if (datasetTable.getLastUpdateTime() == null || datasetTable.getLastUpdateTime() == 0) { - updateTableStatus(datasetTableId, datasetTable, JobStatus.Completed, null); - saveErrorLog(datasetTableId, taskId, new Exception("未进行全量同步")); - lastExecStatus = JobStatus.Error; - return; - } + }else{ + DatasetTableIncrementalConfig datasetTableIncrementalConfig = dataSetTableService.incrementalConfig(datasetTableId); + if (datasetTable.getLastUpdateTime() == null || datasetTable.getLastUpdateTime() == 0) { + throw new Exception("未进行全量同步"); + } - execTime = System.currentTimeMillis(); - if (StringUtils.isNotEmpty(datasetTableIncrementalConfig.getIncrementalAdd()) && StringUtils.isNotEmpty(datasetTableIncrementalConfig.getIncrementalAdd().replace(" ", ""))) {// 增量添加 - String sql = datasetTableIncrementalConfig.getIncrementalAdd().replace(lastUpdateTime, datasetTable.getLastUpdateTime().toString()) - .replace(currentUpdateTime, Long.valueOf(System.currentTimeMillis()).toString()); - extractData(datasetTable, datasource, datasetTableFields, "incremental_add", sql); - } + execTime = System.currentTimeMillis(); + if (datasetTableIncrementalConfig != null && StringUtils.isNotEmpty(datasetTableIncrementalConfig.getIncrementalAdd()) && StringUtils.isNotEmpty(datasetTableIncrementalConfig.getIncrementalAdd().replace(" ", ""))) {// 增量添加 + String sql = datasetTableIncrementalConfig.getIncrementalAdd().replace(lastUpdateTime, datasetTable.getLastUpdateTime().toString()) + .replace(currentUpdateTime, Long.valueOf(System.currentTimeMillis()).toString()); + extractData(datasetTable, datasource, datasetTableFields, "incremental_add", sql); + } - if (StringUtils.isNotEmpty(datasetTableIncrementalConfig.getIncrementalDelete()) && StringUtils.isNotEmpty(datasetTableIncrementalConfig.getIncrementalDelete().replace(" ", ""))) {// 增量删除 - String sql = datasetTableIncrementalConfig.getIncrementalDelete().replace(lastUpdateTime, datasetTable.getLastUpdateTime().toString()) - .replace(currentUpdateTime, Long.valueOf(System.currentTimeMillis()).toString()); - extractData(datasetTable, datasource, datasetTableFields, "incremental_delete", sql); + if (StringUtils.isNotEmpty(datasetTableIncrementalConfig.getIncrementalDelete()) && StringUtils.isNotEmpty(datasetTableIncrementalConfig.getIncrementalDelete().replace(" ", ""))) {// 增量删除 + String sql = datasetTableIncrementalConfig.getIncrementalDelete().replace(lastUpdateTime, datasetTable.getLastUpdateTime().toString()) + .replace(currentUpdateTime, Long.valueOf(System.currentTimeMillis()).toString()); + extractData(datasetTable, datasource, datasetTableFields, "incremental_delete", sql); + } } saveSuccessLog(datasetTableTaskLog); - msg = true; lastExecStatus = JobStatus.Completed; } catch (Exception e) { diff --git a/backend/src/main/java/io/dataease/service/datasource/DatasourceService.java b/backend/src/main/java/io/dataease/service/datasource/DatasourceService.java index 0883d92131..4d2fecdaf5 100644 --- a/backend/src/main/java/io/dataease/service/datasource/DatasourceService.java +++ b/backend/src/main/java/io/dataease/service/datasource/DatasourceService.java @@ -323,11 +323,14 @@ public class DatasourceService { public void initAllDataSourceConnectionPool() { List datasources = datasourceMapper.selectByExampleWithBLOBs(new DatasourceExample()); datasources.forEach(datasource -> { - try { - handleConnectionPool(datasource, "add"); - } catch (Exception e) { - e.printStackTrace(); - } + commonThreadPool.addTask(()->{ + System.out.println(System.currentTimeMillis()); + try { + handleConnectionPool(datasource, "add"); + } catch (Exception e) { + LogUtil.error("Failed to init datasource: " + datasource.getName(), e); + } + }); }); } diff --git a/backend/src/main/resources/application.properties b/backend/src/main/resources/application.properties index fdb33ea352..df130211f2 100644 --- a/backend/src/main/resources/application.properties +++ b/backend/src/main/resources/application.properties @@ -61,13 +61,14 @@ quartz.scheduler-name=deServerJob spring.servlet.multipart.max-file-size=500MB spring.servlet.multipart.max-request-size=500MB # actuator -management.server.port=8083 -management.endpoints.web.exposure.include=* +management.health.redis.enabled=false +#management.server.port=8083 +#management.endpoints.web.exposure.include=* #spring.freemarker.checkTemplateLocation=false #RSA非对称加密参数:私钥 rsa.private_key=MIIBUwIBADANBgkqhkiG9w0BAQEFAASCAT0wggE5AgEAAkEA0vfvyTdGJkdbHkB8mp0f3FE0GYP3AYPaJF7jUd1M0XxFSE2ceK3k2kw20YvQ09NJKk+OMjWQl9WitG9pB6tSCQIDAQABAkA2SimBrWC2/wvauBuYqjCFwLvYiRYqZKThUS3MZlebXJiLB+Ue/gUifAAKIg1avttUZsHBHrop4qfJCwAI0+YRAiEA+W3NK/RaXtnRqmoUUkb59zsZUBLpvZgQPfj1MhyHDz0CIQDYhsAhPJ3mgS64NbUZmGWuuNKp5coY2GIj/zYDMJp6vQIgUueLFXv/eZ1ekgz2Oi67MNCk5jeTF2BurZqNLR3MSmUCIFT3Q6uHMtsB9Eha4u7hS31tj1UWE+D+ADzp59MGnoftAiBeHT7gDMuqeJHPL4b+kC+gzV4FGTfhR9q3tTbklZkD2A== rsa.public_key=MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANL378k3RiZHWx5AfJqdH9xRNBmD9wGD2iRe41HdTNF8RUhNnHit5NpMNtGL0NPTSSpPjjI1kJfVorRvaQerUgkCAwEAAQ== -spring.cache.type=ehcache +#spring.cache.type=ehcache spring.cache.ehcache.config=classpath:/ehcache/ehcache.xml #打印URL路径 #logging.level.org.springframework.web=trace @@ -85,6 +86,32 @@ server.compression.enabled=true server.compression.mime-types=application/javascript,text/css,application/json,application/xml,text/html,text/xml,text/plain server.compression.min-response-size=1024 +#下面的配置新增到/opt/dataease/conf/dataease/properties +#缓存类型 +##spring.cache.type=redis +#spring.cache.type=ehcache +#redis公共配置 +#spring.redis.timeout=10000 +#spring.redis.lettuce.pool.max-active=8 +#spring.redis.lettuce.pool.max-wait=-1 +#spring.redis.lettuce.pool.max-idle=8 + +#单机模式redis配置 +#spring.redis.database=0 +#spring.redis.host=192.168.0.110 +#spring.redis.port=6379 +#spring.redis.password=DataEase_ZNB@REDIS + +#哨兵模式redis配置 +#spring.redis.sentinel.master=mymaster +#spring.redis.sentinel.nodes=192.168.0.110:26379,192.168.0.110:26380,192.168.0.110:26381 +#spring.redis.sentinel.password= + +#cluster模式redis配置 +#spring.redis.cluster.nodes=192.168.0.110:7001,192.168.0.110:7002,192.168.0.110:7003,192.168.0.110:7004,192.168.0.110:7005,192.168.0.110:7006 +#spring.redis.cluster.max-redirects=3 +#spring.redis.password=DataEase_ZNB@REDIS + diff --git a/backend/src/main/resources/db/migration/V33__1.9.sql b/backend/src/main/resources/db/migration/V33__1.9.sql new file mode 100644 index 0000000000..d182498b0b --- /dev/null +++ b/backend/src/main/resources/db/migration/V33__1.9.sql @@ -0,0 +1,2 @@ +ALTER TABLE `chart_view` ADD COLUMN `senior` LONGTEXT COMMENT '高级' AFTER `drill_fields`; +UPDATE `chart_view` SET `senior` = '{}'; diff --git a/backend/src/main/resources/generatorConfig.xml b/backend/src/main/resources/generatorConfig.xml index 71ca683b77..9cbb2f2d7a 100644 --- a/backend/src/main/resources/generatorConfig.xml +++ b/backend/src/main/resources/generatorConfig.xml @@ -60,6 +60,8 @@ + +
diff --git a/frontend/package.json b/frontend/package.json index 47e65a4e38..9cd95b9828 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -13,8 +13,9 @@ "svgo": "svgo -f src/icons/svg --config=src/icons/svgo.yml" }, "dependencies": { - "@antv/g2plot": "^2.3.32", - "@antv/s2": "^1.7.0", + "@antv/g2plot": "^2.4.9", + "@antv/s2": "^1.11.0", + "@antv/util": "^2.0.17", "@riophae/vue-treeselect": "0.4.0", "@tinymce/tinymce-vue": "^3.2.8", "axios": "^0.21.1", diff --git a/frontend/src/components/widget/DeWidget/DeTabs.vue b/frontend/src/components/widget/DeWidget/DeTabs.vue index fb40d17deb..359fd7945b 100644 --- a/frontend/src/components/widget/DeWidget/DeTabs.vue +++ b/frontend/src/components/widget/DeWidget/DeTabs.vue @@ -1,6 +1,6 @@