<?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.sy.coinage.sys.dao.MenuDao">
  <sql id="Base_Column_List">
    id
    , status, sorted, pid, name, icon, component, redirect, hide_menu, title, path, permission
  </sql>
  <resultMap id="MenuResultMap" type="com.sy.coinage.sys.vo.UserMenusVO">
    <id column="id" jdbcType="INTEGER" property="id"/>
    <result column="pid" jdbcType="INTEGER" property="pid"/>
    <result column="name" jdbcType="VARCHAR" property="name"/>
    <result column="path" jdbcType="VARCHAR" property="path"/>
    <result column="component" jdbcType="VARCHAR" property="component"/>
    <result column="redirect" jdbcType="VARCHAR" property="redirect"/>
    <collection column="id" javaType="com.sy.coinage.sys.vo.MetaVO" property="meta"
      select="selectMeta"/>
  </resultMap>
  <select id="selectMeta" resultType="com.sy.coinage.sys.vo.MetaVO">
    SELECT icon,
           title,
           hide_menu as hideMenu
    FROM sys_menu
    where id = #{id}
  </select>
  <select id="queryUserMenusList" resultMap="MenuResultMap">
    select
    sys_menu.id,
    sys_menu.name,
    sys_menu.redirect,
    sys_menu.path,
    sys_menu.component,
    sys_menu.pid
    FROM
    sys_menu
    LEFT JOIN sys_role_menu ON sys_menu.id = sys_role_menu.menu_id
    LEFT JOIN sys_user_role ON sys_role_menu.role_id = sys_user_role.role_id
    LEFT JOIN sys_role ON sys_role.id = sys_user_role.role_id
    <if test="ew.emptyOfWhere == false">
      ${ew.customSqlSegment}
    </if>
  </select>
  <select id="queryList" resultType="com.sy.coinage.sys.vo.MenuListVO">
    select
    <include refid="Base_Column_List"/>
    from sys_menu
    <if test="ew.emptyOfWhere == false">
      ${ew.customSqlSegment}
    </if>
  </select>
  <select id="queryOptList" resultType="com.sy.coinage.core.vo.OptVO">
    select id, pid, name from sys_menu
    <if test="ew.emptyOfWhere == false">
      ${ew.customSqlSegment}
    </if>
  </select>
</mapper>

