<?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.platform.mapper.TGuijiMedicinePlatformMapper">

    <resultMap type="TGuijiMedicinePlatform" id="TGuijiMedicinePlatformResult">
        <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="platformName"    column="platformName"    />
        <result property="constructingUnit"    column="constructingUnit"    />
        <result property="constructingDate"    column="constructingDate"    />
        <result property="platformAddress"    column="platformAddress"    />
        <result property="platformAddressExt"    column="platformAddressExt"    />
        <result property="platformLevel"    column="platformLevel"    />
        <result property="platformType"    column="platformType"    />
    </resultMap>

    <sql id="selectTGuijiMedicinePlatformVo">
        select id, create_time, cd_time, cd_batch, cd_operation, cd_source, platformName, constructingUnit, constructingDate, platformAddress, platformAddressExt, platformLevel, platformType from t_guiji_medicine_platform
    </sql>

    <select id="selectTGuijiMedicinePlatformList" parameterType="TGuijiMedicinePlatform" resultMap="TGuijiMedicinePlatformResult">
        <include refid="selectTGuijiMedicinePlatformVo"/>
        <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="platformName != null  and platformName != ''"> and platformName like concat('%', #{platformName}, '%')</if>
            <if test="constructingUnit != null  and constructingUnit != ''"> and constructingUnit like concat('%', #{constructingUnit}, '%')</if>
            <if test="constructingDate != null  and constructingDate != ''"> and constructingDate = #{constructingDate}</if>
            <if test="platformAddress != null  and platformAddress != ''"> and platformAddress = #{platformAddress}</if>
            <if test="platformAddressExt != null  and platformAddressExt != ''"> and platformAddressExt = #{platformAddressExt}</if>
            <if test="platformLevel != null  and platformLevel != ''"> and platformLevel = #{platformLevel}</if>
            <if test="platformType != null  and platformType != ''"> and platformType = #{platformType}</if>
        </where>
    </select>

    <select id="selectTGuijiMedicinePlatformById" parameterType="String" resultMap="TGuijiMedicinePlatformResult">
        <include refid="selectTGuijiMedicinePlatformVo"/>
        where id = #{id}
    </select>

    <insert id="insertTGuijiMedicinePlatform" parameterType="TGuijiMedicinePlatform">
        insert into t_guiji_medicine_platform
        <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="platformName != null">platformName,</if>
            <if test="constructingUnit != null">constructingUnit,</if>
            <if test="constructingDate != null">constructingDate,</if>
            <if test="platformAddress != null">platformAddress,</if>
            <if test="platformAddressExt != null">platformAddressExt,</if>
            <if test="platformLevel != null">platformLevel,</if>
            <if test="platformType != null">platformType,</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="platformName != null">#{platformName},</if>
            <if test="constructingUnit != null">#{constructingUnit},</if>
            <if test="constructingDate != null">#{constructingDate},</if>
            <if test="platformAddress != null">#{platformAddress},</if>
            <if test="platformAddressExt != null">#{platformAddressExt},</if>
            <if test="platformLevel != null">#{platformLevel},</if>
            <if test="platformType != null">#{platformType},</if>
         </trim>
    </insert>

    <update id="updateTGuijiMedicinePlatform" parameterType="TGuijiMedicinePlatform">
        update t_guiji_medicine_platform
        <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="platformName != null">platformName = #{platformName},</if>
            <if test="constructingUnit != null">constructingUnit = #{constructingUnit},</if>
            <if test="constructingDate != null">constructingDate = #{constructingDate},</if>
            <if test="platformAddress != null">platformAddress = #{platformAddress},</if>
            <if test="platformAddressExt != null">platformAddressExt = #{platformAddressExt},</if>
            <if test="platformLevel != null">platformLevel = #{platformLevel},</if>
            <if test="platformType != null">platformType = #{platformType},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTGuijiMedicinePlatformById" parameterType="String">
        delete from t_guiji_medicine_platform where id = #{id}
    </delete>

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

</mapper>
