<?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.flossom.common.core.mapper.WxModeServiceInfoMapper">

    <resultMap type="WxModeServiceInfo" id="WxModeServiceInfoResult">
        <result property="id"    column="id"    />
        <result property="modeId"    column="mode_id"    />
        <result property="serviceStartTime"    column="service_start_time"    />
        <result property="serviceEndTime"    column="service_end_time"    />
        <result property="startSource"    column="start_source"    />
        <result property="stopSource"    column="stop_source"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
    </resultMap>

    <sql id="selectWxModeServiceInfoVo">
        select id,mode_id, service_start_time, service_end_time, start_source, stop_source, create_time, create_by from wx_mode_service_info
    </sql>

    <select id="selectWxModeServiceInfoList" parameterType="WxModeServiceInfo" resultMap="WxModeServiceInfoResult">
        <include refid="selectWxModeServiceInfoVo"/>
        <where>
            <if test="modeId != null "> and mode_id = #{modeId}</if>
            <if test="serviceStartTime != null "> and service_start_time = #{serviceStartTime}</if>
            <if test="serviceEndTime != null "> and service_end_time = #{serviceEndTime}</if>
            <if test="startSource != null  and startSource != ''"> and start_source = #{startSource}</if>
            <if test="stopSource != null  and stopSource != ''"> and stop_source = #{stopSource}</if>
        </where>
        order by create_time desc
    </select>

    <select id="selectWxModeServiceInfoById" parameterType="Long" resultMap="WxModeServiceInfoResult">
        <include refid="selectWxModeServiceInfoVo"/>
        where id = #{id}
    </select>

    <insert id="insertWxModeServiceInfo" parameterType="WxModeServiceInfo" useGeneratedKeys="true" keyProperty="id">
        insert into wx_mode_service_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="modeId != null">mode_id,</if>
            <if test="serviceStartTime != null">service_start_time,</if>
            <if test="serviceEndTime != null">service_end_time,</if>
            <if test="startSource != null">start_source,</if>
            <if test="stopSource != null">stop_source,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null">create_by,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="modeId != null">#{modeId},</if>
            <if test="serviceStartTime != null">#{serviceStartTime},</if>
            <if test="serviceEndTime != null">#{serviceEndTime},</if>
            <if test="startSource != null">#{startSource},</if>
            <if test="stopSource != null">#{stopSource},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
         </trim>
    </insert>

    <update id="updateWxModeServiceInfo" parameterType="WxModeServiceInfo">
        update wx_mode_service_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="modeId != null">mode_id = #{modeId},</if>
            <if test="serviceStartTime != null">service_start_time = #{serviceStartTime},</if>
            <if test="serviceEndTime != null">service_end_time = #{serviceEndTime},</if>
            <if test="startSource != null">start_source = #{startSource},</if>
            <if test="stopSource != null">stop_source = #{stopSource},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteWxModeServiceInfoById" parameterType="Long">
        delete from wx_mode_service_info where id = #{id}
    </delete>


    <delete id="deleteWxModeServiceInfoByModeId" parameterType="Long">
        delete from wx_mode_service_info where mode_id = #{modeId}
    </delete>


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