<?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.app.admin.framework.system.permission.authorization.dao.SysRoleModuleDao">
  <resultMap id="SysModuleResultMap" type="com.app.admin.framework.system.module.model.SysModule">
    <id column="oid" jdbcType="BIGINT" property="oid" />
    <result column="iconCls" jdbcType="VARCHAR" property="iconcls" />
    <result column="mark" jdbcType="VARCHAR" property="mark" />
    <result column="morder" jdbcType="INTEGER" property="morder" />
    <result column="mtype" jdbcType="INTEGER" property="mtype" />
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result column="params" jdbcType="VARCHAR" property="params" />
    <result column="PARENT_ID" jdbcType="BIGINT" property="parentId" />
    <result column="remark" jdbcType="VARCHAR" property="remark" />
    <result column="visiturl" jdbcType="VARCHAR" property="visiturl" />
    <result column="state" jdbcType="INTEGER" property="state" />
    <result column="english_name" jdbcType="VARCHAR" property="englishName" />
  </resultMap>

  <select id="selectByRoleIds" resultMap="SysModuleResultMap" parameterType="map">
    select distinct m.* from sys_permission_role_module r left join sys_module m on m.OID=r.module_id
    where r.role_id in
    <foreach item="item" index="index" collection="roleIds" open="(" separator="," close=")">
      #{item}
    </foreach>
    <if test="mtype != null" >
      and m.mtype = #{mtype,jdbcType=INTEGER}
    </if>
    order by m.morder asc
  </select>

</mapper>