jiangqs
2023-04-30 dca0031ad5552679d6dfbb80d6edd7adbfc7ec2c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?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.ruoyi.order.mapper.order.ShoppingCartMapper">
 
    <resultMap type="ShoppingCart" id="ShoppingCartResult">
        <result property="id"    column="id"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="userId"    column="user_id"    />
        <result property="shopId"    column="shop_id"    />
        <result property="goodsId"    column="goods_id"    />
        <result property="buyNum"    column="buy_num"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateime"    column="update_time"    />
    </resultMap>
 
    <sql id="selectShoppingCartVo">
        select id, del_flag, user_id, shop_id, goods_id, buy_num, create_time, update_time from t_shopping_cart
    </sql>
 
    <select id="selectShoppingCartList" parameterType="ShoppingCart" resultMap="ShoppingCartResult">
        <include refid="selectShoppingCartVo"/>
        <where>
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="shopId != null "> and shop_id = #{shopId}</if>
            <if test="goodsId != null  and goodsId != ''"> and goods_id = #{goodsId}</if>
            <if test="buyNum != null "> and buy_num = #{buyNum}</if>
        </where>
    </select>
 
    <select id="selectShoppingCartById" parameterType="Long" resultMap="ShoppingCartResult">
        <include refid="selectShoppingCartVo"/>
        where id = #{id}
    </select>
 
    <insert id="insertShoppingCart" parameterType="ShoppingCart" useGeneratedKeys="true" keyProperty="id">
        insert into t_shopping_cart
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="delFlag != null">del_flag,</if>
            <if test="userId != null">user_id,</if>
            <if test="shopId != null">shop_id,</if>
            <if test="goodsId != null">goods_id,</if>
            <if test="buyNum != null">buy_num,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateime != null">update_time,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="delFlag != null">#{delFlag},</if>
            <if test="userId != null">#{userId},</if>
            <if test="shopId != null">#{shopId},</if>
            <if test="goodsId != null">#{goodsId},</if>
            <if test="buyNum != null">#{buyNum},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateime != null">#{updateime},</if>
        </trim>
    </insert>
 
    <update id="updateShoppingCart" parameterType="ShoppingCart">
        update t_shopping_cart
        <trim prefix="SET" suffixOverrides=",">
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="userId != null">user_id = #{userId},</if>
            <if test="shopId != null">shop_id = #{shopId},</if>
            <if test="goodsId != null">goods_id = #{goodsId},</if>
            <if test="buyNum != null">buy_num = #{buyNum},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateime != null">update_time = #{updateime},</if>
        </trim>
        where id = #{id}
    </update>
 
    <delete id="deleteShoppingCartById" parameterType="Long">
        update t_shopping_cart set del_flag = 1 where id = #{id}
    </delete>
 
    <delete id="deleteShoppingCartByIds" parameterType="String">
        update t_shopping_cart set del_flag = 1 where id in
        <foreach item="ids" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
 
</mapper>