Skip to content

Commit

Permalink
Merge pull request #45 from Likelion-Inner-Join/fix/application
Browse files Browse the repository at this point in the history
[Fix] cors 해결 및 지원자 면접시간 수정 로직 변경
  • Loading branch information
luna156 authored Dec 26, 2024
2 parents eb54850 + e5b4bb2 commit cf0ad22
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void addCorsMappings(CorsRegistry registry) {
.allowedOrigins("http://localhost:3000",
"http://localhost:3001",
"https://innerjoin.vercel.app") // 허용할 도메인
.allowedMethods("GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS") // 허용할 HTTP 메소드
.allowedMethods("*") // 허용할 HTTP 메소드
.allowedHeaders("*") // 허용할 헤더
.allowCredentials(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
import com.likelion.innerjoin.post.model.entity.Recruiting;
import org.springframework.data.jpa.repository.JpaRepository;

import java.time.LocalDateTime;
import java.util.List;

public interface MeetingTimeRepository extends JpaRepository<MeetingTime, Long> {
List<MeetingTime> findByRecruiting(Recruiting recruiting);
List<MeetingTime> findByRecruitingId(Long recruitingId);
MeetingTime findByMeetingStartTimeAndMeetingEndTimeAndRecruiting(LocalDateTime meetingStartTime, LocalDateTime meetingEndTime, Recruiting recruiting);
}
Original file line number Diff line number Diff line change
Expand Up @@ -134,24 +134,22 @@ public ApplicationDto updateApplication(
throw new UnauthorizedException("권한이 없습니다.");
}

MeetingTime meetingTime = meetingTimeRepository.findByMeetingStartTimeAndMeetingEndTimeAndRecruiting(
applicationPutRequestDto.getMeetingStartTime(),
applicationPutRequestDto.getMeetingEndTime(),
application.getRecruiting()
);
if(meetingTime == null) {
throw new MeetingTimeNotFound("면접시간이 존재하지 않습니다.");
}

application.setFormResult(applicationPutRequestDto.getFormResult());
application.setMeetingResult(applicationPutRequestDto.getMeetingResult());

if(application.getMeetingTime() != null){
application.getMeetingTime().setMeetingStartTime(applicationPutRequestDto.getMeetingStartTime());
application.getMeetingTime().setMeetingEndTime(applicationPutRequestDto.getMeetingEndTime());
}else{
// 임시 meetingtime 데이터 만들기
MeetingTime meetingTime = new MeetingTime();
meetingTime.setMeetingStartTime(applicationPutRequestDto.getMeetingStartTime());
meetingTime.setMeetingEndTime(applicationPutRequestDto.getMeetingEndTime());
meetingTime.setAllowedNum(1);

meetingTime.setApplicationList(new ArrayList<>());
meetingTime.getApplicationList().add(application);

application.setMeetingTime(meetingTimeRepository.save(meetingTime));
if(meetingTime.getApplicationList().size() >= meetingTime.getAllowedNum() && !meetingTime.getApplicationList().contains(application)){
throw new AllowedNumExceededException("허용 인원을 초과하였습니다.");
}
application.setMeetingTime(meetingTime);

applicationRepository.save(application);
return applicationMapper.toApplicationDto(application, false);
Expand Down

0 comments on commit cf0ad22

Please sign in to comment.