<?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.basicArchives.CpmBuildingDao">
    <select id="list" parameterType="com.api.model.basicArchives.CpmBuilding" resultType="com.api.model.basicArchives.CpmBuilding">
        select id,no,name,code from cpm_building
        <where>
            <if test="no != null">
                and no like concat('%',#{no},'%')
            </if>
            <if test="name != null and name != ''">
                and name like concat('%',#{name},'%')
            </if>
            <if test="code != null and code != ''">
                and code like concat('%',#{code},'%')
            </if>
        </where>
        order by create_date desc
    </select>

    <insert id="insert" parameterType="com.api.model.basicArchives.CpmBuilding">
        insert into
        <trim prefix="cpm_building(" suffix=")" suffixOverrides=",">
            no,
            name,
            code,
            <if test="coordinate != null and coordinate != ''">
                coordinate,
            </if>
            <if test="totalFloor != null">
                total_floor,
            </if>
            create_id,
            create_date,
            <if test="modifyId != null">
                modify_id,
            </if>
            <if test="modifyDate != null">
                modify_date,
            </if>
        </trim>
         values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            #{no},
            #{name},
            #{code},
            <if test="coordinate != null and coordinate != ''">
                #{coordinate},
            </if>
            <if test="totalFloor != null">
                #{totalFloor},
            </if>
            #{createId},
            #{createDate},
            <if test="modifyId != null">
                #{modifyId},
            </if>
            <if test="modifyDate != null">
                #{modifyDate},
            </if>
        </trim>
    </insert>

    <select id="findById" parameterType="java.lang.Integer" resultType="com.api.model.basicArchives.CpmBuilding">
        select id,no,name,code
        from cpm_building
        where id = #{id}
    </select>

    <update id="update" parameterType="com.api.model.basicArchives.CpmBuilding">
        update cpm_building
        <set>
            <if test="name != null and name != ''">
                name = #{name},
            </if>
            <if test="no != null">
                no = #{no},
            </if>
            <if test="modifyId != null">
                modify_id = #{modifyId},
            </if>
            <if test="modifyDate != null">
                modify_date = #{modifyDate},
            </if>
        </set>
        where id = #{id}
    </update>

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

    <select id="findAll" resultType="com.api.vo.basicArchives.VoFindAll">
        select id as `value`,name as label from cpm_building
    </select>

    <select id="findByNo" parameterType="java.lang.Integer" resultType="com.api.model.basicArchives.CpmBuilding">
        select id,no,name,code
        from cpm_building
        where no = #{no}
    </select>

    <select id="findByName" parameterType="java.lang.String" resultType="com.api.model.basicArchives.CpmBuilding">
        select id,no,name,code
        from cpm_building
        where name = #{name}
    </select>
</mapper>