提交 521b35f9 authored 作者: wangjiahao's avatar wangjiahao

refactor: 优化系统响应速度

上级 c2a50813
...@@ -22,4 +22,6 @@ public interface ExtChartViewMapper { ...@@ -22,4 +22,6 @@ public interface ExtChartViewMapper {
String searchAdviceSceneId(@Param("userId") String userId,@Param("panelId") String panelId); String searchAdviceSceneId(@Param("userId") String userId,@Param("panelId") String panelId);
int checkSameDataSet(@Param("viewIdSource") String viewIdSource,@Param("viewIdTarget") String viewIdTarget); int checkSameDataSet(@Param("viewIdSource") String viewIdSource,@Param("viewIdTarget") String viewIdTarget);
ChartViewDTO searchOneWithPrivileges(@Param("userId") String userId,@Param("id") String id );
} }
...@@ -8,6 +8,13 @@ ...@@ -8,6 +8,13 @@
<result column="privileges" property="privileges"/> <result column="privileges" property="privileges"/>
</resultMap> </resultMap>
<select id="searchOneWithPrivileges" resultMap="BaseResultMapDTO">
select
chart_view.*,
get_auths(id,'chart',#{userId}) as `privileges`
from chart_view where id = #{id}
</select>
<select id="searchOne" resultMap="BaseResultMapDTO"> <select id="searchOne" resultMap="BaseResultMapDTO">
select select
id, `name`, scene_id, table_id, `type`, title, create_by, create_time, update_time, id, `name`, scene_id, table_id, `type`, title, create_by, create_time, update_time,
......
...@@ -11,9 +11,8 @@ ...@@ -11,9 +11,8 @@
select select
id, `name`, scene_id, data_source_id, `type`, `mode`,`info`, create_by, create_time, id, `name`, scene_id, data_source_id, `type`, `mode`,`info`, create_by, create_time,
get_auths(id,'dataset',#{userId}) as `privileges` get_auths(id,'dataset',#{userId}) as `privileges`
from (select GET_V_AUTH_MODEL_ID_P_USE (#{userId}, 'dataset') cids) t,dataset_table from dataset_table
<where> <where>
FIND_IN_SET(dataset_table.id,cids)
<if test="id != null"> <if test="id != null">
and id = #{id,jdbcType=VARCHAR} and id = #{id,jdbcType=VARCHAR}
</if> </if>
......
...@@ -88,10 +88,6 @@ public class ChartViewController { ...@@ -88,10 +88,6 @@ public class ChartViewController {
public ChartViewDTO getOneWithPermission(@PathVariable String id, @RequestBody ChartExtRequest requestList) throws Exception { public ChartViewDTO getOneWithPermission(@PathVariable String id, @RequestBody ChartExtRequest requestList) throws Exception {
//如果能获取用户 则添加对应的权限 //如果能获取用户 则添加对应的权限
ChartViewDTO dto = chartViewService.getData(id, requestList); ChartViewDTO dto = chartViewService.getData(id, requestList);
if (dto != null && AuthUtils.getUser() != null) {
ChartViewDTO permissionDto = chartViewService.getOneWithPermission(dto.getId());
dto.setPrivileges(permissionDto.getPrivileges());
}
return dto; return dto;
} }
......
package io.dataease.controller.request.chart; package io.dataease.controller.request.chart;
import io.dataease.base.domain.ChartViewWithBLOBs; import io.dataease.base.domain.ChartViewWithBLOBs;
import io.dataease.dto.chart.ChartViewDTO;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
...@@ -11,7 +12,7 @@ import lombok.Data; ...@@ -11,7 +12,7 @@ import lombok.Data;
@Data @Data
public class ChartCalRequest { public class ChartCalRequest {
@ApiModelProperty("视图") @ApiModelProperty("视图")
private ChartViewWithBLOBs view; private ChartViewDTO view;
@ApiModelProperty("额外请求参数") @ApiModelProperty("额外请求参数")
private ChartExtRequest requestList; private ChartExtRequest requestList;
} }
...@@ -79,11 +79,6 @@ public class ChartViewService { ...@@ -79,11 +79,6 @@ public class ChartViewService {
Optional.ofNullable(chartView.getId()).ifPresent(id -> { Optional.ofNullable(chartView.getId()).ifPresent(id -> {
CacheUtils.remove(JdbcConstants.VIEW_CACHE_KEY, id); CacheUtils.remove(JdbcConstants.VIEW_CACHE_KEY, id);
}); });
try {
calcData(chartView, new ChartExtRequest(), true);
} catch (Exception e) {
}
return getOneWithPermission(chartView.getId()); return getOneWithPermission(chartView.getId());
} }
...@@ -167,12 +162,9 @@ public class ChartViewService { ...@@ -167,12 +162,9 @@ public class ChartViewService {
} }
public ChartViewDTO getOneWithPermission(String id) { public ChartViewDTO getOneWithPermission(String id) {
ChartViewRequest chartViewRequest = new ChartViewRequest(); String userId = AuthUtils.getUser()!=null?String.valueOf(AuthUtils.getUser().getUserId()):"NONE";
chartViewRequest.setId(id); return extChartViewMapper.searchOneWithPrivileges(userId,id);
chartViewRequest.setUserId(String.valueOf(AuthUtils.getUser().getUserId()));
return extChartViewMapper.searchOne(chartViewRequest);
} }
public void delete(String id) { public void delete(String id) {
chartViewMapper.deleteByPrimaryKey(id); chartViewMapper.deleteByPrimaryKey(id);
} }
...@@ -184,7 +176,7 @@ public class ChartViewService { ...@@ -184,7 +176,7 @@ public class ChartViewService {
} }
public ChartViewDTO getData(String id, ChartExtRequest request) throws Exception { public ChartViewDTO getData(String id, ChartExtRequest request) throws Exception {
ChartViewWithBLOBs view = chartViewMapper.selectByPrimaryKey(id); ChartViewDTO view = this.getOneWithPermission(id);
// 如果是从仪表板获取视图数据,则仪表板的查询模式,查询结果的数量,覆盖视图对应的属性 // 如果是从仪表板获取视图数据,则仪表板的查询模式,查询结果的数量,覆盖视图对应的属性
if (CommonConstants.VIEW_QUERY_FROM.PANEL.equals(request.getQueryFrom()) && CommonConstants.VIEW_RESULT_MODE.CUSTOM.equals(request.getResultMode())) { if (CommonConstants.VIEW_QUERY_FROM.PANEL.equals(request.getQueryFrom()) && CommonConstants.VIEW_RESULT_MODE.CUSTOM.equals(request.getResultMode())) {
view.setResultMode(request.getResultMode()); view.setResultMode(request.getResultMode());
...@@ -193,7 +185,7 @@ public class ChartViewService { ...@@ -193,7 +185,7 @@ public class ChartViewService {
return calcData(view, request, request.isCache()); return calcData(view, request, request.isCache());
} }
public ChartViewDTO calcData(ChartViewWithBLOBs view, ChartExtRequest requestList, boolean cache) throws Exception { public ChartViewDTO calcData(ChartViewDTO view, ChartExtRequest requestList, boolean cache) throws Exception {
if (ObjectUtils.isEmpty(view)) { if (ObjectUtils.isEmpty(view)) {
throw new RuntimeException(Translator.get("i18n_chart_delete")); throw new RuntimeException(Translator.get("i18n_chart_delete"));
} }
......
...@@ -80,7 +80,7 @@ export function listDatasource() { ...@@ -80,7 +80,7 @@ export function listDatasource() {
export function getTable(id, hideMsg = false) { export function getTable(id, hideMsg = false) {
return request({ return request({
url: '/dataset/table/get/' + id, url: '/dataset/table/get/' + id,
loading: true, loading: false,
method: 'post', method: 'post',
hideMsg: hideMsg hideMsg: hideMsg
}) })
......
...@@ -428,8 +428,8 @@ export default { ...@@ -428,8 +428,8 @@ export default {
type: 'success', type: 'success',
showClose: true showClose: true
}) })
_this.expandedArray.push(response.data.sceneId) _this.expandedArray.push(table.sceneId)
_this.$refs.datasetTreeRef.setCurrentKey(response.data.id) _this.$refs.datasetTreeRef.setCurrentKey(table.id)
_this.treeNode() _this.treeNode()
this.$store.dispatch('dataset/setTable', new Date().getTime()) this.$store.dispatch('dataset/setTable', new Date().getTime())
}) })
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论