From 942e6003e19af442000dece6fe8037ac70554830 Mon Sep 17 00:00:00 2001 From: JeongHoon Lee Date: Sat, 10 Aug 2024 21:01:02 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=A7=80=EC=9B=90=20=EA=B3=B5=EA=B3=A0?= =?UTF-8?q?=20=EB=82=A0=EC=A7=9C=20=EC=88=98=EC=A0=95=20PI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/CI_MVP.yml | 1 + .../recruit/controller/RecruitController.java | 28 +++++++++++++------ .../controller/port/RecruitService.java | 2 ++ .../kkijuk/server/recruit/domain/Recruit.java | 15 ++++++++++ .../domain/RecruitApplyDateUpdate.java | 19 +++++++++++++ .../recruit/service/RecruitServiceImpl.java | 12 ++++++++ 6 files changed, 69 insertions(+), 8 deletions(-) create mode 100644 src/main/java/umc/kkijuk/server/recruit/domain/RecruitApplyDateUpdate.java diff --git a/.github/workflows/CI_MVP.yml b/.github/workflows/CI_MVP.yml index dd5bed37..b6ceade6 100644 --- a/.github/workflows/CI_MVP.yml +++ b/.github/workflows/CI_MVP.yml @@ -8,6 +8,7 @@ on: - mvp/career - mvp/portfolio - feature/record + - feat/update-recruit-date jobs: CI: diff --git a/src/main/java/umc/kkijuk/server/recruit/controller/RecruitController.java b/src/main/java/umc/kkijuk/server/recruit/controller/RecruitController.java index 0772eb50..74ea9b45 100644 --- a/src/main/java/umc/kkijuk/server/recruit/controller/RecruitController.java +++ b/src/main/java/umc/kkijuk/server/recruit/controller/RecruitController.java @@ -5,7 +5,6 @@ import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; import lombok.*; -import org.springframework.data.repository.query.Param; import org.springframework.format.annotation.DateTimeFormat; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -51,27 +50,27 @@ public ResponseEntity create(@RequestBody @Valid RecruitCreat description = "주어진 정보를 바탕으로 지원 공고 데이터를 수정합니다.") @Parameter(name = "recruitId", description = "지원 공고 ID", example = "1") @PutMapping("/{recruitId}") - public ResponseEntity update(@RequestBody @Valid RecruitUpdate recruitUpdate, + public ResponseEntity update(@RequestBody @Valid RecruitUpdate recruitUpdate, @PathVariable long recruitId) { // Member requestMember = memberService.findOne(LoginUser.get().getId()); Recruit recruit = recruitService.update(requestMember, recruitId, recruitUpdate); return ResponseEntity .status(HttpStatus.OK) - .body(recruit.getId()); + .body(RecruitIdResponse.from(recruit)); } @Operation( summary = "지원 공고 상태 수정", description = "다음 중 주어진 상태로 지원 공고의 상태를 수정합니다." + " [UNAPPLIED / PLANNED / APPLYING / REJECTED / ACCEPTED]") @Parameter(name = "recruitId", description = "지원 공고 ID", example = "1") - @PatchMapping("/{recruitId}") - public ResponseEntity updateState(@RequestBody @Valid RecruitStatusUpdate recruitStatusUpdate, + @PatchMapping("/{recruitId}/status") + public ResponseEntity updateState(@RequestBody @Valid RecruitStatusUpdate recruitStatusUpdate, @PathVariable long recruitId) { // Member requestMember = memberService.findOne(LoginUser.get().getId()); Recruit recruit = recruitService.updateStatus(requestMember, recruitId, recruitStatusUpdate); return ResponseEntity .ok() - .body(recruit.getId()); + .body(RecruitIdResponse.from(recruit)); } @Operation( @@ -79,12 +78,12 @@ public ResponseEntity updateState(@RequestBody @Valid RecruitStatusUpdate description = "지원 공고 ID에 해당 하는 공고를 삭제합니다") @Parameter(name = "recruitId", description = "지원 공고 ID", example = "1") @DeleteMapping("/{recruitId}") - public ResponseEntity delete(@PathVariable long recruitId) { + public ResponseEntity delete(@PathVariable long recruitId) { // Member requestMember = memberService.findOne(LoginUser.get().getId()); Recruit recruit = recruitService.disable(requestMember, recruitId); return ResponseEntity .ok() - .body(recruit.getId()); + .body(RecruitIdResponse.from(recruit)); } @Operation( @@ -162,4 +161,17 @@ public ResponseEntity getByMonth( .ok() .body(RecruitListByMonthResponse.from(recruitListByMonthDtoList)); } + + @Operation( + summary = "공고 지워 날짜 수정", + description = "공고 지원 날짜를 주어진 날짜로 수정합니다.") + @PatchMapping("/{recruitId}/apply-date") + public ResponseEntity updateApplyDate(@RequestBody @Valid RecruitApplyDateUpdate recruitApplyDateUpdate, + @PathVariable long recruitId) { +// Member requestMember = memberService.findOne(LoginUser.get().getId()); + Recruit recruit = recruitService.updateApplyDate(requestMember, recruitId, recruitApplyDateUpdate); + return ResponseEntity + .ok() + .body(RecruitIdResponse.from(recruit)); + } } \ No newline at end of file diff --git a/src/main/java/umc/kkijuk/server/recruit/controller/port/RecruitService.java b/src/main/java/umc/kkijuk/server/recruit/controller/port/RecruitService.java index 7e745a18..356c2d67 100644 --- a/src/main/java/umc/kkijuk/server/recruit/controller/port/RecruitService.java +++ b/src/main/java/umc/kkijuk/server/recruit/controller/port/RecruitService.java @@ -27,4 +27,6 @@ public interface RecruitService { List findAllValidRecruitByMemberId(Member member, LocalDateTime endTime); List findAllValidRecruitByYearAndMonth(Member member, Integer year, Integer month); + + Recruit updateApplyDate(Member requestMember, long recruitId, RecruitApplyDateUpdate recruitApplyDateUpdate); } diff --git a/src/main/java/umc/kkijuk/server/recruit/domain/Recruit.java b/src/main/java/umc/kkijuk/server/recruit/domain/Recruit.java index d2dda197..5d593e97 100644 --- a/src/main/java/umc/kkijuk/server/recruit/domain/Recruit.java +++ b/src/main/java/umc/kkijuk/server/recruit/domain/Recruit.java @@ -82,4 +82,19 @@ public Recruit disable() { .disabledTime(LocalDateTime.now()) .build(); } + + public Recruit updateApplyDate(RecruitApplyDateUpdate recruitApplyDateUpdate) { + return Recruit.builder() + .id(this.id) + .memberId(memberId) + .title(this.getTitle()) + .status(this.getStatus()) + .startTime(this.getStartTime()) + .endTime(this.getEndTime()) + .applyDate(recruitApplyDateUpdate.getApplyDate()) + .tags(this.getTags()) + .link(this.getLink()) + .active(this.active) + .build(); + } } diff --git a/src/main/java/umc/kkijuk/server/recruit/domain/RecruitApplyDateUpdate.java b/src/main/java/umc/kkijuk/server/recruit/domain/RecruitApplyDateUpdate.java new file mode 100644 index 00000000..8a74c837 --- /dev/null +++ b/src/main/java/umc/kkijuk/server/recruit/domain/RecruitApplyDateUpdate.java @@ -0,0 +1,19 @@ +package umc.kkijuk.server.recruit.domain; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; +import lombok.*; + +import java.time.LocalDate; + +@Getter +@Builder +@AllArgsConstructor +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class RecruitApplyDateUpdate { + @NotNull + @Schema(description = "공고 지원 날짜", pattern = "yyyy-MM-dd") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "Asia/Seoul") + private LocalDate applyDate; +} diff --git a/src/main/java/umc/kkijuk/server/recruit/service/RecruitServiceImpl.java b/src/main/java/umc/kkijuk/server/recruit/service/RecruitServiceImpl.java index 1e0dd269..546b6998 100644 --- a/src/main/java/umc/kkijuk/server/recruit/service/RecruitServiceImpl.java +++ b/src/main/java/umc/kkijuk/server/recruit/service/RecruitServiceImpl.java @@ -8,6 +8,7 @@ import umc.kkijuk.server.common.domian.exception.ResourceNotFoundException; import umc.kkijuk.server.member.domain.Member; import umc.kkijuk.server.recruit.controller.port.RecruitService; +import umc.kkijuk.server.recruit.domain.RecruitApplyDateUpdate; import umc.kkijuk.server.recruit.domain.*; import umc.kkijuk.server.recruit.service.port.RecruitRepository; @@ -100,6 +101,17 @@ public List findAllValidRecruitByYearAndMonth(Member requ .toList(); } + @Override + public Recruit updateApplyDate(Member requestMember, long recruitId, RecruitApplyDateUpdate recruitApplyDateUpdate) { + Recruit recruit = getById(recruitId); + if (!recruit.getMemberId().equals(requestMember.getId())) { + throw new RecruitOwnerMismatchException(); + } + + recruit = recruit.updateApplyDate(recruitApplyDateUpdate); + return recruitRepository.save(recruit); + } + private boolean isUnappliedOrPlanned(Recruit recruit) { return recruit.getStatus().equals(RecruitStatus.UNAPPLIED) || recruit.getStatus().equals(RecruitStatus.PLANNED);