From 5a320ebb07b611ac0d7324784444d2f745d89a41 Mon Sep 17 00:00:00 2001 From: miiiinju1 Date: Sat, 4 Nov 2023 16:49:24 +0900 Subject: [PATCH 1/4] =?UTF-8?q?:truck:=20[Refactor]=20Test=20Type=20Info?= =?UTF-8?q?=20Request=EC=99=80=20Response=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/TestInfoController.java | 31 ++++++++++--------- ...ageDto.java => MyTestHistoryResponse.java} | 6 ++-- ...TypeDto.java => TestTypeInfoResponse.java} | 2 +- .../testInfo/mapper/TestTypeMapper.java | 7 +++-- .../service/CompanyTestInfoService.java | 4 +-- .../service/LatestTestInfoService.java | 7 ++--- .../service/PracticeTestInfoService.java | 4 +-- .../service/RandomDefenseInfoService.java | 4 +-- .../testInfo/service/TestTypeInfoService.java | 6 ++-- .../controller/TestRetryController.java | 2 -- 10 files changed, 37 insertions(+), 36 deletions(-) rename src/main/java/swm_nm/morandi/domain/testInfo/dto/{TestPageDto.java => MyTestHistoryResponse.java} (70%) rename src/main/java/swm_nm/morandi/domain/testInfo/dto/{TestTypeDto.java => TestTypeInfoResponse.java} (93%) diff --git a/src/main/java/swm_nm/morandi/domain/testInfo/controller/TestInfoController.java b/src/main/java/swm_nm/morandi/domain/testInfo/controller/TestInfoController.java index 17f738b0..dc777e51 100644 --- a/src/main/java/swm_nm/morandi/domain/testInfo/controller/TestInfoController.java +++ b/src/main/java/swm_nm/morandi/domain/testInfo/controller/TestInfoController.java @@ -3,11 +3,9 @@ import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; -import swm_nm.morandi.domain.testInfo.dto.TestPageDto; -import swm_nm.morandi.domain.testRecord.dto.TestRecordDto; -import swm_nm.morandi.domain.testInfo.dto.TestTypeDto; +import swm_nm.morandi.domain.testInfo.dto.MyTestHistoryResponse; +import swm_nm.morandi.domain.testInfo.dto.TestTypeInfoResponse; import swm_nm.morandi.domain.testInfo.service.*; import swm_nm.morandi.domain.testRecord.dto.TestRecordRequestDto; @@ -29,28 +27,33 @@ public class TestInfoController { private final TestTypeInfoService testTypeInfoService; @GetMapping("/latest") + @ResponseStatus(HttpStatus.OK) @Operation(summary = "최근에 본 테스트 목록", description = "마이 페이지에서 최근에 본 테스트 4개를 제공합니다.") - public ResponseEntity getLatestTestDtos(TestRecordRequestDto testRecordRequestDto) { - return new ResponseEntity<>(latestTestInfoService.getTestRecordDtosLatest(testRecordRequestDto), HttpStatus.OK); + public MyTestHistoryResponse getLatestTestDtos(TestRecordRequestDto testRecordRequestDto) { + return latestTestInfoService.getTestRecordDtosLatest(testRecordRequestDto); } @GetMapping("/practice") + @ResponseStatus(HttpStatus.OK) @Operation(summary = "연습 테스트 목록", description = "메인 페이지에서 현재 있는 연습 테스트 정보를 제공합니다.") - public ResponseEntity> getPracticeTestTypeDtos() { - return new ResponseEntity<>(practiceTestInfoService.getPracticeTestTypeDtos(), HttpStatus.OK); + public List getPracticeTestTypeDtos() { + return practiceTestInfoService.getPracticeTestTypeDtos(); } @GetMapping("/company") + @ResponseStatus(HttpStatus.OK) @Operation(summary = "기업 테스트 목록", description = "메인 페이지에서 현재 있는 기업 테스트 정보를 제공합니다.") - public ResponseEntity> getCompanyTestTypeDtos() { - return new ResponseEntity<>(companyTestInfoService.getCompanyTestTypeDtos(), HttpStatus.OK); + public List getCompanyTestTypeDtos() { + return companyTestInfoService.getCompanyTestTypeDtos(); } @GetMapping("/random-defense") + @ResponseStatus(HttpStatus.OK) @Operation(summary = "랜덤 디펜스 목록", description = "메인 페이지에서 현재 있는 랜덤 디펜스 정보를 제공합니다.") - public ResponseEntity> getRandomDefenseTestTypeDtos() { - return new ResponseEntity<>(randomDefenseInfoService.getRandomDefenseTestTypeDtos(), HttpStatus.OK); + public List getRandomDefenseTestTypeDtos() { + return randomDefenseInfoService.getRandomDefenseTestTypeDtos(); } @GetMapping("/{testTypeId}") + @ResponseStatus(HttpStatus.OK) @Operation(summary = "테스트 상세 정보", description = "사용자가 원하는 테스트 유형을 눌렀을 때 상세 테스트 정보를 제공합니다.") - public ResponseEntity getTestTypeInfo(@PathVariable Long testTypeId) { - return new ResponseEntity<>(testTypeInfoService.getTestTypeDto(testTypeId), HttpStatus.OK); + public TestTypeInfoResponse getTestTypeInfo(@PathVariable Long testTypeId) { + return testTypeInfoService.getTestTypeDto(testTypeId); } } \ No newline at end of file diff --git a/src/main/java/swm_nm/morandi/domain/testInfo/dto/TestPageDto.java b/src/main/java/swm_nm/morandi/domain/testInfo/dto/MyTestHistoryResponse.java similarity index 70% rename from src/main/java/swm_nm/morandi/domain/testInfo/dto/TestPageDto.java rename to src/main/java/swm_nm/morandi/domain/testInfo/dto/MyTestHistoryResponse.java index 382f213a..aa4e8e54 100644 --- a/src/main/java/swm_nm/morandi/domain/testInfo/dto/TestPageDto.java +++ b/src/main/java/swm_nm/morandi/domain/testInfo/dto/MyTestHistoryResponse.java @@ -10,11 +10,11 @@ @NoArgsConstructor @AllArgsConstructor @Builder -public class TestPageDto { +public class MyTestHistoryResponse { private Long totalElements; private List testRecordDtos = new ArrayList<>(); - public static TestPageDto getTestPageDto(Long totalElements, List testRecordDtos) { - return TestPageDto.builder() + public static MyTestHistoryResponse getTestPageDto(Long totalElements, List testRecordDtos) { + return MyTestHistoryResponse.builder() .totalElements(totalElements) .testRecordDtos(testRecordDtos) .build(); diff --git a/src/main/java/swm_nm/morandi/domain/testInfo/dto/TestTypeDto.java b/src/main/java/swm_nm/morandi/domain/testInfo/dto/TestTypeInfoResponse.java similarity index 93% rename from src/main/java/swm_nm/morandi/domain/testInfo/dto/TestTypeDto.java rename to src/main/java/swm_nm/morandi/domain/testInfo/dto/TestTypeInfoResponse.java index 88a21969..df9f5e35 100644 --- a/src/main/java/swm_nm/morandi/domain/testInfo/dto/TestTypeDto.java +++ b/src/main/java/swm_nm/morandi/domain/testInfo/dto/TestTypeInfoResponse.java @@ -7,7 +7,7 @@ @NoArgsConstructor @AllArgsConstructor @Builder -public class TestTypeDto { +public class TestTypeInfoResponse { private Long testTypeId; private String testTypename; private String frequentTypes; diff --git a/src/main/java/swm_nm/morandi/domain/testInfo/mapper/TestTypeMapper.java b/src/main/java/swm_nm/morandi/domain/testInfo/mapper/TestTypeMapper.java index 11326720..c3250cc7 100644 --- a/src/main/java/swm_nm/morandi/domain/testInfo/mapper/TestTypeMapper.java +++ b/src/main/java/swm_nm/morandi/domain/testInfo/mapper/TestTypeMapper.java @@ -1,11 +1,12 @@ package swm_nm.morandi.domain.testInfo.mapper; +import swm_nm.morandi.domain.testInfo.dto.TestTypeInfoResponse; import swm_nm.morandi.domain.testInfo.entity.TestType; -import swm_nm.morandi.domain.testInfo.dto.TestTypeDto; + public class TestTypeMapper { - public static TestTypeDto convertToDto(TestType testType) { - TestTypeDto testTypeDto = TestTypeDto.builder() + public static TestTypeInfoResponse convertToDto(TestType testType) { + TestTypeInfoResponse testTypeDto = TestTypeInfoResponse.builder() .testTypeId(testType.getTestTypeId()) .testTypename(testType.getTestTypename()) .frequentTypes(testType.getFrequentTypes()) diff --git a/src/main/java/swm_nm/morandi/domain/testInfo/service/CompanyTestInfoService.java b/src/main/java/swm_nm/morandi/domain/testInfo/service/CompanyTestInfoService.java index 6bcf042d..042e3620 100644 --- a/src/main/java/swm_nm/morandi/domain/testInfo/service/CompanyTestInfoService.java +++ b/src/main/java/swm_nm/morandi/domain/testInfo/service/CompanyTestInfoService.java @@ -4,7 +4,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import swm_nm.morandi.domain.testInfo.dto.TestTypeDto; +import swm_nm.morandi.domain.testInfo.dto.TestTypeInfoResponse; import swm_nm.morandi.domain.testInfo.entity.TestType; import swm_nm.morandi.domain.testInfo.mapper.TestTypeMapper; import swm_nm.morandi.domain.testInfo.repository.TestTypeRepository; @@ -23,7 +23,7 @@ public class CompanyTestInfoService { private final TestTypeRepository testTypeRepository; @Transactional(readOnly = true) - public List getCompanyTestTypeDtos() { + public List getCompanyTestTypeDtos() { List ids = LongStream.rangeClosed(7, 12).boxed().toList(); List testTypes = testTypeRepository.findAllById(ids); diff --git a/src/main/java/swm_nm/morandi/domain/testInfo/service/LatestTestInfoService.java b/src/main/java/swm_nm/morandi/domain/testInfo/service/LatestTestInfoService.java index 66ac8575..de559096 100644 --- a/src/main/java/swm_nm/morandi/domain/testInfo/service/LatestTestInfoService.java +++ b/src/main/java/swm_nm/morandi/domain/testInfo/service/LatestTestInfoService.java @@ -9,7 +9,7 @@ import org.springframework.transaction.annotation.Transactional; import swm_nm.morandi.domain.testDuring.dto.TestStatus; import swm_nm.morandi.domain.testExit.dto.AttemptProblemDto; -import swm_nm.morandi.domain.testInfo.dto.TestPageDto; +import swm_nm.morandi.domain.testInfo.dto.MyTestHistoryResponse; import swm_nm.morandi.domain.testRecord.dto.TestRecordDto; import swm_nm.morandi.domain.testInfo.entity.Tests; import swm_nm.morandi.domain.testRecord.dto.TestRecordRequestDto; @@ -29,7 +29,7 @@ public class LatestTestInfoService { private final TestRepository testRepository; @Transactional(readOnly = true) - public TestPageDto getTestRecordDtosLatest(TestRecordRequestDto testRecordRequestDto) { + public MyTestHistoryResponse getTestRecordDtosLatest(TestRecordRequestDto testRecordRequestDto) { Long memberId = SecurityUtils.getCurrentMemberId(); Integer page = testRecordRequestDto.getPage(); Integer size = testRecordRequestDto.getSize(); @@ -49,9 +49,8 @@ public TestPageDto getTestRecordDtosLatest(TestRecordRequestDto testRecordReques //테스트 기록이 4개 미만일 경우 더미 데이터를 넣어줌 getTestRecordDtos(testRecordDtos); - TestPageDto testPageDto = TestPageDto.getTestPageDto(recentTests.getTotalElements(), testRecordDtos); + return MyTestHistoryResponse.getTestPageDto(recentTests.getTotalElements(), testRecordDtos); - return testPageDto; } //테스트 기록을 받아와서 dto로 변환하면서 getAttemptProblemDtos를 통해 테스트 문제들을 dto로 변환 diff --git a/src/main/java/swm_nm/morandi/domain/testInfo/service/PracticeTestInfoService.java b/src/main/java/swm_nm/morandi/domain/testInfo/service/PracticeTestInfoService.java index a4142f93..992e63ca 100644 --- a/src/main/java/swm_nm/morandi/domain/testInfo/service/PracticeTestInfoService.java +++ b/src/main/java/swm_nm/morandi/domain/testInfo/service/PracticeTestInfoService.java @@ -4,7 +4,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import swm_nm.morandi.domain.testInfo.dto.TestTypeDto; +import swm_nm.morandi.domain.testInfo.dto.TestTypeInfoResponse; import swm_nm.morandi.domain.testInfo.entity.TestType; import swm_nm.morandi.domain.testInfo.mapper.TestTypeMapper; import swm_nm.morandi.domain.testInfo.repository.TestTypeRepository; @@ -23,7 +23,7 @@ public class PracticeTestInfoService { private final TestTypeRepository testTypeRepository; @Transactional(readOnly = true) - public List getPracticeTestTypeDtos() { + public List getPracticeTestTypeDtos() { List ids = LongStream.rangeClosed(1, 6).boxed().toList(); List testTypes = testTypeRepository.findAllById(ids); diff --git a/src/main/java/swm_nm/morandi/domain/testInfo/service/RandomDefenseInfoService.java b/src/main/java/swm_nm/morandi/domain/testInfo/service/RandomDefenseInfoService.java index 601518f4..02f3cf9e 100644 --- a/src/main/java/swm_nm/morandi/domain/testInfo/service/RandomDefenseInfoService.java +++ b/src/main/java/swm_nm/morandi/domain/testInfo/service/RandomDefenseInfoService.java @@ -4,7 +4,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import swm_nm.morandi.domain.testInfo.dto.TestTypeDto; +import swm_nm.morandi.domain.testInfo.dto.TestTypeInfoResponse; import swm_nm.morandi.domain.testInfo.entity.TestType; import swm_nm.morandi.domain.testInfo.mapper.TestTypeMapper; import swm_nm.morandi.domain.testInfo.repository.TestTypeRepository; @@ -23,7 +23,7 @@ public class RandomDefenseInfoService { private final TestTypeRepository testTypeRepository; @Transactional(readOnly = true) - public List getRandomDefenseTestTypeDtos() { + public List getRandomDefenseTestTypeDtos() { List ids = LongStream.rangeClosed(13, 15).boxed().toList(); List testTypes = testTypeRepository.findAllById(ids); diff --git a/src/main/java/swm_nm/morandi/domain/testInfo/service/TestTypeInfoService.java b/src/main/java/swm_nm/morandi/domain/testInfo/service/TestTypeInfoService.java index 64ce58e5..925ebaea 100644 --- a/src/main/java/swm_nm/morandi/domain/testInfo/service/TestTypeInfoService.java +++ b/src/main/java/swm_nm/morandi/domain/testInfo/service/TestTypeInfoService.java @@ -4,7 +4,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import swm_nm.morandi.domain.testInfo.dto.TestTypeDto; +import swm_nm.morandi.domain.testInfo.dto.TestTypeInfoResponse; import swm_nm.morandi.domain.testInfo.entity.TestType; import swm_nm.morandi.domain.testInfo.mapper.TestTypeMapper; import swm_nm.morandi.domain.testInfo.repository.TestTypeRepository; @@ -19,9 +19,9 @@ public class TestTypeInfoService { private final TestTypeRepository testTypeRepository; @Transactional(readOnly = true) - public TestTypeDto getTestTypeDto(Long testTypeId) { + public TestTypeInfoResponse getTestTypeDto(Long testTypeId) { TestType testType = testTypeRepository.findById(testTypeId).orElseThrow(() -> new MorandiException(TestTypeErrorCode.TEST_TYPE_NOT_FOUND)); - TestTypeDto testTypeDto = TestTypeMapper.convertToDto(testType); + TestTypeInfoResponse testTypeDto = TestTypeMapper.convertToDto(testType); return testTypeDto; } } diff --git a/src/main/java/swm_nm/morandi/domain/testRetry/controller/TestRetryController.java b/src/main/java/swm_nm/morandi/domain/testRetry/controller/TestRetryController.java index 480fb25b..d1a5bb76 100644 --- a/src/main/java/swm_nm/morandi/domain/testRetry/controller/TestRetryController.java +++ b/src/main/java/swm_nm/morandi/domain/testRetry/controller/TestRetryController.java @@ -6,9 +6,7 @@ import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.*; import swm_nm.morandi.domain.codeSubmit.dto.SolutionIdResponse; -import swm_nm.morandi.domain.codeSubmit.dto.SubmitCodeDto; import swm_nm.morandi.domain.testDuring.dto.OutputDto; -import swm_nm.morandi.domain.testInfo.dto.TestDto; import swm_nm.morandi.domain.testRetry.request.RetryRunCodeRequest; import swm_nm.morandi.domain.testRetry.request.RetryRunTestCaseRequest; import swm_nm.morandi.domain.testRetry.request.RetrySubmitRequest; From 975fddda7d924e1c6972e42f8d3c180065cb25c4 Mon Sep 17 00:00:00 2001 From: miiiinju1 Date: Sat, 4 Nov 2023 16:58:27 +0900 Subject: [PATCH 2/4] =?UTF-8?q?:truck:=20[Refactor]=20=EB=B0=B1=EC=A4=80?= =?UTF-8?q?=20=EC=A0=9C=EC=B6=9C=20=EA=B4=80=EB=A0=A8=20Dto=20Request?= =?UTF-8?q?=EC=99=80=20Response=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/CodeSubmitController.java | 25 ++++++----- ....java => AttemptProblemResultRequest.java} | 2 +- ...nUserDto.java => BaekjoonUserRequest.java} | 2 +- ...java => PracticeProblemResultRequest.java} | 2 +- ...mitCodeDto.java => SubmitCodeRequest.java} | 2 +- .../service/BaekjoonSubmitService.java | 44 +++++++++---------- .../service/SaveSubmitResultService.java | 15 ++++--- 7 files changed, 49 insertions(+), 43 deletions(-) rename src/main/java/swm_nm/morandi/domain/codeSubmit/dto/{AttemptProblemResultDto.java => AttemptProblemResultRequest.java} (89%) rename src/main/java/swm_nm/morandi/domain/codeSubmit/dto/{BaekjoonUserDto.java => BaekjoonUserRequest.java} (90%) rename src/main/java/swm_nm/morandi/domain/codeSubmit/dto/{PracticeProblemResultDto.java => PracticeProblemResultRequest.java} (76%) rename src/main/java/swm_nm/morandi/domain/codeSubmit/dto/{SubmitCodeDto.java => SubmitCodeRequest.java} (97%) diff --git a/src/main/java/swm_nm/morandi/domain/codeSubmit/controller/CodeSubmitController.java b/src/main/java/swm_nm/morandi/domain/codeSubmit/controller/CodeSubmitController.java index 3fa7e4e7..d7da65bd 100644 --- a/src/main/java/swm_nm/morandi/domain/codeSubmit/controller/CodeSubmitController.java +++ b/src/main/java/swm_nm/morandi/domain/codeSubmit/controller/CodeSubmitController.java @@ -3,7 +3,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; -import org.springframework.http.ResponseEntity; +import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.*; import swm_nm.morandi.domain.codeSubmit.dto.*; import swm_nm.morandi.domain.codeSubmit.service.BaekjoonSubmitService; @@ -14,34 +14,39 @@ @RestController @RequiredArgsConstructor @RequestMapping("/submit") -@Tag(name = "CodeSubmitController", description = "코드 제출과 관련된 컨트롤러") +@Tag(name = "CodeSubmitController", description = "백준 코드 제출과 관련된 컨트롤러") public class CodeSubmitController { private final BaekjoonSubmitService submitService; private final SaveSubmitResultService saveSubmitResultService; @PostMapping("/baekjoon") + @ResponseStatus(HttpStatus.OK) @Operation(summary = "문제 번호, 언어이름, 소스코드를 백준에 제출하는 컨트롤러 ", description = "사용자가 테스트 중 코드를 제출하는 경우 백준에 제출하는 컨트롤러입니다.") - public ResponseEntity submit(@RequestBody @Valid SubmitCodeDto submitCodeDto) { - return submitService.submit(submitCodeDto); + public SolutionIdResponse submit(@RequestBody @Valid SubmitCodeRequest submitCodeRequest) { + return submitService.submit(submitCodeRequest); } @PostMapping("/baekjoon/practice") + @ResponseStatus(HttpStatus.OK) @Operation(summary = "문제 번호, 언어 이름, 소스코드를 백준에 제출하는 컨트롤러", description = "사용자가 연습 문제를 제출하는 경우 백준에 제출하는 컨트롤러입니다.") - public ResponseEntity submit(@RequestBody @Valid PracticeProblemSubmitCodeRequest practiceProblemSubmitCodeRequest) { + public SolutionIdResponse submit(@RequestBody @Valid PracticeProblemSubmitCodeRequest practiceProblemSubmitCodeRequest) { return submitService.submit(practiceProblemSubmitCodeRequest); } @PostMapping("/cookie") - public String loginForSubmit(@RequestBody @Valid BaekjoonUserDto userDto) { - return submitService.saveBaekjoonInfo(userDto); + @ResponseStatus(HttpStatus.OK) + public String loginForSubmit(@RequestBody @Valid BaekjoonUserRequest baekjoonUserRequest) { + return submitService.saveBaekjoonInfo(baekjoonUserRequest); } @PostMapping("/result") + @ResponseStatus(HttpStatus.OK) @Operation(summary = "testId, bojProblemId, 정답여부를 전달하는 컨트롤러", description = "제출 후 채점 결과에 대한 내용을 백엔드에 전달하는 컨트롤러입니다.") - public String saveSubmitResult(@RequestBody @Valid AttemptProblemResultDto attemptProblemResultDto){ + public String saveSubmitResult(@RequestBody @Valid AttemptProblemResultRequest attemptProblemResultDto){ return saveSubmitResultService.saveSubmitResult(attemptProblemResultDto); } @PostMapping("/result/practice") + @ResponseStatus(HttpStatus.OK) @Operation(summary = "정답여부를 전달하는 컨트롤러", description = "제출 후 연습 문제에 대한 내용을 백엔드에 전달하는 컨트롤러입니다.") - public String savePracticeProblemSubmitResult(@RequestBody @Valid PracticeProblemResultDto practiceProblemResultDto) { - return saveSubmitResultService.savePracticeProblemSubmit(practiceProblemResultDto); + public String savePracticeProblemSubmitResult(@RequestBody @Valid PracticeProblemResultRequest practiceProblemResultRequest) { + return saveSubmitResultService.savePracticeProblemSubmit(practiceProblemResultRequest); } } diff --git a/src/main/java/swm_nm/morandi/domain/codeSubmit/dto/AttemptProblemResultDto.java b/src/main/java/swm_nm/morandi/domain/codeSubmit/dto/AttemptProblemResultRequest.java similarity index 89% rename from src/main/java/swm_nm/morandi/domain/codeSubmit/dto/AttemptProblemResultDto.java rename to src/main/java/swm_nm/morandi/domain/codeSubmit/dto/AttemptProblemResultRequest.java index d2a09753..c02d8c57 100644 --- a/src/main/java/swm_nm/morandi/domain/codeSubmit/dto/AttemptProblemResultDto.java +++ b/src/main/java/swm_nm/morandi/domain/codeSubmit/dto/AttemptProblemResultRequest.java @@ -6,7 +6,7 @@ import javax.validation.constraints.NotNull; @Getter @Setter -public class AttemptProblemResultDto { +public class AttemptProblemResultRequest { @NotNull(message = "testId는 null일 수 없습니다, 정수형") private Long testId; diff --git a/src/main/java/swm_nm/morandi/domain/codeSubmit/dto/BaekjoonUserDto.java b/src/main/java/swm_nm/morandi/domain/codeSubmit/dto/BaekjoonUserRequest.java similarity index 90% rename from src/main/java/swm_nm/morandi/domain/codeSubmit/dto/BaekjoonUserDto.java rename to src/main/java/swm_nm/morandi/domain/codeSubmit/dto/BaekjoonUserRequest.java index ec0c4928..61e44f52 100644 --- a/src/main/java/swm_nm/morandi/domain/codeSubmit/dto/BaekjoonUserDto.java +++ b/src/main/java/swm_nm/morandi/domain/codeSubmit/dto/BaekjoonUserRequest.java @@ -8,7 +8,7 @@ @Getter @Setter -public class BaekjoonUserDto { +public class BaekjoonUserRequest { @NotNull(message = "백준 아이디를 입력해주세요") public String bojId; diff --git a/src/main/java/swm_nm/morandi/domain/codeSubmit/dto/PracticeProblemResultDto.java b/src/main/java/swm_nm/morandi/domain/codeSubmit/dto/PracticeProblemResultRequest.java similarity index 76% rename from src/main/java/swm_nm/morandi/domain/codeSubmit/dto/PracticeProblemResultDto.java rename to src/main/java/swm_nm/morandi/domain/codeSubmit/dto/PracticeProblemResultRequest.java index 57505f0f..b734cf71 100644 --- a/src/main/java/swm_nm/morandi/domain/codeSubmit/dto/PracticeProblemResultDto.java +++ b/src/main/java/swm_nm/morandi/domain/codeSubmit/dto/PracticeProblemResultRequest.java @@ -4,6 +4,6 @@ import lombok.Setter; @Getter @Setter -public class PracticeProblemResultDto { +public class PracticeProblemResultRequest { private Long practiceProblemId; } diff --git a/src/main/java/swm_nm/morandi/domain/codeSubmit/dto/SubmitCodeDto.java b/src/main/java/swm_nm/morandi/domain/codeSubmit/dto/SubmitCodeRequest.java similarity index 97% rename from src/main/java/swm_nm/morandi/domain/codeSubmit/dto/SubmitCodeDto.java rename to src/main/java/swm_nm/morandi/domain/codeSubmit/dto/SubmitCodeRequest.java index 5cafdc9d..e0e570cc 100644 --- a/src/main/java/swm_nm/morandi/domain/codeSubmit/dto/SubmitCodeDto.java +++ b/src/main/java/swm_nm/morandi/domain/codeSubmit/dto/SubmitCodeRequest.java @@ -12,7 +12,7 @@ @Getter @Setter -public class SubmitCodeDto { +public class SubmitCodeRequest { @NotNull(message = "백준 문제 번호를 입력해주세요") public String bojProblemId; diff --git a/src/main/java/swm_nm/morandi/domain/codeSubmit/service/BaekjoonSubmitService.java b/src/main/java/swm_nm/morandi/domain/codeSubmit/service/BaekjoonSubmitService.java index 6e1189dd..44677cd4 100644 --- a/src/main/java/swm_nm/morandi/domain/codeSubmit/service/BaekjoonSubmitService.java +++ b/src/main/java/swm_nm/morandi/domain/codeSubmit/service/BaekjoonSubmitService.java @@ -16,10 +16,10 @@ import org.springframework.web.client.RestTemplate; import swm_nm.morandi.aop.annotation.MemberLock; import swm_nm.morandi.domain.codeSubmit.constants.CodeVisuabilityConstants; -import swm_nm.morandi.domain.codeSubmit.dto.BaekjoonUserDto; +import swm_nm.morandi.domain.codeSubmit.dto.BaekjoonUserRequest; import swm_nm.morandi.domain.codeSubmit.dto.PracticeProblemSubmitCodeRequest; import swm_nm.morandi.domain.codeSubmit.dto.SolutionIdResponse; -import swm_nm.morandi.domain.codeSubmit.dto.SubmitCodeDto; +import swm_nm.morandi.domain.codeSubmit.dto.SubmitCodeRequest; import swm_nm.morandi.domain.common.Language; import swm_nm.morandi.domain.member.entity.Member; import swm_nm.morandi.domain.member.repository.MemberRepository; @@ -65,20 +65,20 @@ public class BaekjoonSubmitService { //백준 로그인용 쿠키 저장 //Redis에 현재 로그인한 사용자의 백준 제출용 쿠키를 저장 @Transactional - public String saveBaekjoonInfo(BaekjoonUserDto baekjoonUserDto) { + public String saveBaekjoonInfo(BaekjoonUserRequest baekjoonUserRequest) { Long memberId = SecurityUtils.getCurrentMemberId(); Member member = memberRepository.findById(memberId) .orElseThrow(() -> new MorandiException(MemberErrorCode.EXTENSION_MEMBER_NOT_FOUND)); //validateBojId(member, baekjoonUserDto.getBojId()); - saveCookieToRedis(memberId, baekjoonUserDto.getCookie()); + saveCookieToRedis(memberId, baekjoonUserRequest.getCookie()); //Member에 백준 아이디 초기화 // if(member.getBojId()==null) { - updateMemberInfo(member, baekjoonUserDto.getBojId()); + updateMemberInfo(member, baekjoonUserRequest.getBojId()); // } - return baekjoonUserDto.getCookie(); + return baekjoonUserRequest.getCookie(); } private void validateBojId(Member member, String bojId) { @@ -108,24 +108,24 @@ private void updateMemberInfo(Member member, String bojId){ } @MemberLock @Transactional - public ResponseEntity submit(SubmitCodeDto submitCodeDto) { - validateBojProblemId(submitCodeDto.getBojProblemId()); + public SolutionIdResponse submit(SubmitCodeRequest submitCodeRequest) { + validateBojProblemId(submitCodeRequest.getBojProblemId()); Long memberId = SecurityUtils.getCurrentMemberId(); String cookie = getCookieFromRedis(generateKey(memberId)); - String CSRFKey = getCSRFKey(cookie, submitCodeDto.getBojProblemId()); + String CSRFKey = getCSRFKey(cookie, submitCodeRequest.getBojProblemId()); - SolutionIdResponse solutionId = sendSubmitRequest(cookie, CSRFKey, submitCodeDto.getBojProblemId(), submitCodeDto.getLanguage(), submitCodeDto.getSourceCode()); + SolutionIdResponse solutionId = sendSubmitRequest(cookie, CSRFKey, submitCodeRequest.getBojProblemId(), submitCodeRequest.getLanguage(), submitCodeRequest.getSourceCode()); //제출한 코드 정보를 저장 - saveSubmitTempCode(submitCodeDto); + saveSubmitTempCode(submitCodeRequest); - return ResponseEntity.status(HttpStatus.OK).body(solutionId); + return solutionId; } @MemberLock @Transactional - public ResponseEntity submit(PracticeProblemSubmitCodeRequest practiceProblemSubmitCodeRequest) { + public SolutionIdResponse submit(PracticeProblemSubmitCodeRequest practiceProblemSubmitCodeRequest) { validateBojProblemId(practiceProblemSubmitCodeRequest.getBojProblemId()); Long memberId = SecurityUtils.getCurrentMemberId(); @@ -138,7 +138,7 @@ public ResponseEntity submit(PracticeProblemSubmitCodeReques //제출한 코드 정보를 저장 savePracticeProblemSubmitTempCode(practiceProblemSubmitCodeRequest); - return ResponseEntity.status(HttpStatus.OK).body(solutionId); + return solutionId; } @@ -260,7 +260,7 @@ private SolutionIdResponse sendSubmitRequest(String cookie, String CSRFKey, Stri private MultiValueMap createParameters(String bojProblemId, Language language, String sourceCode, String CSRFKey) { MultiValueMap parameters = new LinkedMultiValueMap<>(); parameters.add("problem_id", bojProblemId); - parameters.add("language", SubmitCodeDto.getLanguageId(language)); + parameters.add("language", SubmitCodeRequest.getLanguageId(language)); parameters.add("code_open", CodeVisuabilityConstants.CLOSE.getCodeVisuability()); parameters.add("source", sourceCode); parameters.add("csrf_key", CSRFKey); @@ -290,15 +290,15 @@ private SolutionIdResponse extractSolutionIdFromHtml(String html) { } } - private void saveSubmitTempCode(SubmitCodeDto submitCodeDto) + private void saveSubmitTempCode(SubmitCodeRequest submitCodeRequest) { String ongoingTestKey = redisKeyGenerator.generateOngoingTestKey(); Long testId = ((TestInfo) Optional.ofNullable(redisTemplate.opsForValue().get(ongoingTestKey)) .orElseThrow(() -> new MorandiException(SubmitErrorCode.TEST_NOT_EXIST))).getTestId(); - tempCodeService.saveTempCode(testId, submitCodeDto.getProblemNumber(), submitCodeDto.getLanguage(), submitCodeDto.getSourceCode()); + tempCodeService.saveTempCode(testId, submitCodeRequest.getProblemNumber(), submitCodeRequest.getLanguage(), submitCodeRequest.getSourceCode()); - saveSubmitCodeToDatabase(testId, submitCodeDto); + saveSubmitCodeToDatabase(testId, submitCodeRequest); } private void savePracticeProblemSubmitTempCode(PracticeProblemSubmitCodeRequest practiceProblemSubmitCodeRequest) { @@ -309,12 +309,12 @@ private void savePracticeProblemSubmitTempCode(PracticeProblemSubmitCodeRequest savePracticeProblemToDatabase(practiceProblemId, practiceProblemSubmitCodeRequest); } - private void saveSubmitCodeToDatabase(Long testId, SubmitCodeDto submitCodeDto) { - AttemptProblem attemptProblem = attemptProblemRepository.findByTest_TestIdAndProblem_BojProblemId(testId,Long.parseLong(submitCodeDto.getBojProblemId())) + private void saveSubmitCodeToDatabase(Long testId, SubmitCodeRequest submitCodeRequest) { + AttemptProblem attemptProblem = attemptProblemRepository.findByTest_TestIdAndProblem_BojProblemId(testId,Long.parseLong(submitCodeRequest.getBojProblemId())) .orElseThrow(() -> new MorandiException(SubmitErrorCode.TEST_NOT_EXIST)); - attemptProblem.setSubmitCode(submitCodeDto.getSourceCode()); - attemptProblem.setSubmitLanguage(submitCodeDto.getLanguage()); + attemptProblem.setSubmitCode(submitCodeRequest.getSourceCode()); + attemptProblem.setSubmitLanguage(submitCodeRequest.getLanguage()); //TODO //attemptProblem에 마지막으로 제출한 language의 정보가 빠져있음 -> 이거 나중에 추가하던지 해야함 attemptProblemRepository.save(attemptProblem); diff --git a/src/main/java/swm_nm/morandi/domain/codeSubmit/service/SaveSubmitResultService.java b/src/main/java/swm_nm/morandi/domain/codeSubmit/service/SaveSubmitResultService.java index dd623970..e4ec4e31 100644 --- a/src/main/java/swm_nm/morandi/domain/codeSubmit/service/SaveSubmitResultService.java +++ b/src/main/java/swm_nm/morandi/domain/codeSubmit/service/SaveSubmitResultService.java @@ -4,9 +4,8 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import swm_nm.morandi.domain.codeSubmit.dto.AttemptProblemResultDto; -import swm_nm.morandi.domain.codeSubmit.dto.PracticeProblemResultDto; -import swm_nm.morandi.domain.practice.dto.PracticeProblemCode; +import swm_nm.morandi.domain.codeSubmit.dto.AttemptProblemResultRequest; +import swm_nm.morandi.domain.codeSubmit.dto.PracticeProblemResultRequest; import swm_nm.morandi.domain.practice.entity.PracticeProblem; import swm_nm.morandi.domain.practice.repository.PracticeProblemRepository; import swm_nm.morandi.domain.testDuring.dto.TestStatus; @@ -29,12 +28,14 @@ public class SaveSubmitResultService { private final PracticeProblemRepository practiceProblemRepository; + + // 시험 중 정답으로 판명된 문제를 정답으로 처리하는 메서드 @Transactional - public String saveSubmitResult(AttemptProblemResultDto attemptProblemResultDto) { + public String saveSubmitResult(AttemptProblemResultRequest attemptProblemResultRequest) { Long memberId = SecurityUtils.getCurrentMemberId(); AttemptProblem attemptProblem = attemptProblemRepository.findByMember_MemberIdAndTest_testIdAndTest_TestStatusAndProblem_BojProblemId(memberId, - attemptProblemResultDto.getTestId(), TestStatus.IN_PROGRESS,attemptProblemResultDto.getBojProblemId()) + attemptProblemResultRequest.getTestId(), TestStatus.IN_PROGRESS,attemptProblemResultRequest.getBojProblemId()) .orElseThrow(() -> new MorandiException(AttemptProblemErrorCode.ATTEMPT_PROBLEM_NOT_FOUND_DURING_TEST)); if (attemptProblem.getIsSolved()) @@ -57,8 +58,8 @@ public String saveSubmitResult(AttemptProblemResultDto attemptProblemResultDto) } @Transactional - public String savePracticeProblemSubmit(PracticeProblemResultDto practiceProblemResultDto) { - PracticeProblem practiceProblem = practiceProblemRepository.findById(practiceProblemResultDto.getPracticeProblemId()) + public String savePracticeProblemSubmit(PracticeProblemResultRequest practiceProblemResultRequest) { + PracticeProblem practiceProblem = practiceProblemRepository.findById(practiceProblemResultRequest.getPracticeProblemId()) .orElseThrow(() -> new MorandiException(PracticeProblemErrorCode.PRACTICE_PROBLEM_NOT_FOUND)); practiceProblem.setIsSolved(true); practiceProblemRepository.save(practiceProblem); From c2109c4c9999cf77e9326c1d786b5f5189bf8dd3 Mon Sep 17 00:00:00 2001 From: miiiinju1 Date: Sun, 5 Nov 2023 15:54:33 +0900 Subject: [PATCH 3/4] =?UTF-8?q?:truck:=20[Refactor]=20Member=20=EA=B4=80?= =?UTF-8?q?=EB=A0=A8=20Dto=20Request=EC=99=80=20Response=20=EB=B6=84?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../member/controller/MemberController.java | 37 ++++++++++--------- ...berInfoDto.java => MemberInfoRequest.java} | 2 +- ...RequestDto.java => MemberListRequest.java} | 2 +- ...sponseDto.java => MemberListResponse.java} | 2 +- ...rInfoDto.java => RegisterInfoRequest.java} | 2 +- .../member/service/MemberInfoService.java | 6 +-- .../member/service/MemberInitService.java | 4 +- .../member/service/MemberListService.java | 15 ++++---- .../member/service/MemberEditServiceTest.java | 6 +-- .../member/service/MemberInfoServiceTest.java | 5 +-- .../member/service/MemberInitServiceTest.java | 7 +--- 11 files changed, 42 insertions(+), 46 deletions(-) rename src/main/java/swm_nm/morandi/domain/member/dto/{MemberInfoDto.java => MemberInfoRequest.java} (89%) rename src/main/java/swm_nm/morandi/domain/member/dto/{MemberListRequestDto.java => MemberListRequest.java} (86%) rename src/main/java/swm_nm/morandi/domain/member/dto/{MemberListResponseDto.java => MemberListResponse.java} (84%) rename src/main/java/swm_nm/morandi/domain/member/dto/{RegisterInfoDto.java => RegisterInfoRequest.java} (86%) diff --git a/src/main/java/swm_nm/morandi/domain/member/controller/MemberController.java b/src/main/java/swm_nm/morandi/domain/member/controller/MemberController.java index 07d79881..760928ff 100644 --- a/src/main/java/swm_nm/morandi/domain/member/controller/MemberController.java +++ b/src/main/java/swm_nm/morandi/domain/member/controller/MemberController.java @@ -3,12 +3,11 @@ import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; -import swm_nm.morandi.domain.member.dto.MemberInfoDto; -import swm_nm.morandi.domain.member.dto.MemberListRequestDto; -import swm_nm.morandi.domain.member.dto.MemberListResponseDto; -import swm_nm.morandi.domain.member.dto.RegisterInfoDto; +import swm_nm.morandi.domain.member.dto.MemberInfoRequest; +import swm_nm.morandi.domain.member.dto.MemberListRequest; +import swm_nm.morandi.domain.member.dto.MemberListResponse; +import swm_nm.morandi.domain.member.dto.RegisterInfoRequest; import swm_nm.morandi.domain.member.service.MemberEditService; import swm_nm.morandi.domain.member.service.MemberInfoService; import swm_nm.morandi.domain.member.service.MemberInitService; @@ -31,33 +30,37 @@ public class MemberController { private final MemberListService memberListService; @GetMapping("/check") + @ResponseStatus(HttpStatus.OK) @Operation(summary = "백준 id 등록되어있는지 확인", description ="백준 id가 등록되어있는지 확인합니다. 200반환 시 정상," + " \"code\": \"BAEKJOON_ID_NULL\" 반환 시 백준 id가 등록되지 않은 상태, 토큰 오류 시 403") - public ResponseEntity checkMemberInitialized(){ - return new ResponseEntity<>(HttpStatus.OK); + public void checkMemberInitialized(){ } @PostMapping("/register-info") + @ResponseStatus(HttpStatus.OK) @Operation(summary = "사용자 최초 등록", description = "사용자 최초 등록시 백준 아이디가 필수적으로 필요합니다.") - public ResponseEntity memberInitialize(@RequestBody @Valid RegisterInfoDto registerInfoDto) { - return new ResponseEntity<>(memberInitService.memberInitialize(registerInfoDto), HttpStatus.OK); + public RegisterInfoRequest memberInitialize(@RequestBody @Valid RegisterInfoRequest registerInfoRequest) { + return memberInitService.memberInitialize(registerInfoRequest); } @GetMapping("/info") + @ResponseStatus(HttpStatus.OK) @Operation(summary = "사용자 정보", description = "사용자의 닉네임과 백준 아이디를 보여줍니다.") - public ResponseEntity memberInfo() { - return new ResponseEntity<>(memberInfoService.getMemberInfo(), HttpStatus.OK); + public MemberInfoRequest memberInfo() { + return memberInfoService.getMemberInfo(); } @PostMapping("/edit") + @ResponseStatus(HttpStatus.OK) @Operation(summary = "사용자 정보 수정", description = "사용자의 닉네임 또는 백준 아이디를 수정합니다.") - public ResponseEntity editProfile(@RequestBody MemberInfoDto memberInfoDto) { - memberEditService.editProfile(memberInfoDto.getIntroduceInfo(), memberInfoDto.getBojId()); - return new ResponseEntity(memberInfoDto, HttpStatus.OK); + public MemberInfoRequest editProfile(@RequestBody MemberInfoRequest memberInfoRequest) { + memberEditService.editProfile(memberInfoRequest.getIntroduceInfo(), memberInfoRequest.getBojId()); + return memberInfoRequest; } @GetMapping("/list") + @ResponseStatus(HttpStatus.OK) @Operation(summary = "사용자 전체 리스트 정보", description = "서비스를 이용하는 모든 사용자 정보를 보여줍니다. page = (페이지 번호), size = (한 페이지 당 크기) " + "ex. page = 1, size = 10 -> 1페이지에 10명의 유저 리스트를 보여줍니다.") - public ResponseEntity> memberList(MemberListRequestDto memberListRequestDto) { - List memberListResponseDtos = memberListService.findAll(memberListRequestDto); - return new ResponseEntity<>(memberListResponseDtos, HttpStatus.OK); + public List memberList(MemberListRequest memberListRequest) { + return memberListService.findAll(memberListRequest); + } } diff --git a/src/main/java/swm_nm/morandi/domain/member/dto/MemberInfoDto.java b/src/main/java/swm_nm/morandi/domain/member/dto/MemberInfoRequest.java similarity index 89% rename from src/main/java/swm_nm/morandi/domain/member/dto/MemberInfoDto.java rename to src/main/java/swm_nm/morandi/domain/member/dto/MemberInfoRequest.java index 3e5c8bc7..84bc80e6 100644 --- a/src/main/java/swm_nm/morandi/domain/member/dto/MemberInfoDto.java +++ b/src/main/java/swm_nm/morandi/domain/member/dto/MemberInfoRequest.java @@ -8,7 +8,7 @@ @Getter @Setter @AllArgsConstructor @NoArgsConstructor -public class MemberInfoDto { +public class MemberInfoRequest { private String introduceInfo; private String bojId; } diff --git a/src/main/java/swm_nm/morandi/domain/member/dto/MemberListRequestDto.java b/src/main/java/swm_nm/morandi/domain/member/dto/MemberListRequest.java similarity index 86% rename from src/main/java/swm_nm/morandi/domain/member/dto/MemberListRequestDto.java rename to src/main/java/swm_nm/morandi/domain/member/dto/MemberListRequest.java index 92f0326e..84e0b468 100644 --- a/src/main/java/swm_nm/morandi/domain/member/dto/MemberListRequestDto.java +++ b/src/main/java/swm_nm/morandi/domain/member/dto/MemberListRequest.java @@ -6,7 +6,7 @@ @Getter @Setter @RequiredArgsConstructor -public class MemberListRequestDto { +public class MemberListRequest { private Integer page = 1; private Integer size = 15; } diff --git a/src/main/java/swm_nm/morandi/domain/member/dto/MemberListResponseDto.java b/src/main/java/swm_nm/morandi/domain/member/dto/MemberListResponse.java similarity index 84% rename from src/main/java/swm_nm/morandi/domain/member/dto/MemberListResponseDto.java rename to src/main/java/swm_nm/morandi/domain/member/dto/MemberListResponse.java index fa5a8d3c..917c06c7 100644 --- a/src/main/java/swm_nm/morandi/domain/member/dto/MemberListResponseDto.java +++ b/src/main/java/swm_nm/morandi/domain/member/dto/MemberListResponse.java @@ -6,7 +6,7 @@ @AllArgsConstructor @NoArgsConstructor @Builder -public class MemberListResponseDto { +public class MemberListResponse { private Long rank; private String bojId; diff --git a/src/main/java/swm_nm/morandi/domain/member/dto/RegisterInfoDto.java b/src/main/java/swm_nm/morandi/domain/member/dto/RegisterInfoRequest.java similarity index 86% rename from src/main/java/swm_nm/morandi/domain/member/dto/RegisterInfoDto.java rename to src/main/java/swm_nm/morandi/domain/member/dto/RegisterInfoRequest.java index f4267bff..0cc4bbee 100644 --- a/src/main/java/swm_nm/morandi/domain/member/dto/RegisterInfoDto.java +++ b/src/main/java/swm_nm/morandi/domain/member/dto/RegisterInfoRequest.java @@ -10,7 +10,7 @@ @Builder @AllArgsConstructor @NoArgsConstructor -public class RegisterInfoDto { +public class RegisterInfoRequest { @NotBlank private String bojId; } diff --git a/src/main/java/swm_nm/morandi/domain/member/service/MemberInfoService.java b/src/main/java/swm_nm/morandi/domain/member/service/MemberInfoService.java index 4d56af72..9225a724 100644 --- a/src/main/java/swm_nm/morandi/domain/member/service/MemberInfoService.java +++ b/src/main/java/swm_nm/morandi/domain/member/service/MemberInfoService.java @@ -3,7 +3,7 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; -import swm_nm.morandi.domain.member.dto.MemberInfoDto; +import swm_nm.morandi.domain.member.dto.MemberInfoRequest; import swm_nm.morandi.domain.member.entity.Member; import swm_nm.morandi.domain.member.repository.MemberRepository; import swm_nm.morandi.global.exception.MorandiException; @@ -16,10 +16,10 @@ public class MemberInfoService { private final MemberRepository memberRepository; - public MemberInfoDto getMemberInfo() { + public MemberInfoRequest getMemberInfo() { Long memberId = SecurityUtils.getCurrentMemberId(); Member member = memberRepository.findById(memberId).orElseThrow(() -> new MorandiException(MemberErrorCode.MEMBER_NOT_FOUND)); - MemberInfoDto memberInfoDto = new MemberInfoDto(); + MemberInfoRequest memberInfoDto = new MemberInfoRequest(); memberInfoDto.setIntroduceInfo(member.getIntroduceInfo()); memberInfoDto.setBojId(member.getBojId()); return memberInfoDto; diff --git a/src/main/java/swm_nm/morandi/domain/member/service/MemberInitService.java b/src/main/java/swm_nm/morandi/domain/member/service/MemberInitService.java index 960aaa58..16e354e9 100644 --- a/src/main/java/swm_nm/morandi/domain/member/service/MemberInitService.java +++ b/src/main/java/swm_nm/morandi/domain/member/service/MemberInitService.java @@ -3,7 +3,7 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; -import swm_nm.morandi.domain.member.dto.RegisterInfoDto; +import swm_nm.morandi.domain.member.dto.RegisterInfoRequest; import swm_nm.morandi.domain.member.entity.Member; import swm_nm.morandi.domain.member.repository.MemberRepository; import swm_nm.morandi.global.exception.MorandiException; @@ -20,7 +20,7 @@ public class MemberInitService { private final MemberRepository memberRepository; @Transactional - public RegisterInfoDto memberInitialize(RegisterInfoDto registerInfoDto) { + public RegisterInfoRequest memberInitialize(RegisterInfoRequest registerInfoDto) { Long memberId = SecurityUtils.getCurrentMemberId(); Member member = memberRepository.findById(memberId).orElseThrow(()-> new MorandiException(AuthErrorCode.MEMBER_NOT_FOUND)); member.setBojId(registerInfoDto.getBojId()); diff --git a/src/main/java/swm_nm/morandi/domain/member/service/MemberListService.java b/src/main/java/swm_nm/morandi/domain/member/service/MemberListService.java index ebc5a57b..e13d51fb 100644 --- a/src/main/java/swm_nm/morandi/domain/member/service/MemberListService.java +++ b/src/main/java/swm_nm/morandi/domain/member/service/MemberListService.java @@ -6,10 +6,9 @@ import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; -import org.springframework.data.domain.Sort.Direction; import org.springframework.stereotype.Service; -import swm_nm.morandi.domain.member.dto.MemberListRequestDto; -import swm_nm.morandi.domain.member.dto.MemberListResponseDto; +import swm_nm.morandi.domain.member.dto.MemberListRequest; +import swm_nm.morandi.domain.member.dto.MemberListResponse; import swm_nm.morandi.domain.member.entity.Member; import swm_nm.morandi.domain.member.repository.MemberRepository; @@ -25,16 +24,16 @@ public class MemberListService { private final MemberRepository memberRepository; - public List findAll(MemberListRequestDto memberListRequestDto) { - Integer page = memberListRequestDto.getPage(); - Integer size = memberListRequestDto.getSize(); + public List findAll(MemberListRequest memberListRequest) { + Integer page = memberListRequest.getPage(); + Integer size = memberListRequest.getSize(); Pageable pageable = PageRequest.of(page - 1, size, Sort.by(DESC, "rating")); Page memberPage = memberRepository.findAll(pageable); List members = memberPage.getContent(); - List memberListResponseDtos = new ArrayList<>(); + List memberListResponseDtos = new ArrayList<>(); long rankIndex = (page - 1) * size + 1; for (Member member : members) { - MemberListResponseDto memberListResponseDto = MemberListResponseDto.builder() + MemberListResponse memberListResponseDto = MemberListResponse.builder() .rank(rankIndex++) .bojId(member.getBojId()) .rating(member.getRating()) diff --git a/src/test/java/swm_nm/morandi/domain/member/service/MemberEditServiceTest.java b/src/test/java/swm_nm/morandi/domain/member/service/MemberEditServiceTest.java index 881c1826..b4ee2c72 100644 --- a/src/test/java/swm_nm/morandi/domain/member/service/MemberEditServiceTest.java +++ b/src/test/java/swm_nm/morandi/domain/member/service/MemberEditServiceTest.java @@ -1,19 +1,17 @@ package swm_nm.morandi.domain.member.service; -import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.security.test.context.support.WithMockUser; import org.springframework.transaction.annotation.Transactional; -import swm_nm.morandi.domain.member.dto.MemberInfoDto; +import swm_nm.morandi.domain.member.dto.MemberInfoRequest; import swm_nm.morandi.domain.member.entity.Member; import swm_nm.morandi.domain.member.repository.MemberRepository; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.*; @SpringBootTest @WithMockUser(username = "1", roles = "USER") @@ -28,7 +26,7 @@ class MemberEditServiceTest { @Transactional void editProfile() { // given - MemberInfoDto memberInfoDto = new MemberInfoDto(); + MemberInfoRequest memberInfoDto = new MemberInfoRequest(); memberInfoDto.setIntroduceInfo("hello world"); memberInfoDto.setBojId("aj4941"); diff --git a/src/test/java/swm_nm/morandi/domain/member/service/MemberInfoServiceTest.java b/src/test/java/swm_nm/morandi/domain/member/service/MemberInfoServiceTest.java index 64d1b261..3fa6d193 100644 --- a/src/test/java/swm_nm/morandi/domain/member/service/MemberInfoServiceTest.java +++ b/src/test/java/swm_nm/morandi/domain/member/service/MemberInfoServiceTest.java @@ -1,11 +1,10 @@ package swm_nm.morandi.domain.member.service; -import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.security.test.context.support.WithMockUser; import org.springframework.transaction.annotation.Transactional; -import swm_nm.morandi.domain.member.dto.MemberInfoDto; +import swm_nm.morandi.domain.member.dto.MemberInfoRequest; import swm_nm.morandi.domain.member.entity.Member; import swm_nm.morandi.domain.member.repository.MemberRepository; @@ -30,7 +29,7 @@ void getMemberInfo() { Member member = result.get(); // when - MemberInfoDto memberInfo = memberInfoService.getMemberInfo(); + MemberInfoRequest memberInfo = memberInfoService.getMemberInfo(); // then assertThat(memberInfo.getBojId()).isEqualTo(member.getBojId()); diff --git a/src/test/java/swm_nm/morandi/domain/member/service/MemberInitServiceTest.java b/src/test/java/swm_nm/morandi/domain/member/service/MemberInitServiceTest.java index 4398f7ab..c1ad9031 100644 --- a/src/test/java/swm_nm/morandi/domain/member/service/MemberInitServiceTest.java +++ b/src/test/java/swm_nm/morandi/domain/member/service/MemberInitServiceTest.java @@ -1,15 +1,12 @@ package swm_nm.morandi.domain.member.service; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.security.test.context.support.WithMockUser; -import org.springframework.transaction.annotation.Transactional; -import swm_nm.morandi.domain.member.dto.RegisterInfoDto; +import swm_nm.morandi.domain.member.dto.RegisterInfoRequest; import swm_nm.morandi.domain.member.entity.Member; import swm_nm.morandi.domain.member.repository.MemberRepository; -import java.util.List; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat; @SpringBootTest @@ -24,7 +21,7 @@ class MemberInitServiceTest { @Test void memberInitialize() { // given - RegisterInfoDto registerInfoDto = RegisterInfoDto.builder() + RegisterInfoRequest registerInfoDto = RegisterInfoRequest.builder() .bojId("aj4941") .build(); From c5f1f4a4bb075e5ccf107c8583ad6e14cf0358c1 Mon Sep 17 00:00:00 2001 From: miiiinju1 Date: Sun, 5 Nov 2023 16:08:12 +0900 Subject: [PATCH 4/4] =?UTF-8?q?:truck:=20[Refactor]=20Test=20=EA=B4=80?= =?UTF-8?q?=EB=A0=A8=20Dto=20Request=EC=99=80=20Response=20=EB=B6=84?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/PracticeController.java | 11 ++-- .../controller/TestExitController.java | 21 +++---- ...ptCodeDto.java => AttemptCodeRequest.java} | 2 +- ...ResultDto.java => TestResultResponse.java} | 2 +- .../testExit/service/SaveCodeService.java | 4 +- .../testExit/service/TestExitService.java | 10 ++-- .../controller/TestInfoController.java | 4 +- .../testInfo/dto/MyTestHistoryResponse.java | 6 +- .../service/LatestTestInfoService.java | 12 ++-- .../controller/TestRecordController.java | 21 ++++--- .../dto/AllTestHistoryResponse.java | 2 +- ...ingDto.java => CurrentRatingResponse.java} | 2 +- .../domain/testRecord/dto/GraphDto.java | 12 ---- ...aphResponseDto.java => GraphResponse.java} | 4 +- .../domain/testRecord/dto/GrassDto.java | 15 ----- ...GraphDto.java => RatingGraphResponse.java} | 2 +- ...storyDto.java => TestHistoryResponse.java} | 2 +- .../domain/testRecord/dto/TestRatingDto.java | 24 -------- ...estDto.java => TestRecordPageRequest.java} | 2 +- ...RecordDto.java => TestRecordResponse.java} | 2 +- .../testRecord/mapper/TestRecordMapper.java | 10 ++-- .../testRecord/service/GetGraphService.java | 16 +---- .../testRecord/service/GetGrassService.java | 58 ------------------- .../testRecord/service/RatingService.java | 12 ++-- .../service/TestDetailsService.java | 6 +- 25 files changed, 70 insertions(+), 192 deletions(-) rename src/main/java/swm_nm/morandi/domain/testExit/dto/{AttemptCodeDto.java => AttemptCodeRequest.java} (86%) rename src/main/java/swm_nm/morandi/domain/testExit/dto/{TestResultDto.java => TestResultResponse.java} (96%) rename src/main/java/swm_nm/morandi/domain/testRecord/dto/{CurrentRatingDto.java => CurrentRatingResponse.java} (80%) delete mode 100644 src/main/java/swm_nm/morandi/domain/testRecord/dto/GraphDto.java rename src/main/java/swm_nm/morandi/domain/testRecord/dto/{GraphResponseDto.java => GraphResponse.java} (91%) delete mode 100644 src/main/java/swm_nm/morandi/domain/testRecord/dto/GrassDto.java rename src/main/java/swm_nm/morandi/domain/testRecord/dto/{RatingGraphDto.java => RatingGraphResponse.java} (95%) rename src/main/java/swm_nm/morandi/domain/testRecord/dto/{TestHistoryDto.java => TestHistoryResponse.java} (96%) delete mode 100644 src/main/java/swm_nm/morandi/domain/testRecord/dto/TestRatingDto.java rename src/main/java/swm_nm/morandi/domain/testRecord/dto/{TestRecordRequestDto.java => TestRecordPageRequest.java} (84%) rename src/main/java/swm_nm/morandi/domain/testRecord/dto/{TestRecordDto.java => TestRecordResponse.java} (97%) delete mode 100644 src/main/java/swm_nm/morandi/domain/testRecord/service/GetGrassService.java diff --git a/src/main/java/swm_nm/morandi/domain/practice/controller/PracticeController.java b/src/main/java/swm_nm/morandi/domain/practice/controller/PracticeController.java index 3a6ddf32..08434a9a 100644 --- a/src/main/java/swm_nm/morandi/domain/practice/controller/PracticeController.java +++ b/src/main/java/swm_nm/morandi/domain/practice/controller/PracticeController.java @@ -4,10 +4,7 @@ import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -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 swm_nm.morandi.domain.practice.dto.PracticeExitDto; import swm_nm.morandi.domain.practice.dto.PracticeResultDto; import swm_nm.morandi.domain.practice.dto.PracticeStartDto; @@ -29,10 +26,10 @@ public class PracticeController { private final RunCodeService runCodeService; @PostMapping + @ResponseStatus(HttpStatus.OK) @Operation(summary = "연습 문제 시작하기", description = "사용자가 임의로 백준 문제 번호를 골라서 문제를 풀려고 시도할 때 테이블을 구성합니다.") - public ResponseEntity practiceStart(@RequestBody PracticeStartDto practiceStartDto) { - PracticeStartResponseDto practiceStartResponseDto = practiceProblemService.startPractices(practiceStartDto.getBojProblemId()); - return new ResponseEntity(practiceStartResponseDto, HttpStatus.OK); + public PracticeStartResponseDto practiceStart(@RequestBody PracticeStartDto practiceStartDto) { + return practiceProblemService.startPractices(practiceStartDto.getBojProblemId()); } @PostMapping("/exit") @Operation(summary = "연습 문제 종료하기", description = "사용자가 시도한 연습문제를 종료할 경우 결과 데이터를 반환합니다.") diff --git a/src/main/java/swm_nm/morandi/domain/testExit/controller/TestExitController.java b/src/main/java/swm_nm/morandi/domain/testExit/controller/TestExitController.java index 3a59410d..0367af36 100644 --- a/src/main/java/swm_nm/morandi/domain/testExit/controller/TestExitController.java +++ b/src/main/java/swm_nm/morandi/domain/testExit/controller/TestExitController.java @@ -3,19 +3,16 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; -import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; -import org.springframework.web.servlet.support.ServletUriComponentsBuilder; import swm_nm.morandi.domain.testDuring.dto.TestCheckDto; -import swm_nm.morandi.domain.testExit.dto.AttemptCodeDto; -import swm_nm.morandi.domain.testExit.dto.TestResultDto; +import swm_nm.morandi.domain.testExit.dto.AttemptCodeRequest; +import swm_nm.morandi.domain.testExit.dto.TestResultResponse; import swm_nm.morandi.domain.testExit.service.SaveCodeService; import swm_nm.morandi.domain.testExit.service.TestExitService; import javax.servlet.http.HttpSession; -import java.net.URI; @RestController @RequestMapping("/tests") @@ -28,23 +25,23 @@ public class TestExitController { private final SaveCodeService saveCodeService; @PostMapping("/exit") @Operation(summary = "테스트 종료하기", description = "테스트를 종료할 경우 문제별 정답 여부와 이를 기반으로 레이팅을 계산합니다.") - public ResponseEntity saveAttemptedProblemResultByPost(@RequestBody TestCheckDto testCheckDto, + public ResponseEntity saveAttemptedProblemResultByPost(@RequestBody TestCheckDto testCheckDto, HttpSession session) { session.setAttribute("testResultDto", testExitService.testExit(testCheckDto)); return new ResponseEntity<>(HttpStatus.SEE_OTHER); } @GetMapping("/result") + @ResponseStatus(HttpStatus.OK) @Operation(summary = "테스트 결과 데이터 제공", description = "테스트를 종료할 때 POST 요청을 받은 것을 PRG 패턴을 통해 GET 요청으로 받습니다.") - public ResponseEntity saveAttemptedProblemResultByGet(HttpSession session) { - TestResultDto testResultDto = (TestResultDto) session.getAttribute("testResultDto"); - return new ResponseEntity<>(testResultDto, HttpStatus.OK); + public TestResultResponse saveAttemptedProblemResultByGet(HttpSession session) { + return (TestResultResponse) session.getAttribute("testResultDto"); } @PostMapping("/submit") + @ResponseStatus(HttpStatus.OK) @Operation(summary = "테스트 종료 시점 코드 저장", description = "테스트 종료 시점에서 종료하기 직전 API를 호출하여 사용자가 풀어둔 코드를 저장해야 합니다.") - public ResponseEntity saveCode(@RequestBody AttemptCodeDto attemptCodeDto) { - saveCodeService.saveEachCodeinAttemptProblems(attemptCodeDto); - return new ResponseEntity<>(HttpStatus.OK); + public void saveCode(@RequestBody AttemptCodeRequest attemptCodeDto) { + saveCodeService.saveEachCodeinAttemptProblems(attemptCodeDto); } } diff --git a/src/main/java/swm_nm/morandi/domain/testExit/dto/AttemptCodeDto.java b/src/main/java/swm_nm/morandi/domain/testExit/dto/AttemptCodeRequest.java similarity index 86% rename from src/main/java/swm_nm/morandi/domain/testExit/dto/AttemptCodeDto.java rename to src/main/java/swm_nm/morandi/domain/testExit/dto/AttemptCodeRequest.java index 92801491..6409ac13 100644 --- a/src/main/java/swm_nm/morandi/domain/testExit/dto/AttemptCodeDto.java +++ b/src/main/java/swm_nm/morandi/domain/testExit/dto/AttemptCodeRequest.java @@ -9,7 +9,7 @@ @Setter @NoArgsConstructor @AllArgsConstructor -public class AttemptCodeDto { +public class AttemptCodeRequest { private Long testId; private Map submitCode; } diff --git a/src/main/java/swm_nm/morandi/domain/testExit/dto/TestResultDto.java b/src/main/java/swm_nm/morandi/domain/testExit/dto/TestResultResponse.java similarity index 96% rename from src/main/java/swm_nm/morandi/domain/testExit/dto/TestResultDto.java rename to src/main/java/swm_nm/morandi/domain/testExit/dto/TestResultResponse.java index abeb6dd4..32bb9194 100644 --- a/src/main/java/swm_nm/morandi/domain/testExit/dto/TestResultDto.java +++ b/src/main/java/swm_nm/morandi/domain/testExit/dto/TestResultResponse.java @@ -15,7 +15,7 @@ @Builder @NoArgsConstructor @AllArgsConstructor -public class TestResultDto { +public class TestResultResponse { @JsonSerialize(using = LocalDateTimeSerializer.class) @JsonDeserialize(using = LocalDateTimeDeserializer.class) diff --git a/src/main/java/swm_nm/morandi/domain/testExit/service/SaveCodeService.java b/src/main/java/swm_nm/morandi/domain/testExit/service/SaveCodeService.java index ed68e5a3..459bea91 100644 --- a/src/main/java/swm_nm/morandi/domain/testExit/service/SaveCodeService.java +++ b/src/main/java/swm_nm/morandi/domain/testExit/service/SaveCodeService.java @@ -4,7 +4,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import swm_nm.morandi.domain.testInfo.entity.AttemptProblem; -import swm_nm.morandi.domain.testExit.dto.AttemptCodeDto; +import swm_nm.morandi.domain.testExit.dto.AttemptCodeRequest; import swm_nm.morandi.domain.testRecord.repository.AttemptProblemRepository; import swm_nm.morandi.global.exception.MorandiException; import swm_nm.morandi.global.exception.errorcode.AttemptProblemErrorCode; @@ -19,7 +19,7 @@ public class SaveCodeService { private final AttemptProblemRepository attemptProblemRepository; - public void saveEachCodeinAttemptProblems(AttemptCodeDto attemptCodeDto) { + public void saveEachCodeinAttemptProblems(AttemptCodeRequest attemptCodeDto) { List attemptProblems = attemptProblemRepository.findAttemptProblemsByTest_TestId(attemptCodeDto.getTestId()); if(attemptProblems.isEmpty()) { diff --git a/src/main/java/swm_nm/morandi/domain/testExit/service/TestExitService.java b/src/main/java/swm_nm/morandi/domain/testExit/service/TestExitService.java index 923decf4..b7c9129c 100644 --- a/src/main/java/swm_nm/morandi/domain/testExit/service/TestExitService.java +++ b/src/main/java/swm_nm/morandi/domain/testExit/service/TestExitService.java @@ -6,7 +6,7 @@ import org.springframework.stereotype.Service; import swm_nm.morandi.domain.testDuring.dto.TestCheckDto; import swm_nm.morandi.domain.testDuring.dto.TestStatus; -import swm_nm.morandi.domain.testExit.dto.TestResultDto; +import swm_nm.morandi.domain.testExit.dto.TestResultResponse; import swm_nm.morandi.domain.testInfo.entity.AttemptProblem; import swm_nm.morandi.domain.testInfo.entity.TestType; import swm_nm.morandi.domain.testInfo.entity.Tests; @@ -51,7 +51,7 @@ public class TestExitService { private final RedisKeyGenerator redisKeyGenerator; //Controller에서 사용되는 것 - public TestResultDto testExit(TestCheckDto testCheckDto) + public TestResultResponse testExit(TestCheckDto testCheckDto) { Long memberId = SecurityUtils.getCurrentMemberId(); Member member = memberRepository.findById(memberId) @@ -64,11 +64,11 @@ public TestResultDto testExit(TestCheckDto testCheckDto) } @Transactional - public TestResultDto testExit(TestCheckDto testCheckDto, Member member, Tests test, TestType testType) { + public TestResultResponse testExit(TestCheckDto testCheckDto, Member member, Tests test, TestType testType) { String bojId = testCheckDto.getBojId(); solvedCheckService.checkAttemptedProblemResult(test, bojId); - TestResultDto testResultDto = TestResultDto.builder().build(); + TestResultResponse testResultDto = TestResultResponse.builder().build(); saveTestResult(member, test, testType, testResultDto); List attemptProblems = attemptProblemRepository.findAttemptProblemsByTest_TestId(test.getTestId()); @@ -88,7 +88,7 @@ public TestResultDto testExit(TestCheckDto testCheckDto, Member member, Tests te } @Transactional - public void saveTestResult(Member member, Tests test, TestType testType, TestResultDto testResultDto) { + public void saveTestResult(Member member, Tests test, TestType testType, TestResultResponse testResultDto) { test.setTestStatus(TestStatus.COMPLETED); List attemptProblems = attemptProblemRepository.findAllByTest_TestId(test.getTestId()); long correct = attemptProblems.stream() diff --git a/src/main/java/swm_nm/morandi/domain/testInfo/controller/TestInfoController.java b/src/main/java/swm_nm/morandi/domain/testInfo/controller/TestInfoController.java index dc777e51..c8d22f4e 100644 --- a/src/main/java/swm_nm/morandi/domain/testInfo/controller/TestInfoController.java +++ b/src/main/java/swm_nm/morandi/domain/testInfo/controller/TestInfoController.java @@ -7,7 +7,7 @@ import swm_nm.morandi.domain.testInfo.dto.MyTestHistoryResponse; import swm_nm.morandi.domain.testInfo.dto.TestTypeInfoResponse; import swm_nm.morandi.domain.testInfo.service.*; -import swm_nm.morandi.domain.testRecord.dto.TestRecordRequestDto; +import swm_nm.morandi.domain.testRecord.dto.TestRecordPageRequest; import java.util.List; @@ -29,7 +29,7 @@ public class TestInfoController { @GetMapping("/latest") @ResponseStatus(HttpStatus.OK) @Operation(summary = "최근에 본 테스트 목록", description = "마이 페이지에서 최근에 본 테스트 4개를 제공합니다.") - public MyTestHistoryResponse getLatestTestDtos(TestRecordRequestDto testRecordRequestDto) { + public MyTestHistoryResponse getLatestTestDtos(TestRecordPageRequest testRecordRequestDto) { return latestTestInfoService.getTestRecordDtosLatest(testRecordRequestDto); } @GetMapping("/practice") diff --git a/src/main/java/swm_nm/morandi/domain/testInfo/dto/MyTestHistoryResponse.java b/src/main/java/swm_nm/morandi/domain/testInfo/dto/MyTestHistoryResponse.java index aa4e8e54..b8717a5c 100644 --- a/src/main/java/swm_nm/morandi/domain/testInfo/dto/MyTestHistoryResponse.java +++ b/src/main/java/swm_nm/morandi/domain/testInfo/dto/MyTestHistoryResponse.java @@ -1,7 +1,7 @@ package swm_nm.morandi.domain.testInfo.dto; import lombok.*; -import swm_nm.morandi.domain.testRecord.dto.TestRecordDto; +import swm_nm.morandi.domain.testRecord.dto.TestRecordResponse; import java.util.ArrayList; import java.util.List; @@ -12,8 +12,8 @@ @Builder public class MyTestHistoryResponse { private Long totalElements; - private List testRecordDtos = new ArrayList<>(); - public static MyTestHistoryResponse getTestPageDto(Long totalElements, List testRecordDtos) { + private List testRecordDtos = new ArrayList<>(); + public static MyTestHistoryResponse getTestPageDto(Long totalElements, List testRecordDtos) { return MyTestHistoryResponse.builder() .totalElements(totalElements) .testRecordDtos(testRecordDtos) diff --git a/src/main/java/swm_nm/morandi/domain/testInfo/service/LatestTestInfoService.java b/src/main/java/swm_nm/morandi/domain/testInfo/service/LatestTestInfoService.java index de559096..55bb868c 100644 --- a/src/main/java/swm_nm/morandi/domain/testInfo/service/LatestTestInfoService.java +++ b/src/main/java/swm_nm/morandi/domain/testInfo/service/LatestTestInfoService.java @@ -10,9 +10,9 @@ import swm_nm.morandi.domain.testDuring.dto.TestStatus; import swm_nm.morandi.domain.testExit.dto.AttemptProblemDto; import swm_nm.morandi.domain.testInfo.dto.MyTestHistoryResponse; -import swm_nm.morandi.domain.testRecord.dto.TestRecordDto; +import swm_nm.morandi.domain.testRecord.dto.TestRecordResponse; import swm_nm.morandi.domain.testInfo.entity.Tests; -import swm_nm.morandi.domain.testRecord.dto.TestRecordRequestDto; +import swm_nm.morandi.domain.testRecord.dto.TestRecordPageRequest; import swm_nm.morandi.domain.testRecord.mapper.TestRecordMapper; import swm_nm.morandi.domain.testInfo.repository.TestRepository; import swm_nm.morandi.global.utils.SecurityUtils; @@ -29,7 +29,7 @@ public class LatestTestInfoService { private final TestRepository testRepository; @Transactional(readOnly = true) - public MyTestHistoryResponse getTestRecordDtosLatest(TestRecordRequestDto testRecordRequestDto) { + public MyTestHistoryResponse getTestRecordDtosLatest(TestRecordPageRequest testRecordRequestDto) { Long memberId = SecurityUtils.getCurrentMemberId(); Integer page = testRecordRequestDto.getPage(); Integer size = testRecordRequestDto.getSize(); @@ -39,10 +39,10 @@ public MyTestHistoryResponse getTestRecordDtosLatest(TestRecordRequestDto testRe Page recentTests = testRepository.findAllTestsByMember_MemberIdAndTestStatus(memberId, TestStatus.COMPLETED, pageable); //테스트 기록을 받아와서 dto로 변환하면서 getAttemptProblemDtos를 통해 테스트 문제들을 dto로 변환 - List testRecordDtos = + List testRecordDtos = recentTests.stream().map(recentTest -> { List attemptProblemDtos = getAttemptProblemDtos(recentTest); - TestRecordDto testRecordDto = TestRecordMapper.convertToDto(recentTest, attemptProblemDtos); + TestRecordResponse testRecordDto = TestRecordMapper.convertToDto(recentTest, attemptProblemDtos); return testRecordDto;}) .collect(Collectors.toList()); @@ -66,7 +66,7 @@ public List getAttemptProblemDtos(Tests test) { }).collect(Collectors.toList()); } - private static void getTestRecordDtos(List testRecordDtos) { + private static void getTestRecordDtos(List testRecordDtos) { while (testRecordDtos.size() < 4) { testRecordDtos.add(TestRecordMapper.dummyDto()); } diff --git a/src/main/java/swm_nm/morandi/domain/testRecord/controller/TestRecordController.java b/src/main/java/swm_nm/morandi/domain/testRecord/controller/TestRecordController.java index bb42df98..48eb270e 100644 --- a/src/main/java/swm_nm/morandi/domain/testRecord/controller/TestRecordController.java +++ b/src/main/java/swm_nm/morandi/domain/testRecord/controller/TestRecordController.java @@ -31,27 +31,30 @@ public ResponseEntity> memberRecordGrass() { return new ResponseEntity<>(grassHeatMapService.getGrassHeatMap(), HttpStatus.OK); } @GetMapping("/graphs") + @ResponseStatus(HttpStatus.OK) @Operation(summary = "사용자 그래프 분석 데이터", description = "사용자가 테스트를 본 결과를 바탕으로 그래프 분석 데이터를 보여줍니다.") - public ResponseEntity memberRecordGraph() { - // return new ResponseEntity<>(getGraphService.getGraphDtos(), HttpStatus.OK); - return new ResponseEntity<>(getGraphService.getGraph(), HttpStatus.OK); + public GraphResponse memberRecordGraph() { + return getGraphService.getMemberGraph(); } @GetMapping("/current-rating") + @ResponseStatus(HttpStatus.OK) @Operation(summary = "사용자 현재 레이팅", description = "사용자가 가지고 있는 현재 레이팅을 보여줍니다.") - public ResponseEntity memberCurrentRating() { - return new ResponseEntity<>(ratingService.getCurrentRatingDto(), HttpStatus.OK); + public CurrentRatingResponse memberCurrentRating() { + return ratingService.getCurrentRatingDto(); } @GetMapping("/rating-graph") + @ResponseStatus(HttpStatus.OK) @Operation(summary = "사용자 그래프 분석 데이터", description = "1년 동안의 사용자 테스트 레이팅 결과 데이터를 최근 날짜부터 내림차순으로 보여줍니다.") - public ResponseEntity> memberRatingGraph(){ - return new ResponseEntity<>(ratingService.getRatingGraphSinceOneYear(), HttpStatus.OK); + public List memberRatingGraph(){ + return ratingService.getRatingGraphSinceOneYear(); } @GetMapping("/{testId}") + @ResponseStatus(HttpStatus.OK) @Operation(summary = "사용자 테스트 기록 상세 보기", description = "사용자가 진행한 특정 테스트의 상세보기를 클릭한 경우 테스트 상세 기록을 보여줍니다.") - public ResponseEntity testRecordInfo(@PathVariable Long testId) { - return new ResponseEntity<>(testDetailsService.getTestRecordDtoByTestId(testId), HttpStatus.OK); + public TestRecordResponse testRecordInfo(@PathVariable Long testId) { + return testDetailsService.getTestRecordDtoByTestId(testId); } @GetMapping diff --git a/src/main/java/swm_nm/morandi/domain/testRecord/dto/AllTestHistoryResponse.java b/src/main/java/swm_nm/morandi/domain/testRecord/dto/AllTestHistoryResponse.java index 023e671c..d4b71d43 100644 --- a/src/main/java/swm_nm/morandi/domain/testRecord/dto/AllTestHistoryResponse.java +++ b/src/main/java/swm_nm/morandi/domain/testRecord/dto/AllTestHistoryResponse.java @@ -14,6 +14,6 @@ public class AllTestHistoryResponse { public long totalElements; public int currentSize; - public List testHistorys; + public List testHistorys; } diff --git a/src/main/java/swm_nm/morandi/domain/testRecord/dto/CurrentRatingDto.java b/src/main/java/swm_nm/morandi/domain/testRecord/dto/CurrentRatingResponse.java similarity index 80% rename from src/main/java/swm_nm/morandi/domain/testRecord/dto/CurrentRatingDto.java rename to src/main/java/swm_nm/morandi/domain/testRecord/dto/CurrentRatingResponse.java index f6d4113a..74a6f558 100644 --- a/src/main/java/swm_nm/morandi/domain/testRecord/dto/CurrentRatingDto.java +++ b/src/main/java/swm_nm/morandi/domain/testRecord/dto/CurrentRatingResponse.java @@ -6,7 +6,7 @@ @NoArgsConstructor @AllArgsConstructor @Builder -public class CurrentRatingDto { +public class CurrentRatingResponse { private Long rating; } diff --git a/src/main/java/swm_nm/morandi/domain/testRecord/dto/GraphDto.java b/src/main/java/swm_nm/morandi/domain/testRecord/dto/GraphDto.java deleted file mode 100644 index 7a0894ac..00000000 --- a/src/main/java/swm_nm/morandi/domain/testRecord/dto/GraphDto.java +++ /dev/null @@ -1,12 +0,0 @@ -package swm_nm.morandi.domain.testRecord.dto; - -import lombok.*; - -@Getter @Setter -@NoArgsConstructor -@AllArgsConstructor -@Builder -public class GraphDto { - private String algorithmName; - private Long solvedRate; -} diff --git a/src/main/java/swm_nm/morandi/domain/testRecord/dto/GraphResponseDto.java b/src/main/java/swm_nm/morandi/domain/testRecord/dto/GraphResponse.java similarity index 91% rename from src/main/java/swm_nm/morandi/domain/testRecord/dto/GraphResponseDto.java rename to src/main/java/swm_nm/morandi/domain/testRecord/dto/GraphResponse.java index ee6bb8cf..74e23811 100644 --- a/src/main/java/swm_nm/morandi/domain/testRecord/dto/GraphResponseDto.java +++ b/src/main/java/swm_nm/morandi/domain/testRecord/dto/GraphResponse.java @@ -11,11 +11,11 @@ @Getter @Builder @AllArgsConstructor -public class GraphResponseDto { +public class GraphResponse { public HashMap solvedRates; - public GraphResponseDto() { + public GraphResponse() { this.solvedRates = new HashMap<>(); solvedRates.put("구현", 0L); solvedRates.put("그래프", 0L); diff --git a/src/main/java/swm_nm/morandi/domain/testRecord/dto/GrassDto.java b/src/main/java/swm_nm/morandi/domain/testRecord/dto/GrassDto.java deleted file mode 100644 index 4f867f1b..00000000 --- a/src/main/java/swm_nm/morandi/domain/testRecord/dto/GrassDto.java +++ /dev/null @@ -1,15 +0,0 @@ -package swm_nm.morandi.domain.testRecord.dto; - -import lombok.*; - -import java.time.LocalDate; - -@Getter @Setter -@NoArgsConstructor -@AllArgsConstructor -@Builder -public class GrassDto { - - private LocalDate testDate; - private Integer solvedCount; -} diff --git a/src/main/java/swm_nm/morandi/domain/testRecord/dto/RatingGraphDto.java b/src/main/java/swm_nm/morandi/domain/testRecord/dto/RatingGraphResponse.java similarity index 95% rename from src/main/java/swm_nm/morandi/domain/testRecord/dto/RatingGraphDto.java rename to src/main/java/swm_nm/morandi/domain/testRecord/dto/RatingGraphResponse.java index c3c79a38..29a38e63 100644 --- a/src/main/java/swm_nm/morandi/domain/testRecord/dto/RatingGraphDto.java +++ b/src/main/java/swm_nm/morandi/domain/testRecord/dto/RatingGraphResponse.java @@ -14,7 +14,7 @@ @Getter @Builder @AllArgsConstructor -public class RatingGraphDto { +public class RatingGraphResponse { @JsonSerialize(using = LocalDateTimeSerializer.class) @JsonDeserialize(using = LocalDateTimeDeserializer.class) diff --git a/src/main/java/swm_nm/morandi/domain/testRecord/dto/TestHistoryDto.java b/src/main/java/swm_nm/morandi/domain/testRecord/dto/TestHistoryResponse.java similarity index 96% rename from src/main/java/swm_nm/morandi/domain/testRecord/dto/TestHistoryDto.java rename to src/main/java/swm_nm/morandi/domain/testRecord/dto/TestHistoryResponse.java index 3d8f0c60..b427fc0a 100644 --- a/src/main/java/swm_nm/morandi/domain/testRecord/dto/TestHistoryDto.java +++ b/src/main/java/swm_nm/morandi/domain/testRecord/dto/TestHistoryResponse.java @@ -17,7 +17,7 @@ @Setter @AllArgsConstructor @Builder -public class TestHistoryDto { +public class TestHistoryResponse { public Long testId; diff --git a/src/main/java/swm_nm/morandi/domain/testRecord/dto/TestRatingDto.java b/src/main/java/swm_nm/morandi/domain/testRecord/dto/TestRatingDto.java deleted file mode 100644 index 71628d70..00000000 --- a/src/main/java/swm_nm/morandi/domain/testRecord/dto/TestRatingDto.java +++ /dev/null @@ -1,24 +0,0 @@ -package swm_nm.morandi.domain.testRecord.dto; - -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; -import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; -import lombok.*; - -import java.time.LocalDateTime; - -@Getter @Setter -@NoArgsConstructor -@AllArgsConstructor -@Builder -public class TestRatingDto { - private Long testId; - @JsonSerialize(using = LocalDateTimeSerializer.class) - @JsonDeserialize(using = LocalDateTimeDeserializer.class) - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime testDate; - private String testTypeName; - private Long testRating; -} diff --git a/src/main/java/swm_nm/morandi/domain/testRecord/dto/TestRecordRequestDto.java b/src/main/java/swm_nm/morandi/domain/testRecord/dto/TestRecordPageRequest.java similarity index 84% rename from src/main/java/swm_nm/morandi/domain/testRecord/dto/TestRecordRequestDto.java rename to src/main/java/swm_nm/morandi/domain/testRecord/dto/TestRecordPageRequest.java index 813ea554..568e9513 100644 --- a/src/main/java/swm_nm/morandi/domain/testRecord/dto/TestRecordRequestDto.java +++ b/src/main/java/swm_nm/morandi/domain/testRecord/dto/TestRecordPageRequest.java @@ -8,7 +8,7 @@ @AllArgsConstructor @Builder @ToString -public class TestRecordRequestDto { +public class TestRecordPageRequest { private Integer page = 1; private Integer size = 4; } diff --git a/src/main/java/swm_nm/morandi/domain/testRecord/dto/TestRecordDto.java b/src/main/java/swm_nm/morandi/domain/testRecord/dto/TestRecordResponse.java similarity index 97% rename from src/main/java/swm_nm/morandi/domain/testRecord/dto/TestRecordDto.java rename to src/main/java/swm_nm/morandi/domain/testRecord/dto/TestRecordResponse.java index 2d13e73c..bd07a7ba 100644 --- a/src/main/java/swm_nm/morandi/domain/testRecord/dto/TestRecordDto.java +++ b/src/main/java/swm_nm/morandi/domain/testRecord/dto/TestRecordResponse.java @@ -17,7 +17,7 @@ @AllArgsConstructor @Builder @ToString -public class TestRecordDto { +public class TestRecordResponse { private Long testId; @JsonSerialize(using = LocalDateTimeSerializer.class) diff --git a/src/main/java/swm_nm/morandi/domain/testRecord/mapper/TestRecordMapper.java b/src/main/java/swm_nm/morandi/domain/testRecord/mapper/TestRecordMapper.java index 405ced45..1b444d9e 100644 --- a/src/main/java/swm_nm/morandi/domain/testRecord/mapper/TestRecordMapper.java +++ b/src/main/java/swm_nm/morandi/domain/testRecord/mapper/TestRecordMapper.java @@ -3,20 +3,20 @@ import swm_nm.morandi.domain.problem.dto.DifficultyLevel; import swm_nm.morandi.domain.testExit.dto.AttemptProblemDto; import swm_nm.morandi.domain.testInfo.entity.Tests; -import swm_nm.morandi.domain.testRecord.dto.TestRecordDto; +import swm_nm.morandi.domain.testRecord.dto.TestRecordResponse; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; public class TestRecordMapper { - public static TestRecordDto convertToDto(Tests test, List attemptProblemDtos) { + public static TestRecordResponse convertToDto(Tests test, List attemptProblemDtos) { Integer acceptCount = 0; for (AttemptProblemDto attemptProblemDto : attemptProblemDtos) { if (attemptProblemDto.getIsSolved()) acceptCount++; } - TestRecordDto testRecordDto = TestRecordDto.builder() + TestRecordResponse testRecordDto = TestRecordResponse.builder() .testId(test.getTestId()) .testDate(test.getTestDate()) .testTime(test.getTestTime()) @@ -33,8 +33,8 @@ public static TestRecordDto convertToDto(Tests test, List att return testRecordDto; } - public static TestRecordDto dummyDto() { - TestRecordDto testRecordDto = TestRecordDto.builder() + public static TestRecordResponse dummyDto() { + TestRecordResponse testRecordDto = TestRecordResponse.builder() .testId(0L) .testDate(LocalDateTime.now()) .testTime(0L) diff --git a/src/main/java/swm_nm/morandi/domain/testRecord/service/GetGraphService.java b/src/main/java/swm_nm/morandi/domain/testRecord/service/GetGraphService.java index c54a4ad4..6c46135d 100644 --- a/src/main/java/swm_nm/morandi/domain/testRecord/service/GetGraphService.java +++ b/src/main/java/swm_nm/morandi/domain/testRecord/service/GetGraphService.java @@ -4,21 +4,11 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import swm_nm.morandi.domain.testRecord.dto.GraphDto; -import swm_nm.morandi.domain.problem.entity.Algorithm; -import swm_nm.morandi.domain.problem.entity.AlgorithmProblemList; -import swm_nm.morandi.domain.problem.repository.AlgorithmProblemListRepository; -import swm_nm.morandi.domain.problem.repository.AlgorithmRepository; -import swm_nm.morandi.domain.testInfo.entity.AttemptProblem; -import swm_nm.morandi.domain.testRecord.dto.GraphResponseDto; +import swm_nm.morandi.domain.testRecord.dto.GraphResponse; import swm_nm.morandi.domain.testRecord.repository.AttemptProblemRepository; import swm_nm.morandi.global.utils.SecurityUtils; -import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; @Service @RequiredArgsConstructor @@ -33,11 +23,11 @@ public class GetGraphService { @Transactional(readOnly = true) - public GraphResponseDto getGraph(){ + public GraphResponse getMemberGraph(){ Long memberId = SecurityUtils.getCurrentMemberId(); List result = attemptProblemRepository.getAttemptStatisticsCollectByAlgorithm(memberId); - GraphResponseDto graphResponseDto = new GraphResponseDto(); + GraphResponse graphResponseDto = new GraphResponse(); result.forEach(objects -> graphResponseDto.solvedRates diff --git a/src/main/java/swm_nm/morandi/domain/testRecord/service/GetGrassService.java b/src/main/java/swm_nm/morandi/domain/testRecord/service/GetGrassService.java deleted file mode 100644 index ada7f73b..00000000 --- a/src/main/java/swm_nm/morandi/domain/testRecord/service/GetGrassService.java +++ /dev/null @@ -1,58 +0,0 @@ -package swm_nm.morandi.domain.testRecord.service; - -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import swm_nm.morandi.domain.testRecord.dto.GrassDto; -import swm_nm.morandi.domain.testInfo.entity.AttemptProblem; -import swm_nm.morandi.domain.testRecord.repository.AttemptProblemRepository; -import swm_nm.morandi.global.utils.SecurityUtils; - -import java.time.LocalDate; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -@Service -@RequiredArgsConstructor -@Slf4j -public class GetGrassService { - - private final AttemptProblemRepository attemptProblemRepository; - - public List getGrassDtos() { - Long memberId = SecurityUtils.getCurrentMemberId(); - java.util.List grassDtos = new ArrayList<>(); - java.util.List attemptProblems = attemptProblemRepository.findAllByMember_MemberId(memberId); - if (!attemptProblems.isEmpty()) { - Map grassMap = new HashMap<>(); - attemptProblems.forEach(attemptProblem -> { - LocalDate testDate = attemptProblem.getTestDate(); - if (attemptProblem.getIsSolved()) { - Integer currentValue = grassMap.getOrDefault(testDate, 0); - Integer newValue = currentValue + 1; - grassMap.put(testDate, newValue); - } - }); - grassMap.entrySet().forEach(entry -> { - LocalDate testDate = entry.getKey(); - Integer solvedCount = entry.getValue(); - GrassDto grassDto = GrassDto.builder() - .testDate(testDate) - .solvedCount(solvedCount) - .build(); - grassDtos.add(grassDto); - }); - } - - if (grassDtos.size() == 0) { - GrassDto grassDto = GrassDto.builder() - .testDate(null) - .solvedCount(null) - .build(); - grassDtos.add(grassDto); - } - return grassDtos; - } -} diff --git a/src/main/java/swm_nm/morandi/domain/testRecord/service/RatingService.java b/src/main/java/swm_nm/morandi/domain/testRecord/service/RatingService.java index 5fb2d853..8b034762 100644 --- a/src/main/java/swm_nm/morandi/domain/testRecord/service/RatingService.java +++ b/src/main/java/swm_nm/morandi/domain/testRecord/service/RatingService.java @@ -8,8 +8,8 @@ import swm_nm.morandi.domain.testDuring.dto.TestStatus; import swm_nm.morandi.domain.testInfo.entity.Tests; import swm_nm.morandi.domain.testInfo.repository.TestRepository; -import swm_nm.morandi.domain.testRecord.dto.CurrentRatingDto; -import swm_nm.morandi.domain.testRecord.dto.RatingGraphDto; +import swm_nm.morandi.domain.testRecord.dto.CurrentRatingResponse; +import swm_nm.morandi.domain.testRecord.dto.RatingGraphResponse; import swm_nm.morandi.global.exception.MorandiException; import swm_nm.morandi.global.exception.errorcode.MemberErrorCode; import swm_nm.morandi.global.utils.SecurityUtils; @@ -26,10 +26,10 @@ public class RatingService { //현재 레이팅 정보 반환 @Transactional(readOnly = true) - public CurrentRatingDto getCurrentRatingDto() { + public CurrentRatingResponse getCurrentRatingDto() { Long memberId = SecurityUtils.getCurrentMemberId(); Member member = memberRepository.findById(memberId).orElseThrow(() -> new MorandiException(MemberErrorCode.MEMBER_NOT_FOUND)); - CurrentRatingDto currentRatingDto = CurrentRatingDto.builder() + CurrentRatingResponse currentRatingDto = CurrentRatingResponse.builder() .rating(member.getRating()) .build(); return currentRatingDto; @@ -37,13 +37,13 @@ public CurrentRatingDto getCurrentRatingDto() { // 1년동안의 레이팅 그래프 데이터를 가져옴 @Transactional(readOnly = true) - public List getRatingGraphSinceOneYear(){ + public List getRatingGraphSinceOneYear(){ Long memberId = SecurityUtils.getCurrentMemberId(); LocalDateTime oneYearAgo = LocalDateTime.now().minusYears(1); List tests = testRepository.findAllTestsByMember_MemberIdAndTestStatusAndTestDateAfterOrderByTestDateAsc(memberId, TestStatus.COMPLETED, oneYearAgo); return tests.stream().map(test -> - RatingGraphDto.builder() + RatingGraphResponse.builder() .testDate(test.getTestDate()) .testRating(test.getTestRating()) .testTypeName(test.getTestTypename()) diff --git a/src/main/java/swm_nm/morandi/domain/testRecord/service/TestDetailsService.java b/src/main/java/swm_nm/morandi/domain/testRecord/service/TestDetailsService.java index 3cfa2092..f8f2c6ee 100644 --- a/src/main/java/swm_nm/morandi/domain/testRecord/service/TestDetailsService.java +++ b/src/main/java/swm_nm/morandi/domain/testRecord/service/TestDetailsService.java @@ -29,7 +29,7 @@ public class TestDetailsService { private final TestHistoryRepositoryImpl testStatusRepository; @Transactional(readOnly = true) - public TestRecordDto getTestRecordDtoByTestId(Long testId) { + public TestRecordResponse getTestRecordDtoByTestId(Long testId) { //N+1문제 발생하여 fetch join으로 해결 List attemptProblems = attemptProblemRepository.findTestDetailsByTest_TestId(testId); if (attemptProblems.isEmpty()) { @@ -46,7 +46,7 @@ public TestRecordDto getTestRecordDtoByTestId(Long testId) { }).collect(Collectors.toList()); - TestRecordDto testRecordDto = TestRecordMapper.convertToDto(test, attemptProblemDtos); + TestRecordResponse testRecordDto = TestRecordMapper.convertToDto(test, attemptProblemDtos); return testRecordDto; } @@ -54,7 +54,7 @@ public TestRecordDto getTestRecordDtoByTestId(Long testId) { public AllTestHistoryResponse findAllTestStatusByCondition(TestHistoryCondition testHistoryCondition) { Page testHistory = testStatusRepository.findAllTestHistoryByCondition(testHistoryCondition); - List testHistoryDtos = testHistory.stream().map(tests -> TestHistoryDto.builder(). + List testHistoryDtos = testHistory.stream().map(tests -> TestHistoryResponse.builder(). testId(tests.getTestId()) .testDate(tests.getTestDate()) .memberId(tests.getMember().getMemberId())