feat(修改): 生成路由
This commit is contained in:
parent
0fc1567c82
commit
a5680029ff
|
@ -0,0 +1,59 @@
|
||||||
|
package cn.bunny.dao.vo.router;
|
||||||
|
|
||||||
|
import cn.bunny.dao.vo.BaseVo;
|
||||||
|
import com.alibaba.fastjson2.annotation.JSONField;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Builder
|
||||||
|
@ApiModel(value = "RouterControllerVo对象", description = "路由管理端返回对象")
|
||||||
|
public class RouterManageVo extends BaseVo {
|
||||||
|
|
||||||
|
@ApiModelProperty("在项目中路径")
|
||||||
|
private String path;
|
||||||
|
|
||||||
|
@ApiModelProperty("路由名称")
|
||||||
|
@JsonProperty("name")
|
||||||
|
private String routeName;
|
||||||
|
|
||||||
|
@ApiModelProperty("父级id")
|
||||||
|
@JsonProperty("parentId")
|
||||||
|
@JsonFormat(shape = JsonFormat.Shape.STRING)
|
||||||
|
@JSONField(serializeUsing = ToStringSerializer.class)
|
||||||
|
private Long parentId;
|
||||||
|
|
||||||
|
@ApiModelProperty("菜单类型")
|
||||||
|
private Integer menuType;
|
||||||
|
|
||||||
|
@ApiModelProperty("路由title")
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
@ApiModelProperty("图标")
|
||||||
|
private String icon;
|
||||||
|
|
||||||
|
@ApiModelProperty("链接地址(需要内嵌的`iframe`链接地址)")
|
||||||
|
private String frameSrc;
|
||||||
|
|
||||||
|
@ApiModelProperty("等级")
|
||||||
|
@JsonProperty("rank")
|
||||||
|
private Integer routerRank;
|
||||||
|
|
||||||
|
@ApiModelProperty("是否显示")
|
||||||
|
private Boolean visible;
|
||||||
|
|
||||||
|
@ApiModelProperty("是否显示")
|
||||||
|
private Boolean frameLoading;
|
||||||
|
|
||||||
|
@ApiModelProperty("子路由")
|
||||||
|
private List<RouterManageVo> children;
|
||||||
|
}
|
|
@ -0,0 +1,69 @@
|
||||||
|
<?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="cn.bunny.services.mapper.RouterMapper">
|
||||||
|
|
||||||
|
<!-- 通用查询映射结果 -->
|
||||||
|
<resultMap id="BaseResultMap" type="cn.bunny.dao.entity.system.Router">
|
||||||
|
<id column="id" property="id"/>
|
||||||
|
<result column="path" property="path"/>
|
||||||
|
<result column="route_name" property="routeName"/>
|
||||||
|
<result column="parent_id" property="parentId"/>
|
||||||
|
<result column="menu_type" property="menuType"/>
|
||||||
|
<result column="title" property="title"/>
|
||||||
|
<result column="icon" property="icon"/>
|
||||||
|
<result column="enter_transition" property="enterTransition"/>
|
||||||
|
<result column="leave_transition" property="leaveTransition"/>
|
||||||
|
<result column="router_rank" property="routerRank"/>
|
||||||
|
<result column="visible" property="visible"/>
|
||||||
|
<result column="create_user" property="createUser"/>
|
||||||
|
<result column="update_user" property="updateUser"/>
|
||||||
|
<result column="update_time" property="updateTime"/>
|
||||||
|
<result column="create_time" property="createTime"/>
|
||||||
|
<result column="is_deleted" property="isDeleted"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<!-- 通用查询结果列 -->
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
id
|
||||||
|
, path, route_name, parent_id, menu_type, title, icon, enter_transition, leave_transition, router_rank, visible, create_user, update_user, update_time, create_time, is_deleted
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<!-- 根据用户ID查找路由列表 -->
|
||||||
|
<select id="selectListByUserId" resultType="java.lang.Long">
|
||||||
|
SELECT router.id
|
||||||
|
FROM sys_user_role user_role
|
||||||
|
LEFT JOIN sys_user user ON user_role.user_id = user.id
|
||||||
|
LEFT JOIN sys_router_role router_role ON user_role.role_id = router_role.role_id
|
||||||
|
LEFT JOIN sys_router router ON router_role.router_id = router.id
|
||||||
|
WHERE user.id = #{userId}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 递归查询所有父级Id,直到查询到父级Id为0 -->
|
||||||
|
<select id="selectParentListByRouterId" resultType="cn.bunny.dao.entity.system.Router">
|
||||||
|
WITH RECURSIVE ParentChain AS (
|
||||||
|
SELECT * FROM sys_router
|
||||||
|
WHERE id IN
|
||||||
|
<foreach collection="ids" item="id" open="(" close=")" separator=",">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
UNION ALL
|
||||||
|
SELECT r.* FROM sys_router r
|
||||||
|
INNER JOIN ParentChain pc ON r.id = pc.parent_id
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
<include refid="Base_Column_List"/>
|
||||||
|
FROM ParentChain;
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 管理菜单列表 -->
|
||||||
|
<select id="selectListByPage" resultType="cn.bunny.dao.entity.system.Router">
|
||||||
|
select *
|
||||||
|
from sys_router
|
||||||
|
<if test="dto.title != null and dto.title != ''">
|
||||||
|
title like CONCAT('%',#{dto.title},'%')
|
||||||
|
</if>
|
||||||
|
<if test="dto.visible != null">
|
||||||
|
visible = #{dto.visible}
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
</mapper>
|
Loading…
Reference in New Issue