Skip to content

Commit

Permalink
feat: 지원 공고 날짜 수정 PI
Browse files Browse the repository at this point in the history
  • Loading branch information
tape4 committed Aug 10, 2024
1 parent 708d807 commit 942e600
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 8 deletions.
1 change: 1 addition & 0 deletions .github/workflows/CI_MVP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
- mvp/career
- mvp/portfolio
- feature/record
- feat/update-recruit-date

jobs:
CI:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -51,40 +50,40 @@ public ResponseEntity<RecruitIdResponse> create(@RequestBody @Valid RecruitCreat
description = "주어진 정보를 바탕으로 지원 공고 데이터를 수정합니다.")
@Parameter(name = "recruitId", description = "지원 공고 ID", example = "1")
@PutMapping("/{recruitId}")
public ResponseEntity<Long> update(@RequestBody @Valid RecruitUpdate recruitUpdate,
public ResponseEntity<RecruitIdResponse> 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<Long> updateState(@RequestBody @Valid RecruitStatusUpdate recruitStatusUpdate,
@PatchMapping("/{recruitId}/status")
public ResponseEntity<RecruitIdResponse> 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(
summary = "지원 공고 삭제",
description = "지원 공고 ID에 해당 하는 공고를 삭제합니다")
@Parameter(name = "recruitId", description = "지원 공고 ID", example = "1")
@DeleteMapping("/{recruitId}")
public ResponseEntity<Long> delete(@PathVariable long recruitId) {
public ResponseEntity<RecruitIdResponse> 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(
Expand Down Expand Up @@ -162,4 +161,17 @@ public ResponseEntity<RecruitListByMonthResponse> getByMonth(
.ok()
.body(RecruitListByMonthResponse.from(recruitListByMonthDtoList));
}

@Operation(
summary = "공고 지워 날짜 수정",
description = "공고 지원 날짜를 주어진 날짜로 수정합니다.")
@PatchMapping("/{recruitId}/apply-date")
public ResponseEntity<RecruitIdResponse> 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));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ public interface RecruitService {
List<ValidRecruitDto> findAllValidRecruitByMemberId(Member member, LocalDateTime endTime);

List<RecruitListByMonthDto> findAllValidRecruitByYearAndMonth(Member member, Integer year, Integer month);

Recruit updateApplyDate(Member requestMember, long recruitId, RecruitApplyDateUpdate recruitApplyDateUpdate);
}
15 changes: 15 additions & 0 deletions src/main/java/umc/kkijuk/server/recruit/domain/Recruit.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -100,6 +101,17 @@ public List<RecruitListByMonthDto> 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);
Expand Down

0 comments on commit 942e600

Please sign in to comment.