Skip to content

Commit 37539ae

Browse files
committed
fix(system/message): 修复查询用户未读消息错误
Closes #ID2803
1 parent 9b5eab6 commit 37539ae

File tree

2 files changed

+9
-18
lines changed

2 files changed

+9
-18
lines changed

continew-system/src/main/java/top/continew/admin/system/model/resp/message/MessageDetailResp.java

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,21 +81,15 @@ public class MessageDetailResp implements Serializable {
8181
@Schema(description = "通知用户", example = "[1,2]")
8282
private List<String> users;
8383

84-
/**
85-
* 是否已读
86-
*/
87-
@Schema(description = "是否已读", example = "true")
88-
private Boolean isRead;
89-
90-
/**
91-
* 读取时间
92-
*/
93-
@Schema(description = "读取时间", example = "2023-08-08 23:59:59", type = "string")
94-
private LocalDateTime readTime;
95-
9684
/**
9785
* 创建时间
9886
*/
9987
@Schema(description = "创建时间", example = "2023-08-08 08:08:08", type = "string")
10088
private LocalDateTime createTime;
89+
90+
/**
91+
* 是否已读
92+
*/
93+
@Schema(description = "是否已读", example = "true")
94+
private Boolean isRead;
10195
}

continew-system/src/main/resources/mapper/MessageMapper.xml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
t2.read_time IS NOT NULL AS isRead,
1919
t2.read_time AS readTime
2020
FROM sys_message AS t1
21-
LEFT JOIN sys_message_log AS t2 ON t2.message_id = t1.id
21+
LEFT JOIN sys_message_log AS t2 ON t2.message_id = t1.id <if test="query.userId != null">AND t2.user_id = #{query.userId}</if>
2222
<where>
2323
<if test="query.userId != null">
2424
<choose>
2525
<when test="_databaseId == 'mysql'">
26-
(t1.scope = 1 OR (t1.scope = 2 AND JSON_EXTRACT(t1.users, "$[0]") = CAST(#{query.userId} AS CHAR)))
26+
(t1.scope = 1 OR (t1.scope = 2 AND JSON_CONTAINS(t1.users, CONCAT('"', #{query.userId}, '"'))))
2727
</when>
2828
<when test="_databaseId == 'pgsql'">
2929
(t1.scope = 1 OR (t1.scope = 2 AND t1.users::jsonb @> jsonb_build_array(#{query.userId}::text)))
@@ -52,11 +52,8 @@
5252
t1.path,
5353
t1.scope,
5454
t1.users,
55-
t1.create_time,
56-
t2.read_time IS NOT NULL AS isRead,
57-
t2.read_time AS readTime
55+
t1.create_time
5856
FROM sys_message AS t1
59-
LEFT JOIN sys_message_log AS t2 ON t2.message_id = t1.id
6057
WHERE t1.id = #{id}
6158
</select>
6259

0 commit comments

Comments
 (0)