<?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.fastbee.xunjian.mapper.XjInspectionNoteMapper">

    <resultMap type="com.fastbee.xunjian.domain.XjInspectionNote" id="XjInspectionNoteResult">
        <result property="id" column="id"/>
        <result property="title" column="title"/>
        <result property="content" column="content"/>
        <result property="projectId" column="project_id"/>
        <result property="engineeringObjectType" column="engineering_object_type"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateTime" column="update_time"/>
        <result property="updateBy" column="update_by"/>
    </resultMap>

    <sql id="selectXjInspectionNoteVo">
        select *
        from xj_inspection_note
    </sql>

    <select id="selectXjInspectionNoteList" parameterType="com.fastbee.xunjian.domain.XjInspectionNote"
            resultMap="XjInspectionNoteResult">
        <include refid="selectXjInspectionNoteVo"/>
        <where>
            <if test="title != null  and title != ''">and title = #{title}</if>
            <if test="content != null  and content != ''">and content = #{content}</if>
            <if test="projectId != null ">and project_id = #{projectId}</if>
            <if test="engineeringObjectType != null  and engineeringObjectType != ''">and engineering_object_type =
                #{engineeringObjectType}
            </if>
            <if test="params != null and params.ids!= null and params.ids!= ''">
                AND id in
                <foreach item="id" collection="params.ids.split(',')" open="(" separator="," close=")">
                    #{id}
                </foreach>
            </if>
        </where>
        order by id desc
    </select>

    <select id="selectXjInspectionNoteById" parameterType="Long" resultMap="XjInspectionNoteResult">
        <include refid="selectXjInspectionNoteVo"/>
        where id = #{id}
    </select>

    <insert id="insertXjInspectionNote" parameterType="com.fastbee.xunjian.domain.XjInspectionNote"
            useGeneratedKeys="true" keyProperty="id">
        insert into xj_inspection_note
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="title != null">title,</if>
            <if test="content != null">content,</if>
            <if test="projectId != null">project_id,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="engineeringObjectType != null">engineering_object_type,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="title != null">#{title},</if>
            <if test="content != null">#{content},</if>
            <if test="projectId != null">#{projectId},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="engineeringObjectType != null">#{engineeringObjectType},</if>
        </trim>
    </insert>

    <update id="updateXjInspectionNote" parameterType="com.fastbee.xunjian.domain.XjInspectionNote">
        update xj_inspection_note
        <trim prefix="SET" suffixOverrides=",">
            <if test="title != null">title = #{title},</if>
            <if test="content != null">content = #{content},</if>
            <if test="projectId != null">project_id = #{projectId},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="engineeringObjectType != null">engineering_object_type = #{engineeringObjectType},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteXjInspectionNoteById" parameterType="Long">
        delete
        from xj_inspection_note
        where id = #{id}
    </delete>

    <delete id="deleteXjInspectionNoteByIds" parameterType="String">
        delete from xj_inspection_note where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>
