<?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.mall.mapper.MallConfigMapper">

    <resultMap type="MallConfig" id="MallConfigResult">
        <result property="id"    column="id"    />
        <result property="identifying"    column="identifying"    />
        <result property="name"    column="name"    />
        <result property="configExplain"    column="config_explain"    />
        <result property="configInt"    column="config_int"    />
        <result property="configTwo"    column="config_two"    />
        <result property="configThree"    column="config_three"    />
        <result property="configString"    column="config_string"    />
        <result property="type"    column="type"    />
        <result property="status"    column="status"    />
        <result property="createAt"    column="create_at"    />
        <result property="updateAt"    column="update_at"    />
        <result property="delFlag"    column="del_flag"    />
    </resultMap>

    <sql id="selectMallConfigVo">
        select id, identifying, name, config_explain, config_int, config_two, config_three, config_string, type, status, create_at, update_at, del_flag from mall_config
    </sql>

    <select id="selectMallConfigList" parameterType="MallConfig" resultMap="MallConfigResult">
        <include refid="selectMallConfigVo"/>
        <where>
            <if test="identifying != null  and identifying != ''"> and identifying = #{identifying}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="configExplain != null  and configExplain != ''"> and config_explain = #{configExplain}</if>
            <if test="configInt != null "> and config_int = #{configInt}</if>
            <if test="configTwo != null "> and config_two = #{configTwo}</if>
            <if test="configThree != null "> and config_three = #{configThree}</if>
            <if test="configString != null  and configString != ''"> and config_string = #{configString}</if>
            <if test="type != null "> and type = #{type}</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="createAt != null  and createAt != ''"> and create_at = #{createAt}</if>
            <if test="updateAt != null "> and update_at = #{updateAt}</if>
            <if test="delFlag != null "> and del_flag = #{delFlag}</if>
        </where>
    </select>

    <select id="selectMallConfigById" parameterType="Long" resultMap="MallConfigResult">
        <include refid="selectMallConfigVo"/>
        where id = #{id}
    </select>

    <insert id="insertMallConfig" parameterType="MallConfig" useGeneratedKeys="true" keyProperty="id">
        insert into mall_config
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="identifying != null">identifying,</if>
            <if test="name != null">name,</if>
            <if test="configExplain != null">config_explain,</if>
            <if test="configInt != null">config_int,</if>
            <if test="configTwo != null">config_two,</if>
            <if test="configThree != null">config_three,</if>
            <if test="configString != null">config_string,</if>
            <if test="type != null">type,</if>
            <if test="status != null">status,</if>
            <if test="createAt != null">create_at,</if>
            <if test="updateAt != null">update_at,</if>
            <if test="delFlag != null">del_flag,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="identifying != null">#{identifying},</if>
            <if test="name != null">#{name},</if>
            <if test="configExplain != null">#{configExplain},</if>
            <if test="configInt != null">#{configInt},</if>
            <if test="configTwo != null">#{configTwo},</if>
            <if test="configThree != null">#{configThree},</if>
            <if test="configString != null">#{configString},</if>
            <if test="type != null">#{type},</if>
            <if test="status != null">#{status},</if>
            <if test="createAt != null">#{createAt},</if>
            <if test="updateAt != null">#{updateAt},</if>
            <if test="delFlag != null">#{delFlag},</if>
         </trim>
    </insert>

    <update id="updateMallConfig" parameterType="MallConfig">
        update mall_config
        <trim prefix="SET" suffixOverrides=",">
            <if test="identifying != null">identifying = #{identifying},</if>
            <if test="name != null">name = #{name},</if>
            <if test="configExplain != null">config_explain = #{configExplain},</if>
            <if test="configInt != null">config_int = #{configInt},</if>
            <if test="configTwo != null">config_two = #{configTwo},</if>
            <if test="configThree != null">config_three = #{configThree},</if>
            <if test="configString != null">config_string = #{configString},</if>
            <if test="type != null">type = #{type},</if>
            <if test="status != null">status = #{status},</if>
            <if test="createAt != null">create_at = #{createAt},</if>
            <if test="updateAt != null">update_at = #{updateAt},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteMallConfigById" parameterType="Long">
        delete from mall_config where id = #{id}
    </delete>

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

    <select id="selectMallConfigByIdentifying" resultMap="MallConfigResult">
        <include refid="selectMallConfigVo"/>
        where identifying = #{identifying}
        limit  1
    </select>
</mapper>
