<?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.applet.mapper.nursemanagepersonwechatinfo.NurseManagePersonWechatInfoMapper">

    <resultMap type="NurseManagePersonWechatInfo" id="NurseManagePersonWechatInfoResult">
        <result property="id" column="id"/>
        <result property="nurseStationId" column="nurse_station_id"/>
        <result property="userId" column="user_id"/>
        <result property="openid" column="openid"/>
        <result property="unionid" column="unionid"/>
        <result property="phone" column="phone"/>
        <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="selectNurseManagePersonWechatInfoVo">
        select id,
               nurse_station_id,
               user_id,
               openid,
               unionid,
               phone,
               create_by,
               create_time,
               update_by,
               update_time
        from nurse_manage_person_wechat_info
    </sql>

    <select id="selectNurseManagePersonWechatInfoList" parameterType="NurseManagePersonWechatInfo"
            resultMap="NurseManagePersonWechatInfoResult">
        <include refid="selectNurseManagePersonWechatInfoVo"/>
        <where>
            <if test="nurseStationId != null and nurseStationId != ''">
                and nurse_station_id = #{nurseStationId}
            </if>
            <if test="userId != null ">
                and user_id = #{userId}
            </if>
            <if test="openid != null  and openid != ''">
                and openid = #{openid}
            </if>
            <if test="unionid != null  and unionid != ''">
                and unionid = #{unionid}
            </if>
            <if test="phone != null  and phone != ''">
                and phone = #{phone}
            </if>
        </where>
    </select>

    <select id="selectNurseManagePersonWechatInfoById" parameterType="Long"
            resultMap="NurseManagePersonWechatInfoResult">
        <include refid="selectNurseManagePersonWechatInfoVo"/>
        where id = #{id}
    </select>

    <insert id="insertNurseManagePersonWechatInfo" parameterType="NurseManagePersonWechatInfo" useGeneratedKeys="true"
            keyProperty="id">
        insert into nurse_manage_person_wechat_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="nurseStationId != null">nurse_station_id,
            </if>
            <if test="userId != null">user_id,
            </if>
            <if test="openid != null">openid,
            </if>
            <if test="unionid != null">unionid,
            </if>
            <if test="phone != null">phone,
            </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="nurseStationId != null">#{nurseStationId},
            </if>
            <if test="userId != null">#{userId},
            </if>
            <if test="openid != null">#{openid},
            </if>
            <if test="unionid != null">#{unionid},
            </if>
            <if test="phone != null">#{phone},
            </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="updateNurseManagePersonWechatInfo" parameterType="NurseManagePersonWechatInfo">
        update nurse_manage_person_wechat_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="nurseStationId != null">nurse_station_id =
                #{nurseStationId},
            </if>
            <if test="userId != null">user_id =
                #{userId},
            </if>
            <if test="openid != null">openid =
                #{openid},
            </if>
            <if test="unionid != null">unionid =
                #{unionid},
            </if>
            <if test="phone != null">phone =
                #{phone},
            </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="deleteNurseManagePersonWechatInfoById" parameterType="Long">
        delete
        from nurse_manage_person_wechat_info
        where id = #{id}
    </delete>

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

    <select id="selectNurseManagePersonWechatInfoByPhone"
            resultType="com.xinelu.manage.domain.nursemanagepersonwechatinfo.NurseManagePersonWechatInfo">
        <include refid="selectNurseManagePersonWechatInfoVo"/>
        where phone = #{phone}
    </select>
</mapper>