MenuMapper.xml 2.85 KB
<?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.com.glsx.dj.system.mapper.MenuMapper" >
  <resultMap id="BaseResultMap" type="cn.com.glsx.dj.system.model.Menu" >
    <!--
      WARNING - @mbg.generated
    -->
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="code" property="code" jdbcType="INTEGER" />
    <result column="name" property="name" jdbcType="VARCHAR" />
    <result column="url" property="url" jdbcType="VARCHAR" />
    <result column="parent_code" property="parentCode" jdbcType="INTEGER" />
    <result column="type" property="type" jdbcType="TINYINT" />
    <result column="order_no" property="orderNo" jdbcType="INTEGER" />
    <result column="created_by" property="createdBy" jdbcType="VARCHAR" />
    <result column="created_date" property="createdDate" jdbcType="TIMESTAMP" />
    <result column="updated_by" property="updatedBy" jdbcType="VARCHAR" />
    <result column="updated_date" property="updatedDate" jdbcType="TIMESTAMP" />
    <result column="deleted_flag" property="deletedFlag" jdbcType="CHAR" />
  </resultMap>
  <resultMap id="DTOResultMap" type="cn.com.glsx.dj.system.dto.MenuDTO" extends="BaseResultMap"></resultMap>
  <sql id="Base_Column_List" >
    <!--
      WARNING - @mbg.generated
    -->
    id, code, name, url, parent_code, type,order_no, created_by, created_date, updated_by, 
    updated_date, deleted_flag
  </sql>
  
  <select id="list" parameterType="cn.com.glsx.dj.system.dto.MenuDTO" resultMap="DTOResultMap">
  	select <include refid="Base_Column_List"/> from dj_system_menu a
  	<where>
  		deleted_flag = 'N'
  		<if test="name != null and name !=''">
  			and name LIKE "%"#{name}"%"
  		</if>
  		<if test="code != null">
  			and code =#{code}
  		</if>
  		<if test="parentCode != null">
  			and parent_code = #{parentCode}
  		</if>
  		<if test="userId != null or roleId != null">
			and a.code in (
			select b.menu_code from dj_system_role_menu b
			left join dj_system_role c on c.id=b.role_id
			left join dj_system_user_role d on d.role_id=b.role_id and d.deleted_flag='N' 
			where b.deleted_flag='N' and c.deleted_flag='N'  
			<if test="userId != null">
				and d.user_id = #{userId}
			</if>
			<if test="roleId != null">
				and b.role_id = #{roleId}
			</if>
			)
		</if>
  	</where>
  	order by order_no asc
  </select>
  
  <select id="listUserAuth" parameterType="cn.com.glsx.dj.system.dto.MenuDTO" resultMap="DTOResultMap">
  	select id,code,name,url,parent_code,type,order_no from dj_system_menu a
  	<where>
  		deleted_flag = 'N'
  		<if test="menuCodes != null">
  			and code in 
  			<foreach collection="menuCodes" index="index" item="item" open="(" separator="," close=")">
				#{item}       
    		</foreach>  
  		</if>
  	</where>
  	order by order_no asc
  </select>
  
</mapper>