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

编程入门 行业动态 更新时间:2024-10-14 16:27:40

SSM项目之<a href=https://www.elefans.com/category/jswz/34/1751652.html style=商铺系统(十六) 商品类别列表展示从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层的开发

本文发布于:2024-02-06 23:49:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1751865.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:商铺   类别   项目   商品   列表

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!