zhanghua
2023-09-08 7ef4892f9f24f941aca37e6b3991b808a0aca619
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
<?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.ycl.mapper.message.MessageMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.ycl.entity.message.Message">
        <id column="id" property="id" />
        <result column="parent_id" property="parentId" />
        <result column="head" property="head" />
        <result column="channel_code" property="channelCode" />
        <result column="message_type" property="messageType" />
        <result column="body" property="body" />
        <result column="target_from" property="targetFrom" />
        <result column="target_to" property="targetTo" />
        <result column="message_number" property="messageNumber" />
        <result column="random_code" property="randomCode" />
        <result column="over_time" property="overTime" />
        <result column="send_time" property="sendTime" />
        <result column="is_scan" property="isScan" />
        <result column="status" property="status" />
        <result column="is_view" property="isView" />
        <result column="remark" property="remark" />
        <result column="version" property="version" />
        <result column="create_user" property="createUser" />
        <result column="create_time" property="createTime" />
        <result column="update_user" property="updateUser" />
        <result column="update_time" property="updateTime" />
        <result column="respond_result" property="respondResult" />
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, parent_id, head, channel_code, message_type, body, target_from, target_to, message_number, random_code, over_time, send_time, is_scan, status, is_view, remark, version, create_user, create_time, update_user, update_time, respond_result
    </sql>
 
    <select id="selectMessagePage" parameterType="com.ycl.dto.message.MessageParam"
            resultType="com.ycl.vo.message.MessageVO">
        SELECT
        t1.id,
        t1.target_from,
        t3.column_name as messageTypeName,
        t1.`status`,
        t1.body,
        t1.send_time,
        t1.create_time,
        t1.respond_result,
        t1.head,
        t1.target_to,
        t1.message_type,
        t1.channel_code,
        t4.username as createUser,
        t1.phone_number
        FROM
        `ums_message` t1
        left join ums_admin t4 on t1.create_user = t4.id
        LEFT JOIN ums_message_column t3 ON t3.id = t1.message_type
        <where>
            <if test="messageParam.head !=null and messageParam.head !=''">
                t1.head like concat('%',#{messageParam.head},'%')
            </if>
            <if test="messageParam.channelCode !='' and messageParam.channelCode != null">
                and t1.channel_code=#{messageParam.channelCode}
            </if>
            <if test="messageParam.targetTo !='' and messageParam.targetTo != null">
                and t1.target_to=#{messageParam.targetTo}
            </if>
            <if test="messageParam.messageType != null">
                and t1.message_type=#{messageParam.messageType}
            </if>
            <if test="messageParam.isView != null">
                and t1.is_view=#{messageParam.isView}
            </if>
            <if test="messageParam.startTime != null and messageParam.startTime != '' and messageParam.endTime != null and messageParam.endTime != '' ">
                and t1.create_time between #{messageParam.startTime} and #{messageParam.endTime}
            </if>
 
            <if test="messageParam.status != null">
                and t1.status=#{messageParam.status}
            </if>
            <if test="messageParam.respondResult !=null and messageParam.respondResult !='' ">
                and t1.respond_result=#{messageParam.respondResult}
            </if>
            <if test="messageParam.sort==1">
                ORDER BY t1.create_time desc
            </if>
            <if test="messageParam.sort==0">
                ORDER BY t1.create_time asc
            </if>
        </where>
        order by t1.create_time desc 
    </select>
 
    <select id="selectUserColumn" resultType="com.ycl.vo.message.MessageColumnUserVO">
        SELECT
            t1.*,
            t2.is_receive
        FROM
            ums_message_column t1 LEFT JOIN ums_message_column_set t2 ON t1.id = t2.message_column_id
        WHERE
            t2.user_id=#{id}
          and t1.is_show=1
    </select>
 
</mapper>