<?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.QwAppContactWayMapper">

    <resultMap type="QwAppContactWay" id="QwAppContactWayResult">
        <result property="id"    column="id"    />
        <result property="state"    column="state"    />
        <result property="userId"    column="user_id"    />
        <result property="qrCode"    column="qr_code"    />
        <result property="configId"    column="config_id"    />
        <result property="status"    column="status"    />
        <result property="wayStatus"    column="way_status"    />
        <result property="qwUserIds"    column="qw_user_ids"    />
        <result property="corpId"    column="corp_id"    />
        <result property="createTime"    column="create_time"    />
        <result property="expirationTime"    column="expiration_time"    />
    </resultMap>

    <sql id="selectQwAppContactWayVo">
        select id, state, user_id, qr_code, config_id, status, way_status, qw_user_ids, corp_id, create_time, expiration_time from qw_app_contact_way
    </sql>

    <select id="selectQwAppContactWayList" parameterType="QwAppContactWay" resultMap="QwAppContactWayResult">
        <include refid="selectQwAppContactWayVo"/>
        <where>
            <if test="state != null  and state != ''"> and state = #{state}</if>
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="qrCode != null  and qrCode != ''"> and qr_code = #{qrCode}</if>
            <if test="configId != null "> and config_id = #{configId}</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="wayStatus != null "> and way_status = #{wayStatus}</if>
            <if test="qwUserIds != null  and qwUserIds != ''"> and qw_user_ids = #{qwUserIds}</if>
            <if test="corpId != null  and corpId != ''"> and corp_id = #{corpId}</if>
            <if test="expirationTime != null "> and expiration_time = #{expirationTime}</if>
        </where>
    </select>

    <select id="selectQwAppContactWayById" parameterType="Long" resultMap="QwAppContactWayResult">
        <include refid="selectQwAppContactWayVo"/>
        where id = #{id}
    </select>

    <insert id="insertQwAppContactWay" parameterType="QwAppContactWay" useGeneratedKeys="true" keyProperty="id">
        insert into qw_app_contact_way
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="state != null">state,</if>
            <if test="userId != null">user_id,</if>
            <if test="qrCode != null">qr_code,</if>
            <if test="configId != null">config_id,</if>
            <if test="status != null">status,</if>
            <if test="wayStatus != null">way_status,</if>
            <if test="qwUserIds != null">qw_user_ids,</if>
            <if test="corpId != null">corp_id,</if>
            <if test="createTime != null">create_time,</if>
            <if test="expirationTime != null">expiration_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="state != null">#{state},</if>
            <if test="userId != null">#{userId},</if>
            <if test="qrCode != null">#{qrCode},</if>
            <if test="configId != null">#{configId},</if>
            <if test="status != null">#{status},</if>
            <if test="wayStatus != null">#{wayStatus},</if>
            <if test="qwUserIds != null">#{qwUserIds},</if>
            <if test="corpId != null">#{corpId},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="expirationTime != null">#{expirationTime},</if>
         </trim>
    </insert>

    <update id="updateQwAppContactWay" parameterType="QwAppContactWay">
        update qw_app_contact_way
        <trim prefix="SET" suffixOverrides=",">
            <if test="state != null">state = #{state},</if>
            <if test="userId != null">user_id = #{userId},</if>
            <if test="qrCode != null">qr_code = #{qrCode},</if>
            <if test="configId != null">config_id = #{configId},</if>
            <if test="status != null">status = #{status},</if>
            <if test="wayStatus != null">way_status = #{wayStatus},</if>
            <if test="qwUserIds != null">qw_user_ids = #{qwUserIds},</if>
            <if test="corpId != null">corp_id = #{corpId},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="expirationTime != null">expiration_time = #{expirationTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteQwAppContactWayById" parameterType="Long">
        delete from qw_app_contact_way where id = #{id}
    </delete>

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