31 lines
1.4 KiB
XML
31 lines
1.4 KiB
XML
<?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.sky.mapper.ShoppingCartMapper">
|
|
<insert id="insert">
|
|
insert into shopping_cart (name, user_id, dish_id, setmeal_id, dish_flavor, number, amount, image, create_time)
|
|
values (#{name},#{userId},#{dishId},#{setmealId},#{dishFlavor},#{number},#{amount},#{image},#{createTime})
|
|
</insert>
|
|
<insert id="insertBatch" parameterType="list">
|
|
insert into shopping_cart
|
|
(name, image, user_id, dish_id, setmeal_id, dish_flavor, number, amount, create_time)
|
|
values
|
|
<foreach collection="shoppingCartList" item="sc" separator=",">
|
|
(#{sc.name},#{sc.image},#{sc.userId},#{sc.dishId},#{sc.setmealId},#{sc.dishFlavor},#{sc.number},#{sc.amount},#{sc.createTime})
|
|
</foreach>
|
|
</insert>
|
|
<update id="updateNumberById">
|
|
update shopping_cart set number = #{number} where id = #{id}
|
|
</update>
|
|
|
|
<select id="list" resultType="com.sky.entity.ShoppingCart">
|
|
select * from shopping_cart
|
|
<where>
|
|
user_id=#{userId}
|
|
<if test="dishId!=null">and dish_id=#{dishId}</if>
|
|
<if test="setmealId!=null">and setmeal_id=#{setmealId}</if>
|
|
<if test="dishFlavor!=null">and dish_flavor=#{dishFlavor}</if>
|
|
</where>
|
|
order by create_time desc
|
|
</select>
|
|
</mapper> |