wlzboy
1 天以前 08f95b2f159b56fa3bd4f4b348855989de8aa456
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<?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.system.mapper.NotifySendLogMapper">
    
    <resultMap type="NotifySendLog" id="NotifySendLogResult">
        <result property="id"           column="id"           />
        <result property="notifyTaskId" column="notify_task_id"/>
        <result property="taskId"       column="task_id"      />
        <result property="userId"       column="user_id"      />
        <result property="userName"     column="user_name"    />
        <result property="notifyType"   column="notify_type"  />
        <result property="channel"      column="channel"      />
        <result property="sendStatus"   column="send_status"  />
        <result property="sendContent"  column="send_content" />
        <result property="sendTime"     column="send_time"    />
        <result property="sendResult"   column="send_result"  />
        <result property="responseMsg"  column="response_msg" />
        <result property="retryCount"   column="retry_count"  />
        <result property="createTime"   column="create_time"  />
        <result property="createBy"     column="create_by"    />
        <result property="updateTime"   column="update_time"  />
        <result property="updateBy"     column="update_by"    />
        <result property="remark"       column="remark"       />
    </resultMap>
 
    <sql id="selectNotifySendLogVo">
        select id, notify_task_id, task_id, user_id, user_name, notify_type, channel, send_status, 
               send_content, send_time, send_result, response_msg, retry_count, create_time, create_by, 
               update_time, update_by, remark
        from sys_notify_send_log
    </sql>
 
    <select id="selectNotifySendLogList" parameterType="NotifySendLog" resultMap="NotifySendLogResult">
        <include refid="selectNotifySendLogVo"/>
        <where>
            <if test="taskId != null">
                AND task_id = #{taskId}
            </if>
            <if test="userId != null">
                AND user_id = #{userId}
            </if>
            <if test="userName != null and userName != ''">
                AND user_name like concat('%', #{userName}, '%')
            </if>
            <if test="notifyType != null and notifyType != ''">
                AND notify_type = #{notifyType}
            </if>
            <if test="channel != null and channel != ''">
                AND channel = #{channel}
            </if>
            <if test="sendStatus != null and sendStatus != ''">
                AND send_status = #{sendStatus}
            </if>
            <if test="params.beginSendTime != null and params.beginSendTime != ''">
                AND send_time &gt;= #{params.beginSendTime}
            </if>
            <if test="params.endSendTime != null and params.endSendTime != ''">
                AND send_time &lt;= #{params.endSendTime}
            </if>
        </where>
        order by create_time desc
    </select>
    
    <select id="selectNotifySendLogById" parameterType="Long" resultMap="NotifySendLogResult">
        <include refid="selectNotifySendLogVo"/>
        where id = #{id}
    </select>
 
    <select id="checkNotifySendLogExists" resultType="int">
        select count(1) from sys_notify_send_log
        where task_id = #{taskId}
          and user_id = #{userId}
          and notify_type = #{notifyType}
          and channel = #{channel}
    </select>
 
    <select id="selectNotifySendLog" resultMap="NotifySendLogResult">
        <include refid="selectNotifySendLogVo"/>
        where task_id = #{taskId}
          and user_id = #{userId}
          and notify_type = #{notifyType}
          and channel = #{channel}
        limit 1
    </select>
 
    <select id="selectFailedNotifySendLogs" resultMap="NotifySendLogResult">
        <include refid="selectNotifySendLogVo"/>
        where send_status = '2'
          and retry_count &lt; #{maxRetryCount}
        order by create_time asc
        limit 100
    </select>
 
    <insert id="insertNotifySendLog" parameterType="NotifySendLog" useGeneratedKeys="true" keyProperty="id">
        insert into sys_notify_send_log
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="notifyTaskId != null">notify_task_id,</if>
            <if test="taskId != null">task_id,</if>
            <if test="userId != null">user_id,</if>
            <if test="userName != null">user_name,</if>
            <if test="notifyType != null and notifyType != ''">notify_type,</if>
            <if test="channel != null and channel != ''">channel,</if>
            <if test="sendStatus != null">send_status,</if>
            <if test="sendContent != null">send_content,</if>
            <if test="sendTime != null">send_time,</if>
            <if test="sendResult != null">send_result,</if>
            <if test="responseMsg != null">response_msg,</if>
            <if test="retryCount != null">retry_count,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="remark != null">remark,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="notifyTaskId != null">#{notifyTaskId},</if>
            <if test="taskId != null">#{taskId},</if>
            <if test="userId != null">#{userId},</if>
            <if test="userName != null">#{userName},</if>
            <if test="notifyType != null and notifyType != ''">#{notifyType},</if>
            <if test="channel != null and channel != ''">#{channel},</if>
            <if test="sendStatus != null">#{sendStatus},</if>
            <if test="sendContent != null">#{sendContent},</if>
            <if test="sendTime != null">#{sendTime},</if>
            <if test="sendResult != null">#{sendResult},</if>
            <if test="responseMsg != null">#{responseMsg},</if>
            <if test="retryCount != null">#{retryCount},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="remark != null">#{remark},</if>
        </trim>
    </insert>
 
    <update id="updateNotifySendLog" parameterType="NotifySendLog">
        update sys_notify_send_log
        <trim prefix="SET" suffixOverrides=",">
            <if test="taskId != null">task_id = #{taskId},</if>
            <if test="userId != null">user_id = #{userId},</if>
            <if test="userName != null">user_name = #{userName},</if>
            <if test="notifyType != null and notifyType != ''">notify_type = #{notifyType},</if>
            <if test="channel != null and channel != ''">channel = #{channel},</if>
            <if test="sendStatus != null">send_status = #{sendStatus},</if>
            <if test="sendContent != null">send_content = #{sendContent},</if>
            <if test="sendTime != null">send_time = #{sendTime},</if>
            <if test="sendResult != null">send_result = #{sendResult},</if>
            <if test="retryCount != null">retry_count = #{retryCount},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>
 
    <update id="updateSendStatus">
        update sys_notify_send_log
        set send_status = #{sendStatus},
            send_result = #{sendResult},
            send_content = #{sendContent},
            send_time = now(),
            update_time = now(),
            retry_count = retry_count + 1
        where id = #{id}
    </update>
 
    <delete id="deleteNotifySendLogById" parameterType="Long">
        delete from sys_notify_send_log where id = #{id}
    </delete>
 
    <delete id="deleteNotifySendLogByIds" parameterType="String">
        delete from sys_notify_send_log where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>