forked from github/dataease
fix: tree搜索
This commit is contained in:
parent
8bd6a1a298
commit
4c5290d87b
@ -37,6 +37,12 @@
|
||||
<if test="createTime != null">
|
||||
and chart_group.create_time = #{createTime,jdbcType=BIGINT}
|
||||
</if>
|
||||
<if test="ids != null and ids.size() > 0">
|
||||
and id in
|
||||
<foreach collection="ids" item="item" separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
<if test="sort != null">
|
||||
order by ${sort}
|
||||
|
@ -39,6 +39,9 @@
|
||||
<if test="sceneId != null">
|
||||
and scene_id = #{sceneId,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="name != null">
|
||||
and name like CONCAT('%', #{name},'%')
|
||||
</if>
|
||||
</where>
|
||||
<if test="sort != null">
|
||||
order by ${sort}
|
||||
|
@ -37,6 +37,12 @@
|
||||
<if test="createTime != null">
|
||||
and dataset_group.create_time = #{createTime,jdbcType=BIGINT}
|
||||
</if>
|
||||
<if test="ids != null and ids.size() > 0">
|
||||
and id in
|
||||
<foreach collection="ids" item="item" separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
<if test="sort != null">
|
||||
order by ${sort}
|
||||
|
@ -45,6 +45,9 @@
|
||||
<if test="sceneId != null">
|
||||
and scene_id = #{sceneId,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="name != null">
|
||||
and name like CONCAT('%', #{name},'%')
|
||||
</if>
|
||||
<if test="mode != null">
|
||||
and mode = #{mode,jdbcType=INTEGER}
|
||||
</if>
|
||||
|
@ -4,7 +4,9 @@ import io.dataease.base.domain.ChartViewWithBLOBs;
|
||||
import io.dataease.commons.utils.AuthUtils;
|
||||
import io.dataease.controller.request.chart.ChartExtRequest;
|
||||
import io.dataease.controller.request.chart.ChartViewRequest;
|
||||
import io.dataease.controller.request.dataset.DataSetTableRequest;
|
||||
import io.dataease.dto.chart.ChartViewDTO;
|
||||
import io.dataease.dto.dataset.DataSetTableDTO;
|
||||
import io.dataease.service.chart.ChartViewService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@ -63,7 +65,7 @@ public class ChartViewController {
|
||||
}
|
||||
|
||||
@GetMapping("searchAdviceSceneId/{panelId}")
|
||||
public String searchAdviceSceneId(@PathVariable String panelId){
|
||||
public String searchAdviceSceneId(@PathVariable String panelId) {
|
||||
return chartViewService.searchAdviceSceneId(panelId);
|
||||
}
|
||||
|
||||
@ -71,10 +73,16 @@ public class ChartViewController {
|
||||
public ChartViewDTO getOneWithPermission(@PathVariable String id, @RequestBody ChartExtRequest requestList) throws Exception {
|
||||
//如果能获取用户 则添加对应的权限
|
||||
ChartViewDTO dto = chartViewService.getData(id, requestList);
|
||||
if(dto!=null && AuthUtils.getUser()!=null){
|
||||
ChartViewDTO permissionDto = chartViewService.getOneWithPermission(dto.getId());
|
||||
if (dto != null && AuthUtils.getUser() != null) {
|
||||
ChartViewDTO permissionDto = chartViewService.getOneWithPermission(dto.getId());
|
||||
dto.setPrivileges(permissionDto.getPrivileges());
|
||||
}
|
||||
return dto;
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("search")
|
||||
public List<ChartViewDTO> search(@RequestBody ChartViewRequest chartViewRequest) {
|
||||
return chartViewService.search(chartViewRequest);
|
||||
}
|
||||
}
|
||||
|
@ -108,4 +108,9 @@ public class DataSetTableController {
|
||||
public Boolean checkDorisTableIsExists(@PathVariable String id) throws Exception {
|
||||
return dataSetTableService.checkDorisTableIsExists(id);
|
||||
}
|
||||
|
||||
@PostMapping("search")
|
||||
public List<DataSetTableDTO> search(@RequestBody DataSetTableRequest dataSetTableRequest) {
|
||||
return dataSetTableService.search(dataSetTableRequest);
|
||||
}
|
||||
}
|
||||
|
@ -3,9 +3,12 @@ package io.dataease.controller.request.chart;
|
||||
import io.dataease.base.domain.ChartGroup;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
@Data
|
||||
public class ChartGroupRequest extends ChartGroup {
|
||||
private String sort;
|
||||
private String userId;
|
||||
private Set<String> ids;
|
||||
}
|
||||
|
@ -3,6 +3,9 @@ package io.dataease.controller.request.dataset;
|
||||
import io.dataease.base.domain.DatasetGroup;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @Author gin
|
||||
* @Date 2021/2/22 1:30 下午
|
||||
@ -12,4 +15,6 @@ public class DataSetGroupRequest extends DatasetGroup {
|
||||
private String sort;
|
||||
|
||||
private String userId;
|
||||
|
||||
private Set<String> ids;
|
||||
}
|
||||
|
@ -15,11 +15,15 @@ import io.dataease.controller.request.chart.ChartExtFilterRequest;
|
||||
import io.dataease.controller.request.chart.ChartExtRequest;
|
||||
import io.dataease.controller.request.chart.ChartGroupRequest;
|
||||
import io.dataease.controller.request.chart.ChartViewRequest;
|
||||
import io.dataease.controller.request.dataset.DataSetGroupRequest;
|
||||
import io.dataease.controller.request.dataset.DataSetTableRequest;
|
||||
import io.dataease.datasource.provider.DatasourceProvider;
|
||||
import io.dataease.datasource.provider.ProviderFactory;
|
||||
import io.dataease.datasource.request.DatasourceRequest;
|
||||
import io.dataease.datasource.service.DatasourceService;
|
||||
import io.dataease.dto.chart.*;
|
||||
import io.dataease.dto.dataset.DataSetGroupDTO;
|
||||
import io.dataease.dto.dataset.DataSetTableDTO;
|
||||
import io.dataease.dto.dataset.DataSetTableUnionDTO;
|
||||
import io.dataease.dto.dataset.DataTableInfoDTO;
|
||||
import io.dataease.i18n.Translator;
|
||||
@ -110,6 +114,41 @@ public class ChartViewService {
|
||||
return group;
|
||||
}
|
||||
|
||||
public List<ChartViewDTO> search(ChartViewRequest chartViewRequest) {
|
||||
String userId = String.valueOf(AuthUtils.getUser().getUserId());
|
||||
chartViewRequest.setUserId(userId);
|
||||
List<ChartViewDTO> ds = extChartViewMapper.search(chartViewRequest);
|
||||
if (CollectionUtils.isEmpty(ds)) {
|
||||
return ds;
|
||||
}
|
||||
|
||||
TreeSet<String> ids = new TreeSet<>();
|
||||
ds.forEach(ele -> {
|
||||
ele.setIsLeaf(true);
|
||||
ele.setPid(ele.getSceneId());
|
||||
ids.add(ele.getPid());
|
||||
});
|
||||
|
||||
ChartGroupRequest chartGroupRequest = new ChartGroupRequest();
|
||||
chartGroupRequest.setUserId(userId);
|
||||
chartGroupRequest.setIds(ids);
|
||||
List<ChartGroupDTO> search = extChartGroupMapper.search(chartGroupRequest);
|
||||
while (CollectionUtils.isNotEmpty(search)) {
|
||||
ids.clear();
|
||||
search.forEach(ele -> {
|
||||
ChartViewDTO dto = new ChartViewDTO();
|
||||
BeanUtils.copyBean(dto, ele);
|
||||
dto.setIsLeaf(false);
|
||||
dto.setType("group");
|
||||
ds.add(dto);
|
||||
ids.add(ele.getPid());
|
||||
});
|
||||
chartGroupRequest.setIds(ids);
|
||||
search = extChartGroupMapper.search(chartGroupRequest);
|
||||
}
|
||||
return ds;
|
||||
}
|
||||
|
||||
public ChartViewWithBLOBs get(String id) {
|
||||
return chartViewMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import io.dataease.commons.constants.JobStatus;
|
||||
import io.dataease.commons.constants.ScheduleType;
|
||||
import io.dataease.commons.constants.TaskStatus;
|
||||
import io.dataease.commons.utils.*;
|
||||
import io.dataease.controller.request.chart.ChartGroupRequest;
|
||||
import io.dataease.controller.request.dataset.DataSetGroupRequest;
|
||||
import io.dataease.controller.request.dataset.DataSetTableRequest;
|
||||
import io.dataease.controller.request.dataset.DataSetTaskRequest;
|
||||
@ -232,6 +233,41 @@ public class DataSetTableService {
|
||||
return group;
|
||||
}
|
||||
|
||||
public List<DataSetTableDTO> search(DataSetTableRequest dataSetTableRequest) {
|
||||
String userId = String.valueOf(AuthUtils.getUser().getUserId());
|
||||
dataSetTableRequest.setUserId(userId);
|
||||
List<DataSetTableDTO> ds = extDataSetTableMapper.search(dataSetTableRequest);
|
||||
if (CollectionUtils.isEmpty(ds)) {
|
||||
return ds;
|
||||
}
|
||||
|
||||
TreeSet<String> ids = new TreeSet<>();
|
||||
ds.forEach(ele -> {
|
||||
ele.setIsLeaf(true);
|
||||
ele.setPid(ele.getSceneId());
|
||||
ids.add(ele.getPid());
|
||||
});
|
||||
|
||||
DataSetGroupRequest dataSetGroupRequest = new DataSetGroupRequest();
|
||||
dataSetGroupRequest.setUserId(userId);
|
||||
dataSetGroupRequest.setIds(ids);
|
||||
List<DataSetGroupDTO> search = extDataSetGroupMapper.search(dataSetGroupRequest);
|
||||
while (CollectionUtils.isNotEmpty(search)) {
|
||||
ids.clear();
|
||||
search.forEach(ele -> {
|
||||
DataSetTableDTO dto = new DataSetTableDTO();
|
||||
BeanUtils.copyBean(dto, ele);
|
||||
dto.setIsLeaf(false);
|
||||
dto.setType("group");
|
||||
ds.add(dto);
|
||||
ids.add(ele.getPid());
|
||||
});
|
||||
dataSetGroupRequest.setIds(ids);
|
||||
search = extDataSetGroupMapper.search(dataSetGroupRequest);
|
||||
}
|
||||
return ds;
|
||||
}
|
||||
|
||||
public DatasetTable get(String id) {
|
||||
return datasetTableMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
@ -891,14 +891,18 @@ export default {
|
||||
|
||||
searchTree(val) {
|
||||
const queryCondition = {
|
||||
withExtend: 'parent',
|
||||
modelType: 'chart',
|
||||
// withExtend: 'parent',
|
||||
// modelType: 'chart',
|
||||
name: val
|
||||
}
|
||||
authModel(queryCondition).then(res => {
|
||||
// this.highlights(res.data)
|
||||
// authModel(queryCondition).then(res => {
|
||||
// // this.highlights(res.data)
|
||||
// this.tData = this.buildTree(res.data)
|
||||
// // console.log(this.tData)
|
||||
// })
|
||||
|
||||
post('/chart/view/search', queryCondition).then(res => {
|
||||
this.tData = this.buildTree(res.data)
|
||||
// console.log(this.tData)
|
||||
})
|
||||
},
|
||||
|
||||
@ -910,8 +914,8 @@ export default {
|
||||
const roots = []
|
||||
arrs.forEach(el => {
|
||||
// 判断根节点 ###
|
||||
el.type = el.modelInnerType
|
||||
el.isLeaf = el.leaf
|
||||
// el.type = el.modelInnerType
|
||||
// el.isLeaf = el.leaf
|
||||
if (el[this.treeProps.parentId] === null || el[this.treeProps.parentId] === 0 || el[this.treeProps.parentId] === '0') {
|
||||
roots.push(el)
|
||||
return
|
||||
|
@ -856,14 +856,18 @@ export default {
|
||||
|
||||
searchTree(val) {
|
||||
const queryCondition = {
|
||||
withExtend: 'parent',
|
||||
modelType: 'dataset',
|
||||
// withExtend: 'parent',
|
||||
// modelType: 'dataset',
|
||||
name: val
|
||||
}
|
||||
authModel(queryCondition).then(res => {
|
||||
// this.highlights(res.data)
|
||||
// authModel(queryCondition).then(res => {
|
||||
// // this.highlights(res.data)
|
||||
// this.tData = this.buildTree(res.data)
|
||||
// // console.log(this.tData)
|
||||
// })
|
||||
|
||||
post('/dataset/table/search', queryCondition).then(res => {
|
||||
this.tData = this.buildTree(res.data)
|
||||
// console.log(this.tData)
|
||||
})
|
||||
},
|
||||
|
||||
@ -875,8 +879,8 @@ export default {
|
||||
const roots = []
|
||||
arrs.forEach(el => {
|
||||
// 判断根节点 ###
|
||||
el.type = el.modelInnerType
|
||||
el.isLeaf = el.leaf
|
||||
// el.type = el.modelInnerType
|
||||
// el.isLeaf = el.leaf
|
||||
if (el[this.treeProps.parentId] === null || el[this.treeProps.parentId] === 0 || el[this.treeProps.parentId] === '0') {
|
||||
roots.push(el)
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user