<?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="org.dromara.system.mapper.SysImgMapper">

    <resultMap type="org.dromara.system.domain.vo.SysImgVo" id="SysImgResult">
    </resultMap>

    <delete id="batchDelete" parameterType="list">
        DELETE FROM sys_img WHERE oss_id IN
        <foreach item="item" collection="list" open="(" separator="," close=")">
            #{item}
        </foreach>
    </delete>
    <select id="selectEnum" resultType="org.dromara.system.domain.bo.SysImgBo">
        SELECT
            oss_id,
            img_type,
            url,
            file_name,
            enum_c,
            create_dept,
            create_by,
            create_time,
            update_by,
            update_time
        FROM
            sys_img
        WHERE
            img_type = '0' and enum_c = '0'
        order by update_time desc;
    </select>

    <select id="selectImg" resultType="org.dromara.system.domain.vo.SysImgVo">
        SELECT
            oss_id,
            img_type,
            url,
            file_name,
            enum_c,
            create_dept,
            create_by,
            create_time,
            update_by,
            update_time
        FROM
            sys_img
        WHERE
            img_type = '0'
    </select>

    <select id="selectByRoomId" resultType="org.dromara.system.domain.vo.SysImgVo">
        select * from sys_img si
        where si.oss_id in(
            select it.img_id from img_type it
            where it.type_id in(
                select rg.region_id from region rg where region_id in(
                    select rr.region_id FROM room r
                    LEFT JOIN room_region rr on r.room_id = rr.room_id
                    where r.room_id = #{roomId}
                ) and rg.region_id = #{regionId}
            )
        );
    </select>

    <select id="selectByList" parameterType="list" resultMap="SysImgResult">
        select * FROM sys_img WHERE oss_id IN
        <foreach item="item" collection="list" open="(" separator="," close=")">
            #{item}
        </foreach>
    </select>

</mapper>
