前段页面模糊查询输入关键字查询不到并清空,区域分类和二级列表都能查询到返回

来源:6-8 店铺列表展示前端开发

三岁小绵阳

2019-05-17

shoplist.js中图片描述
shopDao的代码<mapper namespace="com.imooc.o2o.dao.ShopDao"> <resultMap type="com.imooc.o2o.entity.Shop" id="shopMap"> <id column="shop_id" property="shopId" /> <result column="shop_name" property="shopName" /> <result column="shop_desc" property="shopDesc" /> <result column="shop_addr" property="shopAddr" /> <result column="phone" property="phone" /> <result column="shop_img" property="shopImg" /> <result column="priority" property="priority" /> <result column="create_time" property="createTime" /> <result column="last_edit_time" property="lastEditTime" /> <result column="enable_status" property="enableStatus" /> <result column="advice" property="advice" /> <association property="area" column="area_id" javaType="com.imooc.o2o.entity.Area"> <id column="area_id" property="areaId" /> <result column="area_name" property="areaName" /> </association> <association property="shopCategory" column="shop_category_id" javaType="com.imooc.o2o.entity.ShopCategory"> <id column="shop_category_id" property="shopCategoryId" /> <result column="shop_category_name" property="shopCategoryName" /> </association> <association property="owner" column="user_id" javaType="com.imooc.o2o.entity.PersonInfo"> <id column="user_id" property="userId" /> <result column="name" property="name" /> </association> </resultMap> <select id="queryShopList" resultMap="shopMap"> 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> <if test="shopCondition.shopCategory != null and shopCondition.shopCategory.shopCategoryId != null"> and s.shop_category_id = #{shopCondition.shopCategory.shopCategoryId} </if> <if test="shopCondition.shopCategory != null and shopCondition.shopCategory.parent!=null and shopCondition.shopCategory.parent.shopCategoryId !=null"> and s.shop_category_id in (select shop_category_id from tb_shop_category WHERE parent_id = #{shopCondition.shopCategory.parent.shopCategoryId}) </if> <if test="shopCondition.area != null and shopCondition.area.areaId != null"> and s.area_id = #{shopCondition.area.areaId} </if> <if test="shopCondition.shopName != null"> and s.shop_name like '%${shopCondition.shopName}%' </if> <if test="shopCondition.enableStatus != null"> and s.enable_status = #{shopCondition.enableStatus} </if> <if test="shopCondition.owner != null and shopCondition.owner.userId != null"> and s.owner_id = #{shopCondition.owner.userId} </if> AND s.area_id=a.area_id AND s.shop_category_id = sc.shop_category_id </where> ORDER BY s.priority DESC LIMIT #{rowIndex},#{pageSize}; </select> <select id="queryShopCount" resultType="int"> SELECT count(1) FROM tb_shop s, tb_area a, tb_shop_category sc <where> <if test="shopCondition.shopCategory != null and shopCondition.shopCategory.shopCategoryId != null"> and s.shop_category_id = #{shopCondition.shopCategory.shopCategoryId} </if> <if test="shopCondition.shopCategory != null and shopCondition.shopCategory.parent!=null and shopCondition.shopCategory.parent.shopCategoryId !=null"> and s.shop_category_id in (select shop_category_id from tb_shop_category WHERE parent_id = #{shopCondition.shopCategory.parent.shopCategoryId}) </if> <if test="shopCondition.area != null and shopCondition.area.areaId != null"> and s.area_id = #{shopCondition.area.areaId} </if> <if test="shopCondition.shopName != null"> and s.shop_name like '%${shopCondition.shopName}%' </if> <if test="shopCondition.enableStatus != null"> and s.enable_status = #{shopCondition.enableStatus} </if> <if test="shopCondition.owner != null and shopCondition.owner.userId != null"> and s.owner_id = #{shopCondition.owner.userId} </if> AND s.area_id=a.area_id AND s.shop_category_id = sc.shop_category_id </where> </select> <select id="queryByShopId" resultMap="shopMap" parameterType="Long"> 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=a.area_id AND s.shop_category_id = sc.shop_category_id AND s.shop_id = #{shopId} </select> <insert id="insertShop" useGeneratedKeys="true" keyColumn="shop_id" keyProperty="shopId"> INSERT INTO tb_shop(owner_id, area_id, shop_category_id, shop_name, shop_desc, shop_addr, phone, shop_img, priority, create_time, last_edit_time, enable_status, advice) VALUES (#{owner.userId},#{area.areaId},#{shopCategory.shopCategoryId},#{shopName}, #{shopDesc},#{shopAddr},#{phone},#{shopImg},#{priority}, #{createTime},#{lastEditTime}, #{enableStatus},#{advice}) </insert> <update id="updateShop" parameterType="com.imooc.o2o.entity.Shop"> update tb_shop <set> <if test="shopName != null">shop_name=#{shopName},</if> <if test="shopDesc != null">shop_desc=#{shopDesc},</if> <if test="shopAddr != null">shop_addr=#{shopAddr},</if> <if test="phone != null">phone=#{phone},</if> <if test="shopImg != null">shop_img=#{shopImg},</if> <if test="priority != null">priority=#{priority},</if> <if test="lastEditTime != null">last_edit_time=#{lastEditTime},</if> <if test="enableStatus != null">enable_status=#{enableStatus},</if> <if test="advice != null">advice=#{advice},</if> <if test="area != null">area_id=#{area.areaId},</if> <if test="shopCategory != null">shop_category_id=#{shopCategory.shopCategoryId}</if> </set> where shop_id=#{shopId} </update> </mapper>

写回答

1回答

翔仔

2019-05-18

同学好,同学再把问题描述得清楚些哈,不用着急贴代码,主要是啥问题,看得不是很懂。。

0
2
翔仔
回复
三岁小绵阳
同学调试一下?看看当时你控制台的sql是啥,复制粘贴到mysql客户端去执行一下,传入当时一模一样的parameters执行看看,为什么不行,然后sql要怎么改才能取到,之后再回溯到代码里,看看当时是怎么拼接的,这个是需要前后端联调才能知道问题呢,直接这样的信息我也没办法精确定位,不过按照这个方法倒推是没问题的,顺便提升下自己解决问题的能力,加油
2019-05-19
共2条回复

Java双版本(SSM到SpringBoot)校园商铺全栈开发

SSM商铺V1.0,解决毕设痛点;SpringBoot商铺V2.0,满足工作刚需

5113 学习 · 8144 问题

查看课程