SSM项目之商铺系统(十六) 商品类别列表展示从Dao到View层的开发


概述

在这里插入图片描述

进入owner拥有的店铺列表后,对某个店铺进行管理,其中类别管理模块的效果如上。所以获取商品类别的时候要传入shopId.

通过前面的博客,我们对开发流程有了较为清晰的认识,这里我们将类别管理这部分的内容从下至上来实现下吧。


Dao层

ProductCategoryDao接口

package com.imooc.o2o.dao;

import java.util.List;

import com.imooc.o2o.entity.ProductCategory;

public interface ProductCategoryDao {
   

	List<ProductCategory> selectProductCategoryList(long shopId);
}


ProductCategoryDao Mapper配置文件

<?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.artisan.o2o.dao.ProductCategoryDao">
	<select id="selectProductCategoryList" resultType="ProductCategory">
		SELECT
			tpc.product_category_id,
			tpc.product_category_name,
			tpc.product_category_desc,
			tpc.priority,
			tpc.create_time,
			tpc.last_edit_time,
			tpc.shop_id
		FROM
			tb_product_category tpc
		WHERE
			tpc.shop_id = #{
   shopId}
		ORDER BY
			priority 
		DESC
	</select>
</mapper>   

单元测试


    /**
     * 测试查询
     * @throws Exception
     */
    @Test
    public void testselectProductList() throws Exception {
   
        long shopId = 29;
        List<ProductCategory> productCategoryList = productCategoryDao.selectProductList(shopId);
        System.out.println("该店铺自定义类别数为:" + productCategoryList.size());

        for (ProductCategory productCategory :productCategoryList) {
   
            System.out.println(productCategory.toString());
        }


    }

在这里插入图片描述

Service层

ProductCategoryService 接口

package com.artisan.o2o.service;

import java.util.List;

import com.imooc.o2o.entity.ProductCategory;

public interface ProductCategoryService {
   

	List<ProductCategory> queryProductCategoryList(long shopId);

}

ProductCategoryServiceImpl接口实现类

package com.imooc.o2o.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.imooc.o2o.dao.ProductCategoryDao;
import com.imooc.o2o.entity.ProductCategory;
import com.imooc.o2o.service.ProductCategoryService;

/**
 * 
 * 
 * @ClassName: ProductCategoryServiceImpl
 * 
 * @Description: 使用@Service,交由Spring托管
 * 
 * @author: Mr.Yang
 * 
 * @date: 2018年6月9日 上午2:46:07
 */

@Service
public class ProductCategoryServiceImpl implements ProductCategoryService {
   

	@Autowired
	private ProductCategoryDao productCategoryDao;

	@Override
	public List<ProductCategory> queryProductCategoryList(long shopId) {
   
		return productCategoryDao.selectProductCategoryList(shopId);
	}

}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值