|
|
|
@ -0,0 +1,38 @@
|
|
|
|
|
<?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.yami.shop.dao.CategoryMapper">
|
|
|
|
|
|
|
|
|
|
<!-- resultMap定义了数据库表字段与Java对象属性之间的映射关系,用于分类及其产品信息 -->
|
|
|
|
|
<resultMap id="categoryProdMap" type="com.yami.shop.bean.model.Category">
|
|
|
|
|
<id column="category_id" jdbcType="BIGINT" property="categoryId" />
|
|
|
|
|
<result column="category_name" jdbcType="VARCHAR" property="categoryName" />
|
|
|
|
|
<!-- 集合属性,表示一个分类下有多個产品 -->
|
|
|
|
|
<collection property="products" column="prod_id" ofType="com.yami.shop.bean.model.Product">
|
|
|
|
|
<!-- 以下是产品的属性与数据库字段的映射 -->
|
|
|
|
|
<id property="prodId" column="prod_id"/>
|
|
|
|
|
<result property="prodName" column="prod_name"/>
|
|
|
|
|
<result property="shopId" column="shop_id"/>
|
|
|
|
|
<result property="oriPrice" column="ori_price"/>
|
|
|
|
|
<result property="price" column="price"/>
|
|
|
|
|
<result property="brief" column="brief"/>
|
|
|
|
|
<result property="content" column="content"/>
|
|
|
|
|
<result property="imgs" column="imgs"/>
|
|
|
|
|
<result property="status" column="status"/>
|
|
|
|
|
<result property="categoryId" column="category_id"/>
|
|
|
|
|
<result property="soldNum" column="sold_num"/>
|
|
|
|
|
<result property="totalStocks" column="total_stocks"/>
|
|
|
|
|
<result property="createTime" column="create_time"/>
|
|
|
|
|
<result property="updateTime" column="update_time"/>
|
|
|
|
|
</collection>
|
|
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
|
|
<!-- 查询语句,根据父级ID查询分类列表 -->
|
|
|
|
|
<select id="listByParentId" resultType="com.yami.shop.bean.model.Category">
|
|
|
|
|
select category_id,category_name,`seq`,`status`,pic from tz_category where parent_id = #{parentId} and `status` = 1 order by seq
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<!-- 查询语句,根据店铺ID查询分类列表 -->
|
|
|
|
|
<select id="tableCategory" resultType="com.yami.shop.bean.model.Category">
|
|
|
|
|
select category_id ,parent_id ,category_name,pic,seq,status from tz_category where shop_id = #{shopId} order by seq
|
|
|
|
|
</select>
|
|
|
|
|
</mapper>
|