Skip to content

Commit

Permalink
Merge pull request #20 from Leets-Official/fix/#18/DTO-수정
Browse files Browse the repository at this point in the history
[fix] #20 dto 수정
  • Loading branch information
ay-eonii authored Jan 30, 2024
2 parents d3ade28 + ce74ca4 commit c3ade91
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import jakarta.validation.constraints.NotNull;
import land.leets.domain.application.type.ApplicationStatus;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@AllArgsConstructor
@NoArgsConstructor
public class StatusRequest {
@NotNull
private ApplicationStatus applicationStatus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
import land.leets.domain.interview.domain.Interview;
import land.leets.domain.interview.presentation.dto.req.FixedInterviewRequest;
import land.leets.domain.interview.presentation.dto.req.InterviewAttendanceRequest;
import land.leets.domain.interview.presentation.dto.req.InterviewRequest;
import land.leets.domain.interview.type.HasInterview;
import land.leets.domain.interview.usecase.CreateInterview;
import land.leets.domain.interview.usecase.UpdateInterview;
import land.leets.domain.mail.usecase.CreateInterviewRequest;
import land.leets.global.error.ErrorResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
Expand All @@ -25,7 +26,7 @@
@Tag(name = "INTERVIEW")
public class InterviewController {
private final UpdateInterview updateInterview;
private final CreateInterviewRequest createInterviewRequest;
private final CreateInterview createInterview;

@Operation(summary = "(유저) 면접 참여 여부 변경", description = "면접 참여 여부를 변경합니다.")
@ApiResponses({
Expand All @@ -48,11 +49,24 @@ public Interview update(@RequestBody InterviewAttendanceRequest request) {
@ApiResponse(responseCode = "404", content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = "500", content = @Content(schema = @Schema(implementation = ErrorResponse.class)))
})
@PostMapping("/{id}")
@PatchMapping("/{id}")
public Interview update(@PathVariable Long id, @RequestBody FixedInterviewRequest request) {
return updateInterview.byAdmin(id, request);
}

@Operation(summary = "(관리자) 면접 정보 생성", description = "면접 정보를 생성합니다.")
@ApiResponses({
@ApiResponse(responseCode = "200"),
@ApiResponse(responseCode = "400", content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = "403", content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = "404", content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = "500", content = @Content(schema = @Schema(implementation = ErrorResponse.class)))
})
@PostMapping
public Interview create(@RequestBody InterviewRequest request) {
return createInterview.execute(request);
}

@Operation(summary = "(유저) 면접 여부 변경 요청 생성하기", description = "면접 참가 여부 변경 요청을 생성합니다.")
@ApiResponses({
@ApiResponse(responseCode = "200"),
Expand All @@ -63,7 +77,7 @@ public Interview update(@PathVariable Long id, @RequestBody FixedInterviewReques
})
@GetMapping
public RedirectView hasInterview(@RequestParam UUID uid, @RequestParam HasInterview hasInterview) {
createInterviewRequest.execute(uid, hasInterview);
createInterview.execute(uid, hasInterview);
RedirectView redirectView = new RedirectView();
redirectView.setUrl("https://www.leets.land");
return redirectView;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package land.leets.domain.interview.presentation.dto.req;

import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.time.LocalDateTime;

@Getter
@AllArgsConstructor
public class InterviewRequest {
@NotNull
private Long applicationId;

@NotNull
private LocalDateTime fixedInterviewDate;

@NotNull
private String place;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

import land.leets.domain.interview.type.HasInterview;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;

import java.time.LocalDateTime;

@Getter
@Builder
@AllArgsConstructor
public class InterviewDetailsResponse {
private HasInterview hasInterview;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package land.leets.domain.interview.usecase;

import land.leets.domain.interview.domain.Interview;
import land.leets.domain.interview.presentation.dto.req.InterviewRequest;
import land.leets.domain.interview.type.HasInterview;

import java.util.UUID;

public interface CreateInterview {
void execute(UUID uid, HasInterview hasInterview);

Interview execute(InterviewRequest request);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package land.leets.domain.mail.usecase;
package land.leets.domain.interview.usecase;

import land.leets.domain.application.domain.Application;
import land.leets.domain.application.domain.repository.ApplicationRepository;
import land.leets.domain.application.exception.ApplicationNotFoundException;
import land.leets.domain.interview.domain.Interview;
import land.leets.domain.interview.presentation.dto.req.InterviewAttendanceRequest;
import land.leets.domain.interview.presentation.dto.req.InterviewRequest;
import land.leets.domain.interview.type.HasInterview;
import land.leets.domain.mail.exception.PatchRequestFailException;
import lombok.RequiredArgsConstructor;
Expand All @@ -19,8 +24,9 @@
@Service
@Transactional
@RequiredArgsConstructor
public class CreateInterviewRequestImpl implements CreateInterviewRequest {
public class CreateInterviewImpl implements CreateInterview {
private final Environment environment;
private final ApplicationRepository applicationRepository;

@Value("${target.url.dev}")
private String TARGET_URI_DEV;
Expand All @@ -46,6 +52,17 @@ public void execute(UUID uid, HasInterview hasInterview) {
throw new PatchRequestFailException();
}
}

@Override
public Interview execute(InterviewRequest request) {
Application application = applicationRepository.findById(request.getApplicationId())
.orElseThrow(ApplicationNotFoundException::new);
return Interview.builder()
.application(application)
.fixedInterviewDate(request.getFixedInterviewDate())
.place(request.getPlace())
.build();
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
import land.leets.domain.application.domain.Application;
import land.leets.domain.interview.domain.Interview;
import land.leets.domain.interview.domain.repository.InterviewRepository;
import land.leets.domain.interview.exception.InterviewNotFoundException;
import land.leets.domain.interview.presentation.dto.res.InterviewDetailsResponse;
import land.leets.domain.interview.presentation.mapper.InterviewMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Optional;

@Service
@RequiredArgsConstructor
public class GetInterviewDetailsImpl implements GetInterviewDetails {
Expand All @@ -17,7 +18,10 @@ public class GetInterviewDetailsImpl implements GetInterviewDetails {

@Override
public InterviewDetailsResponse execute(Application application) {
Interview interview = interviewRepository.findByApplication(application).orElseThrow(InterviewNotFoundException::new);
return interviewMapper.mappingDetailsToDto(interview);
Optional<Interview> interview = interviewRepository.findByApplication(application);
if (interview.isPresent()) {
return interviewMapper.mappingDetailsToDto(interview.get());
}
return InterviewDetailsResponse.builder().build();
}
}

This file was deleted.

0 comments on commit c3ade91

Please sign in to comment.