mitao
2025-01-17 afa0dbb4f54e7244835dd67ec33c3e545f122f71
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
<?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.member.mapper.coupon.CouponRelUserMapper">
 
    <resultMap type="CouponRelUser" id="CouponRelUserResult">
        <result property="id"    column="id"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="couponId"    column="coupon_id"    />
        <result property="userId"    column="user_id"    />
    </resultMap>
 
    <sql id="selectCouponRelUserVo">
        select id, del_flag, coupon_id, user_id from t_coupon_rel_user
    </sql>
 
    <select id="selectCouponRelUserList" parameterType="CouponRelUser" resultMap="CouponRelUserResult">
        <include refid="selectCouponRelUserVo"/>
        <where>
            <if test="couponId != null  and couponId != ''"> and coupon_id = #{couponId}</if>
            <if test="userId != null "> and user_id = #{userId}</if>
        </where>
    </select>
 
    <select id="selectCouponRelUserById" parameterType="Long" resultMap="CouponRelUserResult">
        <include refid="selectCouponRelUserVo"/>
        where id = #{id}
    </select>
 
    <insert id="insertCouponRelUser" parameterType="CouponRelUser" useGeneratedKeys="true" keyProperty="id">
        insert into t_coupon_rel_user
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="delFlag != null">del_flag,</if>
            <if test="couponId != null">coupon_id,</if>
            <if test="userId != null">user_id,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="delFlag != null">#{delFlag},</if>
            <if test="couponId != null">#{couponId},</if>
            <if test="userId != null">#{userId},</if>
        </trim>
    </insert>
 
    <update id="updateCouponRelUser" parameterType="CouponRelUser">
        update t_coupon_rel_user
        <trim prefix="SET" suffixOverrides=",">
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="couponId != null">coupon_id = #{couponId},</if>
            <if test="userId != null">user_id = #{userId},</if>
        </trim>
        where id = #{id}
    </update>
 
    <delete id="deleteCouponRelUserById" parameterType="Long">
        delete from t_coupon_rel_user where id = #{id}
    </delete>
 
    <delete id="deleteCouponRelUserByIds" parameterType="String">
        delete from t_coupon_rel_user where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
 
    <select id="listCouponMemberVo" resultType="com.ruoyi.member.domain.vo.MgtCouponMemberListVo">
        SELECT
            tm.member_id memberId,
            tm.user_id userId,
            tm.nick_name nickName,
            tm.real_name realName,
            tm.mobile mobile,
            tm.avatar avatar
        FROM
            t_coupon_rel_user tcru
                INNER JOIN t_member tm ON tm.user_id = tcru.user_id
        WHERE tm.del_flag = 0 AND tcru.del_flag = 0 AND tcru.coupon_id = #{couponId}
    </select>
</mapper>