<?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.rongwei.bscommon.sys.dao.EquMaintenanceOrderDao">
    
    <select id="selectRoleList" resultType="java.lang.String">
        SELECT su.ID
          FROM sys_role sr
           LEFT JOIN sys_user_role sur ON sr.ID = sur.ROLEID and sur.DELETED = 0
           LEFT JOIN sys_user su ON sur.USERID = su.ID and su.DELETED = 0
           LEFT JOIN sys_user_org suo ON suo.USERID = su.ID AND suo.DELETED = 0
           LEFT JOIN sys_organization so ON suo.ORGID = so.ID AND so.DELETED = 0
        <where>
            su.DELETED ='0'

            <if test="roleCodes != null and roleCodes.size()>0">
                AND sr.code in
                <foreach collection="roleCodes" item="roleCode" open="(" close=")" separator=",">
                    #{roleCode}
                </foreach>
            </if>

        </where>
        
    </select>
</mapper>
