<?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.api.manage.dao.operationManagement.SysHouseTypeDescriptionDao">

    <select id="list" parameterType="com.api.model.operationManagement.SearchHouseTypeDescription" resultType="com.api.vo.operationManagement.SysHouseTypeDescriptionListVo">
        select shtd.*,su.actual_name as create_name
        from sys_house_type_description as shtd
        LEFT JOIN sys_user as su on shtd.create_id = su.id
        <where>
            <if test="name != null and name != ''">
                and shtd.name like concat('%',#{name},'%')
            </if>
            <if test="status != null">
                and shtd.status = #{status}
            </if>
            <if test="createName != null and createName != ''">
                and su.actual_name like concat('%',#{createName},'%')
            </if>
            <if test="releaseDateStart != null">
                and shtd.release_date <![CDATA[ >= ]]> #{releaseDateStart}
            </if>
            <if test="releaseDateEnd != null">
                and shtd.release_date <![CDATA[ <= ]]> #{releaseDateEnd}
            </if>
        </where>
    </select>
    <select id="findById" parameterType="java.lang.Integer" resultType="com.api.vo.operationManagement.SysHouseTypeDescriptionFBIVo">
        select * from sys_house_type_description where id = #{id}
    </select>

    <insert id="insert" parameterType="com.api.model.operationManagement.SysHouseTypeDescription">
        insert into sys_house_type_description(
            name,
            content,
            status,
            <if test="releaseDate != null">
               release_date,
            </if>
            create_id,
            create_date
        ) value (
            #{name},
            #{content},
            #{status},
            <if test="releaseDate != null">
                #{releaseDate},
            </if>
            #{createId},
            #{createDate}
        )
        <selectKey keyProperty="id" resultType="java.lang.Integer">
            select LAST_INSERT_ID() AS id
        </selectKey>
    </insert>

    <update id="update" parameterType="com.api.model.operationManagement.SysHouseTypeDescription">
        update sys_house_type_description
        <set>
            <if test="name != null and name != ''">
                name = #{name},
            </if>
            <if test="content != null and content != ''">
                content = #{content},
            </if>
            <if test="status != null">
                status = #{status},
            </if>
            <if test="releaseDate != null">
                release_date = #{releaseDate},
            </if>
            modify_id = #{modifyId},
            modify_date = #{modifyDate}
        </set>
        where id = #{id}
    </update>

    <delete id="delete" parameterType="java.lang.Integer">
        delete from sys_house_type_description where id = #{id}
    </delete>

    <update id="release" parameterType="com.api.model.operationManagement.SysHouseTypeDescription">
        update sys_house_type_description
        set status  = #{status},release_date = #{releaseDate}
        where id = #{id}
    </update>

    <update id="cancelRelease">
        update sys_house_type_description
        set status  = #{status}
        where id = #{id}
    </update>


</mapper>