商铺系统(十六) 商品类别列表展示从Dao到View层的开发"/>
SSM项目之商铺系统(十六) 商品类别列表展示从Dao到View层的开发
文章目录
- 概述
- Dao层
- ProductCategoryDao接口
- ProductCategoryDao Mapper配置文件
- 单元测试
- Service层
- ProductCategoryService 接口
- ProductCategoryServiceImpl接口实现类
- Controller层
- 泛型类 Result
- 状态信息ProductCategoryStateEnum
- 控制类ProductCategoryController
- ShopAdminController 添加路由信息转发到页面
- 单元测试
- productcategorymanage.html
- productcategorymanage.js
- productcategorymanage.css
- 运行测试
概述
进入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//DTD Mapper 3.0//EN"".dtd">
<mapper namespace="com.artisan.o2o.dao.ProductCategoryDao"><select id="selectProductCategoryList" resultType="ProductCategory">SELECTtpc.product_category_id,tpc.product_category_name,tpc.product_category_desc,tpc.priority,tpc.create_time,tpc.last_edit_time,tpc.shop_idFROMtb_product_category tpcWHEREtpc.shop_id = #{shopId}ORDER BYpriority DESC</select>
</mapper>
单元测试
/*** 测试查询* @throws Exception*/@Testpublic 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
pu
更多推荐
SSM项目之商铺系统(十六) 商品类别列表展示从Dao到View层的开发
发布评论