<?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="pharmacistsMapper">

    <select id="selectPharmacists" parameterType="pd" resultType="pd">
        select * from s_dtp_review_pharmacists where 1=1
        <if test="pharmacistName != null and pharmacistName != ''">
            and pharmacistName like concat('%', #{pharmacistName}, '%')
        </if>
        <if test="id != null">
            and id = #{id}
        </if>
    </select>
    <select id="selectOneById" parameterType="pd" resultType="pd">
        select * from s_dtp_review_pharmacists   where 1=1 and id=#{id}
    </select>
    <update id="updatePharmacists" parameterType="pd">
        update s_dtp_review_pharmacists
        <trim prefix="SET " suffix="" prefixOverrides="," suffixOverrides=",">
            <if test="pharmacistName != null and pharmacistName != ''">
                pharmacistName = #{pharmacistName},
            </if>
            <if test="createBy != null and createBy != ''">
                createBy = #{createBy},
            </if>
            <if test="createTime != null">
                createTime = #{createTime},
            </if>
            <if test="updateBy != null and updateBy != ''">
                updateBy = #{updateBy},
            </if>
            <if test="updateTime != null">
                updateTime = #{updateTime},
            </if>
            <if test="position != null and position !=''">
                position = #{position},
            </if>
            <if test="default_follow_up != null and default_follow_up !=''">
                default_follow_up =  #{default_follow_up},
            </if>
            <if test="storeName != null and storeName != ''">
                storeName = #{storeName},
            </if>
            <if test="reviewPassword != null and reviewPassword != ''">
                reviewPassword = #{reviewPassword},
            </if>
            <if test="phone != null and phone != ''">
                phone = #{phone},
            </if>
            <if test="status != null and status != ''">
                status =  #{status},
            </if>
        </trim>
        <if test="id != null">
            where id = #{id}
        </if>
    </update>
    <delete id="deletePharmacists" parameterType="java.util.List">
        <if test="list != null and list.size() > 0">
            delete from s_dtp_review_pharmacists
            where id in
            <foreach item="id" index="index" collection="list" open="(" separator="," close=")">
                #{id}
            </foreach>
        </if>
    </delete>


    <insert id="insertPharmacists" parameterType="pd">
        insert into s_dtp_review_pharmacists
        <trim prefix="(" suffix=")" prefixOverrides="," suffixOverrides=",">
            <if test="pharmacistName != null and pharmacistName != ''">
                pharmacistName,
            </if>
            <if test="createBy != null and createBy != ''">
                createBy,
            </if>
            <if test="createTime != null">
                createTime,
            </if>
            <if test="updateBy != null and updateBy != ''">
                updateBy,
            </if>
            <if test="updateTime != null">
                updateTime,
            </if>
            <if test="position != null and position !=''">
                position,
            </if>
            <if test="default_follow_up != null and default_follow_up !=''">
                default_follow_up,
            </if>
            <if test="storeName != null and storeName != ''">
                storeName,
            </if>
            <if test="reviewPassword != null and reviewPassword != ''">
                reviewPassword,
            </if>
            <if test="phone != null and phone != ''">
                phone,
            </if>
            <if test="status != null">
                status,
            </if>
            <if test="storeId != null">
                storeId
            </if>
        </trim>
        <trim prefix="VALUES (" suffix=")" prefixOverrides="," suffixOverrides=",">

            <if test="pharmacistName != null and pharmacistName != ''">
                #{pharmacistName},
            </if>
            <if test="createBy != null and createBy != ''">
                #{createBy},
            </if>
            <if test="createTime != null">
                #{createTime},
            </if>
            <if test="updateBy != null and updateBy != ''">
                #{updateBy},
            </if>
            <if test="updateTime != null">
                #{updateTime},
            </if>
            <if test="position != null and position !=''">
                #{position},
            </if>
            <if test="default_follow_up != null and default_follow_up !=''">
                #{default_follow_up},
            </if>
            <if test="storeName != null and storeName != ''">
                #{storeName},
            </if>
            <if test="reviewPassword != null and reviewPassword != ''">
                #{reviewPassword},
            </if>
            <if test="phone != null and phone != ''">
                #{phone},
            </if>
            <if test="status != null and status != ''">
                #{status},
            </if>
            <if test="storeId != null">
                #{storeId},
            </if>
        </trim>
    </insert>


    <!-- 更新默认的任务跟进人 -->
    <update id="updateDefaultFollowUpByStoreId" parameterType="pd">
        update s_dtp_review_pharmacists
        <trim prefix="SET " suffix="" prefixOverrides="," suffixOverrides=",">
            <if test="updateBy != null and updateBy != ''">
                updateBy = #{updateBy},
            </if>
            <if test="updateTime != null">
                updateTime = #{updateTime},
            </if>
            <if test="default_follow_up != null">
                default_follow_up =  #{default_follow_up},
            </if>
        </trim>
        where
        <if test="position != null and position !=''">
             position = #{position}
        </if>
        <if test="storeId != nul">
            and storeId = #{storeId}
        </if>

    </update>
</mapper>
