57 lines
2.1 KiB
Java
57 lines
2.1 KiB
Java
|
|
package com.ai.da.controller;
|
||
|
|
|
||
|
|
import com.ai.da.common.response.PageBaseResponse;
|
||
|
|
import com.ai.da.common.response.Response;
|
||
|
|
import com.ai.da.model.vo.GetNotificationVO;
|
||
|
|
import com.ai.da.model.vo.NotificationVO;
|
||
|
|
import com.ai.da.model.vo.PublishSysNotificationVO;
|
||
|
|
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")
|
||
|
|
public Response<PageBaseResponse<NotificationVO>> getHistoryNotification(@Valid @RequestBody GetNotificationVO getNotificationVO) {
|
||
|
|
return Response.success(messageCenterService.getHistoryNotification(getNotificationVO));
|
||
|
|
}
|
||
|
|
|
||
|
|
// 已读消息
|
||
|
|
@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")
|
||
|
|
public Response<String> publishSysMessage(@Valid @RequestBody PublishSysNotificationVO message) {
|
||
|
|
messageCenterService.publishSystemNotification(message);
|
||
|
|
return Response.success("success");
|
||
|
|
}
|
||
|
|
}
|