<?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.yccrc.kede.mapper.ProjectLogMapper">
    
    <resultMap type="ProjectLog" id="ProjectLogResult">
        <result property="id"    column="id"    />
        <result property="projectId"    column="project_id"    />
        <result property="content"    column="content"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectProjectLogVo">
        select id, project_id, content, create_by, create_time from project_log
    </sql>

    <select id="selectProjectLogList" parameterType="ProjectLog" resultMap="ProjectLogResult">
        <include refid="selectProjectLogVo"/>
        <where>  
            <if test="projectId != null "> and project_id = #{projectId}</if>
            <if test="content != null  and content != ''"> and content = #{content}</if>
        </where>
    </select>
    
    <select id="selectProjectLogById" parameterType="Integer" resultMap="ProjectLogResult">
        <include refid="selectProjectLogVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertProjectLog" parameterType="ProjectLog" useGeneratedKeys="true" keyProperty="id">
        insert into project_log
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="projectId != null">project_id,</if>
            <if test="content != null">content,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="projectId != null">#{projectId},</if>
            <if test="content != null">#{content},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateProjectLog" parameterType="ProjectLog">
        update project_log
        <trim prefix="SET" suffixOverrides=",">
            <if test="projectId != null">project_id = #{projectId},</if>
            <if test="content != null">content = #{content},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteProjectLogById" parameterType="Integer">
        delete from project_log where id = #{id}
    </delete>

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