package com.allfree.allfreespringbackend.controlller; import com.allfree.allfreespringbackend.common.dto.MessageDTO; import com.allfree.allfreespringbackend.model.Message; import com.allfree.allfreespringbackend.service.MessageService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import java.util.List; @CrossOrigin(origins = "*", maxAge = 4200) @RestController @RequestMapping("/api/v1/message") public class MessageController { private final MessageService messageService; @Autowired public MessageController(MessageService messageService) { this.messageService = messageService; } @PostMapping("/add") public ResponseEntity<?> addMessage(@RequestBody MessageDTO messageDTO) { return this.messageService.addMessage(messageDTO); } @GetMapping("/article/{articleId}") public List<Message> getMessagesForArticle(@PathVariable Long articleId) { return this.messageService.getAllMessagesForArticle(articleId); } }