Skip to content

Commit

Permalink
refactor: 몽타주 생성 요청 받을 시 request param 사용
Browse files Browse the repository at this point in the history
  • Loading branch information
xloyeon committed Dec 18, 2023
1 parent c32d894 commit abd8182
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class MontageController {

@PostMapping("/create/{interviewId}")
public MontageResponse createMontage(@PathVariable Long interviewId,
@RequestBody @Valid CreateMontageRequest request){
return montageService.createMontage(interviewId, request);
@RequestParam String prompt){
return montageService.createMontage(interviewId, prompt);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.catchyou.api.montage.dto.CreateMontageRequest;
import com.catchyou.api.montage.dto.MontageResponse;
import com.catchyou.core.dto.BaseResponse;
import com.catchyou.domain.common.Status;
import com.catchyou.domain.criminal.adaptor.CriminalAdaptor;
import com.catchyou.domain.criminal.entity.Criminal;
import com.catchyou.domain.criminal.validator.CriminalValidator;
Expand Down Expand Up @@ -34,7 +35,7 @@ public class MontageService {
private final CriminalValidator criminalValidator;
private final MontageApiFeignClient montageApiFeignClient;

public MontageResponse createMontage(Long interviewId, CreateMontageRequest request){
public MontageResponse createMontage(Long interviewId, String prompt){
User currentUser = userHelper.getCurrentUser();

Interview interview = interviewAdaptor.findById(interviewId);
Expand All @@ -48,14 +49,20 @@ public MontageResponse createMontage(Long interviewId, CreateMontageRequest requ
//인터뷰에서 확정된 몽타주가 있는지 확인
interviewValidator.isValidCreateInterviewMontage(interview);

Montage montage = request.toEntity(interview);
Montage montage = montageAdaptor.save(
Montage.builder()
.interview(interview)
.selected(Status.N)
.build()
);

montageAdaptor.save(montage);

//api 호출
montageApiFeignClient.callMontageApi(request.getPrompt(), montage.getId().toString());
montageApiFeignClient.callMontageApi(prompt, montage.getId().toString());
montageAdaptor.save(montage);

return MontageResponse.of(request.getPrompt(), montage);
return MontageResponse.of(prompt, montage);
}

}

0 comments on commit abd8182

Please sign in to comment.