xuhy
2025-01-09 712f70b2936079a131ecb1e63c6d337171618cad
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
<?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.stylefeng.guns.modular.system.dao.TbCommentMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.stylefeng.guns.modular.system.model.TbComment">
        <id column="id" property="id" />
        <result column="userType" property="userType" />
        <result column="userId" property="userId" />
        <result column="type" property="type" />
        <result column="orderId" property="orderId" />
        <result column="replyUserType" property="replyUserType" />
        <result column="replyUserId" property="replyUserId" />
        <result column="content" property="content" />
        <result column="createTime" property="createTime" />
        <result column="orderInfo" property="orderInfo" />
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, userType, userId, type, orderId, replyUserType, replyUserId, content, createTime, orderInfo
    </sql>
 
    <select id="getList" resultType="com.stylefeng.guns.modular.system.model.TbComment">
        SELECT *
        ,CASE WHEN userType=1 THEN (SELECT nickName FROM t_user WHERE userId=id)
        ELSE (SELECT `name` FROM t_driver WHERE userId=id) END userName
        ,CASE WHEN userType=1 THEN (SELECT avatar FROM t_user WHERE userId=id)
        ELSE (SELECT headImgUrl FROM t_driver WHERE userId=id) END userAvatar
 
        ,CASE WHEN replyUserType=1 THEN (SELECT nickName FROM t_user WHERE replyUserId=id)
        ELSE (SELECT `name` FROM t_driver WHERE replyUserId=id) END replyUserName
        ,CASE WHEN replyUserType=1 THEN (SELECT avatar FROM t_user WHERE replyUserId=id)
        ELSE (SELECT headImgUrl FROM t_driver WHERE replyUserId=id) END replyUserAvatar
         FROM tb_comment
         <where>
             1=1 and isDetele=1
             <if test="type!=null">
                and type=#{type}
             </if>
             <if test="orderId!=null">
                 and orderId=#{orderId}
             </if>
             <if test="pid!=null">
                 and pid=#{pid}
                 order by id asc
             </if>
             <if test="pid==null">
                 and pid is null
                 order by id desc
                 limit #{pageNum}, #{size}
             </if>
         </where>
    </select>
</mapper>