fix(system/message): 修复查看消息详情报错的问题

Closes #193
This commit is contained in:
2025-10-14 20:53:15 +08:00
parent 541e53ea26
commit 9bfde6f6a3
2 changed files with 9 additions and 4 deletions

View File

@@ -16,6 +16,7 @@
package top.continew.admin.system.controller; package top.continew.admin.system.controller;
import cn.hutool.core.collection.CollUtil;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn; import io.swagger.v3.oas.annotations.enums.ParameterIn;
@@ -81,8 +82,8 @@ public class UserMessageController {
@GetMapping("/{id}") @GetMapping("/{id}")
public MessageDetailResp getMessage(@PathVariable Long id) { public MessageDetailResp getMessage(@PathVariable Long id) {
MessageDetailResp detail = messageService.get(id); MessageDetailResp detail = messageService.get(id);
CheckUtils.throwIf(detail == null || (NoticeScopeEnum.USER.equals(detail.getScope()) && !detail.getUsers() CheckUtils.throwIf(detail == null || (NoticeScopeEnum.USER.equals(detail.getScope()) && !CollUtil
.contains(UserContextHolder.getUserId().toString())), "消息不存在或无权限访问"); .contains(detail.getUsers(), UserContextHolder.getUserId().toString())), "消息不存在或无权限访问");
messageService.readMessage(Collections.singletonList(id), UserContextHolder.getUserId()); messageService.readMessage(Collections.singletonList(id), UserContextHolder.getUserId());
detail.setIsRead(true); detail.setIsRead(true);
return detail; return detail;

View File

@@ -2,6 +2,11 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" > "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="top.continew.admin.system.mapper.MessageMapper"> <mapper namespace="top.continew.admin.system.mapper.MessageMapper">
<resultMap id="messageDetailMap" type="top.continew.admin.system.model.resp.message.MessageDetailResp">
<id column="id" property="id" />
<result property="users" column="users" typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" />
</resultMap>
<select id="selectMessagePage" resultType="top.continew.admin.system.model.resp.message.MessageResp"> <select id="selectMessagePage" resultType="top.continew.admin.system.model.resp.message.MessageResp">
SELECT SELECT
t1.id, t1.id,
@@ -9,7 +14,6 @@
t1.type, t1.type,
t1.path, t1.path,
t1.scope, t1.scope,
t1.users,
t1.create_time, t1.create_time,
t2.read_time IS NOT NULL AS isRead, t2.read_time IS NOT NULL AS isRead,
t2.read_time AS readTime t2.read_time AS readTime
@@ -39,7 +43,7 @@
ORDER BY t1.create_time DESC ORDER BY t1.create_time DESC
</select> </select>
<select id="selectMessageById" resultType="top.continew.admin.system.model.resp.message.MessageDetailResp"> <select id="selectMessageById" resultMap="messageDetailMap">
SELECT SELECT
t1.id, t1.id,
t1.title, t1.title,