Skip to content

Commit

Permalink
Merge pull request #60 from depromeet/feature/#56
Browse files Browse the repository at this point in the history
Feature/#56
  • Loading branch information
sejoon00 authored Aug 18, 2024
2 parents 0109e9a + f561987 commit ac98d5e
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.server.bbo_gak.domain.recruit.dto.request;

import com.server.bbo_gak.domain.recruit.entity.Recruit;
import com.server.bbo_gak.domain.recruit.entity.RecruitSchedule;
import com.server.bbo_gak.domain.recruit.entity.RecruitScheduleStage;
import com.server.bbo_gak.domain.recruit.entity.RecruitStatus;
import com.server.bbo_gak.domain.recruit.entity.Season;
Expand All @@ -15,15 +14,14 @@ public record RecruitCreateRequest(
String deadline
) {

public Recruit toEntity(User user, Season season, RecruitSchedule schedule) {
public Recruit toEntity(User user, Season season) {
return Recruit.builder()
.season(season)
.title(title)
.siteUrl(siteUrl)
.recruitStatus(RecruitStatus.APPLICATION_COMPLETED)
.user(user)
.build()
.addSchedule(schedule);
.build();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,12 @@ public RecruitSchedule(Recruit recruit, RecruitScheduleStage recruitScheduleStag
public void setRecruit(Recruit recruit) {
this.recruit = recruit;
}

public static RecruitSchedule of(Recruit recruit, RecruitScheduleStage recruitScheduleStage, String deadLine){
return RecruitSchedule.builder()
.recruit(recruit)
.recruitScheduleStage(recruitScheduleStage)
.deadLine(LocalDate.parse(deadLine)).build();
}

}
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package com.server.bbo_gak.domain.recruit.service;

import com.server.bbo_gak.domain.recruit.dao.RecruitScheduleRepository;
import com.server.bbo_gak.domain.recruit.entity.RecruitSchedule;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class RecruitScheduleServiceImpl implements RecruitScheduleService {

private final RecruitScheduleRepository recruitScheduleRepository;

@Override
public void deleteRecruitSchedule() {

Expand All @@ -23,6 +28,6 @@ public void getRecruitScheduleList() {

@Override
public RecruitSchedule createRecruitSchedule(RecruitSchedule recruitSchedule) {
return null;
return recruitScheduleRepository.save(recruitSchedule);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.server.bbo_gak.domain.recruit.dao.RecruitRepository;
import com.server.bbo_gak.domain.recruit.dto.request.RecruitCreateRequest;
import com.server.bbo_gak.domain.recruit.dto.request.RecruitScheduleCreateRequest;
import com.server.bbo_gak.domain.recruit.dto.response.RecruitGetResponse;
import com.server.bbo_gak.domain.recruit.entity.Recruit;
import com.server.bbo_gak.domain.recruit.entity.RecruitSchedule;
Expand Down Expand Up @@ -92,12 +91,21 @@ private boolean isNeedsScheduleUpdate(Recruit recruit) {
@Transactional
public RecruitGetResponse createRecruit(User user, RecruitCreateRequest request) {

Season season = seasonService.getSeasonByName(user, request.season());
Recruit recruit = request.toEntity(user, season);
// 공고 저장하여 id 확보
Recruit savedRecruit = recruitRepository.save(recruit);

// 공고 일정 생성
RecruitSchedule recruitSchedule = recruitScheduleService.createRecruitSchedule(
RecruitScheduleCreateRequest.of(request.recruitScheduleStage(), request.deadline())
RecruitSchedule.of(recruit, request.recruitScheduleStage(), request.deadline())
);
Season season = seasonService.getSeasonByName(user, request.season());
Recruit recruit = request.toEntity(user, season, recruitSchedule);
return RecruitGetResponse.from(recruitRepository.save(recruit));

// 공고에 공고 일정을 설정
savedRecruit.addSchedule(recruitSchedule);
recruitRepository.save(recruit);

return RecruitGetResponse.from(savedRecruit);
}

@Transactional
Expand Down

0 comments on commit ac98d5e

Please sign in to comment.