317 lines
12 KiB
XML
317 lines
12 KiB
XML
<?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="com.adc.da.sys.dao.mysql.MenuEODao">
|
|
<!-- Result Map-->
|
|
<resultMap id="BaseResultMap" type="com.adc.da.sys.entity.MenuEO">
|
|
<id column="id" property="id"/>
|
|
<result column="del_flag" property="delFlag"/>
|
|
<result column="name" property="name"/>
|
|
<result column="parent_id" property="parentId"/>
|
|
<result column="parent_ids" property="parentIds"/>
|
|
<result column="href" property="href"/>
|
|
<result column="icon" property="icon"/>
|
|
<result column="iconHref" property="iconHref"/>
|
|
<result column="iconClick" property="iconClick"/>
|
|
<result column="iconClickHref" property="iconClickHref"/>
|
|
<result column="is_show" property="isShow"/>
|
|
<result column="permission" property="permission"/>
|
|
<result column="remarks" property="remarks"/>
|
|
<result column="sort" property="sort"/>
|
|
<result column="ext_info" property="extInfo" />
|
|
<result column="is_button" property="isButton" />
|
|
</resultMap>
|
|
|
|
<!-- TS_MENU table all fields -->
|
|
<sql id="Base_Column_List">
|
|
id, del_flag, name, parent_id, parent_ids, href, icon,iconHref,iconClick,iconClickHref, is_show, permission, remarks, sort, ext_info,is_url,is_button
|
|
</sql>
|
|
|
|
<!-- 用于按名称查询记录时的sql,添加前缀TS_MENU -->
|
|
<!-- 2018-08-22 -->
|
|
<sql id="Base_Column_List_V2">
|
|
TS_MENU.id, TS_MENU.del_flag, TS_MENU.name, TS_MENU.parent_id, TS_MENU.parent_ids, TS_MENU.href, TS_MENU.icon, TS_MENU.is_show, TS_MENU.permission, TS_MENU.remarks, TS_MENU.sort, TS_MENU.ext_info
|
|
</sql>
|
|
<!-- 查询条件 -->
|
|
<sql id="Base_Where_Clause">
|
|
where 1=1
|
|
<trim suffixOverrides=",">
|
|
<if test="id != null">
|
|
and id ${idOperator} #{id}
|
|
</if>
|
|
<if test="delFlag != null">
|
|
and del_flag ${delFlagOperator} #{delFlag}
|
|
</if>
|
|
<if test="name != null">
|
|
and name ${nameOperator} #{name}
|
|
</if>
|
|
<if test="parentId != null">
|
|
and parent_id ${parentIdOperator} #{parentId}
|
|
</if>
|
|
<if test="parentIds != null">
|
|
and parent_ids ${parentIdsOperator} #{parentIds}
|
|
</if>
|
|
<if test="href != null">
|
|
and href ${hrefOperator} #{href}
|
|
</if>
|
|
<if test="icon != null">
|
|
and icon ${iconOperator} #{icon}
|
|
</if>
|
|
<if test="isShow != null">
|
|
and is_show ${isShowOperator} #{isShow}
|
|
</if>
|
|
<if test="permission != null">
|
|
and permission ${permissionOperator} #{permission}
|
|
</if>
|
|
<if test="remarks != null">
|
|
and remarks ${remarksOperator} #{remarks}
|
|
</if>
|
|
<if test="sort != null">
|
|
and sort ${sortOperator} #{sort}
|
|
</if>
|
|
</trim>
|
|
</sql>
|
|
|
|
<!-- 插入记录 -->
|
|
<insert id="insert" parameterType="com.adc.da.sys.entity.MenuEO">
|
|
insert into TS_MENU(<include refid="Base_Column_List"/>)
|
|
values (#{id}, #{delFlag}, #{name}, #{parentId}, #{parentIds}, #{href}, #{icon},
|
|
#{iconHref},#{iconClick},#{iconClickHref},#{isShow}, #{permission}, #{remarks}, #{sort}, #{extInfo})
|
|
</insert>
|
|
|
|
<!-- 动态插入记录 主键是序列 -->
|
|
<insert id="insertSelective" parameterType="com.adc.da.sys.entity.MenuEO" >
|
|
insert into TS_MENU
|
|
<trim prefix="(" suffix=")" suffixOverrides="," >
|
|
<if test="extInfo != null" >ext_info,</if>
|
|
<if test="sort != null" >sort,</if>
|
|
<if test="remarks != null" >remarks,</if>
|
|
<if test="permission != null" >permission,</if>
|
|
<if test="isShow != null" >is_show,</if>
|
|
<if test="icon != null" >icon,</if>
|
|
<if test="iconHref != null" >iconHref,</if>
|
|
<if test="iconClick != null" >iconClick,</if>
|
|
<if test="iconClickHref != null" >iconClickHref,</if>
|
|
<if test="href != null" >href,</if>
|
|
<if test="parentIds != null" >parent_ids,</if>
|
|
<if test="parentId != null" >parent_id,</if>
|
|
<if test="name != null" >name,</if>
|
|
<if test="delFlag != null" >del_flag,</if>
|
|
<if test="id != null" >id,</if>
|
|
<if test="isUrl != null" >is_url,</if>
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides="," >
|
|
<if test="extInfo != null" >#{extInfo},</if>
|
|
<if test="sort != null" >#{sort},</if>
|
|
<if test="remarks != null" >#{remarks},</if>
|
|
<if test="permission != null" >#{permission},</if>
|
|
<if test="isShow != null" >#{isShow},</if>
|
|
<if test="icon != null" >#{icon},</if>
|
|
<if test="iconHref != null" >#{iconHref},</if>
|
|
<if test="iconClick != null" >#{iconClick},</if>
|
|
<if test="iconClickHref != null" >#{iconClickHref},</if>
|
|
<if test="href != null" >#{href},</if>
|
|
<if test="parentIds != null" >#{parentIds},</if>
|
|
<if test="parentId != null" >#{parentId},</if>
|
|
<if test="name != null" >#{name},</if>
|
|
<if test="delFlag != null" >#{delFlag},</if>
|
|
<if test="id != null" >#{id},</if>
|
|
<if test="isUrl != null" >#{isUrl},</if>
|
|
</trim>
|
|
</insert>
|
|
|
|
|
|
<!-- 根据pk,修改记录-->
|
|
<update id="updateByPrimaryKey" parameterType="com.adc.da.sys.entity.MenuEO">
|
|
UPDATE TS_MENU
|
|
SET del_flag = #{delFlag},
|
|
NAME = #{name},
|
|
parent_id = #{parentId},
|
|
parent_ids = #{parentIds},
|
|
href = #{href},
|
|
icon = #{icon},
|
|
iconHref = #{iconHref},
|
|
iconClick = #{iconClick},
|
|
iconClickHref = #{iconClickHref},
|
|
is_show = #{isShow},
|
|
PERMISSION = #{permission},
|
|
remarks = #{remarks},
|
|
SORT = #{sort}
|
|
WHERE ID = #{id}
|
|
</update>
|
|
|
|
<!-- 修改记录,只修改只不为空的字段 -->
|
|
<update id="updateByPrimaryKeySelective" parameterType="com.adc.da.sys.entity.MenuEO">
|
|
update TS_MENU
|
|
<set>
|
|
<if test="extInfo != null" >
|
|
ext_info = #{extInfo},
|
|
</if>
|
|
<if test="delFlag != null">
|
|
del_flag = #{delFlag},
|
|
</if>
|
|
<if test="name != null">
|
|
name = #{name},
|
|
</if>
|
|
<if test="parentId != null">
|
|
parent_id = #{parentId},
|
|
</if>
|
|
<if test="parentIds != null">
|
|
parent_ids = #{parentIds},
|
|
</if>
|
|
<if test="href != null">
|
|
href = #{href},
|
|
</if>
|
|
<if test="icon != null">
|
|
icon = #{icon},
|
|
</if>
|
|
<if test="iconHref != null">
|
|
iconHref = #{iconHref},
|
|
</if>
|
|
<if test="iconClick != null">
|
|
iconClick = #{iconClick},
|
|
</if>
|
|
<if test="iconClickHref != null">
|
|
iconClickHref = #{iconClickHref},
|
|
</if>
|
|
<if test="isShow != null">
|
|
is_show = #{isShow},
|
|
</if>
|
|
<if test="permission != null">
|
|
permission = #{permission},
|
|
</if>
|
|
<if test="remarks != null">
|
|
remarks = #{remarks},
|
|
</if>
|
|
<if test="sort != null">
|
|
sort = #{sort},
|
|
</if>
|
|
<if test="isUrl != null">
|
|
is_url = #{isUrl},
|
|
</if>
|
|
</set>
|
|
where id = #{id}
|
|
</update>
|
|
|
|
<!--删除菜单
|
|
逻辑删除-->
|
|
<update id="deleteMenuLogic">
|
|
UPDATE TS_MENU set DEL_FLAG = ${@com.adc.da.util.constant.DeleteFlagEnum@DELETE.getValue()}
|
|
WHERE id in
|
|
<foreach collection="array" item="id" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</update>
|
|
|
|
<update id="deleteMenuByParentId" parameterType="string">
|
|
UPDATE TS_MENU set DEL_FLAG = '1'
|
|
WHERE PARENT_ID=#{pId}
|
|
</update>
|
|
|
|
|
|
<!-- 根据id查询 TS_MENU -->
|
|
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String">
|
|
select
|
|
<include refid="Base_Column_List"/>
|
|
from TS_MENU
|
|
where id = #{value} and del_flag = ${@com.adc.da.util.constant.DeleteFlagEnum@NORMAL.getValue()}
|
|
|
|
</select>
|
|
|
|
|
|
<!--删除角色菜单信息-->
|
|
<delete id="deleteRoleMenus">
|
|
DELETE FROM TR_ROLE_MENU where MENU_ID in
|
|
<foreach collection="array" item="id" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
or MENU_ID in (
|
|
select ID from TS_MENU where
|
|
<foreach collection="array" item="id" open="" separator="or" close="">
|
|
PARENT_IDS like "%"#{id}"%"
|
|
</foreach>
|
|
)
|
|
</delete>
|
|
|
|
<!-- TS_MENU 列表总数-->
|
|
<select id="queryByCount" resultType="java.lang.Integer" parameterType="com.adc.da.base.page.BasePage">
|
|
select count(1) from TS_MENU
|
|
<include refid="Base_Where_Clause"/>
|
|
</select>
|
|
|
|
<!-- 查询TS_MENU列表 -->
|
|
<select id="queryByList" resultMap="BaseResultMap" parameterType="com.adc.da.base.page.BasePage">
|
|
select
|
|
<include refid="Base_Column_List"/>
|
|
from (select t.*,rownum rownu from TS_MENU t
|
|
where rownum<=${pager.endIndex})tt
|
|
where tt.rownu>=${pager.startIndex}
|
|
</select>
|
|
|
|
<!--查询所有菜单记录-->
|
|
<select id="findAll" resultMap="BaseResultMap" flushCache="true" useCache="false">
|
|
SELECT
|
|
<include refid="Base_Column_List"/>
|
|
FROM TS_MENU
|
|
WHERE del_flag ='0'
|
|
</select>
|
|
<!-- -->
|
|
<select id="listMenuEOByUserId" resultMap="BaseResultMap">
|
|
SELECT distinct
|
|
<include refid="Base_Column_List"/>
|
|
FROM TS_MENU M
|
|
LEFT JOIN TR_ROLE_MENU RM ON RM.MENU_ID = M.ID
|
|
LEFT JOIN TR_USER_ROLE UR ON UR.ROLE_ID = RM.ROLE_ID
|
|
WHERE UR.USER_ID = #{userId}
|
|
</select>
|
|
|
|
|
|
<select id="getChildMenus" resultMap="BaseResultMap">
|
|
SELECT
|
|
<include refid="Base_Column_List"/>
|
|
FROM TS_MENU
|
|
WHERE PARENT_IDS like "%"#{parentId}"%"
|
|
</select>
|
|
|
|
<select id="isBelong" resultType="integer">
|
|
SELECT count(1) from TR_ROLE_MENU where ROLE_ID = #{roleId} and MENU_ID = #{menuId}
|
|
</select>
|
|
|
|
<select id="queryAllRoleMenu" resultType="integer">
|
|
SELECT count(1) from TR_ROLE_MENU where ROLE_ID = #{roleId} and MENU_ID = #{menuId}
|
|
</select>
|
|
|
|
|
|
|
|
<select id="listMenuEOByRoleID" resultType="com.adc.da.sys.entity.MenuEO">
|
|
SELECT <include refid="Base_Column_List"/> FROM TS_MENU M LEFT JOIN TR_ROLE_MENU RM ON M.ID = RM.MENU_ID where RM.ROLE_ID = #{roleId}
|
|
</select>
|
|
|
|
<select id="queryConflict" resultType="java.lang.Integer">
|
|
select count(1) from TS_MENU
|
|
where name = #{name} and parent_id = #{parentId} and id != #{id} and del_flag='0'
|
|
|
|
</select>
|
|
|
|
<select id="listMenuEOByMenuIds" resultMap="BaseResultMap">
|
|
SELECT distinct
|
|
<include refid="Base_Column_List"/>
|
|
FROM TS_MENU M
|
|
LEFT JOIN TR_ROLE_MENU RM ON RM.MENU_ID = M.ID
|
|
LEFT JOIN TR_USER_ROLE UR ON UR.ROLE_ID = RM.ROLE_ID
|
|
WHERE M.ID in
|
|
<foreach item="id" collection="ids" open="(" separator=","
|
|
close=")" index="index">
|
|
#{id}
|
|
</foreach>
|
|
</select>
|
|
|
|
<select id="listMenuEOByRoleId" resultMap="BaseResultMap">
|
|
SELECT distinct
|
|
<include refid="Base_Column_List"/>
|
|
FROM TS_MENU M
|
|
LEFT JOIN TR_ROLE_MENU RM ON RM.MENU_ID = M.ID
|
|
WHERE RM.ROLE_ID = #{roleId}
|
|
</select>
|
|
|
|
</mapper>
|