Skip to content

Commit

Permalink
feat: 멤버 별 두피 진단 총 검사 건수 서비스 및 컨트롤러 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
kjungw1025 committed Dec 3, 2023
1 parent a00dcf8 commit 8360840
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -30,4 +30,15 @@ public class DiagnosisResultController {
public List<ResponseDiagnosisResultDTO> 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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -43,4 +44,11 @@ public List<ResponseDiagnosisResultDTO> findDiagnosisResult(RequestMemberDTO dto
throw new DiagnosisResultNotFoundException();
}
}

public ResponseDiagnosisCountDTO findDiagnosisCount(String nickname) {
ResponseDiagnosisCountDTO responseDto = ResponseDiagnosisCountDTO.builder()
.total(diagnosisResultRepository.findAllWithNickname(nickname))
.build();
return responseDto;
}
}

0 comments on commit 8360840

Please sign in to comment.