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

    <resultMap type="MallGoodsSpec" id="MallGoodsSpecResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="createAt"    column="create_at"    />
        <result property="updateAt"    column="update_at"    />
        <result property="status"    column="status"    />
        <result property="delFlag"    column="del_flag"    />
    </resultMap>

    <sql id="selectMallGoodsSpecVo">
        select id, name, create_at, update_at, status, del_flag from mall_goods_spec
    </sql>

    <select id="selectMallGoodsSpecList" parameterType="MallGoodsSpec" resultMap="MallGoodsSpecResult">
        <include refid="selectMallGoodsSpecVo"/>
        <where>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
             and del_flag='0'
        </where>
    </select>

    <select id="selectMallGoodsSpecSelectList" parameterType="MallGoodsSpec" resultMap="MallGoodsSpecResult">
        <include refid="selectMallGoodsSpecVo"/>
        <where>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            and status = '0'
             and del_flag='0'
        </where>
    </select>

    <select id="selectMallGoodsSpecById" parameterType="Long" resultMap="MallGoodsSpecResult">
        <include refid="selectMallGoodsSpecVo"/>
        where id = #{id}
    </select>

    <insert id="insertMallGoodsSpec" parameterType="MallGoodsSpec" useGeneratedKeys="true" keyProperty="id">
        insert into mall_goods_spec
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="name != null">name,</if>
            <if test="createAt != null">create_at,</if>
            <if test="updateAt != null">update_at,</if>
            <if test="status != null">status,</if>
            <if test="delFlag != null">del_flag,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="name != null">#{name},</if>
            <if test="createAt != null">#{createAt},</if>
            <if test="updateAt != null">#{updateAt},</if>
            <if test="status != null">#{status},</if>
            <if test="delFlag != null">#{delFlag},</if>
         </trim>
    </insert>

    <update id="updateMallGoodsSpec" parameterType="MallGoodsSpec">
        update mall_goods_spec
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">name = #{name},</if>
            <if test="createAt != null">create_at = #{createAt},</if>
            <if test="updateAt != null">update_at = #{updateAt},</if>
            <if test="status != null">status = #{status},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteMallGoodsSpecById" parameterType="Long">
        delete from mall_goods_spec where id = #{id}
    </delete>

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