mirror of
https://github.com/dataease/dataease.git
synced 2026-05-15 13:32:18 +08:00
Merge branch 'main' of github.com:dataease/dataease into main
This commit is contained in:
45
backend/src/main/java/io/dataease/base/domain/SysMenu.java
Normal file
45
backend/src/main/java/io/dataease/base/domain/SysMenu.java
Normal file
@@ -0,0 +1,45 @@
|
||||
package io.dataease.base.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SysMenu implements Serializable {
|
||||
private Long menuId;
|
||||
|
||||
private Long pid;
|
||||
|
||||
private Integer subCount;
|
||||
|
||||
private Integer type;
|
||||
|
||||
private String title;
|
||||
|
||||
private String name;
|
||||
|
||||
private String component;
|
||||
|
||||
private Integer menuSort;
|
||||
|
||||
private String icon;
|
||||
|
||||
private String path;
|
||||
|
||||
private Boolean iFrame;
|
||||
|
||||
private Boolean cache;
|
||||
|
||||
private Boolean hidden;
|
||||
|
||||
private String permission;
|
||||
|
||||
private String createBy;
|
||||
|
||||
private String updateBy;
|
||||
|
||||
private Long createTime;
|
||||
|
||||
private Long updateTime;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
1360
backend/src/main/java/io/dataease/base/domain/SysMenuExample.java
Normal file
1360
backend/src/main/java/io/dataease/base/domain/SysMenuExample.java
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,30 @@
|
||||
package io.dataease.base.mapper;
|
||||
|
||||
import io.dataease.base.domain.SysMenu;
|
||||
import io.dataease.base.domain.SysMenuExample;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface SysMenuMapper {
|
||||
long countByExample(SysMenuExample example);
|
||||
|
||||
int deleteByExample(SysMenuExample example);
|
||||
|
||||
int deleteByPrimaryKey(Long menuId);
|
||||
|
||||
int insert(SysMenu record);
|
||||
|
||||
int insertSelective(SysMenu record);
|
||||
|
||||
List<SysMenu> selectByExample(SysMenuExample example);
|
||||
|
||||
SysMenu selectByPrimaryKey(Long menuId);
|
||||
|
||||
int updateByExampleSelective(@Param("record") SysMenu record, @Param("example") SysMenuExample example);
|
||||
|
||||
int updateByExample(@Param("record") SysMenu record, @Param("example") SysMenuExample example);
|
||||
|
||||
int updateByPrimaryKeySelective(SysMenu record);
|
||||
|
||||
int updateByPrimaryKey(SysMenu record);
|
||||
}
|
||||
415
backend/src/main/java/io/dataease/base/mapper/SysMenuMapper.xml
Normal file
415
backend/src/main/java/io/dataease/base/mapper/SysMenuMapper.xml
Normal file
@@ -0,0 +1,415 @@
|
||||
<?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.SysMenuMapper">
|
||||
<resultMap id="BaseResultMap" type="io.dataease.base.domain.SysMenu">
|
||||
<id column="menu_id" jdbcType="BIGINT" property="menuId" />
|
||||
<result column="pid" jdbcType="BIGINT" property="pid" />
|
||||
<result column="sub_count" jdbcType="INTEGER" property="subCount" />
|
||||
<result column="type" jdbcType="INTEGER" property="type" />
|
||||
<result column="title" jdbcType="VARCHAR" property="title" />
|
||||
<result column="name" jdbcType="VARCHAR" property="name" />
|
||||
<result column="component" jdbcType="VARCHAR" property="component" />
|
||||
<result column="menu_sort" jdbcType="INTEGER" property="menuSort" />
|
||||
<result column="icon" jdbcType="VARCHAR" property="icon" />
|
||||
<result column="path" jdbcType="VARCHAR" property="path" />
|
||||
<result column="i_frame" jdbcType="BIT" property="iFrame" />
|
||||
<result column="cache" jdbcType="BIT" property="cache" />
|
||||
<result column="hidden" jdbcType="BIT" property="hidden" />
|
||||
<result column="permission" jdbcType="VARCHAR" property="permission" />
|
||||
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
|
||||
<result column="update_by" jdbcType="VARCHAR" property="updateBy" />
|
||||
<result column="create_time" jdbcType="BIGINT" property="createTime" />
|
||||
<result column="update_time" jdbcType="BIGINT" property="updateTime" />
|
||||
</resultMap>
|
||||
<sql id="Example_Where_Clause">
|
||||
<where>
|
||||
<foreach collection="oredCriteria" item="criteria" separator="or">
|
||||
<if test="criteria.valid">
|
||||
<trim prefix="(" prefixOverrides="and" suffix=")">
|
||||
<foreach collection="criteria.criteria" item="criterion">
|
||||
<choose>
|
||||
<when test="criterion.noValue">
|
||||
and ${criterion.condition}
|
||||
</when>
|
||||
<when test="criterion.singleValue">
|
||||
and ${criterion.condition} #{criterion.value}
|
||||
</when>
|
||||
<when test="criterion.betweenValue">
|
||||
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
|
||||
</when>
|
||||
<when test="criterion.listValue">
|
||||
and ${criterion.condition}
|
||||
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
|
||||
#{listItem}
|
||||
</foreach>
|
||||
</when>
|
||||
</choose>
|
||||
</foreach>
|
||||
</trim>
|
||||
</if>
|
||||
</foreach>
|
||||
</where>
|
||||
</sql>
|
||||
<sql id="Update_By_Example_Where_Clause">
|
||||
<where>
|
||||
<foreach collection="example.oredCriteria" item="criteria" separator="or">
|
||||
<if test="criteria.valid">
|
||||
<trim prefix="(" prefixOverrides="and" suffix=")">
|
||||
<foreach collection="criteria.criteria" item="criterion">
|
||||
<choose>
|
||||
<when test="criterion.noValue">
|
||||
and ${criterion.condition}
|
||||
</when>
|
||||
<when test="criterion.singleValue">
|
||||
and ${criterion.condition} #{criterion.value}
|
||||
</when>
|
||||
<when test="criterion.betweenValue">
|
||||
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
|
||||
</when>
|
||||
<when test="criterion.listValue">
|
||||
and ${criterion.condition}
|
||||
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
|
||||
#{listItem}
|
||||
</foreach>
|
||||
</when>
|
||||
</choose>
|
||||
</foreach>
|
||||
</trim>
|
||||
</if>
|
||||
</foreach>
|
||||
</where>
|
||||
</sql>
|
||||
<sql id="Base_Column_List">
|
||||
menu_id, pid, sub_count, `type`, title, `name`, component, menu_sort, icon, `path`,
|
||||
i_frame, `cache`, hidden, permission, create_by, update_by, create_time, update_time
|
||||
</sql>
|
||||
<select id="selectByExample" parameterType="io.dataease.base.domain.SysMenuExample" resultMap="BaseResultMap">
|
||||
select
|
||||
<if test="distinct">
|
||||
distinct
|
||||
</if>
|
||||
<include refid="Base_Column_List" />
|
||||
from sys_menu
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
<if test="orderByClause != null">
|
||||
order by ${orderByClause}
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from sys_menu
|
||||
where menu_id = #{menuId,jdbcType=BIGINT}
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
|
||||
delete from sys_menu
|
||||
where menu_id = #{menuId,jdbcType=BIGINT}
|
||||
</delete>
|
||||
<delete id="deleteByExample" parameterType="io.dataease.base.domain.SysMenuExample">
|
||||
delete from sys_menu
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
</delete>
|
||||
<insert id="insert" parameterType="io.dataease.base.domain.SysMenu">
|
||||
insert into sys_menu (menu_id, pid, sub_count,
|
||||
`type`, title, `name`,
|
||||
component, menu_sort, icon,
|
||||
`path`, i_frame, `cache`, hidden,
|
||||
permission, create_by, update_by,
|
||||
create_time, update_time)
|
||||
values (#{menuId,jdbcType=BIGINT}, #{pid,jdbcType=BIGINT}, #{subCount,jdbcType=INTEGER},
|
||||
#{type,jdbcType=INTEGER}, #{title,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
|
||||
#{component,jdbcType=VARCHAR}, #{menuSort,jdbcType=INTEGER}, #{icon,jdbcType=VARCHAR},
|
||||
#{path,jdbcType=VARCHAR}, #{iFrame,jdbcType=BIT}, #{cache,jdbcType=BIT}, #{hidden,jdbcType=BIT},
|
||||
#{permission,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR}, #{updateBy,jdbcType=VARCHAR},
|
||||
#{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT})
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="io.dataease.base.domain.SysMenu">
|
||||
insert into sys_menu
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="menuId != null">
|
||||
menu_id,
|
||||
</if>
|
||||
<if test="pid != null">
|
||||
pid,
|
||||
</if>
|
||||
<if test="subCount != null">
|
||||
sub_count,
|
||||
</if>
|
||||
<if test="type != null">
|
||||
`type`,
|
||||
</if>
|
||||
<if test="title != null">
|
||||
title,
|
||||
</if>
|
||||
<if test="name != null">
|
||||
`name`,
|
||||
</if>
|
||||
<if test="component != null">
|
||||
component,
|
||||
</if>
|
||||
<if test="menuSort != null">
|
||||
menu_sort,
|
||||
</if>
|
||||
<if test="icon != null">
|
||||
icon,
|
||||
</if>
|
||||
<if test="path != null">
|
||||
`path`,
|
||||
</if>
|
||||
<if test="iFrame != null">
|
||||
i_frame,
|
||||
</if>
|
||||
<if test="cache != null">
|
||||
`cache`,
|
||||
</if>
|
||||
<if test="hidden != null">
|
||||
hidden,
|
||||
</if>
|
||||
<if test="permission != null">
|
||||
permission,
|
||||
</if>
|
||||
<if test="createBy != null">
|
||||
create_by,
|
||||
</if>
|
||||
<if test="updateBy != null">
|
||||
update_by,
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time,
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="menuId != null">
|
||||
#{menuId,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="pid != null">
|
||||
#{pid,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="subCount != null">
|
||||
#{subCount,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="type != null">
|
||||
#{type,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="title != null">
|
||||
#{title,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="name != null">
|
||||
#{name,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="component != null">
|
||||
#{component,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="menuSort != null">
|
||||
#{menuSort,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="icon != null">
|
||||
#{icon,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="path != null">
|
||||
#{path,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="iFrame != null">
|
||||
#{iFrame,jdbcType=BIT},
|
||||
</if>
|
||||
<if test="cache != null">
|
||||
#{cache,jdbcType=BIT},
|
||||
</if>
|
||||
<if test="hidden != null">
|
||||
#{hidden,jdbcType=BIT},
|
||||
</if>
|
||||
<if test="permission != null">
|
||||
#{permission,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="createBy != null">
|
||||
#{createBy,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="updateBy != null">
|
||||
#{updateBy,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
#{createTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
#{updateTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<select id="countByExample" parameterType="io.dataease.base.domain.SysMenuExample" resultType="java.lang.Long">
|
||||
select count(*) from sys_menu
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
</select>
|
||||
<update id="updateByExampleSelective" parameterType="map">
|
||||
update sys_menu
|
||||
<set>
|
||||
<if test="record.menuId != null">
|
||||
menu_id = #{record.menuId,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="record.pid != null">
|
||||
pid = #{record.pid,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="record.subCount != null">
|
||||
sub_count = #{record.subCount,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="record.type != null">
|
||||
`type` = #{record.type,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="record.title != null">
|
||||
title = #{record.title,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.name != null">
|
||||
`name` = #{record.name,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.component != null">
|
||||
component = #{record.component,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.menuSort != null">
|
||||
menu_sort = #{record.menuSort,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="record.icon != null">
|
||||
icon = #{record.icon,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.path != null">
|
||||
`path` = #{record.path,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.iFrame != null">
|
||||
i_frame = #{record.iFrame,jdbcType=BIT},
|
||||
</if>
|
||||
<if test="record.cache != null">
|
||||
`cache` = #{record.cache,jdbcType=BIT},
|
||||
</if>
|
||||
<if test="record.hidden != null">
|
||||
hidden = #{record.hidden,jdbcType=BIT},
|
||||
</if>
|
||||
<if test="record.permission != null">
|
||||
permission = #{record.permission,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.createBy != null">
|
||||
create_by = #{record.createBy,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.updateBy != null">
|
||||
update_by = #{record.updateBy,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
create_time = #{record.createTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="record.updateTime != null">
|
||||
update_time = #{record.updateTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
</set>
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
</update>
|
||||
<update id="updateByExample" parameterType="map">
|
||||
update sys_menu
|
||||
set menu_id = #{record.menuId,jdbcType=BIGINT},
|
||||
pid = #{record.pid,jdbcType=BIGINT},
|
||||
sub_count = #{record.subCount,jdbcType=INTEGER},
|
||||
`type` = #{record.type,jdbcType=INTEGER},
|
||||
title = #{record.title,jdbcType=VARCHAR},
|
||||
`name` = #{record.name,jdbcType=VARCHAR},
|
||||
component = #{record.component,jdbcType=VARCHAR},
|
||||
menu_sort = #{record.menuSort,jdbcType=INTEGER},
|
||||
icon = #{record.icon,jdbcType=VARCHAR},
|
||||
`path` = #{record.path,jdbcType=VARCHAR},
|
||||
i_frame = #{record.iFrame,jdbcType=BIT},
|
||||
`cache` = #{record.cache,jdbcType=BIT},
|
||||
hidden = #{record.hidden,jdbcType=BIT},
|
||||
permission = #{record.permission,jdbcType=VARCHAR},
|
||||
create_by = #{record.createBy,jdbcType=VARCHAR},
|
||||
update_by = #{record.updateBy,jdbcType=VARCHAR},
|
||||
create_time = #{record.createTime,jdbcType=BIGINT},
|
||||
update_time = #{record.updateTime,jdbcType=BIGINT}
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
</update>
|
||||
<update id="updateByPrimaryKeySelective" parameterType="io.dataease.base.domain.SysMenu">
|
||||
update sys_menu
|
||||
<set>
|
||||
<if test="pid != null">
|
||||
pid = #{pid,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="subCount != null">
|
||||
sub_count = #{subCount,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="type != null">
|
||||
`type` = #{type,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="title != null">
|
||||
title = #{title,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="name != null">
|
||||
`name` = #{name,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="component != null">
|
||||
component = #{component,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="menuSort != null">
|
||||
menu_sort = #{menuSort,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="icon != null">
|
||||
icon = #{icon,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="path != null">
|
||||
`path` = #{path,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="iFrame != null">
|
||||
i_frame = #{iFrame,jdbcType=BIT},
|
||||
</if>
|
||||
<if test="cache != null">
|
||||
`cache` = #{cache,jdbcType=BIT},
|
||||
</if>
|
||||
<if test="hidden != null">
|
||||
hidden = #{hidden,jdbcType=BIT},
|
||||
</if>
|
||||
<if test="permission != null">
|
||||
permission = #{permission,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="createBy != null">
|
||||
create_by = #{createBy,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="updateBy != null">
|
||||
update_by = #{updateBy,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time = #{createTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time = #{updateTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
</set>
|
||||
where menu_id = #{menuId,jdbcType=BIGINT}
|
||||
</update>
|
||||
<update id="updateByPrimaryKey" parameterType="io.dataease.base.domain.SysMenu">
|
||||
update sys_menu
|
||||
set pid = #{pid,jdbcType=BIGINT},
|
||||
sub_count = #{subCount,jdbcType=INTEGER},
|
||||
`type` = #{type,jdbcType=INTEGER},
|
||||
title = #{title,jdbcType=VARCHAR},
|
||||
`name` = #{name,jdbcType=VARCHAR},
|
||||
component = #{component,jdbcType=VARCHAR},
|
||||
menu_sort = #{menuSort,jdbcType=INTEGER},
|
||||
icon = #{icon,jdbcType=VARCHAR},
|
||||
`path` = #{path,jdbcType=VARCHAR},
|
||||
i_frame = #{iFrame,jdbcType=BIT},
|
||||
`cache` = #{cache,jdbcType=BIT},
|
||||
hidden = #{hidden,jdbcType=BIT},
|
||||
permission = #{permission,jdbcType=VARCHAR},
|
||||
create_by = #{createBy,jdbcType=VARCHAR},
|
||||
update_by = #{updateBy,jdbcType=VARCHAR},
|
||||
create_time = #{createTime,jdbcType=BIGINT},
|
||||
update_time = #{updateTime,jdbcType=BIGINT}
|
||||
where menu_id = #{menuId,jdbcType=BIGINT}
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -0,0 +1,15 @@
|
||||
package io.dataease.base.mapper.ext;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
@Mapper
|
||||
public interface ExtMenuMapper {
|
||||
|
||||
@Update(" update sys_menu set sub_count = sub_count+1 where menu_id = #{menuId} ")
|
||||
int incrementalSubcount(@Param("menuId") Long menuId);
|
||||
|
||||
@Update(" update sys_menu set sub_count = sub_count-1 where menu_id = #{menuId} and sub_count > 0")
|
||||
int decreasingSubcount(@Param("menuId") Long menuId);
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package io.dataease.controller.sys;
|
||||
|
||||
|
||||
import io.dataease.base.domain.SysMenu;
|
||||
import io.dataease.commons.utils.BeanUtils;
|
||||
|
||||
import io.dataease.controller.sys.request.MenuCreateRequest;
|
||||
import io.dataease.controller.sys.request.MenuDeleteRequest;
|
||||
import io.dataease.controller.sys.response.MenuNodeResponse;
|
||||
import io.dataease.service.sys.MenuService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "系统:菜单管理")
|
||||
@RequestMapping("/api/menu")
|
||||
public class SysMenuController {
|
||||
|
||||
@Resource
|
||||
private MenuService menuService;
|
||||
|
||||
@ApiOperation("查询跟节点菜单")
|
||||
@PostMapping("/childNodes/{pid}")
|
||||
public List<MenuNodeResponse> childNodes(@PathVariable("pid") Long pid){
|
||||
List<SysMenu> nodes = menuService.nodesByPid(pid);
|
||||
List<MenuNodeResponse> nodeResponses = nodes.stream().map(node -> {
|
||||
MenuNodeResponse menuNodeResponse = BeanUtils.copyBean(new MenuNodeResponse(), node);
|
||||
menuNodeResponse.setHasChildren(node.getSubCount() > 0);
|
||||
menuNodeResponse.setTop(node.getPid() == menuService.MENU_ROOT_PID);
|
||||
return menuNodeResponse;
|
||||
}).collect(Collectors.toList());
|
||||
return nodeResponses;
|
||||
}
|
||||
|
||||
@ApiOperation("新增菜单")
|
||||
@PostMapping("/create")
|
||||
public void create(@RequestBody MenuCreateRequest request){
|
||||
menuService.add(request);
|
||||
}
|
||||
|
||||
@ApiOperation("删除菜单")
|
||||
@PostMapping("/delete")
|
||||
public void delete(@RequestBody MenuDeleteRequest request){
|
||||
menuService.delete(request);
|
||||
}
|
||||
@ApiOperation("更新菜单")
|
||||
@PostMapping("/update")
|
||||
public void update(@RequestBody MenuCreateRequest menu){
|
||||
menuService.update(menu);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package io.dataease.controller.sys.request;
|
||||
|
||||
import io.dataease.base.domain.SysMenu;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MenuCreateRequest extends SysMenu {
|
||||
|
||||
private boolean top;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package io.dataease.controller.sys.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MenuDeleteRequest {
|
||||
|
||||
private Long menuId;
|
||||
|
||||
private Long pid;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package io.dataease.controller.sys.response;
|
||||
|
||||
import io.dataease.base.domain.SysMenu;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MenuNodeResponse extends SysMenu {
|
||||
|
||||
private boolean hasChildren;
|
||||
|
||||
private boolean top;
|
||||
}
|
||||
@@ -24,7 +24,7 @@ public class DatasourceController {
|
||||
}
|
||||
|
||||
@PostMapping("/validate")
|
||||
public void validate(@RequestBody Datasource datasource) throws Exception{
|
||||
public void validate(@RequestBody Datasource datasource) throws Exception {
|
||||
datasourceService.validate(datasource);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class DatasourceController {
|
||||
}
|
||||
|
||||
@PostMapping("/list/{goPage}/{pageSize}")
|
||||
public Pager<List<Datasource>> getDatasourceList(@RequestBody Datasource request, @PathVariable int goPage, @PathVariable int pageSize) throws Exception{
|
||||
public Pager<List<Datasource>> getDatasourceList(@RequestBody Datasource request, @PathVariable int goPage, @PathVariable int pageSize) throws Exception {
|
||||
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
|
||||
return PageUtils.setPageInfo(page, datasourceService.getDatasourceList(request));
|
||||
}
|
||||
@@ -48,4 +48,9 @@ public class DatasourceController {
|
||||
public void updateDatasource(@RequestBody Datasource Datasource) {
|
||||
datasourceService.updateDatasource(Datasource);
|
||||
}
|
||||
|
||||
@PostMapping("/getTables")
|
||||
public List<String> getTables(@RequestBody Datasource datasource) throws Exception {
|
||||
return datasourceService.getTables(datasource);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public class DatasourceService {
|
||||
public Datasource addDatasource(Datasource datasource) {
|
||||
DatasourceExample example = new DatasourceExample();
|
||||
example.createCriteria().andNameEqualTo(datasource.getName());
|
||||
if(CollectionUtils.isNotEmpty(datasourceMapper.selectByExample(example))){
|
||||
if (CollectionUtils.isNotEmpty(datasourceMapper.selectByExample(example))) {
|
||||
DEException.throwException("Exist data connection with the same name ");
|
||||
}
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
@@ -36,7 +36,7 @@ public class DatasourceService {
|
||||
return datasource;
|
||||
}
|
||||
|
||||
public List<Datasource> getDatasourceList(Datasource request)throws Exception{
|
||||
public List<Datasource> getDatasourceList(Datasource request) throws Exception {
|
||||
DatasourceExample example = new DatasourceExample();
|
||||
DatasourceExample.Criteria criteria = example.createCriteria();
|
||||
if (StringUtils.isNotBlank(request.getName())) {
|
||||
@@ -59,13 +59,19 @@ public class DatasourceService {
|
||||
datasourceMapper.updateByPrimaryKeySelective(datasource);
|
||||
}
|
||||
|
||||
public void validate(Datasource datasource)throws Exception {
|
||||
public void validate(Datasource datasource) throws Exception {
|
||||
DatasourceProvider datasourceProvider = ProviderFactory.getProvider(datasource.getType());
|
||||
DatasourceRequest datasourceRequest = new DatasourceRequest();
|
||||
datasourceRequest.setDatasource(datasource);
|
||||
datasourceProvider.test(datasourceRequest);
|
||||
}
|
||||
|
||||
|
||||
public List<String> getTables(Datasource datasource) throws Exception {
|
||||
Datasource ds = datasourceMapper.selectByPrimaryKey(datasource.getId());
|
||||
DatasourceProvider datasourceProvider = ProviderFactory.getProvider(ds.getType());
|
||||
DatasourceRequest datasourceRequest = new DatasourceRequest();
|
||||
datasourceRequest.setDatasource(ds);
|
||||
return datasourceProvider.getTables(datasourceRequest);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
112
backend/src/main/java/io/dataease/service/sys/MenuService.java
Normal file
112
backend/src/main/java/io/dataease/service/sys/MenuService.java
Normal file
@@ -0,0 +1,112 @@
|
||||
package io.dataease.service.sys;
|
||||
|
||||
import io.dataease.base.domain.SysMenu;
|
||||
import io.dataease.base.domain.SysMenuExample;
|
||||
import io.dataease.base.mapper.SysMenuMapper;
|
||||
import io.dataease.base.mapper.ext.ExtMenuMapper;
|
||||
import io.dataease.commons.utils.BeanUtils;
|
||||
import io.dataease.controller.sys.request.MenuCreateRequest;
|
||||
import io.dataease.controller.sys.request.MenuDeleteRequest;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class MenuService {
|
||||
|
||||
|
||||
|
||||
private final static Integer DEFAULT_SUBCOUNT = 0;
|
||||
public final static Long MENU_ROOT_PID = 0L;
|
||||
|
||||
@Resource
|
||||
private SysMenuMapper sysMenuMapper;
|
||||
|
||||
|
||||
@Resource
|
||||
private ExtMenuMapper extMenuMapper;
|
||||
|
||||
public List<SysMenu> nodesByPid(Long pid){
|
||||
SysMenuExample example = new SysMenuExample();
|
||||
SysMenuExample.Criteria criteria = example.createCriteria();
|
||||
if (ObjectUtils.isEmpty(pid)){
|
||||
criteria.andPidEqualTo(MENU_ROOT_PID);
|
||||
}else {
|
||||
criteria.andPidEqualTo(pid);
|
||||
}
|
||||
example.setOrderByClause("menu_sort");
|
||||
List<SysMenu> sysMenus = sysMenuMapper.selectByExample(example);
|
||||
return sysMenus;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public boolean add(MenuCreateRequest menuCreateRequest){
|
||||
SysMenu sysMenu = BeanUtils.copyBean(new SysMenu(), menuCreateRequest);
|
||||
if (menuCreateRequest.isTop()){
|
||||
sysMenu.setPid(MENU_ROOT_PID);
|
||||
}
|
||||
long now = System.currentTimeMillis();
|
||||
sysMenu.setCreateTime(now);
|
||||
sysMenu.setUpdateTime(now);
|
||||
sysMenu.setCreateBy(null);
|
||||
sysMenu.setUpdateBy(null);
|
||||
sysMenu.setSubCount(DEFAULT_SUBCOUNT);
|
||||
try {
|
||||
int insert = sysMenuMapper.insert(sysMenu);
|
||||
Long pid = null;
|
||||
if ((pid = sysMenu.getPid()) != MENU_ROOT_PID ){
|
||||
//这里需要更新上级节点SubCount
|
||||
extMenuMapper.incrementalSubcount(pid);
|
||||
}
|
||||
if (insert == 1){
|
||||
return true;
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public int delete(MenuDeleteRequest request){
|
||||
Long pid = request.getPid();
|
||||
if (pid != MENU_ROOT_PID){
|
||||
extMenuMapper.decreasingSubcount(pid);
|
||||
}
|
||||
Long menuId = request.getMenuId();
|
||||
|
||||
return sysMenuMapper.deleteByPrimaryKey(menuId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Transactional
|
||||
public int update(MenuCreateRequest menuCreateRequest){
|
||||
SysMenu sysMenu = BeanUtils.copyBean(new SysMenu(), menuCreateRequest);
|
||||
if (menuCreateRequest.isTop()){
|
||||
sysMenu.setPid(MENU_ROOT_PID);
|
||||
}
|
||||
|
||||
sysMenu.setUpdateBy(null);
|
||||
sysMenu.setUpdateTime(System.currentTimeMillis());
|
||||
Long menuId = sysMenu.getMenuId();
|
||||
SysMenu menu_old = sysMenuMapper.selectByPrimaryKey(menuId);
|
||||
//如果PID发生了改变
|
||||
//判断oldPid是否是跟节点PID ? nothing : parent.subcount-1
|
||||
//判断newPid是否是跟节点PID ? nothing : parent.subcount+1
|
||||
if (menu_old.getPid() != sysMenu.getPid()){
|
||||
Long oldPid = menu_old.getPid();
|
||||
if (oldPid != MENU_ROOT_PID){
|
||||
extMenuMapper.decreasingSubcount(oldPid);
|
||||
}
|
||||
if (sysMenu.getPid() != MENU_ROOT_PID){
|
||||
extMenuMapper.incrementalSubcount(sysMenu.getPid());
|
||||
}
|
||||
}
|
||||
return sysMenuMapper.updateByPrimaryKeySelective(sysMenu);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user