From ec65cf66abdb3aceb1615c319d62e1c0fed6c22c Mon Sep 17 00:00:00 2001 From: woody35545 Date: Sun, 22 Oct 2023 11:49:09 +0900 Subject: [PATCH] =?UTF-8?q?[+]=20#65=20ReplyerController=20=EB=A9=94?= =?UTF-8?q?=EC=84=9C=EB=93=9C=20=EB=B0=98=ED=99=98=20=ED=83=80=EC=9E=85=20?= =?UTF-8?q?=ED=86=B5=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ReplyerController.java | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/kns/tenquest/controller/ReplyerController.java b/src/main/java/com/kns/tenquest/controller/ReplyerController.java index 1f71d23..f28f9ea 100644 --- a/src/main/java/com/kns/tenquest/controller/ReplyerController.java +++ b/src/main/java/com/kns/tenquest/controller/ReplyerController.java @@ -3,8 +3,10 @@ import com.kns.tenquest.ENV; import com.kns.tenquest.dto.ReplyerDto; import com.kns.tenquest.dto.ResponseDto; +import com.kns.tenquest.dto.ServiceResult; import com.kns.tenquest.entity.Replyer; import com.kns.tenquest.response.Response_Deprecated; +import com.kns.tenquest.response.Response; import com.kns.tenquest.response.ResponseStatus; import com.kns.tenquest.service.ReplyerService; import lombok.RequiredArgsConstructor; @@ -27,20 +29,23 @@ public class ReplyerController { @ResponseBody @GetMapping("/replyers") - public List apiGetReplyers(){ - return replyerService.getAllReplyers(); + public Response apiGetReplyers(){ + + ServiceResult sr = replyerService.getAllReplyers(); + + return sr.isFailed() ? + new Response().BadRequest() : + new Response().Ok().data(sr.getData()); } @GetMapping("/replyers/{replyerid}") - public Response_Deprecated apiGetReplyerByReplyerId(@PathVariable(value = "replyerid")int replyerId){ - ReplyerDto replyerDto = replyerService.getReplyerByReplyerId(replyerId); - ResponseStatus responseStatus = ResponseStatus.OK; - - if (replyerDto.getReplyerId()==-1){ - responseStatus = ResponseStatus.NOT_FOUND; - } - return new ResponseDto(responseStatus,replyerDto).toResponse(); + public Response apiGetReplyerByReplyerId(@PathVariable(value = "replyerid")int replyerId){ + + ServiceResult sr = replyerService.getReplyerByReplyerId(replyerId); + + return sr.isFailed() ? + new Response().BadRequest() : + new Response().Ok().data(sr.getData()); } - }