From 83608407a552fb57026c2bc650fec57582f89198 Mon Sep 17 00:00:00 2001 From: kjungw1025 Date: Sun, 3 Dec 2023 23:16:12 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=A9=A4=EB=B2=84=20=EB=B3=84=20?= =?UTF-8?q?=EB=91=90=ED=94=BC=20=EC=A7=84=EB=8B=A8=20=EC=B4=9D=20=EA=B2=80?= =?UTF-8?q?=EC=82=AC=20=EA=B1=B4=EC=88=98=20=EC=84=9C=EB=B9=84=EC=8A=A4=20?= =?UTF-8?q?=EB=B0=8F=20=EC=BB=A8=ED=8A=B8=EB=A1=A4=EB=9F=AC=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/DiagnosisResultController.java | 19 +++++++++++++++---- .../service/DiagnosisResultService.java | 8 ++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/taba/nimonaemo/diagnosis/controller/DiagnosisResultController.java b/src/main/java/com/taba/nimonaemo/diagnosis/controller/DiagnosisResultController.java index ed9170c..782593e 100644 --- a/src/main/java/com/taba/nimonaemo/diagnosis/controller/DiagnosisResultController.java +++ b/src/main/java/com/taba/nimonaemo/diagnosis/controller/DiagnosisResultController.java @@ -1,14 +1,14 @@ package com.taba.nimonaemo.diagnosis.controller; import com.taba.nimonaemo.diagnosis.model.dto.request.RequestMemberDTO; +import com.taba.nimonaemo.diagnosis.model.dto.response.ResponseDiagnosisCountDTO; import com.taba.nimonaemo.diagnosis.model.dto.response.ResponseDiagnosisResultDTO; import com.taba.nimonaemo.diagnosis.service.DiagnosisResultService; +import com.taba.nimonaemo.global.auth.jwt.AppAuthentication; +import com.taba.nimonaemo.global.auth.role.MemberAuth; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; -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 org.springframework.web.bind.annotation.*; import javax.validation.Valid; import java.util.List; @@ -30,4 +30,15 @@ public class DiagnosisResultController { public List result(@Valid @RequestBody RequestMemberDTO dto) { return diagnosisResultService.findDiagnosisResult(dto); } + + /** + * 멤버 별 두피 진단 총 검사 건수 + * + * @param nickname 멤버 닉네임 + * @return 멤버 별 두피 진단 총 검사 건수 + */ + @PostMapping("/count") + public ResponseDiagnosisCountDTO count(@Valid @RequestParam String nickname) { + return diagnosisResultService.findDiagnosisCount(nickname); + } } diff --git a/src/main/java/com/taba/nimonaemo/diagnosis/service/DiagnosisResultService.java b/src/main/java/com/taba/nimonaemo/diagnosis/service/DiagnosisResultService.java index 5d313d4..e52d705 100644 --- a/src/main/java/com/taba/nimonaemo/diagnosis/service/DiagnosisResultService.java +++ b/src/main/java/com/taba/nimonaemo/diagnosis/service/DiagnosisResultService.java @@ -2,6 +2,7 @@ import com.taba.nimonaemo.diagnosis.exception.DiagnosisResultNotFoundException; import com.taba.nimonaemo.diagnosis.model.dto.request.RequestMemberDTO; +import com.taba.nimonaemo.diagnosis.model.dto.response.ResponseDiagnosisCountDTO; import com.taba.nimonaemo.diagnosis.model.dto.response.ResponseDiagnosisResultDTO; import com.taba.nimonaemo.diagnosis.model.entity.DiagnosisResult; import com.taba.nimonaemo.diagnosis.repository.DiagnosisResultRepository; @@ -43,4 +44,11 @@ public List findDiagnosisResult(RequestMemberDTO dto throw new DiagnosisResultNotFoundException(); } } + + public ResponseDiagnosisCountDTO findDiagnosisCount(String nickname) { + ResponseDiagnosisCountDTO responseDto = ResponseDiagnosisCountDTO.builder() + .total(diagnosisResultRepository.findAllWithNickname(nickname)) + .build(); + return responseDto; + } }