Skip to content

Commit

Permalink
feat: Service Entity 생성 로직 삭제
Browse files Browse the repository at this point in the history
  • Loading branch information
BGuga committed Sep 14, 2023
1 parent 7a82d62 commit bdeee94
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
13 changes: 6 additions & 7 deletions backend/src/main/java/com/festago/application/StageService.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,15 @@ public StageService(StageRepository stageRepository, FestivalRepository festival

public StageResponse create(StageCreateRequest request) {
Festival festival = findFestivalById(request.festivalId());
Stage newStage = stageRepository.save(toStageEntity(request, festival));
Stage newStage = stageRepository.save(new Stage(
request.startTime(),
request.lineUp(),
request.ticketOpenTime(),
festival));

return StageResponse.from(newStage);
}

private Stage toStageEntity(StageCreateRequest request, Festival festival) {
return request.lineUp() == null ?
new Stage(request.startTime(), request.ticketOpenTime(), festival) :
new Stage(request.startTime(), request.lineUp(), request.ticketOpenTime(), festival);
}

private Festival findFestivalById(Long festivalId) {
return festivalRepository.findById(festivalId)
.orElseThrow(() -> new NotFoundException(ErrorCode.FESTIVAL_NOT_FOUND));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ private School findSchool(Long schoolId) {
public void verificate(Long memberId, StudentVerificateRequest request) {
validateStudent(memberId);
Member member = findMember(memberId);
StudentCode studentCode = studentCodeRepository.findByCodeAndMember(new VerificationCode(request.code()),
member)
StudentCode studentCode = studentCodeRepository.findByCodeAndMember(new VerificationCode(request.code()), member)
.orElseThrow(() -> new BadRequestException(ErrorCode.INVALID_STUDENT_VERIFICATION_CODE));
studentRepository.save(new Student(member, studentCode.getSchool(), studentCode.getUsername()));
studentCodeRepository.deleteByMember(member);
Expand Down

0 comments on commit bdeee94

Please sign in to comment.