package com.example.copykamanotes.controller; import com.example.copykamanotes.model.base.ApiResponse; import com.example.copykamanotes.model.base.EmptyVO; import com.example.copykamanotes.model.base.PageVO; import com.example.copykamanotes.model.dto.message.MessageQueryParams; import com.example.copykamanotes.model.vo.message.MessageVO; import com.example.copykamanotes.model.vo.message.UnreadCountByType; import com.example.copykamanotes.service.MessageService; import lombok.RequiredArgsConstructor; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import java.util.List; /** * 消息控制器 */ @RestController @RequestMapping("/api/messages") @RequiredArgsConstructor public class MessageController { private final MessageService messageService; /** * 获取消息列表 * * @param params 查询参数 * @return 消息列表,带分页信息 */ @GetMapping public ApiResponse> getMessages(@Validated MessageQueryParams params) { return messageService.getMessages(params); } /** * 标记消息为已读 * * @param messageId 消息ID * @return 空响应 */ @PutMapping("/{messageId}/read") public ApiResponse markAsRead(@PathVariable Integer messageId) { return messageService.markAsRead(messageId); } /** * 标记所有消息为已读 * * @return 空响应 */ @PutMapping("/read/all") public ApiResponse markAllAsRead() { return messageService.markAllAsRead(); } /** * 删除消息 * * @param messageId 消息ID * @return 空响应 */ @DeleteMapping("/{messageId}") public ApiResponse deleteMessage(@PathVariable Integer messageId) { return messageService.deleteMessage(messageId); } /** * 获取未读消息数量 * * @return 未读消息数量 */ @GetMapping("/unread/count") public ApiResponse getUnreadCount() { return messageService.getUnreadCount(); } /** * 获取各类型未读消息数量 * * @return 各类型未读消息数量 */ @GetMapping("/unread/count/type") public ApiResponse> getUnreadCountByType() { return messageService.getUnreadCountByType(); } }