mirror of
https://github.com/dataease/dataease.git
synced 2026-05-21 04:08:10 +08:00
feat:仪表盘
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
package io.dataease.base.mapper.ext;
|
||||
|
||||
import io.dataease.controller.request.panel.PanelGroupRequest;
|
||||
import io.dataease.dto.panel.PanelGroupDTO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ExtPanelGroupMapper {
|
||||
|
||||
List<PanelGroupDTO> panelGroupList(PanelGroupRequest request);
|
||||
|
||||
//会级联删除pid 下的所有数据
|
||||
int deleteCircle(@Param("pid") String pid);
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="io.dataease.base.mapper.ext.ExtPanelGroupMapper">
|
||||
|
||||
<resultMap id="BaseResultMapDTO" type="io.dataease.dto.panel.PanelGroupDTO" extends="io.dataease.base.mapper.PanelGroupMapper.BaseResultMap">
|
||||
<result column="label" jdbcType="VARCHAR" property="label"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="panelGroupList" resultMap="BaseResultMapDTO">
|
||||
select panel_group.*,panel_group.name as label from panel_group
|
||||
<where>
|
||||
<if test="name != null">
|
||||
and panel_group.name like CONCAT('%', #{name},'%')
|
||||
</if>
|
||||
<if test="nodeType != null">
|
||||
and panel_group.node_type = #{nodeType}
|
||||
</if>
|
||||
<if test="panelType != null">
|
||||
and panel_group.panel_type = #{panelType}
|
||||
</if>
|
||||
<if test="id != null">
|
||||
and panel_group.id = #{id}
|
||||
</if>
|
||||
<if test="pid != null">
|
||||
and panel_group.pid = #{pid}
|
||||
</if>
|
||||
<if test="level != null">
|
||||
and panel_group.level = #{level}
|
||||
</if>
|
||||
</where>
|
||||
<if test="sort != null">
|
||||
order by ${sort}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<delete id="deleteCircle">
|
||||
delete from panel_group where FIND_IN_SET(panel_group.id,GET_PANEL_GROUP_WITH_CHILDREN(#{pid}))
|
||||
</delete>
|
||||
</mapper>
|
||||
@@ -1,14 +1,46 @@
|
||||
package io.dataease.controller.panel;
|
||||
|
||||
import io.dataease.base.domain.DatasetGroup;
|
||||
import io.dataease.controller.request.dataset.DataSetGroupRequest;
|
||||
import io.dataease.controller.request.panel.PanelGroupRequest;
|
||||
import io.dataease.dto.dataset.DataSetGroupDTO;
|
||||
import io.dataease.dto.panel.PanelGroupDTO;
|
||||
import io.dataease.service.panel.PanelGroupService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Author: wangjiahao
|
||||
* Date: 2021-03-05
|
||||
* Description:
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("panel/group")
|
||||
public class PanelGroupController {
|
||||
|
||||
@Resource
|
||||
private PanelGroupService panelGroupService;
|
||||
|
||||
@PostMapping("/tree")
|
||||
public List<PanelGroupDTO> tree(@RequestBody PanelGroupRequest request) {
|
||||
request.setLevel(0);
|
||||
return panelGroupService.tree(request);
|
||||
}
|
||||
|
||||
@PostMapping("/defaultTree")
|
||||
public List<PanelGroupDTO> defaultTree(@RequestBody PanelGroupRequest request) {
|
||||
return panelGroupService.getDefaultTree(request);
|
||||
}
|
||||
|
||||
@PostMapping("/save")
|
||||
public PanelGroupDTO save(@RequestBody PanelGroupRequest request) {
|
||||
return panelGroupService.save(request);
|
||||
}
|
||||
|
||||
@PostMapping("/deleteCircle/{id}")
|
||||
public void deleteCircle(@PathVariable String id) {
|
||||
panelGroupService.deleteCircle(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package io.dataease.controller.request.panel;
|
||||
|
||||
import io.dataease.base.domain.PanelGroup;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* Author: wangjiahao
|
||||
* Date: 2021-03-05
|
||||
* Description:
|
||||
*/
|
||||
@Data
|
||||
public class PanelGroupRequest extends PanelGroup {
|
||||
private String sort;
|
||||
|
||||
public PanelGroupRequest() {
|
||||
}
|
||||
|
||||
public PanelGroupRequest(String pid) {
|
||||
super.setPid(pid);
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package io.dataease.dto.panel;
|
||||
|
||||
import io.dataease.base.domain.PanelGroup;
|
||||
import io.dataease.dto.dataset.DataSetGroupDTO;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -10,25 +11,10 @@ import java.util.List;
|
||||
* Date: 2021-03-05
|
||||
* Description:
|
||||
*/
|
||||
@Data
|
||||
public class PanelGroupDTO extends PanelGroup {
|
||||
|
||||
private String label;
|
||||
|
||||
private List<PanelGroupDTO> children;
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public List<PanelGroupDTO> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<PanelGroupDTO> children) {
|
||||
this.children = children;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,20 @@
|
||||
package io.dataease.service.panel;
|
||||
|
||||
import io.dataease.base.domain.DatasetGroup;
|
||||
import io.dataease.base.mapper.PanelGroupMapper;
|
||||
import io.dataease.base.mapper.ext.ExtPanelGroupMapper;
|
||||
import io.dataease.commons.utils.BeanUtils;
|
||||
import io.dataease.controller.request.panel.PanelGroupRequest;
|
||||
import io.dataease.dto.dataset.DataSetGroupDTO;
|
||||
import io.dataease.dto.panel.PanelGroupDTO;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Author: wangjiahao
|
||||
@@ -15,9 +26,47 @@ public class PanelGroupService {
|
||||
|
||||
@Resource
|
||||
private PanelGroupMapper panelGroupMapper;
|
||||
@Resource
|
||||
private ExtPanelGroupMapper extPanelGroupMapper;
|
||||
|
||||
public List<PanelGroupDTO> tree(PanelGroupRequest panelGroupRequest) {
|
||||
List<PanelGroupDTO> panelGroupDTOList = extPanelGroupMapper.panelGroupList(panelGroupRequest);
|
||||
getTreeChildren(panelGroupDTOList);
|
||||
return panelGroupDTOList;
|
||||
}
|
||||
|
||||
public void getTreeChildren(List<PanelGroupDTO> parentPanelGroupDTO){
|
||||
Optional.ofNullable(parentPanelGroupDTO).ifPresent(parent -> parent.forEach(panelGroupDTO -> {
|
||||
List<PanelGroupDTO> panelGroupDTOChildren = extPanelGroupMapper.panelGroupList(new PanelGroupRequest(panelGroupDTO.getId()));
|
||||
panelGroupDTO.setChildren(panelGroupDTOChildren);
|
||||
getTreeChildren(panelGroupDTOChildren);
|
||||
}));
|
||||
}
|
||||
|
||||
public List<PanelGroupDTO> getDefaultTree(PanelGroupRequest panelGroupRequest){
|
||||
return extPanelGroupMapper.panelGroupList(panelGroupRequest);
|
||||
}
|
||||
|
||||
|
||||
public PanelGroupDTO save(PanelGroupRequest request) {
|
||||
if (StringUtils.isEmpty(request.getId())) {
|
||||
request.setId(UUID.randomUUID().toString());
|
||||
request.setCreateTime(System.currentTimeMillis());
|
||||
panelGroupMapper.insert(request);
|
||||
} else {
|
||||
panelGroupMapper.updateByPrimaryKey(request);
|
||||
}
|
||||
PanelGroupDTO panelGroupDTO = new PanelGroupDTO();
|
||||
BeanUtils.copyBean(panelGroupDTO, request);
|
||||
panelGroupDTO.setLabel(request.getName());
|
||||
return panelGroupDTO;
|
||||
}
|
||||
|
||||
|
||||
public void deleteCircle(String id){
|
||||
Assert.notNull(id, "id cannot be null");
|
||||
extPanelGroupMapper.deleteCircle(id);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user