<?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.sooka.system.medicine.project.mapper.TGuijiMedicineProjectMapper">

    <resultMap type="TGuijiMedicineProject" id="TGuijiMedicineProjectResult">
        <result property="id"    column="id"    />
        <result property="createTime"    column="create_time"    />
        <result property="cdTime"    column="cd_time"    />
        <result property="cdBatch"    column="cd_batch"    />
        <result property="cdOperation"    column="cd_operation"    />
        <result property="cdSource"    column="cd_source"    />
        <result property="projectName"    column="projectName"    />
        <result property="projectOrgName"    column="projectOrgName"    />
        <result property="projectAddress"    column="projectAddress"    />
        <result property="projectStatus"    column="projectStatus"    />
        <result property="projectTotalInvestment"    column="projectTotalInvestment"    />
        <result property="projectStart"    column="projectStart"    />
        <result property="projectEnd"    column="projectEnd"    />
    </resultMap>

    <sql id="selectTGuijiMedicineProjectVo">
        select id, create_time, cd_time, cd_batch, cd_operation, cd_source, projectName, projectOrgName, projectAddress, projectStatus, projectTotalInvestment, projectStart, projectEnd from t_guiji_medicine_project
    </sql>

    <select id="selectTGuijiMedicineProjectList" parameterType="TGuijiMedicineProject" resultMap="TGuijiMedicineProjectResult">
        <include refid="selectTGuijiMedicineProjectVo"/>
        <where>
            <if test="cdTime != null  and cdTime != ''"> and cd_time = #{cdTime}</if>
            <if test="cdBatch != null  and cdBatch != ''"> and cd_batch = #{cdBatch}</if>
            <if test="cdOperation != null  and cdOperation != ''"> and cd_operation = #{cdOperation}</if>
            <if test="cdSource != null  and cdSource != ''"> and cd_source = #{cdSource}</if>
            <if test="projectName != null  and projectName != ''"> and projectName like concat('%', #{projectName}, '%')</if>
            <if test="projectOrgName != null  and projectOrgName != ''"> and projectOrgName like concat('%', #{projectOrgName}, '%')</if>
            <if test="projectAddress != null  and projectAddress != ''"> and projectAddress = #{projectAddress}</if>
            <if test="projectStatus != null  and projectStatus != ''"> and projectStatus = #{projectStatus}</if>
            <if test="projectTotalInvestment != null  and projectTotalInvestment != ''"> and projectTotalInvestment = #{projectTotalInvestment}</if>
            <if test="projectStart != null  and projectStart != ''"> and projectStart = #{projectStart}</if>
            <if test="projectEnd != null  and projectEnd != ''"> and projectEnd = #{projectEnd}</if>
        </where>
    </select>

    <select id="selectTGuijiMedicineProjectById" parameterType="String" resultMap="TGuijiMedicineProjectResult">
        <include refid="selectTGuijiMedicineProjectVo"/>
        where id = #{id}
    </select>

    <insert id="insertTGuijiMedicineProject" parameterType="TGuijiMedicineProject">
        insert into t_guiji_medicine_project
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="createTime != null">create_time,</if>
            <if test="cdTime != null">cd_time,</if>
            <if test="cdBatch != null">cd_batch,</if>
            <if test="cdOperation != null">cd_operation,</if>
            <if test="cdSource != null">cd_source,</if>
            <if test="projectName != null">projectName,</if>
            <if test="projectOrgName != null">projectOrgName,</if>
            <if test="projectAddress != null">projectAddress,</if>
            <if test="projectStatus != null">projectStatus,</if>
            <if test="projectTotalInvestment != null">projectTotalInvestment,</if>
            <if test="projectStart != null">projectStart,</if>
            <if test="projectEnd != null">projectEnd,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="cdTime != null">#{cdTime},</if>
            <if test="cdBatch != null">#{cdBatch},</if>
            <if test="cdOperation != null">#{cdOperation},</if>
            <if test="cdSource != null">#{cdSource},</if>
            <if test="projectName != null">#{projectName},</if>
            <if test="projectOrgName != null">#{projectOrgName},</if>
            <if test="projectAddress != null">#{projectAddress},</if>
            <if test="projectStatus != null">#{projectStatus},</if>
            <if test="projectTotalInvestment != null">#{projectTotalInvestment},</if>
            <if test="projectStart != null">#{projectStart},</if>
            <if test="projectEnd != null">#{projectEnd},</if>
         </trim>
    </insert>

    <update id="updateTGuijiMedicineProject" parameterType="TGuijiMedicineProject">
        update t_guiji_medicine_project
        <trim prefix="SET" suffixOverrides=",">
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="cdTime != null">cd_time = #{cdTime},</if>
            <if test="cdBatch != null">cd_batch = #{cdBatch},</if>
            <if test="cdOperation != null">cd_operation = #{cdOperation},</if>
            <if test="cdSource != null">cd_source = #{cdSource},</if>
            <if test="projectName != null">projectName = #{projectName},</if>
            <if test="projectOrgName != null">projectOrgName = #{projectOrgName},</if>
            <if test="projectAddress != null">projectAddress = #{projectAddress},</if>
            <if test="projectStatus != null">projectStatus = #{projectStatus},</if>
            <if test="projectTotalInvestment != null">projectTotalInvestment = #{projectTotalInvestment},</if>
            <if test="projectStart != null">projectStart = #{projectStart},</if>
            <if test="projectEnd != null">projectEnd = #{projectEnd},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTGuijiMedicineProjectById" parameterType="String">
        delete from t_guiji_medicine_project where id = #{id}
    </delete>

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

</mapper>
