add
yj
2024-12-05 b9900893177c78fc559223521fe839aa21000017
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?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.iotechn.unimall.data.mapper.AppraiseMapper">
 
 
    <select id="selectUserAppraisePage" resultType="com.iotechn.unimall.data.dto.appraise.AppraiseResponseDTO">
        select
            a.id as id,
            a.gmt_create as gmtCreate,
            a.gmt_update as gmtUpdate,
            a.content as content,
            a.score as score,
            a.user_id as userId,
            u.nickname as userNickName,
            u.avatar_url as userAvatarUrl,
            a.order_id as orderId,
            a.spu_id as spuId,
            a.sku_id as skuId,
            sk.title as skuTitle,
            sp.title as spuTitle
        from
            unimall_appraise a,
            unimall_user u,
            unimall_sku sk,
            unimall_spu sp
        where
            a.user_id = u.id
            and a.spu_id = sp.id
            and a.sku_id = sk.id
            and a.user_id = #{userId}
    </select>
 
    <select id="selectSpuAppraisePage" resultType="com.iotechn.unimall.data.dto.appraise.AppraiseResponseDTO">
        select
            a.id as id,
            a.gmt_create as gmtCreate,
            a.gmt_update as gmtUpdate,
            a.content as content,
            a.score as score,
            a.user_id as userId,
            u.nickname as userNickName,
            u.avatar_url as userAvatarUrl,
            a.order_id as orderId,
            a.spu_id as spuId,
            a.sku_id as skuId,
            sk.title as skuTitle,
            sp.title as spuTitle
        from
            unimall_appraise a,
            unimall_user u,
            unimall_sku sk,
            unimall_spu sp
        where
            a.user_id = u.id
            and a.spu_id = sp.id
            and a.sku_id = sk.id
            and a.spu_id = #{spuId}
    </select>
 
    <select id="selectOneById" resultType="com.iotechn.unimall.data.dto.appraise.AppraiseResponseDTO">
        select
            a.id as id,
            a.gmt_create as gmtCreate,
            a.gmt_update as gmtUpdate,
            a.content as content,
            a.score as score,
            a.user_id as userId,
            u.nickname as userNickName,
            u.avatar_url as userAvatarUrl,
            a.order_id as orderId,
            a.spu_id as spuId,
            a.sku_id as skuId,
            sk.title as skuTitle,
            sp.title as spuTitle
        from
            unimall_appraise a,
            unimall_user u,
            unimall_sku sk,
            unimall_spu sp
        where
            a.user_id = u.id
            and a.spu_id = sp.id
            and a.sku_id = sk.id
            and a.id = #{appraiseId}
    </select>
 
    <select id="selectAppraisePage" resultType="com.iotechn.unimall.data.dto.appraise.AppraiseResponseDTO">
        select
        a.id as id,
        a.gmt_create as gmtCreate,
        a.gmt_update as gmtUpdate,
        a.content as content,
        a.score as score,
        a.user_id as userId,
        u.nickname as userNickName,
        u.avatar_url as userAvatarUrl,
        a.order_id as orderId,
        a.spu_id as spuId,
        a.sku_id as skuId,
        sk.title as skuTitle,
        sp.title as spuTitle
        from
        unimall_appraise a
        LEFT JOIN unimall_user u ON a.user_id = u.id
        LEFT JOIN unimall_sku sk ON a.sku_id = sk.id
        LEFT JOIN unimall_spu sp ON a.spu_id = sp.id
        where
        1 = 1
        <if test="id != null">
          AND  a.id = #{id}
        </if>
        <if test="userName != null">
          AND u.nickname LIKE concat("%",#{userName},"%")
        </if>
        <if test="spuName != null">
          AND  sp.title LIKE concat("%",#{spuName},"%")
        </if>
        <if test="orderId != null">
          AND  a.order_id = #{orderId}
        </if>
        <if test="score != null">
          AND  a.score = #{score}
        </if>
        <if test="content != null">
          AND  a.content LIKE concat("%",#{content},"%")
        </if>
        order by a.id desc
    </select>
 
</mapper>