ReplyController
페이지 정보
본문
package web.controller;
import java.util.HashMap;
import java.util.Map;
import org.springframework.http.MediaType;
import org.springframework.validation.BindException;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.validation.Valid;
import lombok.extern.log4j.Log4j2;
import web.dto.ReplyDTO;
@RestController
@Log4j2
@RequestMapping("/replies")
public class ReplyController {
//스프링부트 2
//@ApiOperation(value = "Replies POST", notes = "POST 방식으로 댓글 등록")
//스프링부트 3
@Operation(summary = "Replies POST", description = "POST 방식으로 댓글 등록")
@PostMapping(value = "/", consumes = MediaType.APPLICATION_JSON_VALUE)
public Map<String, Long> register(@Valid @RequestBody ReplyDTO replyDTO, BindingResult bindingResult) throws BindException {
log.info(replyDTO);
if(bindingResult.hasErrors()) {
throw new BindException(bindingResult);
}
Map<String, Long> resultMap = new HashMap<>();
resultMap.put("rno", 100L);
return resultMap;
}
}
댓글목록
등록된 댓글이 없습니다.