Files
aida_back/src/main/java/com/ai/da/controller/MessageCenterController.java

64 lines
2.3 KiB
Java
Raw Normal View History

2024-08-15 16:25:44 +08:00
package com.ai.da.controller;
import com.ai.da.common.response.PageBaseResponse;
import com.ai.da.common.response.Response;
2024-08-21 10:23:55 +08:00
import com.ai.da.model.dto.GetNotificationDTO;
2024-08-15 16:25:44 +08:00
import com.ai.da.model.vo.NotificationVO;
2024-08-21 10:23:55 +08:00
import com.ai.da.model.dto.PublishSysNotificationDTO;
2024-08-15 16:25:44 +08:00
import com.ai.da.service.MessageCenterService;
2025-12-11 10:35:08 +08:00
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
2024-08-15 16:25:44 +08:00
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
2025-11-25 16:46:05 +08:00
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
2024-08-15 16:25:44 +08:00
import java.util.List;
import java.util.Map;
2025-12-11 10:35:08 +08:00
@Tag(name = "消息中心模块")
2024-08-15 16:25:44 +08:00
@Slf4j
@RestController
@RequestMapping("/api/message")
public class MessageCenterController {
@Resource
private MessageCenterService messageCenterService;
// 获取未读消息总数
2025-12-11 10:35:08 +08:00
@Operation(summary = "获取未读消息数")
2024-08-15 16:25:44 +08:00
@GetMapping("/getUnreadCount")
public Response<Map<String, Long>> getUnreadMessage(){
return Response.success(messageCenterService.getAllTypeMessageUnreadCount());
}
// 获取历史消息
2025-12-11 10:35:08 +08:00
@Operation(summary = "获取历史消息")
2024-08-15 16:25:44 +08:00
@PostMapping("/getHistoryNotification")
2024-08-21 10:23:55 +08:00
public Response<PageBaseResponse<NotificationVO>> getHistoryNotification(@Valid @RequestBody GetNotificationDTO getNotificationDTO) {
return Response.success(messageCenterService.getHistoryNotification(getNotificationDTO));
2024-08-15 16:25:44 +08:00
}
// 已读消息
2025-12-11 10:35:08 +08:00
@Operation(summary = "设置消息状态为已读")
2024-08-15 16:25:44 +08:00
@PostMapping("/setReadStatus")
public Response<Boolean> setReadStatus(@RequestParam("notificationIdList") List<Long> notificationIdList, @RequestParam("type") String type) {
return Response.success(messageCenterService.setReadStatus(notificationIdList, type));
}
// 发布系统消息
2025-12-11 10:35:08 +08:00
@Operation(summary = "发布系统消息")
2024-08-15 16:25:44 +08:00
@PostMapping("/publishSysMessage")
2024-08-21 10:23:55 +08:00
public Response<String> publishSysMessage(@Valid @RequestBody PublishSysNotificationDTO message) {
2024-08-15 16:25:44 +08:00
messageCenterService.publishSystemNotification(message);
return Response.success("success");
}
2025-12-11 10:35:08 +08:00
@Operation(summary = "一键已读")
@PostMapping("/oneClickRead")
public Response<String> setReadAll(@RequestParam("type") String type) {
messageCenterService.setReadAll(type);
return Response.success("success");
}
2024-08-15 16:25:44 +08:00
}