Skip to content

Commit

Permalink
Merge pull request #42 from mju-likelion/feature/introduce-get-applic…
Browse files Browse the repository at this point in the history
…ationId-refactor-#41

Feature/#41 자기소개서 조회 방식 변경
  • Loading branch information
Dh3356 authored Feb 28, 2024
2 parents 35539fd + d311e7e commit e5f80cd
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package org.mjulikelion.baker.controller;

import static org.mjulikelion.baker.constant.RegexPatterns.APPLICATION_STUDENT_ID_PATTERN;

import jakarta.validation.constraints.Pattern;
import java.util.UUID;
import lombok.AllArgsConstructor;
import org.mjulikelion.baker.dto.response.ResponseDto;
import org.mjulikelion.baker.dto.response.introduce.IntroduceGetResponseData;
Expand All @@ -19,11 +17,10 @@ public class IntroduceController {
private final IntroduceQueryService introduceQueryService;

@GetMapping("/introduces")
@Cacheable(value = "applicationByStudentId", key = "#studentId")
@Cacheable(value = "applicationByApplicationId", key = "#applicationId")
public ResponseEntity<ResponseDto<IntroduceGetResponseData>> getStudentIntroduce(
@RequestParam(value = "studentId")
@Pattern(regexp = APPLICATION_STUDENT_ID_PATTERN, message = "학번이 형식에 맞지 않습니다.") String studentId
@RequestParam(value = "applicationId") UUID applicationId
) {
return this.introduceQueryService.getStudentIntroduce(studentId);
return this.introduceQueryService.getStudentIntroduce(applicationId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

@Builder
public class IntroduceGetResponseData {
@JsonProperty
private final String studentId;
@JsonProperty
private final String name;
@JsonProperty
private final Part part;
@JsonProperty
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package org.mjulikelion.baker.service.introduce;

import java.util.UUID;
import org.mjulikelion.baker.dto.response.ResponseDto;
import org.mjulikelion.baker.dto.response.introduce.IntroduceGetResponseData;
import org.springframework.http.ResponseEntity;

public interface IntroduceQueryService {
ResponseEntity<ResponseDto<IntroduceGetResponseData>> getStudentIntroduce(String studentId);
ResponseEntity<ResponseDto<IntroduceGetResponseData>> getStudentIntroduce(UUID applicationId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,23 @@ public class IntroduceQueryServiceImpl implements IntroduceQueryService {

@Override
@Transactional(readOnly = true)
public ResponseEntity<ResponseDto<IntroduceGetResponseData>> getStudentIntroduce(String studentId) {
Application application = this.findApplicationByStudentId(studentId);
public ResponseEntity<ResponseDto<IntroduceGetResponseData>> getStudentIntroduce(UUID applicationId) {
Application application = this.findApplicationById(applicationId);
List<ApplicationIntroduce> applicationIntroduceList = this.findApplicationIntroduces(application.getId());
List<IntroduceDetailVO> introduceDetailVOList = this.buildIntroduceDetailVOList(applicationIntroduceList);

IntroduceGetResponseData introduceGetResponseData = IntroduceGetResponseData.builder()
.introduceDetailVOList(introduceDetailVOList)
.studentId(application.getStudentId())
.name(application.getName())
.part(application.getPart())
.build();

return ResponseEntity.ok(ResponseDto.res(HttpStatus.OK, "OK", introduceGetResponseData));
}

private Application findApplicationByStudentId(String studentId) {
return this.applicationRepository.findByStudentId(studentId)
private Application findApplicationById(UUID applicationId) {
return this.applicationRepository.findById(applicationId)
.orElseThrow(() -> new ApplicationNotFoundException(APPLICATION_NOT_FOUND_ERROR));
}

Expand Down

0 comments on commit e5f80cd

Please sign in to comment.