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

    <resultMap type="WxModeOpenSource" id="WxModeOpenSourceResult">
        <result property="id"    column="id"    />
        <result property="modeId"    column="mode_id"    />
        <result property="openTitle"    column="open_title"    />
        <result property="openSourceUrl"    column="open_source_url"    />
        <result property="openSourceName"    column="open_source_name"    />
        <result property="openSourceSuffix"    column="open_source_suffix"    />
        <result property="openContent"    column="open_content"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
    </resultMap>

    <sql id="selectWxModeOpenSourceVo">
        select id, mode_id,open_title, open_source_url, open_source_name, open_source_suffix, open_content, create_time, create_by from wx_mode_open_source
    </sql>

    <select id="selectWxModeOpenSourceList" parameterType="WxModeOpenSource" resultMap="WxModeOpenSourceResult">
        <include refid="selectWxModeOpenSourceVo"/>
        <where>
            <if test="modeId != null  and modeId != ''"> and mode_id = #{modeId}</if>
            <if test="openTitle != null  and openTitle != ''"> and open_title = #{openTitle}</if>
            <if test="openSourceUrl != null  and openSourceUrl != ''"> and open_source_url = #{openSourceUrl}</if>
            <if test="openSourceName != null  and openSourceName != ''"> and open_source_name like concat('%', #{openSourceName}, '%')</if>
            <if test="openSourceSuffix != null  and openSourceSuffix != ''"> and open_source_suffix = #{openSourceSuffix}</if>
            <if test="openContent != null  and openContent != ''"> and open_content = #{openContent}</if>
        </where>
        order by create_time desc
    </select>

    <select id="selectWxModeOpenSourceById" parameterType="Long" resultMap="WxModeOpenSourceResult">
        <include refid="selectWxModeOpenSourceVo"/>
        where id = #{id}
    </select>

    <insert id="insertWxModeOpenSource" parameterType="WxModeOpenSource">
        insert into wx_mode_open_source
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="modeId != null">mode_id,</if>
            <if test="openTitle != null">open_title,</if>
            <if test="openSourceUrl != null">open_source_url,</if>
            <if test="openSourceName != null">open_source_name,</if>
            <if test="openSourceSuffix != null">open_source_suffix,</if>
            <if test="openContent != null">open_content,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null">create_by,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="modeId != null">#{modeId},</if>
            <if test="openTitle != null">#{openTitle},</if>
            <if test="openSourceUrl != null">#{openSourceUrl},</if>
            <if test="openSourceName != null">#{openSourceName},</if>
            <if test="openSourceSuffix != null">#{openSourceSuffix},</if>
            <if test="openContent != null">#{openContent},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
         </trim>
    </insert>

    <update id="updateWxModeOpenSource" parameterType="WxModeOpenSource">
        update wx_mode_open_source
        <trim prefix="SET" suffixOverrides=",">
            <if test="modeId != null">mode_id = #{modeId},</if>
            <if test="openTitle != null">open_title = #{openTitle},</if>
            <if test="openSourceUrl != null">open_source_url = #{openSourceUrl},</if>
            <if test="openSourceName != null">open_source_name = #{openSourceName},</if>
            <if test="openSourceSuffix != null">open_source_suffix = #{openSourceSuffix},</if>
            <if test="openContent != null">open_content = #{openContent},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteWxModeOpenSourceById" parameterType="Long">
        delete from wx_mode_open_source where id = #{id}
    </delete>

    <delete id="deleteWxModeOpenSourceByModeId" parameterType="Long">
        delete from wx_mode_open_source where mode_id = #{modId}
    </delete>
    <delete id="deleteWxModeOpenSourceByIds" parameterType="String">
        delete from wx_mode_open_source where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>
