<?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.kmall.api.dao.ApiAttributeCategoryMapper">

    <!-- 可根据自己的需求，是否要使用 -->
    <resultMap type="com.kmall.api.entity.AttributeCategoryVo" id="attributeCategoryMap">
        <result property="id" column="id"/>
        <result property="name" column="name"/>
        <result property="enabled" column="enabled"/>
    </resultMap>

    <select id="queryObject" resultType="com.kmall.api.entity.AttributeCategoryVo">
		select * from mall_attribute_category where id = #{value}
	</select>

    <select id="queryList" resultType="com.kmall.api.entity.AttributeCategoryVo">
        select * from mall_attribute_category
        <choose>
            <when test="sidx != null and sidx.trim() != ''">
                order by ${sidx} ${order}
            </when>
            <otherwise>
                order by id desc
            </otherwise>
        </choose>
        <if test="offset != null and limit != null">
            limit #{offset}, #{limit}
        </if>
    </select>

    <select id="queryTotal" resultType="int">
		select count(*) from mall_attribute_category
	</select>

    <insert id="save" parameterType="com.kmall.api.entity.AttributeCategoryVo">
		insert into mall_attribute_category
		(
			`id`, 
			`name`, 
			`enabled`
		)
		values
		(
			#{id}, 
			#{name}, 
			#{enabled}
		)
	</insert>

    <update id="update" parameterType="com.kmall.api.entity.AttributeCategoryVo">
        update mall_attribute_category
        <set>
            <if test="name != null">`name` = #{name},</if>
            <if test="enabled != null">`enabled` = #{enabled}</if>
        </set>
        where id = #{id}
    </update>

    <delete id="delete">
		delete from mall_attribute_category where id = #{value}
	</delete>

    <delete id="deleteBatch">
        delete from mall_attribute_category where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

</mapper>