<?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.ischoolbar.programmer.dao.common.ProductCategoryDao">
	<!-- 商品分类插入操作 -->
	<insert id="add" parameterType="com.ischoolbar.programmer.entity.common.ProductCategory">
		insert into product_category(id,parentId,name,tags,remark) values(null,#{parentId},#{name},#{tags},#{remark})
	</insert>
	<!-- 商品分类更新操作 -->
	<update id="edit" parameterType="com.ischoolbar.programmer.entity.common.ProductCategory">
		update product_category set parentId = #{parentId},name = #{name},tags = #{tags},remark = #{remark} where id = #{id}
	</update>
	<!-- 商品分类信息搜索查询 -->
	<select id="findList" parameterType="Map" resultType="com.ischoolbar.programmer.entity.common.ProductCategory">
		select * from product_category 
		<if test="name != null">
			where name like '%${name}%' 
		</if>
		<if test="offset != null and pageSize != null">
			limit #{offset},#{pageSize}
		</if>
	</select>
	<!-- 模糊搜索总条数 -->
	<select id="getTotal" parameterType="Map" resultType="Integer">
		select count(*) from product_category 
		<if test="name != null">
			where name like '%${name}%' 
		</if>
	</select>
	<!-- 根据id查询分类 -->
	<select id="findById" parameterType="Long" resultType="com.ischoolbar.programmer.entity.common.ProductCategory">
		select * from product_category where id = #{value}
	</select>
	<!-- 删除商品分类信息 -->
	<delete id="delete" parameterType="String">
		delete from product_category where id in(${value})
	</delete>
</mapper>