<?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.frequency.mallgoodstype.mapper.MallGoodsTypeMapper">

    <resultMap type="com.ruoyi.frequency.mallgoodstype.entity.MallGoodsType" id="MallGoodsTypeResult">
        <result property="id"    column="id"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="name"    column="name"    />
        <result property="sort"    column="sort"    />
        <result property="logo"    column="logo"    />
        </resultMap>



    <sql id="selectMallGoodsTypeVo">
        select
            t.id ,
            t.del_flag ,
            t.create_by ,
            t.create_time ,
            t.update_by ,
            t.update_time ,
            t.name ,
            t.sort ,
            t.logo
        from mall_goods_type AS t

    </sql>

    <select id="selectMallGoodsTypeList" parameterType="com.ruoyi.frequency.mallgoodstype.entity.MallGoodsType" resultMap="MallGoodsTypeResult">
        <include refid="selectMallGoodsTypeVo"/>
        <where> AND t.del_flag != 2
            <if test="name != null  and name != ''"> and t.name like concat('%', #{name}, '%')</if>
            <if test="sort != null "> and t.sort = #{sort}</if>
            <if test="logo != null  and logo != ''"> and t.logo = #{logo}</if>
            <if test="delFlag != null and delFlag != ''"> and t.del_flag = #{delFlag}</if>
        </where>
        order by t.sort
    </select>

    <select id="selectMallGoodsTypeById" parameterType="Long" resultMap="MallGoodsTypeResult">
        <include refid="selectMallGoodsTypeVo"/>
        where t.id = #{id}
    </select>

    <insert id="insertMallGoodsType" parameterType="com.ruoyi.frequency.mallgoodstype.entity.MallGoodsType">
        insert into mall_goods_type
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="name != null">name,</if>
            <if test="sort != null">sort,</if>
            <if test="logo != null">logo,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="name != null">#{name},</if>
            <if test="sort != null">#{sort},</if>
            <if test="logo != null">#{logo},</if>
        </trim>
    </insert>

    <update id="updateMallGoodsType" parameterType="com.ruoyi.frequency.mallgoodstype.entity.MallGoodsType">
        update mall_goods_type
        <trim prefix="SET" suffixOverrides=",">
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="name != null">name = #{name},</if>
            <if test="sort != null">sort = #{sort},</if>
            <if test="logo != null">logo = #{logo},</if>
        </trim>
        where id = #{id}
    </update>
                                                                                                                        </mapper>
