文章目录

  • 概述
  • ShopDao接口
  • ShopDao.xml配置SQL
  • DAO层单元测试
  • Github地址

概述

商铺注册和商铺编辑开发完成之后,我们来做一下商铺列表页面。

  • 列表页面需要支持分页 (MySql数据库,我们使用limit关键字)

ShopDao接口

com.artisan.o2o.dao.ShopDao 新增两个接口方法

  • selectShopCount
  • selectShopList
/*** * * @Title: selectShopList* * @Description: 带有分页功能的查询商铺列表 。* *               可输入的查询条件:商铺名(要求模糊查询) 区域Id 商铺状态 商铺类别 owner*               (注意在sqlmapper中按照前端入参拼装不同的查询语句)* * * @param shopConditionShop* @param rowIndex*            从第几行开始取* @param pageSize*            返回多少行数据(页面上的数据量)* *            比如 rowIndex为1,pageSize为5 即为 从第一行开始取,取5行数据* * @return: List<Shop>*/List<Shop> selectShopList(@Param("shopCondition") Shop shopCondition, @Param("rowIndex") int rowIndex, @Param("pageSize") int pageSize);/*** * * @Title: selectShopCount* * @Description: 按照条件查询 符合前台传入的条件的商铺的总数* * @param shopCondition* * @return: int*/int selectShopCount(@Param("shopCondition") Shop shopCondition);

ShopDao.xml配置SQL

/o2o/src/main/resources/mapper/ShopDao.xml

因为统计的SQL和查询商铺列表的SQL中的where条件是相同的,所以这里我们使用SQL片段的方式,简化配置

Sql中可将重复的sql提取出来,使用时用include引用即可,最终达到sql重用的目的

注意:如果引用其它mapper.xml的sql片段,则在引用时需要加上namespace,如下:<include refid="namespace.sql片段”/>

<sql id="selectShopByCondition"><!-- 可输入的查询条件:商铺名(要求模糊查询) 区域Id 商铺状态 商铺类别 owner (注意在sqlmapper中按照前端入参拼装不同的查询语句) --><!-- 商铺名(要求模糊查询) --><if test="shopCondition.shopName != null and '' != shopCondition.shopName"><!--  两种写法都可以 注意第二种是 ${}传值 --><!-- #{}和${}#{}表示一个占位符号,通过#{}可以实现preparedStatement向占位符中设置值,自动进行java类型和jdbc类型转换,#{}可以有效防止sql注入。 #{}可以接收简单类型值或pojo属性值。如果parameterType传输单个简单类型值,#{}括号中可以是value或其它名称。${}表示拼接sql串,通过${}可以将parameterType 传入的内容拼接在sql中且不进行jdbc类型转换, ${}可以接收简单类型值或pojo属性值,如果parameterType传输单个简单类型值,${}括号中只能是value。--><!-- and s.shop_name like concat('%',#{shopCondition.shopName},'%')-->and s.shop_name like '%${shopCondition.shopName}%'</if><!-- 区域Id  --><if test="shopCondition.area != null and shopCondition.area.areaId != null ">and s.area_id = #{shopCondition.area.areaId}</if><!-- 商铺状态  --><if test="shopCondition.enableStatus !=null">and s.enable_status = #{shopCondition.enableStatus}</if><!-- 商铺类别  --><if test="shopCondition.shopCategory != null and shopCondition.shopCategory.shopCategoryId != null ">and s.shop_category_id = #{shopCondition.shopCategory.shopCategoryId}</if><!-- owner  --><if test="shopCondition.owner != null and shopCondition.owner.userId != null">and s.owner_id = #{shopCondition.owner.userId}</if>   </sql><select id="selectShopList" resultMap="shopMap">SELECTs.shop_id,s.shop_name,s.shop_desc,s.shop_addr,s.phone,s.shop_img,s.priority,s.create_time,s.last_edit_time,s.enable_status,s.advice,a.area_id,a.area_name,sc.shop_category_id,sc.shop_category_nameFROMtb_shop s,tb_area a,tb_shop_category sc<where><include refid="selectShopByCondition"/></where>AND s.area_id = a.area_idAND s.shop_category_id = sc.shop_category_id ORDER BY s.priority DESCLIMIT #{rowIndex} , #{pageSize}</select><select id="selectShopCount" resultType="Integer">SELECTcount(1)FROMtb_shop s,tb_area a,tb_shop_category sc<where><include refid="selectShopByCondition"/></where>AND    s.area_id = a.area_idAND s.shop_category_id = sc.shop_category_id </select>

DAO层单元测试

结合tb_shop中数据,编写如下单元测试

@Testpublic void testSelectShopListAndCount() {Area area = new Area();ShopCategory shopCategory = new ShopCategory();PersonInfo personInfo = new PersonInfo();List<Shop> shopList = null;/*** 可输入的查询条件: 1.商铺名(要求模糊查询) 2.区域Id 3.商铺状态 4.商铺类别 5.owner* * * 首先按照单个条件进行单元测试,然后组合测试**/// 1.商铺名(要求模糊查询)Shop shopCondition = new Shop();shopCondition.setShopName("咖啡");// 1.1 数据库中只有3条数据符合 ,我们分页条件 取出5条,即全部取出 验证rowIndex 和 pageSizeshopList = shopDao.selectShopList(shopCondition, 0, 5);Assert.assertEquals(3, shopList.size());int count1 = shopDao.selectShopCount(shopCondition);Assert.assertEquals(3, count1);// 1.2 数据库中只有3条数据符合 ,我们分页条件 取出2条,即取出前两条 验证rowIndex 和 pageSizeshopList = shopDao.selectShopList(shopCondition, 0, 2);Assert.assertEquals(2, shopList.size());// 总数依然是3条int count2 = shopDao.selectShopCount(shopCondition);Assert.assertEquals(3, count2);// 为了不影响测试, 新实例化出来一个Shop// 2.区域Id 库表中符合条件的记录有10条 areaId=1 10条 areaId=2 3条Shop shopCondition2 = new Shop();area.setAreaId(1);shopCondition2.setArea(area);shopList = shopDao.selectShopList(shopCondition2, 0, 99);Assert.assertEquals(10, shopList.size());area.setAreaId(2);shopCondition2.setArea(area);shopList = shopDao.selectShopList(shopCondition2, 0, 99);Assert.assertEquals(3, shopList.size());// 3.商铺状态 EnableStatus=0 12条 EnableStatus=1 1条Shop shopCondition3 = new Shop();shopCondition3.setEnableStatus(0);shopList = shopDao.selectShopList(shopCondition3, 0, 99);Assert.assertEquals(12, shopList.size());shopCondition3.setEnableStatus(1);shopList = shopDao.selectShopList(shopCondition3, 0, 99);Assert.assertEquals(1, shopList.size());// 4.商铺类别// shop_category_id = 1 9条数据// shop_category_id = 2 3条数据// shop_category_id = 3 1条数据Shop shopCondition4 = new Shop();shopCategory.setShopCategoryId(1L);shopCondition4.setShopCategory(shopCategory);shopList = shopDao.selectShopList(shopCondition4, 0, 99);Assert.assertEquals(9, shopList.size());shopCategory.setShopCategoryId(2L);shopCondition4.setShopCategory(shopCategory);shopList = shopDao.selectShopList(shopCondition4, 0, 99);Assert.assertEquals(3, shopList.size());shopCategory.setShopCategoryId(3L);shopCondition4.setShopCategory(shopCategory);shopList = shopDao.selectShopList(shopCondition4, 0, 99);Assert.assertEquals(1, shopList.size());// 5.owner_id=1 13条 其余0条Shop shopCondition5 = new Shop();personInfo.setUserId(1L);shopCondition5.setOwner(personInfo);shopList = shopDao.selectShopList(shopCondition5, 0, 99);Assert.assertEquals(13, shopList.size());personInfo.setUserId(877L);shopCondition5.setOwner(personInfo);shopList = shopDao.selectShopList(shopCondition5, 0, 99);Assert.assertEquals(0, shopList.size());// 组合场景不全面,仅列几个// 组合场景 owner_id =1 shop_name like %咖啡%Shop shopCondition6 = new Shop();personInfo.setUserId(1L);shopCondition6.setOwner(personInfo);shopCondition6.setShopName("咖啡");shopList = shopDao.selectShopList(shopCondition6, 0, 99);Assert.assertEquals(3, shopList.size());int count6 = shopDao.selectShopCount(shopCondition6);Assert.assertEquals(3, count6);// 组合场景 area_id =1 shop_name like %咖啡% owner_id=1Shop shopCondition7 = new Shop();personInfo.setUserId(1L);area.setAreaId(1);shopCondition7.setOwner(personInfo);shopCondition7.setArea(area);shopCondition7.setShopName("咖啡");shopList = shopDao.selectShopList(shopCondition7, 0, 99);Assert.assertEquals(2, shopList.size());int count7 = shopDao.selectShopCount(shopCondition7);Assert.assertEquals(2, count7);}

单元测试OK

控制台SQL日志如下:

JDBC Connection [com.mchange.v2.c3p0.impl.NewProxyConnection@7fb95505] will not be managed by Spring
==>  Preparing: SELECT s.shop_id, s.shop_name, s.shop_desc, s.shop_addr, s.phone, s.shop_img, s.priority, s.create_time, s.last_edit_time, s.enable_status, s.advice, a.area_id, a.area_name, sc.shop_category_id, sc.shop_category_name FROM tb_shop s, tb_area a, tb_shop_category sc WHERE s.shop_name like '%咖啡%' AND s.area_id = a.area_id AND s.shop_category_id = sc.shop_category_id ORDER BY s.priority DESC LIMIT ? , ?
==> Parameters: 0(Integer), 5(Integer)
<==    Columns: shop_id, shop_name, shop_desc, shop_addr, phone, shop_img, priority, create_time, last_edit_time, enable_status, advice, area_id, area_name, shop_category_id, shop_category_name
<==        Row: 24, 咖啡点, 小工匠的咖啡店, NanJing, 9876553, \upload\item\shopImage\24\2018052118095757182.jpg, 99, 2018-05-21 18:09:57.0, 2018-05-21 18:09:57.0, 0, 审核中, 1, 北京, 1, 咖啡奶茶
<==        Row: 25, 咖啡店Improve, 小工匠的咖啡店Improve, NanJing-Improve, 9876553, \upload\item\shopImage\25\2018052214472089649.jpg, 99, 2018-05-22 14:46:16.0, 2018-05-22 14:46:18.0, 0, 审核中Improve, 1, 北京, 1, 咖啡奶茶
<==        Row: 28, Modify咖啡店, Modify小工匠的咖啡店28, Modify-NanJing218, 12345628, \upload\item\shopImage\28\2018060500333541696.jpg, 78, 2018-05-28 23:13:37.0, 2018-06-06 20:56:31.0, 0, null, 2, 上海, 2, 咖啡
<==      Total: 3
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@12d2ce03]
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@2e6a5539] was not registered for synchronization because synchronization is not active
JDBC Connection [com.mchange.v2.c3p0.impl.NewProxyConnection@6d025197] will not be managed by Spring
==>  Preparing: SELECT count(1) FROM tb_shop s, tb_area a, tb_shop_category sc WHERE s.shop_name like '%咖啡%' AND s.area_id = a.area_id AND s.shop_category_id = sc.shop_category_id
==> Parameters:
<==    Columns: count(1)
<==        Row: 3
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@2e6a5539]
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1b955cac] was not registered for synchronization because synchronization is not active
JDBC Connection [com.mchange.v2.c3p0.impl.NewProxyConnection@5a1de7fb] will not be managed by Spring
==>  Preparing: SELECT s.shop_id, s.shop_name, s.shop_desc, s.shop_addr, s.phone, s.shop_img, s.priority, s.create_time, s.last_edit_time, s.enable_status, s.advice, a.area_id, a.area_name, sc.shop_category_id, sc.shop_category_name FROM tb_shop s, tb_area a, tb_shop_category sc WHERE s.shop_name like '%咖啡%' AND s.area_id = a.area_id AND s.shop_category_id = sc.shop_category_id ORDER BY s.priority DESC LIMIT ? , ?
==> Parameters: 0(Integer), 2(Integer)
<==    Columns: shop_id, shop_name, shop_desc, shop_addr, phone, shop_img, priority, create_time, last_edit_time, enable_status, advice, area_id, area_name, shop_category_id, shop_category_name
<==        Row: 24, 咖啡点, 小工匠的咖啡店, NanJing, 9876553, \upload\item\shopImage\24\2018052118095757182.jpg, 99, 2018-05-21 18:09:57.0, 2018-05-21 18:09:57.0, 0, 审核中, 1, 北京, 1, 咖啡奶茶
<==        Row: 25, 咖啡店Improve, 小工匠的咖啡店Improve, NanJing-Improve, 9876553, \upload\item\shopImage\25\2018052214472089649.jpg, 99, 2018-05-22 14:46:16.0, 2018-05-22 14:46:18.0, 0, 审核中Improve, 1, 北京, 1, 咖啡奶茶
<==      Total: 2
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1b955cac]
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@31dadd46] was not registered for synchronization because synchronization is not active
JDBC Connection [com.mchange.v2.c3p0.impl.NewProxyConnection@12f9af83] will not be managed by Spring
==>  Preparing: SELECT count(1) FROM tb_shop s, tb_area a, tb_shop_category sc WHERE s.shop_name like '%咖啡%' AND s.area_id = a.area_id AND s.shop_category_id = sc.shop_category_id
==> Parameters:
<==    Columns: count(1)
<==        Row: 3
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@31dadd46]
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@ee86bcb] was not registered for synchronization because synchronization is not active
JDBC Connection [com.mchange.v2.c3p0.impl.NewProxyConnection@19835e64] will not be managed by Spring
==>  Preparing: SELECT s.shop_id, s.shop_name, s.shop_desc, s.shop_addr, s.phone, s.shop_img, s.priority, s.create_time, s.last_edit_time, s.enable_status, s.advice, a.area_id, a.area_name, sc.shop_category_id, sc.shop_category_name FROM tb_shop s, tb_area a, tb_shop_category sc WHERE s.area_id = ? AND s.area_id = a.area_id AND s.shop_category_id = sc.shop_category_id ORDER BY s.priority DESC LIMIT ? , ?
==> Parameters: 1(Integer), 0(Integer), 99(Integer)
<==    Columns: shop_id, shop_name, shop_desc, shop_addr, phone, shop_img, priority, create_time, last_edit_time, enable_status, advice, area_id, area_name, shop_category_id, shop_category_name
<==        Row: 33, Artisan, ArtisanDesc, NanJing, 123456, /xxx/xxx, 99, 2018-06-06 17:54:45.0, 2018-06-06 17:54:45.0, 0, Waring, 1, 北京, 1, 咖啡奶茶
<==        Row: 25, 咖啡店Improve, 小工匠的咖啡店Improve, NanJing-Improve, 9876553, \upload\item\shopImage\25\2018052214472089649.jpg, 99, 2018-05-22 14:46:16.0, 2018-05-22 14:46:18.0, 0, 审核中Improve, 1, 北京, 1, 咖啡奶茶
<==        Row: 36, Artisan, ArtisanDesc, NanJing, 123456, /xxx/xxx, 99, 2018-06-06 18:01:49.0, 2018-06-06 18:01:49.0, 0, Waring, 1, 北京, 1, 咖啡奶茶
<==        Row: 31, Artisan, ArtisanDesc, NanJing, 123456, /xxx/xxx, 99, 2018-06-06 17:52:58.0, 2018-06-06 17:52:58.0, 0, Waring, 1, 北京, 1, 咖啡奶茶
<==        Row: 34, Artisan, ArtisanDesc, NanJing, 123456, /xxx/xxx, 99, 2018-06-06 17:55:18.0, 2018-06-06 17:55:18.0, 0, Waring, 1, 北京, 1, 咖啡奶茶
<==        Row: 32, Artisan, ArtisanDesc, NanJing, 123456, /xxx/xxx, 99, 2018-06-06 17:54:24.0, 2018-06-06 17:54:24.0, 0, Waring, 1, 北京, 1, 咖啡奶茶
<==        Row: 24, 咖啡点, 小工匠的咖啡店, NanJing, 9876553, \upload\item\shopImage\24\2018052118095757182.jpg, 99, 2018-05-21 18:09:57.0, 2018-05-21 18:09:57.0, 0, 审核中, 1, 北京, 1, 咖啡奶茶
<==        Row: 35, Artisan, ArtisanDesc, NanJing, 123456, /xxx/xxx, 99, 2018-06-06 17:59:29.0, 2018-06-06 17:59:29.0, 0, Waring, 1, 北京, 1, 咖啡奶茶
<==        Row: 27, 星巴克, 星巴克复兴街店, 复兴街, 56544565, \upload\item\shopImage\27\2018052816202438800.jpg, null, 2018-05-28 16:20:24.0, 2018-05-28 16:20:24.0, 0, null, 1, 北京, 1, 咖啡奶茶
<==        Row: 30, 优乐美, 优乐美奶茶店, 复兴街, 123456, \upload\item\shopImage\30\2018053001010899137.png, null, 2018-05-30 01:01:07.0, 2018-05-30 01:01:07.0, 0, null, 1, 北京, 3, 奶茶
<==      Total: 10
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@ee86bcb]
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7d1cfb8b] was not registered for synchronization because synchronization is not active
JDBC Connection [com.mchange.v2.c3p0.impl.NewProxyConnection@2e1ef60] will not be managed by Spring
==>  Preparing: SELECT s.shop_id, s.shop_name, s.shop_desc, s.shop_addr, s.phone, s.shop_img, s.priority, s.create_time, s.last_edit_time, s.enable_status, s.advice, a.area_id, a.area_name, sc.shop_category_id, sc.shop_category_name FROM tb_shop s, tb_area a, tb_shop_category sc WHERE s.area_id = ? AND s.area_id = a.area_id AND s.shop_category_id = sc.shop_category_id ORDER BY s.priority DESC LIMIT ? , ?
==> Parameters: 2(Integer), 0(Integer), 99(Integer)
<==    Columns: shop_id, shop_name, shop_desc, shop_addr, phone, shop_img, priority, create_time, last_edit_time, enable_status, advice, area_id, area_name, shop_category_id, shop_category_name
<==        Row: 28, Modify咖啡店, Modify小工匠的咖啡店28, Modify-NanJing218, 12345628, \upload\item\shopImage\28\2018060500333541696.jpg, 78, 2018-05-28 23:13:37.0, 2018-06-06 20:56:31.0, 0, null, 2, 上海, 2, 咖啡
<==        Row: 5, ArtisanUP, ArtisanDescUP, NanJingUP, 123456UP, /xxx/xxx/UP, 66, 2018-05-18 02:17:26.0, 2018-06-06 18:01:50.0, 1, Waring UP, 2, 上海, 2, 咖啡
<==        Row: 29, NEW, eeeee, NEW ADDR, 123, \upload\item\shopImage\29\2018052914541464482.png, null, 2018-05-29 14:54:14.0, 2018-05-29 14:54:14.0, 0, null, 2, 上海, 2, 咖啡
<==      Total: 3
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7d1cfb8b]
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7b94089b] was not registered for synchronization because synchronization is not active
JDBC Connection [com.mchange.v2.c3p0.impl.NewProxyConnection@47f9738] will not be managed by Spring
==>  Preparing: SELECT s.shop_id, s.shop_name, s.shop_desc, s.shop_addr, s.phone, s.shop_img, s.priority, s.create_time, s.last_edit_time, s.enable_status, s.advice, a.area_id, a.area_name, sc.shop_category_id, sc.shop_category_name FROM tb_shop s, tb_area a, tb_shop_category sc WHERE s.enable_status = ? AND s.area_id = a.area_id AND s.shop_category_id = sc.shop_category_id ORDER BY s.priority DESC LIMIT ? , ?
==> Parameters: 0(Integer), 0(Integer), 99(Integer)
<==    Columns: shop_id, shop_name, shop_desc, shop_addr, phone, shop_img, priority, create_time, last_edit_time, enable_status, advice, area_id, area_name, shop_category_id, shop_category_name
<==        Row: 24, 咖啡点, 小工匠的咖啡店, NanJing, 9876553, \upload\item\shopImage\24\2018052118095757182.jpg, 99, 2018-05-21 18:09:57.0, 2018-05-21 18:09:57.0, 0, 审核中, 1, 北京, 1, 咖啡奶茶
<==        Row: 25, 咖啡店Improve, 小工匠的咖啡店Improve, NanJing-Improve, 9876553, \upload\item\shopImage\25\2018052214472089649.jpg, 99, 2018-05-22 14:46:16.0, 2018-05-22 14:46:18.0, 0, 审核中Improve, 1, 北京, 1, 咖啡奶茶
<==        Row: 31, Artisan, ArtisanDesc, NanJing, 123456, /xxx/xxx, 99, 2018-06-06 17:52:58.0, 2018-06-06 17:52:58.0, 0, Waring, 1, 北京, 1, 咖啡奶茶
<==        Row: 32, Artisan, ArtisanDesc, NanJing, 123456, /xxx/xxx, 99, 2018-06-06 17:54:24.0, 2018-06-06 17:54:24.0, 0, Waring, 1, 北京, 1, 咖啡奶茶
<==        Row: 33, Artisan, ArtisanDesc, NanJing, 123456, /xxx/xxx, 99, 2018-06-06 17:54:45.0, 2018-06-06 17:54:45.0, 0, Waring, 1, 北京, 1, 咖啡奶茶
<==        Row: 34, Artisan, ArtisanDesc, NanJing, 123456, /xxx/xxx, 99, 2018-06-06 17:55:18.0, 2018-06-06 17:55:18.0, 0, Waring, 1, 北京, 1, 咖啡奶茶
<==        Row: 35, Artisan, ArtisanDesc, NanJing, 123456, /xxx/xxx, 99, 2018-06-06 17:59:29.0, 2018-06-06 17:59:29.0, 0, Waring, 1, 北京, 1, 咖啡奶茶
<==        Row: 36, Artisan, ArtisanDesc, NanJing, 123456, /xxx/xxx, 99, 2018-06-06 18:01:49.0, 2018-06-06 18:01:49.0, 0, Waring, 1, 北京, 1, 咖啡奶茶
<==        Row: 28, Modify咖啡店, Modify小工匠的咖啡店28, Modify-NanJing218, 12345628, \upload\item\shopImage\28\2018060500333541696.jpg, 78, 2018-05-28 23:13:37.0, 2018-06-06 20:56:31.0, 0, null, 2, 上海, 2, 咖啡
<==        Row: 27, 星巴克, 星巴克复兴街店, 复兴街, 56544565, \upload\item\shopImage\27\2018052816202438800.jpg, null, 2018-05-28 16:20:24.0, 2018-05-28 16:20:24.0, 0, null, 1, 北京, 1, 咖啡奶茶
<==        Row: 29, NEW, eeeee, NEW ADDR, 123, \upload\item\shopImage\29\2018052914541464482.png, null, 2018-05-29 14:54:14.0, 2018-05-29 14:54:14.0, 0, null, 2, 上海, 2, 咖啡
<==        Row: 30, 优乐美, 优乐美奶茶店, 复兴街, 123456, \upload\item\shopImage\30\2018053001010899137.png, null, 2018-05-30 01:01:07.0, 2018-05-30 01:01:07.0, 0, null, 1, 北京, 3, 奶茶
<==      Total: 12
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7b94089b]
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@21a21c64] was not registered for synchronization because synchronization is not active
JDBC Connection [com.mchange.v2.c3p0.impl.NewProxyConnection@531f4093] will not be managed by Spring
==>  Preparing: SELECT s.shop_id, s.shop_name, s.shop_desc, s.shop_addr, s.phone, s.shop_img, s.priority, s.create_time, s.last_edit_time, s.enable_status, s.advice, a.area_id, a.area_name, sc.shop_category_id, sc.shop_category_name FROM tb_shop s, tb_area a, tb_shop_category sc WHERE s.enable_status = ? AND s.area_id = a.area_id AND s.shop_category_id = sc.shop_category_id ORDER BY s.priority DESC LIMIT ? , ?
==> Parameters: 1(Integer), 0(Integer), 99(Integer)
<==    Columns: shop_id, shop_name, shop_desc, shop_addr, phone, shop_img, priority, create_time, last_edit_time, enable_status, advice, area_id, area_name, shop_category_id, shop_category_name
<==        Row: 5, ArtisanUP, ArtisanDescUP, NanJingUP, 123456UP, /xxx/xxx/UP, 66, 2018-05-18 02:17:26.0, 2018-06-06 18:01:50.0, 1, Waring UP, 2, 上海, 2, 咖啡
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@21a21c64]
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@16fdec90] was not registered for synchronization because synchronization is not active
JDBC Connection [com.mchange.v2.c3p0.impl.NewProxyConnection@40238dd0] will not be managed by Spring
==>  Preparing: SELECT s.shop_id, s.shop_name, s.shop_desc, s.shop_addr, s.phone, s.shop_img, s.priority, s.create_time, s.last_edit_time, s.enable_status, s.advice, a.area_id, a.area_name, sc.shop_category_id, sc.shop_category_name FROM tb_shop s, tb_area a, tb_shop_category sc WHERE s.shop_category_id = ? AND s.area_id = a.area_id AND s.shop_category_id = sc.shop_category_id ORDER BY s.priority DESC LIMIT ? , ?
==> Parameters: 1(Long), 0(Integer), 99(Integer)
<==    Columns: shop_id, shop_name, shop_desc, shop_addr, phone, shop_img, priority, create_time, last_edit_time, enable_status, advice, area_id, area_name, shop_category_id, shop_category_name
<==        Row: 35, Artisan, ArtisanDesc, NanJing, 123456, /xxx/xxx, 99, 2018-06-06 17:59:29.0, 2018-06-06 17:59:29.0, 0, Waring, 1, 北京, 1, 咖啡奶茶
<==        Row: 33, Artisan, ArtisanDesc, NanJing, 123456, /xxx/xxx, 99, 2018-06-06 17:54:45.0, 2018-06-06 17:54:45.0, 0, Waring, 1, 北京, 1, 咖啡奶茶
<==        Row: 36, Artisan, ArtisanDesc, NanJing, 123456, /xxx/xxx, 99, 2018-06-06 18:01:49.0, 2018-06-06 18:01:49.0, 0, Waring, 1, 北京, 1, 咖啡奶茶
<==        Row: 32, Artisan, ArtisanDesc, NanJing, 123456, /xxx/xxx, 99, 2018-06-06 17:54:24.0, 2018-06-06 17:54:24.0, 0, Waring, 1, 北京, 1, 咖啡奶茶
<==        Row: 34, Artisan, ArtisanDesc, NanJing, 123456, /xxx/xxx, 99, 2018-06-06 17:55:18.0, 2018-06-06 17:55:18.0, 0, Waring, 1, 北京, 1, 咖啡奶茶
<==        Row: 25, 咖啡店Improve, 小工匠的咖啡店Improve, NanJing-Improve, 9876553, \upload\item\shopImage\25\2018052214472089649.jpg, 99, 2018-05-22 14:46:16.0, 2018-05-22 14:46:18.0, 0, 审核中Improve, 1, 北京, 1, 咖啡奶茶
<==        Row: 31, Artisan, ArtisanDesc, NanJing, 123456, /xxx/xxx, 99, 2018-06-06 17:52:58.0, 2018-06-06 17:52:58.0, 0, Waring, 1, 北京, 1, 咖啡奶茶
<==        Row: 24, 咖啡点, 小工匠的咖啡店, NanJing, 9876553, \upload\item\shopImage\24\2018052118095757182.jpg, 99, 2018-05-21 18:09:57.0, 2018-05-21 18:09:57.0, 0, 审核中, 1, 北京, 1, 咖啡奶茶
<==        Row: 27, 星巴克, 星巴克复兴街店, 复兴街, 56544565, \upload\item\shopImage\27\2018052816202438800.jpg, null, 2018-05-28 16:20:24.0, 2018-05-28 16:20:24.0, 0, null, 1, 北京, 1, 咖啡奶茶
<==      Total: 9
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@16fdec90]
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@2f1de2d6] was not registered for synchronization because synchronization is not active
JDBC Connection [com.mchange.v2.c3p0.impl.NewProxyConnection@79517588] will not be managed by Spring
==>  Preparing: SELECT s.shop_id, s.shop_name, s.shop_desc, s.shop_addr, s.phone, s.shop_img, s.priority, s.create_time, s.last_edit_time, s.enable_status, s.advice, a.area_id, a.area_name, sc.shop_category_id, sc.shop_category_name FROM tb_shop s, tb_area a, tb_shop_category sc WHERE s.shop_category_id = ? AND s.area_id = a.area_id AND s.shop_category_id = sc.shop_category_id ORDER BY s.priority DESC LIMIT ? , ?
==> Parameters: 2(Long), 0(Integer), 99(Integer)
<==    Columns: shop_id, shop_name, shop_desc, shop_addr, phone, shop_img, priority, create_time, last_edit_time, enable_status, advice, area_id, area_name, shop_category_id, shop_category_name
<==        Row: 28, Modify咖啡店, Modify小工匠的咖啡店28, Modify-NanJing218, 12345628, \upload\item\shopImage\28\2018060500333541696.jpg, 78, 2018-05-28 23:13:37.0, 2018-06-06 20:56:31.0, 0, null, 2, 上海, 2, 咖啡
<==        Row: 5, ArtisanUP, ArtisanDescUP, NanJingUP, 123456UP, /xxx/xxx/UP, 66, 2018-05-18 02:17:26.0, 2018-06-06 18:01:50.0, 1, Waring UP, 2, 上海, 2, 咖啡
<==        Row: 29, NEW, eeeee, NEW ADDR, 123, \upload\item\shopImage\29\2018052914541464482.png, null, 2018-05-29 14:54:14.0, 2018-05-29 14:54:14.0, 0, null, 2, 上海, 2, 咖啡
<==      Total: 3
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@2f1de2d6]
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@403f0a22] was not registered for synchronization because synchronization is not active
JDBC Connection [com.mchange.v2.c3p0.impl.NewProxyConnection@4c51cf28] will not be managed by Spring
==>  Preparing: SELECT s.shop_id, s.shop_name, s.shop_desc, s.shop_addr, s.phone, s.shop_img, s.priority, s.create_time, s.last_edit_time, s.enable_status, s.advice, a.area_id, a.area_name, sc.shop_category_id, sc.shop_category_name FROM tb_shop s, tb_area a, tb_shop_category sc WHERE s.shop_category_id = ? AND s.area_id = a.area_id AND s.shop_category_id = sc.shop_category_id ORDER BY s.priority DESC LIMIT ? , ?
==> Parameters: 3(Long), 0(Integer), 99(Integer)
<==    Columns: shop_id, shop_name, shop_desc, shop_addr, phone, shop_img, priority, create_time, last_edit_time, enable_status, advice, area_id, area_name, shop_category_id, shop_category_name
<==        Row: 30, 优乐美, 优乐美奶茶店, 复兴街, 123456, \upload\item\shopImage\30\2018053001010899137.png, null, 2018-05-30 01:01:07.0, 2018-05-30 01:01:07.0, 0, null, 1, 北京, 3, 奶茶
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@403f0a22]
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@3e7dd664] was not registered for synchronization because synchronization is not active
JDBC Connection [com.mchange.v2.c3p0.impl.NewProxyConnection@4b1d6571] will not be managed by Spring
==>  Preparing: SELECT s.shop_id, s.shop_name, s.shop_desc, s.shop_addr, s.phone, s.shop_img, s.priority, s.create_time, s.last_edit_time, s.enable_status, s.advice, a.area_id, a.area_name, sc.shop_category_id, sc.shop_category_name FROM tb_shop s, tb_area a, tb_shop_category sc WHERE s.owner_id = ? AND s.area_id = a.area_id AND s.shop_category_id = sc.shop_category_id ORDER BY s.priority DESC LIMIT ? , ?
==> Parameters: 1(Long), 0(Integer), 99(Integer)
<==    Columns: shop_id, shop_name, shop_desc, shop_addr, phone, shop_img, priority, create_time, last_edit_time, enable_status, advice, area_id, area_name, shop_category_id, shop_category_name
<==        Row: 35, Artisan, ArtisanDesc, NanJing, 123456, /xxx/xxx, 99, 2018-06-06 17:59:29.0, 2018-06-06 17:59:29.0, 0, Waring, 1, 北京, 1, 咖啡奶茶
<==        Row: 25, 咖啡店Improve, 小工匠的咖啡店Improve, NanJing-Improve, 9876553, \upload\item\shopImage\25\2018052214472089649.jpg, 99, 2018-05-22 14:46:16.0, 2018-05-22 14:46:18.0, 0, 审核中Improve, 1, 北京, 1, 咖啡奶茶
<==        Row: 33, Artisan, ArtisanDesc, NanJing, 123456, /xxx/xxx, 99, 2018-06-06 17:54:45.0, 2018-06-06 17:54:45.0, 0, Waring, 1, 北京, 1, 咖啡奶茶
<==        Row: 34, Artisan, ArtisanDesc, NanJing, 123456, /xxx/xxx, 99, 2018-06-06 17:55:18.0, 2018-06-06 17:55:18.0, 0, Waring, 1, 北京, 1, 咖啡奶茶
<==        Row: 24, 咖啡点, 小工匠的咖啡店, NanJing, 9876553, \upload\item\shopImage\24\2018052118095757182.jpg, 99, 2018-05-21 18:09:57.0, 2018-05-21 18:09:57.0, 0, 审核中, 1, 北京, 1, 咖啡奶茶
<==        Row: 32, Artisan, ArtisanDesc, NanJing, 123456, /xxx/xxx, 99, 2018-06-06 17:54:24.0, 2018-06-06 17:54:24.0, 0, Waring, 1, 北京, 1, 咖啡奶茶
<==        Row: 31, Artisan, ArtisanDesc, NanJing, 123456, /xxx/xxx, 99, 2018-06-06 17:52:58.0, 2018-06-06 17:52:58.0, 0, Waring, 1, 北京, 1, 咖啡奶茶
<==        Row: 36, Artisan, ArtisanDesc, NanJing, 123456, /xxx/xxx, 99, 2018-06-06 18:01:49.0, 2018-06-06 18:01:49.0, 0, Waring, 1, 北京, 1, 咖啡奶茶
<==        Row: 28, Modify咖啡店, Modify小工匠的咖啡店28, Modify-NanJing218, 12345628, \upload\item\shopImage\28\2018060500333541696.jpg, 78, 2018-05-28 23:13:37.0, 2018-06-06 20:56:31.0, 0, null, 2, 上海, 2, 咖啡
<==        Row: 5, ArtisanUP, ArtisanDescUP, NanJingUP, 123456UP, /xxx/xxx/UP, 66, 2018-05-18 02:17:26.0, 2018-06-06 18:01:50.0, 1, Waring UP, 2, 上海, 2, 咖啡
<==        Row: 30, 优乐美, 优乐美奶茶店, 复兴街, 123456, \upload\item\shopImage\30\2018053001010899137.png, null, 2018-05-30 01:01:07.0, 2018-05-30 01:01:07.0, 0, null, 1, 北京, 3, 奶茶
<==        Row: 29, NEW, eeeee, NEW ADDR, 123, \upload\item\shopImage\29\2018052914541464482.png, null, 2018-05-29 14:54:14.0, 2018-05-29 14:54:14.0, 0, null, 2, 上海, 2, 咖啡
<==        Row: 27, 星巴克, 星巴克复兴街店, 复兴街, 56544565, \upload\item\shopImage\27\2018052816202438800.jpg, null, 2018-05-28 16:20:24.0, 2018-05-28 16:20:24.0, 0, null, 1, 北京, 1, 咖啡奶茶
<==      Total: 13
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@3e7dd664]
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@16414e40] was not registered for synchronization because synchronization is not active
JDBC Connection [com.mchange.v2.c3p0.impl.NewProxyConnection@525575] will not be managed by Spring
==>  Preparing: SELECT s.shop_id, s.shop_name, s.shop_desc, s.shop_addr, s.phone, s.shop_img, s.priority, s.create_time, s.last_edit_time, s.enable_status, s.advice, a.area_id, a.area_name, sc.shop_category_id, sc.shop_category_name FROM tb_shop s, tb_area a, tb_shop_category sc WHERE s.owner_id = ? AND s.area_id = a.area_id AND s.shop_category_id = sc.shop_category_id ORDER BY s.priority DESC LIMIT ? , ?
==> Parameters: 877(Long), 0(Integer), 99(Integer)
<==      Total: 0
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@16414e40]
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@db57326] was not registered for synchronization because synchronization is not active
JDBC Connection [com.mchange.v2.c3p0.impl.NewProxyConnection@4748a0f9] will not be managed by Spring
==>  Preparing: SELECT s.shop_id, s.shop_name, s.shop_desc, s.shop_addr, s.phone, s.shop_img, s.priority, s.create_time, s.last_edit_time, s.enable_status, s.advice, a.area_id, a.area_name, sc.shop_category_id, sc.shop_category_name FROM tb_shop s, tb_area a, tb_shop_category sc WHERE s.shop_name like '%咖啡%' and s.owner_id = ? AND s.area_id = a.area_id AND s.shop_category_id = sc.shop_category_id ORDER BY s.priority DESC LIMIT ? , ?
==> Parameters: 1(Long), 0(Integer), 99(Integer)
<==    Columns: shop_id, shop_name, shop_desc, shop_addr, phone, shop_img, priority, create_time, last_edit_time, enable_status, advice, area_id, area_name, shop_category_id, shop_category_name
<==        Row: 24, 咖啡点, 小工匠的咖啡店, NanJing, 9876553, \upload\item\shopImage\24\2018052118095757182.jpg, 99, 2018-05-21 18:09:57.0, 2018-05-21 18:09:57.0, 0, 审核中, 1, 北京, 1, 咖啡奶茶
<==        Row: 25, 咖啡店Improve, 小工匠的咖啡店Improve, NanJing-Improve, 9876553, \upload\item\shopImage\25\2018052214472089649.jpg, 99, 2018-05-22 14:46:16.0, 2018-05-22 14:46:18.0, 0, 审核中Improve, 1, 北京, 1, 咖啡奶茶
<==        Row: 28, Modify咖啡店, Modify小工匠的咖啡店28, Modify-NanJing218, 12345628, \upload\item\shopImage\28\2018060500333541696.jpg, 78, 2018-05-28 23:13:37.0, 2018-06-06 20:56:31.0, 0, null, 2, 上海, 2, 咖啡
<==      Total: 3
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@db57326]
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@6dee4f1b] was not registered for synchronization because synchronization is not active
JDBC Connection [com.mchange.v2.c3p0.impl.NewProxyConnection@6ee6f53] will not be managed by Spring
==>  Preparing: SELECT count(1) FROM tb_shop s, tb_area a, tb_shop_category sc WHERE s.shop_name like '%咖啡%' and s.owner_id = ? AND s.area_id = a.area_id AND s.shop_category_id = sc.shop_category_id
==> Parameters: 1(Long)
<==    Columns: count(1)
<==        Row: 3
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@6dee4f1b]
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@31bcf236] was not registered for synchronization because synchronization is not active
JDBC Connection [com.mchange.v2.c3p0.impl.NewProxyConnection@4fad9bb2] will not be managed by Spring
==>  Preparing: SELECT s.shop_id, s.shop_name, s.shop_desc, s.shop_addr, s.phone, s.shop_img, s.priority, s.create_time, s.last_edit_time, s.enable_status, s.advice, a.area_id, a.area_name, sc.shop_category_id, sc.shop_category_name FROM tb_shop s, tb_area a, tb_shop_category sc WHERE s.shop_name like '%咖啡%' and s.area_id = ? and s.owner_id = ? AND s.area_id = a.area_id AND s.shop_category_id = sc.shop_category_id ORDER BY s.priority DESC LIMIT ? , ?
==> Parameters: 1(Integer), 1(Long), 0(Integer), 99(Integer)
<==    Columns: shop_id, shop_name, shop_desc, shop_addr, phone, shop_img, priority, create_time, last_edit_time, enable_status, advice, area_id, area_name, shop_category_id, shop_category_name
<==        Row: 24, 咖啡点, 小工匠的咖啡店, NanJing, 9876553, \upload\item\shopImage\24\2018052118095757182.jpg, 99, 2018-05-21 18:09:57.0, 2018-05-21 18:09:57.0, 0, 审核中, 1, 北京, 1, 咖啡奶茶
<==        Row: 25, 咖啡店Improve, 小工匠的咖啡店Improve, NanJing-Improve, 9876553, \upload\item\shopImage\25\2018052214472089649.jpg, 99, 2018-05-22 14:46:16.0, 2018-05-22 14:46:18.0, 0, 审核中Improve, 1, 北京, 1, 咖啡奶茶
<==      Total: 2
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@31bcf236]
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7241a47d] was not registered for synchronization because synchronization is not active
JDBC Connection [com.mchange.v2.c3p0.impl.NewProxyConnection@5dcd8c7a] will not be managed by Spring
==>  Preparing: SELECT count(1) FROM tb_shop s, tb_area a, tb_shop_category sc WHERE s.shop_name like '%咖啡%' and s.area_id = ? and s.owner_id = ? AND s.area_id = a.area_id AND s.shop_category_id = sc.shop_category_id
==> Parameters: 1(Integer), 1(Long)
<==    Columns: count(1)
<==        Row: 2
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7241a47d]
六月 06, 2018 10:30:47 下午 org.springframework.context.support.GenericApplicationContext doClose
信息: Closing org.springframework.context.support.GenericApplicationContext@45afc369: startup date [Wed Jun 06 22:30:42 BOT 2018]; root of context hierarchy

Github地址

代码地址: https://github.com/yangshangwei/o2o

实战SSM_O2O商铺_21【商铺列表】Dao层开发相关推荐

  1. SpringBoot实现Java高并发秒杀系统之DAO层开发(一)

    SpringBoot实现Java高并发秒杀系统之DAO层开发(一) 秒杀系统在如今电商项目中是很常见的,最近在学习电商项目时讲到了秒杀系统的实现,于是打算使用SpringBoot框架学习一下秒杀系统( ...

  2. Mybatis 原始Dao层开发

    对Mybatis进行原始Dao层开发的举例子: 定义获取session工具类: package com.langsin.unit;import java.io.InputStream;import o ...

  3. 校园O2O商铺平台-店铺注册DAO层与图片处理

    DAO层之新增店铺 正在更新 DAO层之更新店铺 正在更新 Thumbnailator图片处理和封装Util 正在更新 Dto之ShopExecution的实现 正在更新

  4. (转)MyBatis框架的学习(三)——Dao层开发方法

    http://blog.csdn.net/yerenyuan_pku/article/details/71700957 使用MyBatis开发Dao层,通常有两个方法,即原始Dao开发方法和Mappe ...

  5. 淘淘商城第53讲——商品搜索之dao层开发

    终于进入到商品搜索功能的开发中了,本文我来教大家编写实现商品搜索功能的dao层代码. 我们现在是在开发商品搜索这一功能,那么肯定是要访问索引库的,很显然在dao层中应该使用HttpSolrClient ...

  6. 实战SSM_O2O商铺_17【商铺编辑】Dao层开发

    文章目录 概述 ShopDao接口 ShopDao映射文件 单元测试 Github地址 概述 ShopDao接口 com.artisan.o2o.dao.ShopDao.java 新增查询接口 /** ...

  7. MyBatis DAO层开发——Mapper动态代理方式

    SqlMapConfig.xml <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE conf ...

  8. Spring整合Mybatis之DAO层、Service层开发

    3. Spring整合Mybatis编程DAO层开发 1. 项目引入相关依赖spring mybatis mysql mybatis-spring druid2. 编写spring.xml整合:spr ...

  9. SpringBoot实现Java高并发秒杀系统之Service层开发(二)

    继上一篇文章:SpringBoot实现Java高并发秒杀系统之DAO层开发 我们创建了SpringBoot项目并熟悉了秒杀系统的表设计,下面我们将讲解一下秒杀系统的核心部分:Service业务层的开发 ...

最新文章

  1. [转载]Oracle 游标使用全解
  2. python如何读取配置文件获取url以及hhead_python爬虫小工具:(模块:copyhreaders,直接复制头文件,无须挨个添加双引号)...
  3. 海思Hi3516DV300 SDK首次安装以及编译问题的解决
  4. 网络切片,切开5G万亿级市场“大面包”
  5. USACO Section1.2 Your Ride Is Here(水题)
  6. Python入门学习笔记(6)
  7. Cocos2D中图片加-hd后缀的说明
  8. ICMP协议的作用是什么?
  9. mscorsvw.exe进程占用CPU资源高居不下
  10. oracle从11.0.2.4.0打PSU 11.0.2.4.8
  11. 3月21日短线黑马牛股公开验证
  12. 怎么改图片大小kb像素不变?一键快速修改jpg图片大小?
  13. 2026年中国软件定义存储市场容量将接近45.1亿美元
  14. Java中日志的使用
  15. css图片精灵定位_CSS精灵图片(CSS sprite)使用心得
  16. 头文件和库文件区别,动态库和静态库的区别,动静态库的生成
  17. (9) iphone 开发 AppSettings , 系统setting与应用程序setting间的数据控制
  18. ASP.NET Web API与Owin OAuth:使用Access Toke调用受保护的API(二)
  19. 教你如何在win11家庭版中添加【本地安全策略】
  20. Vue、Html前端页面引入live2dw 使用看板娘

热门文章

  1. OpenCV-Python Feature2D 特征点检测 (SIFT,SURF)
  2. ROC曲线和 AUC值的计算
  3. Leetcode 剑指 Offer 11. 旋转数组的最小数字 (每日一题 20210916)
  4. 在单链表和双链表中删除倒数第K个节点
  5. 遍历二叉树的神级方法(Morris遍历)
  6. 论文笔记 Hierarchical Reinforcement Learning for Scarce Medical Resource Allocation
  7. NTU课程笔记 mas714复习:例题
  8. tensorflow从入门到精通100讲(四)-细粒度的情感分析Gated Convolutional Networks
  9. Meanshift解析
  10. 苹果企业证书_企业签名App稳定吗?