<?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.MallShopExpressCodeMapper">
    
    <resultMap type="MallShopExpressCode" id="MallShopExpressCodeResult">
        <result property="id"    column="id"    />
        <result property="code"    column="code"    />
        <result property="name"    column="name"    />
        <result property="default"    column="default"    />
        <result property="isDefault"    column="is_disabled"    />
        <result property="remark"    column="remark"    />
        <result property="createAt"    column="create_at"    />
        <result property="delFlag"    column="del_flag"    />
    </resultMap>

    <sql id="selectMallShopExpressCodeVo">
        select id, code, name, is_default, disabled, remark, create_at, del_flag from mall_shop_express_code
    </sql>

    <select id="selectMallShopExpressCodeList" parameterType="MallShopExpressCode" resultMap="MallShopExpressCodeResult">
        <include refid="selectMallShopExpressCodeVo"/>
        <where>  
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="isDefault != null "> and is_default = #{isDefault}</if>
            <if test="disabled != null "> and disabled = #{disabled}</if>
        </where>
    </select>
    
    <select id="selectMallShopExpressCodeById" parameterType="Long" resultMap="MallShopExpressCodeResult">
        <include refid="selectMallShopExpressCodeVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertMallShopExpressCode" parameterType="MallShopExpressCode" useGeneratedKeys="true" keyProperty="id">
        insert into mall_shop_express_code
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="code != null">code,</if>
            <if test="name != null">name,</if>
            <if test="isDefault != null">is_default,</if>
            <if test="disabled != null">disabled,</if>
            <if test="remark != null">remark,</if>
            <if test="createAt != null">create_at,</if>
            <if test="delFlag != null">del_flag,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="code != null">#{code},</if>
            <if test="name != null">#{name},</if>
            <if test="isDefault != null">#{isDefault},</if>
            <if test="disabled != null">#{disabled},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createAt != null">#{createAt},</if>
            <if test="delFlag != null">#{delFlag},</if>
         </trim>
    </insert>

    <update id="updateMallShopExpressCode" parameterType="MallShopExpressCode">
        update mall_shop_express_code
        <trim prefix="SET" suffixOverrides=",">
            <if test="code != null">code = #{code},</if>
            <if test="name != null">name = #{name},</if>
            <if test="isDefault != null">is_default = #{isDefault},</if>
            <if test="disabled != null">disabled = #{disabled},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createAt != null">create_at = #{createAt},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteMallShopExpressCodeById" parameterType="Long">
        delete from mall_shop_express_code where id = #{id}
    </delete>

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