update 添加消息标记为已读接口

This commit is contained in:
AprilWind 2026-07-13 14:24:00 +08:00
parent 44a9bd1006
commit b69a8bc793
3 changed files with 68 additions and 3 deletions

View File

@ -6,9 +6,7 @@ import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.common.web.core.BaseController;
import org.dromara.system.domain.vo.SysMessageBoxVo;
import org.dromara.system.service.ISysMessageService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
/**
* 消息记录控制器
@ -31,4 +29,27 @@ public class SysMessageController extends BaseController {
public R<SysMessageBoxVo> getBox() {
return R.ok(messageService.queryMessageBox(LoginHelper.getUserId()));
}
/**
* 将指定单条消息标记为已读
*
* @param messageId 消息主键ID
* @return 操作结果
*/
@PutMapping("/{messageId}/read")
public R<Void> markMessageRead(@PathVariable Long messageId) {
return toAjax(messageService.readMessage(LoginHelper.getUserId(), messageId));
}
/**
* 将当前用户指定分类下所有未读消息标记为已读
*
* @param category 消息分类标识
* @return 操作结果
*/
@PutMapping("/read/category/{category}")
public R<Void> markCategoryAllRead(@PathVariable String category) {
return toAjax(messageService.readAllMessages(LoginHelper.getUserId(), category));
}
}

View File

@ -21,6 +21,24 @@ public interface ISysMessageService {
*/
SysMessageBoxVo queryMessageBox(Long userId);
/**
* 将指定消息标记为已读
*
* @param userId 当前登录用户ID
* @param messageId 待标记的消息主键ID
* @return 结果
*/
boolean readMessage(Long userId, Long messageId);
/**
* 将当前用户指定分类下所有未读消息标记为已读
*
* @param userId 当前登录用户ID
* @param category 消息分类标识
* @return 结果
*/
boolean readAllMessages(Long userId, String category);
/**
* 发送指定用户文本消息
*

View File

@ -81,6 +81,32 @@ public class SysMessageServiceImpl implements ISysMessageService, MessageService
return box;
}
/**
* 将指定消息标记为已读
*
* @param userId 当前登录用户ID
* @param messageId 待标记的消息主键ID
* @return 结果
*/
@Override
public boolean readMessage(Long userId, Long messageId) {
// TODO 自行实现单条消息标记已读业务逻辑
return false;
}
/**
* 将当前用户指定分类下所有未读消息标记为已读
*
* @param userId 当前登录用户ID
* @param category 消息分类标识
* @return 结果
*/
@Override
public boolean readAllMessages(Long userId, String category) {
// TODO 自行实现全部消息批量标记已读业务逻辑
return false;
}
/**
* 发送指定用户文本消息
*