-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #86 from depromeet/develop
feat 56 develop merge
- Loading branch information
Showing
14 changed files
with
484 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
src/main/java/com/server/bbo_gak/domain/recruit/controller/RecruitScheduleController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package com.server.bbo_gak.domain.recruit.controller; | ||
|
||
import com.server.bbo_gak.domain.recruit.dto.request.RecruitScheduleCreateRequest; | ||
import com.server.bbo_gak.domain.recruit.dto.request.RecruitScheduleUpdateDeadLineRequest; | ||
import com.server.bbo_gak.domain.recruit.dto.request.RecruitScheduleUpdateStageRequest; | ||
import com.server.bbo_gak.domain.recruit.dto.response.RecruitScheduleGetResponse; | ||
import com.server.bbo_gak.domain.recruit.entity.RecruitSchedule; | ||
import com.server.bbo_gak.domain.recruit.service.RecruitScheduleService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@RequestMapping("/api/v1/recruits/{id}/recruit-schedule") | ||
@RequiredArgsConstructor | ||
public class RecruitScheduleController { | ||
private final RecruitScheduleService recruitScheduleService; | ||
|
||
|
||
/** | ||
* 공고 일정 생성 | ||
*/ | ||
@PostMapping("") | ||
public ResponseEntity<RecruitScheduleGetResponse> createRecruitSchedule( | ||
@PathVariable("id") Long id, //공고 id | ||
@RequestBody RecruitScheduleCreateRequest request) { | ||
RecruitSchedule recruitSchedule = recruitScheduleService.createRecruitSchedule(id, request); | ||
return ResponseEntity.ok().body(RecruitScheduleGetResponse.from(recruitSchedule)); | ||
} | ||
|
||
/** | ||
* 공고 일정 전체 조회 | ||
*/ | ||
@GetMapping("") | ||
public ResponseEntity<List<RecruitScheduleGetResponse>> getRecruitScheduleList( | ||
@PathVariable("id") Long id //공고 id | ||
) { | ||
return ResponseEntity.ok().body(recruitScheduleService.getRecruitScheduleList(id)); | ||
} | ||
|
||
/** | ||
* 공고 일정 (공고단계) 업데이트 | ||
*/ | ||
@PutMapping("/{recruit-schedule-id}/stage") | ||
public ResponseEntity<Void> updateRecruitScheduleStage( | ||
@PathVariable("id") Long id, //공고 id | ||
@PathVariable("recruit-schedule-id") Long recruitScheduleId, | ||
@RequestBody RecruitScheduleUpdateStageRequest request | ||
) { | ||
recruitScheduleService.updateRecruitScheduleStage(id, recruitScheduleId, request.recruitScheduleStage()); | ||
return ResponseEntity.ok().body(null); | ||
} | ||
|
||
/** | ||
* 공고 일정 (공고 마감일) 업데이트 | ||
*/ | ||
@PutMapping("/{recruit-schedule-id}/deadLine") | ||
public ResponseEntity<Void> updateDeadLine( | ||
@PathVariable("id") Long id, //공고 id | ||
@PathVariable("recruit-schedule-id") Long recruitScheduleId, | ||
@RequestBody RecruitScheduleUpdateDeadLineRequest request | ||
) { | ||
recruitScheduleService.updateDeadLine(id, recruitScheduleId, request.deadLine()); | ||
return ResponseEntity.ok().body(null); | ||
} | ||
|
||
/** | ||
* 공고 일정 삭제 | ||
*/ | ||
@DeleteMapping("/{recruit-schedule-id}") | ||
public ResponseEntity<Void> deleteRecruitSchedule( | ||
@PathVariable("id") Long id, //공고 id | ||
@PathVariable("recruit-schedule-id") Long recruitScheduleId | ||
) { | ||
recruitScheduleService.deleteRecruitSchedule(id, recruitScheduleId); | ||
return ResponseEntity.ok().body(null); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 7 additions & 8 deletions
15
...main/java/com/server/bbo_gak/domain/recruit/dto/request/RecruitScheduleCreateRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,17 @@ | ||
package com.server.bbo_gak.domain.recruit.dto.request; | ||
|
||
import com.server.bbo_gak.domain.recruit.entity.RecruitSchedule; | ||
import com.server.bbo_gak.domain.recruit.entity.RecruitScheduleStage; | ||
import java.time.LocalDate; | ||
import lombok.Builder; | ||
|
||
@Builder | ||
public record RecruitScheduleCreateRequest( | ||
RecruitScheduleStage recruitScheduleStage, | ||
String deadline | ||
String recruitScheduleStage, | ||
String deadLine | ||
) { | ||
|
||
public static RecruitSchedule of(RecruitScheduleStage recruitScheduleStage, String deadline) { | ||
return RecruitSchedule.builder() | ||
public static RecruitScheduleCreateRequest of(String recruitScheduleStage, String deadLine) { | ||
return RecruitScheduleCreateRequest.builder() | ||
.recruitScheduleStage(recruitScheduleStage) | ||
.deadLine(LocalDate.parse(deadline)) | ||
.deadLine(deadLine) | ||
.build(); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...a/com/server/bbo_gak/domain/recruit/dto/request/RecruitScheduleUpdateDeadLineRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.server.bbo_gak.domain.recruit.dto.request; | ||
|
||
//TODO: deadLine null값 안들어오게 처리하기 | ||
public record RecruitScheduleUpdateDeadLineRequest(String deadLine) { | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
...java/com/server/bbo_gak/domain/recruit/dto/request/RecruitScheduleUpdateStageRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.server.bbo_gak.domain.recruit.dto.request; | ||
|
||
|
||
//TODO: recruitScheduleStage null값 안들어오게 처리하기 | ||
public record RecruitScheduleUpdateStageRequest(String recruitScheduleStage) { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 10 additions & 4 deletions
14
src/main/java/com/server/bbo_gak/domain/recruit/service/RecruitScheduleService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,22 @@ | ||
package com.server.bbo_gak.domain.recruit.service; | ||
|
||
import com.server.bbo_gak.domain.recruit.dto.request.RecruitScheduleCreateRequest; | ||
import com.server.bbo_gak.domain.recruit.dto.response.RecruitScheduleGetResponse; | ||
import com.server.bbo_gak.domain.recruit.entity.RecruitSchedule; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.List; | ||
|
||
@Service | ||
public interface RecruitScheduleService { | ||
|
||
RecruitSchedule createRecruitSchedule(RecruitSchedule recruitSchedule); | ||
RecruitSchedule createRecruitSchedule(Long id, RecruitScheduleCreateRequest request); | ||
|
||
List<RecruitScheduleGetResponse> getRecruitScheduleList(Long recruitId); | ||
|
||
void getRecruitScheduleList(); | ||
void updateRecruitScheduleStage(Long recruitId, Long recruitScheduleId, String stage); | ||
|
||
void updateRecruitSchedule(); | ||
void updateDeadLine(Long recruitId, Long recruitScheduleId, String deadLine); | ||
|
||
void deleteRecruitSchedule(); | ||
void deleteRecruitSchedule(Long recruitId, Long recruitScheduleId); | ||
} |
48 changes: 42 additions & 6 deletions
48
src/main/java/com/server/bbo_gak/domain/recruit/service/RecruitScheduleServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,69 @@ | ||
package com.server.bbo_gak.domain.recruit.service; | ||
|
||
import com.server.bbo_gak.domain.recruit.dao.RecruitRepository; | ||
import com.server.bbo_gak.domain.recruit.dao.RecruitScheduleRepository; | ||
import com.server.bbo_gak.domain.recruit.dto.request.RecruitScheduleCreateRequest; | ||
import com.server.bbo_gak.domain.recruit.dto.response.RecruitScheduleGetResponse; | ||
import com.server.bbo_gak.domain.recruit.entity.Recruit; | ||
import com.server.bbo_gak.domain.recruit.entity.RecruitSchedule; | ||
import com.server.bbo_gak.global.error.exception.ErrorCode; | ||
import com.server.bbo_gak.global.error.exception.NotFoundException; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.List; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class RecruitScheduleServiceImpl implements RecruitScheduleService { | ||
|
||
private final RecruitScheduleRepository recruitScheduleRepository; | ||
private final RecruitRepository recruitRepository; | ||
|
||
@Override | ||
public void deleteRecruitSchedule() { | ||
|
||
@Transactional | ||
public RecruitSchedule createRecruitSchedule(Long id, RecruitScheduleCreateRequest request) { | ||
Recruit recruit = recruitRepository.findById(id) | ||
.orElseThrow(() -> new NotFoundException(ErrorCode.RECRUIT_NOT_FOUND)); | ||
return recruitScheduleRepository.save(RecruitSchedule.of(recruit, request.recruitScheduleStage(), request.deadLine())); | ||
} | ||
|
||
@Override | ||
public void updateRecruitSchedule() { | ||
@Transactional | ||
public List<RecruitScheduleGetResponse> getRecruitScheduleList(Long recruitId) { | ||
return recruitScheduleRepository.findAllByRecruitId(recruitId).stream() | ||
.map(RecruitScheduleGetResponse::from) | ||
.toList(); | ||
} | ||
|
||
@Override | ||
@Transactional | ||
public void updateRecruitScheduleStage(Long recruitId, Long recruitScheduleId, String stage) { | ||
RecruitSchedule recruitSchedule = recruitScheduleRepository.findByIdAndRecruitId( | ||
recruitScheduleId, recruitId) | ||
.orElseThrow(() -> new NotFoundException(ErrorCode.RECRUIT_SCHEDULE_NOT_FOUND)); | ||
|
||
recruitSchedule.updateRecruitScheduleStage(stage); | ||
} | ||
|
||
@Override | ||
public void getRecruitScheduleList() { | ||
@Transactional | ||
public void updateDeadLine(Long recruitId, Long recruitScheduleId, String deadLine){ | ||
RecruitSchedule recruitSchedule = recruitScheduleRepository.findByIdAndRecruitId( | ||
recruitScheduleId, recruitId) | ||
.orElseThrow(() -> new NotFoundException(ErrorCode.RECRUIT_SCHEDULE_NOT_FOUND)); | ||
|
||
recruitSchedule.updateDeadLine(deadLine); | ||
} | ||
|
||
@Override | ||
public RecruitSchedule createRecruitSchedule(RecruitSchedule recruitSchedule) { | ||
return recruitScheduleRepository.save(recruitSchedule); | ||
@Transactional | ||
public void deleteRecruitSchedule(Long recruitId, Long recruitScheduleId) { | ||
RecruitSchedule recruitSchedule = recruitScheduleRepository.findByIdAndRecruitId( | ||
recruitScheduleId, recruitId) | ||
.orElseThrow(() -> new NotFoundException(ErrorCode.RECRUIT_SCHEDULE_NOT_FOUND)); | ||
|
||
recruitScheduleRepository.deleteById(recruitSchedule.getId()); | ||
} | ||
} |
Oops, something went wrong.