27 lines
1.0 KiB
XML
27 lines
1.0 KiB
XML
<?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.atguigu.spzx.manger.mapper.CategoryMapper">
|
|
<resultMap id="categoryMap" type="com.atguigu.spzx.model.entity.product.Category" autoMapping="true"/>
|
|
|
|
<!-- 用于select查询公用抽取的列 -->
|
|
<sql id="columns">
|
|
id,name,image_url,parent_id,status,order_num,create_time,update_time,is_deleted
|
|
</sql>
|
|
|
|
<!-- 根据分类id查询它下面的所有的子分类数据 -->
|
|
<select id="selectByParentId" resultType="com.atguigu.spzx.model.entity.product.Category">
|
|
select
|
|
<include refid="columns"/>
|
|
from category
|
|
where parent_id=#{parentId} and is_deleted=0 order by id desc
|
|
</select>
|
|
|
|
<!-- 查询该分类下子分类的数量 -->
|
|
<select id="countByParentId" resultType="java.lang.Integer">
|
|
select count(id)
|
|
from category
|
|
where parent_id = #{id}
|
|
and is_deleted = 0
|
|
</select>
|
|
</mapper>
|