<?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.lantone.security.mapper.SoftwareMapper">
    <select id="getUserSoftware" resultType="com.lantone.security.dto.SoftwareDTO">
        SELECT DISTINCT
            s.id,
            s.`name`
        FROM
            sys_role r
        JOIN sys_role_software_menu rsm ON r.id = rsm.role_id
        JOIN sys_software_menu sm ON rsm.software_menu_id = sm.id
        JOIN sys_software s ON s.id = sm.software_id
        WHERE
            r.is_deleted = 'N'
        AND rsm.is_deleted = 'N'
        AND sm.is_deleted = 'N'
        AND s.is_deleted = 'N'
        AND r.`status` = '1'
        <if test="roles !=null and roles.size!=0">
            AND r.id IN
            <foreach collection="roles" item="id" open="(" close=")" separator=",">
                #{id}
            </foreach>
        </if>
    </select>
</mapper>