<?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.tourism.webadmin.back.dao.TourHouseEquipmentMapper">
    <resultMap id="BaseResultMap" type="com.tourism.webadmin.back.model.TourHouseEquipment">
        <id column="id" jdbcType="BIGINT" property="id"/>
        <result column="house_id" jdbcType="BIGINT" property="houseId"/>
        <result column="house_detail_image" jdbcType="VARCHAR" property="houseDetailImage"/>
        <result column="icebox" jdbcType="TINYINT" property="icebox"/>
        <result column="washer" jdbcType="TINYINT" property="washer"/>
        <result column="calorifier" jdbcType="TINYINT" property="calorifier"/>
        <result column="broadband" jdbcType="TINYINT" property="broadband"/>
        <result column="sofa" jdbcType="TINYINT" property="sofa"/>
        <result column="range_hood" jdbcType="TINYINT" property="rangeHood"/>
        <result column="gas_stove" jdbcType="TINYINT" property="gasStove"/>
        <result column="able_cook" jdbcType="TINYINT" property="ableCook"/>
        <result column="television" jdbcType="TINYINT" property="television"/>
        <result column="air_conditioner" jdbcType="TINYINT" property="airConditioner"/>
        <result column="wardrobe" jdbcType="TINYINT" property="wardrobe"/>
        <result column="bed" jdbcType="TINYINT" property="bed"/>
        <result column="rest_room" jdbcType="TINYINT" property="restRoom"/>
        <result column="smart_door_lock" jdbcType="TINYINT" property="smartDoorLock"/>
        <result column="balcony" jdbcType="TINYINT" property="balcony"/>
        <result column="heating" jdbcType="TINYINT" property="heating"/>
        <result column="surrounding_support" jdbcType="VARCHAR" property="surroundingSupport"/>
        <result column="surrounding_support_image" jdbcType="VARCHAR" property="surroundingSupportImage"/>
        <result column="plot_introduction" jdbcType="VARCHAR" property="plotIntroduction"/>
        <result column="plot_introduction_image" jdbcType="VARCHAR" property="plotIntroductionImage"/>
        <result column="data_state" jdbcType="TINYINT" property="dataState"/>
        <result column="create_user_id" jdbcType="BIGINT" property="createUserId"/>
        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
        <result column="update_user_id" jdbcType="BIGINT" property="updateUserId"/>
        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
    </resultMap>

    <insert id="insertList">
        INSERT INTO tour_house_equipment
            (id,
            house_id,
            house_detail_image,
            icebox,
            washer,
            calorifier,
            broadband,
            sofa,
            range_hood,
            gas_stove,
            able_cook,
            television,
            air_conditioner,
            wardrobe,
            bed,
            rest_room,
            smart_door_lock,
            balcony,
            heating,
            surrounding_support,
            surrounding_support_image,
            plot_introduction,
            plot_introduction_image,
            data_state,
            create_user_id,
            create_time,
            update_user_id,
            update_time)
        VALUES
        <foreach collection="list" index="index" item="item" separator="," >
            (#{item.id},
            #{item.houseId},
            #{item.houseDetailImage},
            #{item.icebox},
            #{item.washer},
            #{item.calorifier},
            #{item.broadband},
            #{item.sofa},
            #{item.rangeHood},
            #{item.gasStove},
            #{item.ableCook},
            #{item.television},
            #{item.airConditioner},
            #{item.wardrobe},
            #{item.bed},
            #{item.restRoom},
            #{item.smartDoorLock},
            #{item.balcony},
            #{item.heating},
            #{item.surroundingSupport},
            #{item.surroundingSupportImage},
            #{item.plotIntroduction},
            #{item.plotIntroductionImage},
            #{item.dataState},
            #{item.createUserId},
            #{item.createTime},
            #{item.updateUserId},
            #{item.updateTime})
        </foreach>
    </insert>

    <!-- 如果有逻辑删除字段过滤，请写到这里 -->
    <sql id="filterRef">
        <!-- 这里必须加上全包名，否则当filterRef被其他Mapper.xml包含引用的时候，就会调用Mapper.xml中的该SQL片段 -->
        <include refid="com.tourism.webadmin.back.dao.TourHouseEquipmentMapper.inputFilterRef"/>
        AND tour_house_equipment.data_state = ${@com.tourism.common.core.constant.GlobalDeletedFlag@NORMAL}
    </sql>

    <!-- 这里仅包含调用接口输入的主表过滤条件 -->
    <sql id="inputFilterRef">
        <if test="tourHouseEquipmentFilter != null">
            <if test="tourHouseEquipmentFilter.houseId != null">
                AND tour_house_equipment.house_id = #{tourHouseEquipmentFilter.houseId}
            </if>
        </if>
    </sql>

    <select id="getTourHouseEquipmentList" resultMap="BaseResultMap" parameterType="com.tourism.webadmin.back.model.TourHouseEquipment">
        SELECT * FROM tour_house_equipment
        <where>
            <include refid="filterRef"/>
        </where>
        <if test="orderBy != null and orderBy != ''">
            ORDER BY ${orderBy}
        </if>
    </select>
</mapper>
