<mapper namespace="com.bw.dao.ShoppingCarMapper">
<insert id="insertShoppingCar" useGeneratedKeys="true" keyProperty="id" parameterType="shoppingCar">
insert into t_shoppingCar(p_id,u_id,count,priceCount)
values(#{product.id},#{user.id},#{count},#{priceCount})
<selectKey resultType="int" order="AFTER" keyProperty="id">
SELECT LAST_INSERT_ID() AS id
</selectKey>
</insert>
<resultMap type="shoppingCar" id="rm">
<id column="id" property="id"/>
<result column="count" property="count"/>
<result column="priceCount" property="priceCount"/>
<association property="product" javaType="product">
<id column="p_id" property="id"/>
<result column="name" property="name"/>
<result column="price" property="price"/>
<result column="describe" property="describe"/>
</association>
<association property="user" javaType="user">
<id column="u_id" property="id"/>
<result column="uname" property="name"/>
<result column="email" property="email"/>
</association>
</resultMap>
<select id="selectById" parameterType="integer" resultMap ="rm">
select distinct * from t_shoppingCar s,t_order o where s.id !=o.shoppingCar_id and s.p_id=#{id}
</select>
<update id="updateShoppingCar" parameterType="shoppingCar">
update t_shoppingCar set count=#{count} where id=#{id}
</update>
<insert id="insertOeder" parameterType="integer">
insert into t_order(shoppingCar_id) values(#{id})
</insert>
<select id="selectShop" parameterType="user" resultMap="rm">
select distinct s.*,p.* from t_shoppingCar s,t_order o , t_product p where s.id !=o.shoppingCar_id and s.p_id=p.id and s.u_id=#{id}
</select>
<delete id="deleteShop" parameterType="ids">
delete from t_shoppingCar where u_id=#{uid}
<if test="sid!=0">
and id=#{sid}
</if>
</delete>
<update id="updateShop" parameterType="shoppingCar">
update t_shoppingCar set count=#{count},priceCount=#{priceCount} where id=#{id}
</update>
<insert id="insertShoppingCar" useGeneratedKeys="true" keyProperty="id" parameterType="shoppingCar">
insert into t_shoppingCar(p_id,u_id,count,priceCount)
values(#{product.id},#{user.id},#{count},#{priceCount})
<selectKey resultType="int" order="AFTER" keyProperty="id">
SELECT LAST_INSERT_ID() AS id
</selectKey>
</insert>
<resultMap type="shoppingCar" id="rm">
<id column="id" property="id"/>
<result column="count" property="count"/>
<result column="priceCount" property="priceCount"/>
<association property="product" javaType="product">
<id column="p_id" property="id"/>
<result column="name" property="name"/>
<result column="price" property="price"/>
<result column="describe" property="describe"/>
</association>
<association property="user" javaType="user">
<id column="u_id" property="id"/>
<result column="uname" property="name"/>
<result column="email" property="email"/>
</association>
</resultMap>
<select id="selectById" parameterType="integer" resultMap ="rm">
select distinct * from t_shoppingCar s,t_order o where s.id !=o.shoppingCar_id and s.p_id=#{id}
</select>
<update id="updateShoppingCar" parameterType="shoppingCar">
update t_shoppingCar set count=#{count} where id=#{id}
</update>
<insert id="insertOeder" parameterType="integer">
insert into t_order(shoppingCar_id) values(#{id})
</insert>
<select id="selectShop" parameterType="user" resultMap="rm">
select distinct s.*,p.* from t_shoppingCar s,t_order o , t_product p where s.id !=o.shoppingCar_id and s.p_id=p.id and s.u_id=#{id}
</select>
<delete id="deleteShop" parameterType="ids">
delete from t_shoppingCar where u_id=#{uid}
<if test="sid!=0">
and id=#{sid}
</if>
</delete>
<update id="updateShop" parameterType="shoppingCar">
update t_shoppingCar set count=#{count},priceCount=#{priceCount} where id=#{id}
</update>