<?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.ruoyi.model.mapper.UserBindingConfigMapper">
    
    <resultMap type="UserBindingConfig" id="UserBindingConfigResult">
        <result property="id"    column="id"    />
        <result property="promotionName"    column="promotion_name"    />
        <result property="promotionIcon"    column="promotion_icon"    />
        <result property="promotionType"    column="promotion_type"    />
        <result property="category"    column="category"    />
        <result property="remark"    column="remark"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="delFlag"    column="del_flag"    />
    </resultMap>

    <sql id="selectUserBindingConfigVo">
        select id, promotion_name, promotion_icon, promotion_type, category, remark, create_time, create_by, update_time, update_by, del_flag from user_binding_config
    </sql>

    <select id="selectUserBindingConfigList" parameterType="UserBindingConfig" resultMap="UserBindingConfigResult">
        <include refid="selectUserBindingConfigVo"/>
        <where>  
            <if test="promotionName != null  and promotionName != ''"> and promotion_name like concat('%', #{promotionName}, '%')</if>
            <if test="promotionIcon != null  and promotionIcon != ''"> and promotion_icon = #{promotionIcon}</if>
            <if test="promotionType != null  and promotionType != ''"> and promotion_type = #{promotionType}</if>
            <if test="category != null "> and category = #{category}</if>
        </where>
    </select>
    
    <select id="selectUserBindingConfigById" parameterType="Long" resultMap="UserBindingConfigResult">
        <include refid="selectUserBindingConfigVo"/>
        where id = #{id}
    </select>

    <insert id="insertUserBindingConfig" parameterType="UserBindingConfig">
        insert into user_binding_config
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="promotionName != null">promotion_name,</if>
            <if test="promotionIcon != null">promotion_icon,</if>
            <if test="promotionType != null">promotion_type,</if>
            <if test="category != null">category,</if>
            <if test="remark != null">remark,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="delFlag != null">del_flag,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="promotionName != null">#{promotionName},</if>
            <if test="promotionIcon != null">#{promotionIcon},</if>
            <if test="promotionType != null">#{promotionType},</if>
            <if test="category != null">#{category},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="delFlag != null">#{delFlag},</if>
         </trim>
    </insert>

    <update id="updateUserBindingConfig" parameterType="UserBindingConfig">
        update user_binding_config
        <trim prefix="SET" suffixOverrides=",">
            <if test="promotionName != null">promotion_name = #{promotionName},</if>
            <if test="promotionIcon != null">promotion_icon = #{promotionIcon},</if>
            <if test="promotionType != null">promotion_type = #{promotionType},</if>
            <if test="category != null">category = #{category},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteUserBindingConfigById" parameterType="Long">
        delete from user_binding_config where id = #{id}
    </delete>

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