<?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.izouma.awesomeadmin.dao.HouseImageMapper">
    <resultMap id="BaseResultMap" type="com.izouma.awesomeadmin.model.HouseImage">
        <id column="id" property="id" jdbcType="INTEGER"/>
        <result column="del_flag" property="delFlag" jdbcType="CHAR"/>
        <result column="house_id" property="houseId" jdbcType="INTEGER"/>
        <result column="image_type" property="imageType" jdbcType="INTEGER"/>
        <result column="image_name" property="imageName" jdbcType="VARCHAR"/>
        <result column="image_url" property="imageUrl" jdbcType="VARCHAR"/>
        <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
        <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
    </resultMap>
    <sql id="Base_Column_List">
            id,            del_flag,            house_id,            image_type,
             image_name,            image_url,            create_time,            update_time
    </sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
        select
        <include refid="Base_Column_List"/>
        from house_image
        where id = #{id,jdbcType=INTEGER}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
        delete from house_image
        where id = #{id,jdbcType=INTEGER}
    </delete>
    <insert id="insertSelective" parameterType="com.izouma.awesomeadmin.model.HouseImage" useGeneratedKeys="true"
            keyProperty="id">
        insert into house_image
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id!= null">
                id,
            </if>
            <if test="delFlag!= null">
                del_flag,
            </if>
            <if test="houseId!= null">
                house_id,
            </if>
            <if test="imageType!= null">
                image_type,
            </if>
            <if test="imageName!= null">
                image_name,
            </if>
            <if test="imageUrl!= null">
                image_url,
            </if>
            <if test="createTime!= null">
                create_time,
            </if>
            <if test="updateTime!= null">
                update_time,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=INTEGER},
            </if>
            <if test="delFlag != null">
                #{delFlag,jdbcType=CHAR},
            </if>
            <if test="houseId != null">
                #{houseId,jdbcType=INTEGER},
            </if>
            <if test="imageType != null">
                #{imageType,jdbcType=INTEGER},
            </if>
            <if test="imageName != null">
                #{imageName,jdbcType=VARCHAR},
            </if>
            <if test="imageUrl != null">
                #{imageUrl,jdbcType=VARCHAR},
            </if>
            <if test="createTime != null">
                #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateTime != null">
                #{updateTime,jdbcType=TIMESTAMP},
            </if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.izouma.awesomeadmin.model.HouseImage">
        update house_image
        <set>
            <if test="id != null">
                id= #{id,jdbcType=INTEGER},
            </if>
            <if test="delFlag != null">
                del_flag= #{delFlag,jdbcType=CHAR},
            </if>
            <if test="houseId != null">
                house_id= #{houseId,jdbcType=INTEGER},
            </if>
            <if test="imageType != null">
                image_type= #{imageType,jdbcType=INTEGER},
            </if>
            <if test="imageName != null">
                image_name= #{imageName,jdbcType=VARCHAR},
            </if>
            <if test="imageUrl != null">
                image_url= #{imageUrl,jdbcType=VARCHAR},
            </if>
            <if test="createTime != null">
                create_time= #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateTime != null">
                update_time= #{updateTime,jdbcType=TIMESTAMP},
            </if>
        </set>
        where id = #{id,jdbcType=INTEGER}
    </update>
    <select id="queryHouseImageByPage" parameterType="java.util.Map"
            resultType="com.izouma.awesomeadmin.model.HouseImage">
        select
        <include refid="Base_Column_List"/>
        from house_image
        <where>
            and del_flag = 'N'
            <if test="record.id != null and !&quot;&quot;.equals(record.id)">
                and id = #{record.id}
            </if>
            <if test="record.delFlag != null and !&quot;&quot;.equals(record.delFlag)">
                and del_flag = #{record.delFlag}
            </if>
            <if test="record.houseId != null and !&quot;&quot;.equals(record.houseId)">
                and house_id = #{record.houseId}
            </if>
            <if test="record.imageType != null and !&quot;&quot;.equals(record.imageType)">
                and image_type = #{record.imageType}
            </if>
            <if test="record.imageName != null and !&quot;&quot;.equals(record.imageName)">
                and image_name = #{record.imageName}
            </if>
            <if test="record.imageUrl != null and !&quot;&quot;.equals(record.imageUrl)">
                and image_url = #{record.imageUrl}
            </if>
            <if test="record.createTime != null and !&quot;&quot;.equals(record.createTime)">
                and create_time = #{record.createTime}
            </if>
            <if test="record.updateTime != null and !&quot;&quot;.equals(record.updateTime)">
                and update_time = #{record.updateTime}
            </if>

            <if test="record.searchKey != null and !&quot;&quot;.equals(record.searchKey)">
                <trim prefix="and (" suffix=")" prefixOverrides="OR">
                    OR house_id LIKE concat('%',#{record.searchKey},'%')
                    OR image_name LIKE concat('%',#{record.searchKey},'%')
                </trim>
            </if>

        </where>
        order by house_id, image_type desc ,id desc
    </select>
    <select id="queryAllHouseImage" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.HouseImage">
        select
        <include refid="Base_Column_List"/>
        from house_image
        <where>
            and del_flag = 'N'
            <if test="id != null and !&quot;&quot;.equals(id)">
                and id = #{id}
            </if>
            <if test="delFlag != null and !&quot;&quot;.equals(delFlag)">
                and del_flag = #{delFlag}
            </if>
            <if test="houseId != null and !&quot;&quot;.equals(houseId)">
                and house_id = #{houseId}
            </if>
            <if test="imageType != null and !&quot;&quot;.equals(imageType)">
                and image_type = #{imageType}
            </if>
            <if test="imageName != null and !&quot;&quot;.equals(imageName)">
                and image_name = #{imageName}
            </if>
            <if test="imageUrl != null and !&quot;&quot;.equals(imageUrl)">
                and image_url = #{imageUrl}
            </if>
            <if test="createTime != null and !&quot;&quot;.equals(createTime)">
                and create_time = #{createTime}
            </if>
            <if test="updateTime != null and !&quot;&quot;.equals(updateTime)">
                and update_time = #{updateTime}
            </if>
        </where>
        order by house_id, image_type desc ,id desc
    </select>
    <select id="queryHouseImage" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.HouseImage">
        select
        <include refid="Base_Column_List"/>
        from house_image
        <where>
            and del_flag = 'N'
            <if test="id != null and !&quot;&quot;.equals(id)">
                and id = #{id}
            </if>
            <if test="delFlag != null and !&quot;&quot;.equals(delFlag)">
                and del_flag = #{delFlag}
            </if>
            <if test="houseId != null and !&quot;&quot;.equals(houseId)">
                and house_id = #{houseId}
            </if>
            <if test="imageType != null and !&quot;&quot;.equals(imageType)">
                and image_type = #{imageType}
            </if>
            <if test="imageName != null and !&quot;&quot;.equals(imageName)">
                and image_name = #{imageName}
            </if>
            <if test="imageUrl != null and !&quot;&quot;.equals(imageUrl)">
                and image_url = #{imageUrl}
            </if>
            <if test="createTime != null and !&quot;&quot;.equals(createTime)">
                and create_time = #{createTime}
            </if>
            <if test="updateTime != null and !&quot;&quot;.equals(updateTime)">
                and update_time = #{updateTime}
            </if>

        </where>
        LIMIT 1
    </select>
    <update id="delete">
        UPDATE house_image SET del_flag = 'Y'
        <where>
            AND id = #{id}
        </where>
    </update>
    <select id="query" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.HouseImage">
        select
        <include refid="Base_Column_List"/>
        from house_image
        <where>
            and del_flag = 'N'
        </where>
        order by id desc
    </select>
</mapper>

