<?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.xinelu.manage.mapper.patienttaskpushrecord.PatientTaskPushRecordMapper">

    <resultMap type="PatientTaskPushRecord" id="PatientTaskPushRecordResult">
        <result property="id" column="id"/>
        <result property="patientId" column="patient_id"/>
        <result property="manageRouteNodeId" column="manage_route_node_id"/>
        <result property="patientName" column="patient_name"/>
        <result property="routeNodeName" column="route_node_name"/>
        <result property="taskPushType" column="task_push_type"/>
        <result property="taskPushDate" column="task_push_date"/>
        <result property="taskPushRemark" column="task_push_remark"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
    </resultMap>

    <sql id="selectPatientTaskPushRecordVo">
        select id,
               patient_id,
               manage_route_node_id,
               patient_name,
               route_node_name,
               task_push_type,
               task_push_date,
               task_push_remark,
               create_by,
               create_time,
               update_by,
               update_time
        from patient_task_push_record
    </sql>

    <select id="selectPatientTaskPushRecordList" parameterType="PatientTaskPushRecord"
            resultMap="PatientTaskPushRecordResult">
        <include refid="selectPatientTaskPushRecordVo"/>
        <where>
            <if test="patientId != null ">
                and patient_id = #{patientId}
            </if>
            <if test="manageRouteNodeId != null ">
                and manage_route_node_id = #{manageRouteNodeId}
            </if>
            <if test="patientName != null  and patientName != ''">
                and patient_name like concat('%', #{patientName}, '%')
            </if>
            <if test="routeNodeName != null  and routeNodeName != ''">
                and route_node_name like concat('%', #{routeNodeName}, '%')
            </if>
            <if test="taskPushType != null  and taskPushType != ''">
                and task_push_type = #{taskPushType}
            </if>
            <if test="taskPushDate != null ">
                and task_push_date = #{taskPushDate}
            </if>
            <if test="taskPushRemark != null  and taskPushRemark != ''">
                and task_push_remark = #{taskPushRemark}
            </if>
        </where>
    </select>

    <select id="selectPatientTaskPushRecordById" parameterType="Long"
            resultMap="PatientTaskPushRecordResult">
        <include refid="selectPatientTaskPushRecordVo"/>
        where id = #{id}
    </select>

    <insert id="insertPatientTaskPushRecord" parameterType="PatientTaskPushRecord" useGeneratedKeys="true"
            keyProperty="id">
        insert into patient_task_push_record
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="patientId != null">patient_id,
            </if>
            <if test="manageRouteNodeId != null">manage_route_node_id,
            </if>
            <if test="patientName != null">patient_name,
            </if>
            <if test="routeNodeName != null">route_node_name,
            </if>
            <if test="taskPushType != null">task_push_type,
            </if>
            <if test="taskPushDate != null">task_push_date,
            </if>
            <if test="taskPushRemark != null">task_push_remark,
            </if>
            <if test="createBy != null">create_by,
            </if>
            <if test="createTime != null">create_time,
            </if>
            <if test="updateBy != null">update_by,
            </if>
            <if test="updateTime != null">update_time,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="patientId != null">#{patientId},
            </if>
            <if test="manageRouteNodeId != null">#{manageRouteNodeId},
            </if>
            <if test="patientName != null">#{patientName},
            </if>
            <if test="routeNodeName != null">#{routeNodeName},
            </if>
            <if test="taskPushType != null">#{taskPushType},
            </if>
            <if test="taskPushDate != null">#{taskPushDate},
            </if>
            <if test="taskPushRemark != null">#{taskPushRemark},
            </if>
            <if test="createBy != null">#{createBy},
            </if>
            <if test="createTime != null">#{createTime},
            </if>
            <if test="updateBy != null">#{updateBy},
            </if>
            <if test="updateTime != null">#{updateTime},
            </if>
        </trim>
    </insert>

    <update id="updatePatientTaskPushRecord" parameterType="PatientTaskPushRecord">
        update patient_task_push_record
        <trim prefix="SET" suffixOverrides=",">
            <if test="patientId != null">patient_id =
                #{patientId},
            </if>
            <if test="manageRouteNodeId != null">manage_route_node_id =
                #{manageRouteNodeId},
            </if>
            <if test="patientName != null">patient_name =
                #{patientName},
            </if>
            <if test="routeNodeName != null">route_node_name =
                #{routeNodeName},
            </if>
            <if test="taskPushType != null">task_push_type =
                #{taskPushType},
            </if>
            <if test="taskPushDate != null">task_push_date =
                #{taskPushDate},
            </if>
            <if test="taskPushRemark != null">task_push_remark =
                #{taskPushRemark},
            </if>
            <if test="createBy != null">create_by =
                #{createBy},
            </if>
            <if test="createTime != null">create_time =
                #{createTime},
            </if>
            <if test="updateBy != null">update_by =
                #{updateBy},
            </if>
            <if test="updateTime != null">update_time =
                #{updateTime},
            </if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deletePatientTaskPushRecordById" parameterType="Long">
        delete
        from patient_task_push_record
        where id = #{id}
    </delete>

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