<?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.fs.qw.mapper.QwExternalContactInfoMapper">

    <resultMap type="QwExternalContactInfo" id="QwExternalContactInfoResult">
        <result property="id"    column="id"    />
        <result property="externalContactId"    column="external_contact_id"    />
        <result property="name"    column="name"    />
        <result property="sex"    column="sex"    />
        <result property="age"    column="age"    />
        <result property="address"    column="address"    />
        <result property="habits"    column="habits"    />
        <result property="illnessTime"    column="illness_time"    />
        <result property="body"    column="body"    />
        <result property="study"    column="study"    />
        <result property="courseStatus"    column="course_status"    />
        <result property="family"    column="family"    />
        <result property="familyDisease"    column="family_disease"    />
        <result property="talk"    column="talk"    />
        <result property="userType"    column="user_type"    />
        <result property="isSelf"    column="is_self"    />
        <result property="intensify"    column="intensify"    />
        <result property="isCold"    column="is_cold"    />
        <result property="coldBody"    column="cold_body"    />
        <result property="sweat"    column="sweat"    />
        <result property="other"    column="other"    />
        <result property="toilet"    column="toilet"    />
        <result property="eat"    column="eat"    />
        <result property="menses"    column="menses"    />
        <result property="medicine"    column="medicine"    />
        <result property="constitution"    column="constitution"    />
        <result property="recommendMedicine"    column="recommend_medicine"    />
        <result property="consultProduct"    column="consult_product"    />
        <result property="isBuy"    column="is_buy"    />
        <result property="buyProduct"    column="buy_product"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="disease"    column="disease"    />
        <result property="isLine"    column="is_line"    />
        <result property="course"    column="course"    />
        <result property="productTalk"    column="product_talk"    />
        <result property="diseaseTalk"    column="disease_talk"    />
    </resultMap>

    <sql id="selectQwExternalContactInfoVo">
        select id, external_contact_id,course,product_talk,disease_talk, name,disease,is_line, sex, age, address, habits, illness_time, body, study, course_status, family, family_disease, talk, user_type, is_self, intensify, is_cold, cold_body, sweat, other, toilet, eat, menses, medicine, constitution, recommend_medicine, consult_product, is_buy, buy_product, create_time, update_time from qw_external_contact_info
    </sql>

    <select id="selectQwExternalContactInfoList" parameterType="QwExternalContactInfo" resultMap="QwExternalContactInfoResult">
        <include refid="selectQwExternalContactInfoVo"/>
        <where>
            <if test="externalContactId != null "> and external_contact_id = #{externalContactId}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="sex != null  and sex != ''"> and sex = #{sex}</if>
            <if test="age != null  and age != ''"> and age = #{age}</if>
            <if test="address != null  and address != ''"> and address = #{address}</if>
            <if test="habits != null  and habits != ''"> and habits = #{habits}</if>
            <if test="illnessTime != null  and illnessTime != ''"> and illness_time = #{illnessTime}</if>
            <if test="body != null  and body != ''"> and body = #{body}</if>
            <if test="study != null  and study != ''"> and study = #{study}</if>
            <if test="courseStatus != null  and courseStatus != ''"> and course_status = #{courseStatus}</if>
            <if test="family != null  and family != ''"> and family = #{family}</if>
            <if test="familyDisease != null  and familyDisease != ''"> and family_disease = #{familyDisease}</if>
            <if test="talk != null  and talk != ''"> and talk = #{talk}</if>
            <if test="userType != null  and userType != ''"> and user_type = #{userType}</if>
            <if test="isSelf != null  and isSelf != ''"> and is_self = #{isSelf}</if>
            <if test="intensify != null  and intensify != ''"> and intensify = #{intensify}</if>
            <if test="isCold != null  and isCold != ''"> and is_cold = #{isCold}</if>
            <if test="coldBody != null  and coldBody != ''"> and cold_body = #{coldBody}</if>
            <if test="sweat != null  and sweat != ''"> and sweat = #{sweat}</if>
            <if test="other != null  and other != ''"> and other = #{other}</if>
            <if test="toilet != null  and toilet != ''"> and toilet = #{toilet}</if>
            <if test="eat != null  and eat != ''"> and eat = #{eat}</if>
            <if test="menses != null  and menses != ''"> and menses = #{menses}</if>
            <if test="medicine != null  and medicine != ''"> and medicine = #{medicine}</if>
            <if test="constitution != null  and constitution != ''"> and constitution = #{constitution}</if>
            <if test="recommendMedicine != null  and recommendMedicine != ''"> and recommend_medicine = #{recommendMedicine}</if>
            <if test="consultProduct != null  and consultProduct != ''"> and consult_product = #{consultProduct}</if>
            <if test="isBuy != null  and isBuy != ''"> and is_buy = #{isBuy}</if>
            <if test="buyProduct != null  and buyProduct != ''"> and buy_product = #{buyProduct}</if>
        </where>
    </select>

    <select id="selectQwExternalContactInfoById" parameterType="Long" resultMap="QwExternalContactInfoResult">
        <include refid="selectQwExternalContactInfoVo"/>
        where id = #{id}
    </select>

    <insert id="insertQwExternalContactInfo" parameterType="QwExternalContactInfo" useGeneratedKeys="true" keyProperty="id">
        insert into qw_external_contact_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="externalContactId != null">external_contact_id,</if>
            <if test="name != null">name,</if>
            <if test="sex != null">sex,</if>
            <if test="age != null">age,</if>
            <if test="address != null">address,</if>
            <if test="habits != null">habits,</if>
            <if test="illnessTime != null">illness_time,</if>
            <if test="body != null">body,</if>
            <if test="study != null">study,</if>
            <if test="courseStatus != null">course_status,</if>
            <if test="family != null">family,</if>
            <if test="familyDisease != null">family_disease,</if>
            <if test="talk != null">talk,</if>
            <if test="userType != null">user_type,</if>
            <if test="isSelf != null">is_self,</if>
            <if test="intensify != null">intensify,</if>
            <if test="isCold != null">is_cold,</if>
            <if test="coldBody != null">cold_body,</if>
            <if test="sweat != null">sweat,</if>
            <if test="other != null">other,</if>
            <if test="toilet != null">toilet,</if>
            <if test="eat != null">eat,</if>
            <if test="menses != null">menses,</if>
            <if test="medicine != null">medicine,</if>
            <if test="constitution != null">constitution,</if>
            <if test="recommendMedicine != null">recommend_medicine,</if>
            <if test="consultProduct != null">consult_product,</if>
            <if test="isBuy != null">is_buy,</if>
            <if test="buyProduct != null">buy_product,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="disease != null">disease,</if>
            <if test="isLine != null">is_line,</if>
            <if test="course != null">course,</if>
            <if test="productTalk != null">product_talk,</if>
            <if test="diseaseTalk != null">disease_talk,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="externalContactId != null">#{externalContactId},</if>
            <if test="name != null">#{name},</if>
            <if test="sex != null">#{sex},</if>
            <if test="age != null">#{age},</if>
            <if test="address != null">#{address},</if>
            <if test="habits != null">#{habits},</if>
            <if test="illnessTime != null">#{illnessTime},</if>
            <if test="body != null">#{body},</if>
            <if test="study != null">#{study},</if>
            <if test="courseStatus != null">#{courseStatus},</if>
            <if test="family != null">#{family},</if>
            <if test="familyDisease != null">#{familyDisease},</if>
            <if test="talk != null">#{talk},</if>
            <if test="userType != null">#{userType},</if>
            <if test="isSelf != null">#{isSelf},</if>
            <if test="intensify != null">#{intensify},</if>
            <if test="isCold != null">#{isCold},</if>
            <if test="coldBody != null">#{coldBody},</if>
            <if test="sweat != null">#{sweat},</if>
            <if test="other != null">#{other},</if>
            <if test="toilet != null">#{toilet},</if>
            <if test="eat != null">#{eat},</if>
            <if test="menses != null">#{menses},</if>
            <if test="medicine != null">#{medicine},</if>
            <if test="constitution != null">#{constitution},</if>
            <if test="recommendMedicine != null">#{recommendMedicine},</if>
            <if test="consultProduct != null">#{consultProduct},</if>
            <if test="isBuy != null">#{isBuy},</if>
            <if test="buyProduct != null">#{buyProduct},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="disease != null">#{disease},</if>
            <if test="isLine != null">#{isLine},</if>
            <if test="course != null">#{course},</if>
            <if test="productTalk != null">#{productTalk},</if>
            <if test="diseaseTalk != null">#{diseaseTalk},</if>
        </trim>
    </insert>

    <update id="updateQwExternalContactInfo" parameterType="QwExternalContactInfo">
        update qw_external_contact_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="externalContactId != null">external_contact_id = #{externalContactId},</if>
            <if test="name != null">name = #{name},</if>
            <if test="sex != null">sex = #{sex},</if>
            <if test="age != null">age = #{age},</if>
            <if test="address != null">address = #{address},</if>
            <if test="habits != null">habits = #{habits},</if>
            <if test="illnessTime != null">illness_time = #{illnessTime},</if>
            <if test="body != null">body = #{body},</if>
            <if test="study != null">study = #{study},</if>
            <if test="courseStatus != null">course_status = #{courseStatus},</if>
            <if test="family != null">family = #{family},</if>
            <if test="familyDisease != null">family_disease = #{familyDisease},</if>
            <if test="talk != null">talk = #{talk},</if>
            <if test="userType != null">user_type = #{userType},</if>
            <if test="isSelf != null">is_self = #{isSelf},</if>
            <if test="intensify != null">intensify = #{intensify},</if>
            <if test="isCold != null">is_cold = #{isCold},</if>
            <if test="coldBody != null">cold_body = #{coldBody},</if>
            <if test="sweat != null">sweat = #{sweat},</if>
            <if test="other != null">other = #{other},</if>
            <if test="toilet != null">toilet = #{toilet},</if>
            <if test="eat != null">eat = #{eat},</if>
            <if test="menses != null">menses = #{menses},</if>
            <if test="medicine != null">medicine = #{medicine},</if>
            <if test="constitution != null">constitution = #{constitution},</if>
            <if test="recommendMedicine != null">recommend_medicine = #{recommendMedicine},</if>
            <if test="consultProduct != null">consult_product = #{consultProduct},</if>
            <if test="isBuy != null">is_buy = #{isBuy},</if>
            <if test="buyProduct != null">buy_product = #{buyProduct},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="disease != null">disease = #{disease},</if>
            <if test="isLine != null">is_line = #{isLine},</if>
            <if test="course != null">course = #{course},</if>
            <if test="productTalk != null">product_talk = #{productTalk},</if>
            <if test="diseaseTalk != null">disease_talk = #{diseaseTalk},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteQwExternalContactInfoById" parameterType="Long">
        delete from qw_external_contact_info where id = #{id}
    </delete>

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