Lius
2024-10-21 316ef1bf39d16a29c27fe26393e704c1d0b963f9
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
131
132
<?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="org.jeecg.modules.system.mapper.SysAnnouncementSendMapper">
 
    <resultMap id="AnnouncementSendModel" type="org.jeecg.modules.system.model.AnnouncementSendModel" >
        <result column="id" property="id" jdbcType="VARCHAR"/>
        <result column="annt_id" property="anntId" jdbcType="VARCHAR"/>
        <result column="user_id" property="userId" jdbcType="VARCHAR"/>
        <result column="titile" property="titile" jdbcType="VARCHAR"/>
        <result column="msg_content" property="msgContent" jdbcType="VARCHAR"/>
        <result column="sender" property="sender" jdbcType="VARCHAR"/>
        <result column="priority" property="priority" jdbcType="VARCHAR"/>
        <result column="msg_category" property="msgCategory" jdbcType="VARCHAR"/>
        <result column="send_time" property="sendTime" jdbcType="TIMESTAMP"/>
        <result column="bus_id" property="busId" jdbcType="VARCHAR"/>
        <result column="bus_type" property="busType" jdbcType="VARCHAR"/>
        <result column="open_type" property="openType" jdbcType="VARCHAR"/>
        <result column="open_page" property="openPage" jdbcType="VARCHAR"/>
    </resultMap>
 
    <select id="queryByUserId" parameterType="String"  resultType="String">
       select sas.annt_id from sys_announcement_send sas
       where sas.user_id = #{userId}
    </select>
 
    <select id="getMyAnnouncementSendList" parameterType="Object"  resultMap="AnnouncementSendModel">
       select
               sas.id,
               sas.annt_id,
               sas.user_id,
               sas.read_flag,
               sa.titile as titile,
               sa.msg_content as msg_content,
               sa.sender as sender,
               sa.priority as priority,
               sa.msg_category,
               sa.send_time as send_time,
               sa.bus_id as bus_id,
               sa.bus_type as bus_type,
            sa.open_type as open_type,
            sa.open_page as open_page,
            sa.msg_abstract
       from sys_announcement_send sas
       left join sys_announcement sa ON sas.annt_id = sa.id
       where sa.send_status = '1'
       and sa.del_flag = '0'
       and sas.user_id = #{announcementSendModel.userId}
       <if test="announcementSendModel.titile !=null and announcementSendModel.titile != ''">
               and sa.titile LIKE '%' + #{announcementSendModel.titile} + '%'
       </if>
       <if test="announcementSendModel.sender !=null and announcementSendModel.sender != ''">
               and sa.sender LIKE '%' + #{announcementSendModel.sender} + '%'
       </if>
       <if test="announcementSendModel.readFlag !=null and announcementSendModel.readFlag != ''">
               and sas.read_flag = #{announcementSendModel.readFlag}
       </if>
       <if test="announcementSendModel.busType !=null and announcementSendModel.busType != ''">
               and sa.bus_type = #{announcementSendModel.busType}
       </if>
        <if test="announcementSendModel.bizSource !=null and announcementSendModel.bizSource =='isNoBpm'">
            and (sa.bus_type != 'bpm' or sa.bus_type is null)
        </if>
        <if test="announcementSendModel.msgCategory !=null and announcementSendModel.msgCategory != ''">
            and sa.msg_category = #{announcementSendModel.msgCategory}
        </if>
       order by sas.read_flag,sa.send_time desc
    </select>
 
 
 
    <!-- 查询一条消息 -->
    <select id="getOne" parameterType="String" resultMap="AnnouncementSendModel">
        select
        sas.id,
        sas.annt_id,
        sas.user_id,
        sas.read_flag,
        sa.titile as titile,
        sa.msg_content as msg_content,
        sa.sender as sender,
        sa.priority as priority,
        sa.msg_category,
        sa.send_time as send_time,
        sa.bus_id as bus_id,
        sa.open_type as open_type,
        sa.open_page as open_page,
        sa.msg_abstract
        from sys_announcement_send sas
        left join sys_announcement sa ON sas.annt_id = sa.id
        where sa.send_status = '1'
        and sa.del_flag = '0'
        and sas.id = #{sendId}
    </select>
 
 
    <!-- 修改为已读消息 -->
    <update id="updateReaded">
        update sys_announcement_send set read_flag = '1'
         where user_id = #{userId}
            and annt_id in
        <foreach collection="annoceIdList" index="index" item="id" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>
    <select id="getPrimaryInfo" resultType="org.jeecg.modules.system.entity.SysAnnouncementSend">
        select
        t1.id id,
        t1.annt_id anntId,
        t1.user_id userId,
        t1.read_flag readFlag,
        t2.msg_content msgContent,
        t2.msg_category msgCategory
        from
        sys_announcement_send t1
        left join sys_announcement t2
        on t1.annt_id = t2.id
        where  t1.read_flag = '0'
        and t1.user_id = #{userId}
            <if test="msgCategoryList.size != 0">
                and t2.msg_category in (
                <foreach item="msgCategory" collection="msgCategoryList" separator=",">
                    #{msgCategory}
                </foreach>
                    )
            </if>
    </select>
 
    <select id="findLastMessage" resultType="org.jeecg.modules.system.entity.SysAnnouncement">
        SELECT TOP 1 * FROM sys_announcement WHERE msg_content = #{messageContent} ORDER BY create_time DESC;
    </select>
 
</mapper>