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;
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import javax.validation.Valid;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
@Api(tags = "消息中心模块")
|
|
|
|
|
@Slf4j
|
|
|
|
|
@RestController
|
|
|
|
|
@RequestMapping("/api/message")
|
|
|
|
|
public class MessageCenterController {
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private MessageCenterService messageCenterService;
|
|
|
|
|
|
|
|
|
|
// 获取未读消息总数
|
|
|
|
|
@ApiOperation(value = "获取未读消息数")
|
|
|
|
|
@GetMapping("/getUnreadCount")
|
|
|
|
|
public Response<Map<String, Long>> getUnreadMessage(){
|
|
|
|
|
return Response.success(messageCenterService.getAllTypeMessageUnreadCount());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取历史消息
|
|
|
|
|
@ApiOperation(value = "获取历史消息")
|
|
|
|
|
@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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 已读消息
|
|
|
|
|
@ApiOperation(value = "设置消息状态为已读")
|
|
|
|
|
@PostMapping("/setReadStatus")
|
|
|
|
|
public Response<Boolean> setReadStatus(@RequestParam("notificationIdList") List<Long> notificationIdList, @RequestParam("type") String type) {
|
|
|
|
|
return Response.success(messageCenterService.setReadStatus(notificationIdList, type));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 发布系统消息
|
|
|
|
|
@ApiOperation(value = "发布系统消息")
|
|
|
|
|
@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");
|
|
|
|
|
}
|
2024-08-16 10:32:15 +08:00
|
|
|
|
|
|
|
|
@ApiOperation(value = "一键已读")
|
|
|
|
|
@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
|
|
|
}
|