在测试servicetest的时候报了一个shopCategory看不懂的错

来源:4-5 店铺注册之Service层的实现

慕数据7471109

2018-05-18

http://img.mukewang.com/szimg/5afe7ee800014cc625970461.jpg

写回答

1回答

翔仔

2018-05-18

同学好,应该是和mapper的配置相关,说找不到你的com.o2o.pojo.ShopCategory这个类,请和我的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.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>


0
4
翔仔
回复
慕数据7471109
同学好,你要不仔细检查一下,很多错误都跟不仔细检查相关的。。。你的似乎跟我的不一样啊。。我透过这个不好看的格式都能看出来了:) shop_category_id=#{shopCategory} 这个是啥。。。不对吧
2018-05-18
共4条回复

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

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

5101 学习 · 8139 问题

查看课程