diff --git a/dodam-api/src/main/java/b1nd/dodamapi/nightstudy/NightStudyController.java b/dodam-api/src/main/java/b1nd/dodamapi/nightstudy/NightStudyController.java index 5ee240bb..a9ec8638 100644 --- a/dodam-api/src/main/java/b1nd/dodamapi/nightstudy/NightStudyController.java +++ b/dodam-api/src/main/java/b1nd/dodamapi/nightstudy/NightStudyController.java @@ -4,6 +4,7 @@ import b1nd.dodamapi.common.response.ResponseData; import b1nd.dodamcore.nightstudy.application.NightStudyService; import b1nd.dodamcore.nightstudy.application.dto.req.ApplyNightStudyReq; +import b1nd.dodamcore.nightstudy.application.dto.req.RejectNightStudyReq; import b1nd.dodamcore.nightstudy.domain.enums.NightStudyStatus; import b1nd.dodamcore.nightstudy.application.dto.res.NightStudyRes; import jakarta.validation.Valid; @@ -35,21 +36,21 @@ public Response cancel(@PathVariable Long id) { @PatchMapping("/{id}/allow") public Response allow(@PathVariable Long id) { - nightStudyService.modifyStatus(id, NightStudyStatus.ALLOWED); + nightStudyService.modifyStatus(id, NightStudyStatus.ALLOWED, null); return Response.ok("심야자습 승인 성공"); } @PatchMapping("/{id}/reject") - public Response reject(@PathVariable Long id) { - nightStudyService.modifyStatus(id, NightStudyStatus.REJECTED); + public Response reject(@PathVariable Long id, @RequestBody RejectNightStudyReq req) { + nightStudyService.modifyStatus(id, NightStudyStatus.REJECTED, req.rejectReason()); return Response.ok("심야자습 거절 성공"); } @PatchMapping("/{id}/revert") public Response revert(@PathVariable Long id) { - nightStudyService.modifyStatus(id, NightStudyStatus.PENDING); + nightStudyService.modifyStatus(id, NightStudyStatus.PENDING, null); return Response.ok("심야자습 대기 성공"); } diff --git a/dodam-api/src/main/java/b1nd/dodamapi/outgoing/OutGoingController.java b/dodam-api/src/main/java/b1nd/dodamapi/outgoing/OutGoingController.java index d21e068a..13a6373f 100644 --- a/dodam-api/src/main/java/b1nd/dodamapi/outgoing/OutGoingController.java +++ b/dodam-api/src/main/java/b1nd/dodamapi/outgoing/OutGoingController.java @@ -2,6 +2,7 @@ import b1nd.dodamapi.common.response.Response; import b1nd.dodamapi.common.response.ResponseData; +import b1nd.dodamcore.outgoing.application.dto.req.RejectOutGoingReq; import b1nd.dodamcore.outgoing.application.dto.res.OutGoingRes; import b1nd.dodamcore.outgoing.domain.enums.OutGoingStatus; import b1nd.dodamcore.outgoing.application.OutGoingService; @@ -29,21 +30,21 @@ public Response apply(@RequestBody @Valid ApplyOutGoingReq req) { @PatchMapping("/{id}/allow") public Response allow(@PathVariable Long id) { - outGoingService.modifyStatus(id, OutGoingStatus.ALLOWED); + outGoingService.modifyStatus(id, OutGoingStatus.ALLOWED, null); return Response.noContent("외출 승인 성공"); } @PatchMapping("/{id}/reject") - public Response reject(@PathVariable Long id) { - outGoingService.modifyStatus(id, OutGoingStatus.REJECTED); + public Response reject(@PathVariable Long id, @RequestBody RejectOutGoingReq req) { + outGoingService.modifyStatus(id, OutGoingStatus.REJECTED, req.rejectReason()); return Response.noContent("외출 거절 성공"); } @PatchMapping("/{id}/revert") public Response revert(@PathVariable Long id) { - outGoingService.modifyStatus(id, OutGoingStatus.PENDING); + outGoingService.modifyStatus(id, OutGoingStatus.PENDING, null); return Response.noContent("외출 대기 성공"); } diff --git a/dodam-api/src/main/java/b1nd/dodamapi/outsleeping/OutSleepingController.java b/dodam-api/src/main/java/b1nd/dodamapi/outsleeping/OutSleepingController.java index 6c316479..9e84e976 100644 --- a/dodam-api/src/main/java/b1nd/dodamapi/outsleeping/OutSleepingController.java +++ b/dodam-api/src/main/java/b1nd/dodamapi/outsleeping/OutSleepingController.java @@ -4,6 +4,7 @@ import b1nd.dodamapi.common.response.ResponseData; import b1nd.dodamcore.outsleeping.application.OutSleepingService; import b1nd.dodamcore.outsleeping.application.dto.req.ApplyOutSleepingReq; +import b1nd.dodamcore.outsleeping.application.dto.req.RejectOutSleepingReq; import b1nd.dodamcore.outsleeping.application.dto.res.OutSleepingRes; import b1nd.dodamcore.outsleeping.domain.enums.OutSleepingStatus; import jakarta.validation.Valid; @@ -29,21 +30,21 @@ public Response apply(@RequestBody @Valid ApplyOutSleepingReq req) { @PatchMapping("/{id}/allow") public Response allow(@PathVariable Long id) { - outSleepingService.modifyStatus(id, OutSleepingStatus.ALLOWED); + outSleepingService.modifyStatus(id, OutSleepingStatus.ALLOWED, null); return Response.noContent("외박 승인 성공"); } @PatchMapping("/{id}/reject") - public Response reject(@PathVariable Long id) { - outSleepingService.modifyStatus(id, OutSleepingStatus.REJECTED); + public Response reject(@PathVariable Long id, @RequestBody RejectOutSleepingReq req) { + outSleepingService.modifyStatus(id, OutSleepingStatus.REJECTED, req.rejectReason()); return Response.noContent("외박 거절 성공"); } @PatchMapping("/{id}/revert") public Response revert(@PathVariable Long id) { - outSleepingService.modifyStatus(id, OutSleepingStatus.PENDING); + outSleepingService.modifyStatus(id, OutSleepingStatus.PENDING, null); return Response.noContent("외박 대기 성공"); } diff --git a/dodam-core/src/main/java/b1nd/dodamcore/nightstudy/application/NightStudyService.java b/dodam-core/src/main/java/b1nd/dodamcore/nightstudy/application/NightStudyService.java index 09abe94f..4c0f07ec 100644 --- a/dodam-core/src/main/java/b1nd/dodamcore/nightstudy/application/NightStudyService.java +++ b/dodam-core/src/main/java/b1nd/dodamcore/nightstudy/application/NightStudyService.java @@ -56,13 +56,13 @@ public void cancel(Long id) { } @Transactional - public void modifyStatus(Long id, NightStudyStatus status) { + public void modifyStatus(Long id, NightStudyStatus status, String rejectReason) { NightStudy nightStudy = nightStudyRepository.findById(id) .orElseThrow(NightStudyNotFoundException::new); Teacher teacher = teacherRepository.findByMember(memberSessionHolder.current()) .orElseThrow(TeacherNotFoundException::new); - nightStudy.modifyStatus(teacher, status); + nightStudy.modifyStatus(teacher, status, rejectReason); } @Transactional(readOnly = true) diff --git a/dodam-core/src/main/java/b1nd/dodamcore/nightstudy/domain/entity/NightStudy.java b/dodam-core/src/main/java/b1nd/dodamcore/nightstudy/domain/entity/NightStudy.java index 203f654d..a66ed95c 100644 --- a/dodam-core/src/main/java/b1nd/dodamcore/nightstudy/domain/entity/NightStudy.java +++ b/dodam-core/src/main/java/b1nd/dodamcore/nightstudy/domain/entity/NightStudy.java @@ -55,6 +55,8 @@ public class NightStudy extends BaseEntity { @JoinColumn(name = "fk_teacher_id") private Teacher teacher; + private String rejectReason; + @NotNull private LocalDate startAt; @@ -78,9 +80,21 @@ public NightStudy(String content, boolean doNeedPhone, String reasonForPhone, Sc this.endAt = endAt; } - public void modifyStatus(Teacher teacher, NightStudyStatus status) { + public NightStudy(Student student) { + this.content = "민규야 힘내. 힘규야 민내."; + this.doNeedPhone = false; + this.reasonForPhone = null; + this.place = SchoolPlace.PROGRAMMING_1; + this.status = NightStudyStatus.PENDING; + this.student = student; + this.startAt = LocalDate.now(); + this.endAt = LocalDate.now(); + } + + public void modifyStatus(Teacher teacher, NightStudyStatus status, String rejectReason) { this.status = status; this.teacher = teacher; + this.rejectReason = rejectReason; } public void isApplicant(Student student) { diff --git a/dodam-core/src/main/java/b1nd/dodamcore/outgoing/application/OutGoingService.java b/dodam-core/src/main/java/b1nd/dodamcore/outgoing/application/OutGoingService.java index 02c669d4..0d912a68 100644 --- a/dodam-core/src/main/java/b1nd/dodamcore/outgoing/application/OutGoingService.java +++ b/dodam-core/src/main/java/b1nd/dodamcore/outgoing/application/OutGoingService.java @@ -38,11 +38,11 @@ public void apply(ApplyOutGoingReq req) { } @Transactional - public void modifyStatus(Long id, OutGoingStatus status) { + public void modifyStatus(Long id, OutGoingStatus status, String rejectReason) { Teacher teacher = teacherRepository.getByMember(memberSessionHolder.current()); OutGoing outGoing = outGoingRepository.getById(id); - outGoing.modifyStatus(teacher, status); + outGoing.modifyStatus(teacher, status, rejectReason); } @Transactional diff --git a/dodam-core/src/main/java/b1nd/dodamcore/outgoing/domain/entity/OutGoing.java b/dodam-core/src/main/java/b1nd/dodamcore/outgoing/domain/entity/OutGoing.java index 4ceb16fb..361811eb 100644 --- a/dodam-core/src/main/java/b1nd/dodamcore/outgoing/domain/entity/OutGoing.java +++ b/dodam-core/src/main/java/b1nd/dodamcore/outgoing/domain/entity/OutGoing.java @@ -46,6 +46,8 @@ public class OutGoing extends BaseEntity { @JoinColumn(name = "fk_teacher_id") private Teacher teacher; + private String rejectReason; + @Builder public OutGoing(String reason, LocalDateTime startAt, LocalDateTime endAt, Student student) { isInvalidPeriod(startAt, endAt); @@ -57,9 +59,10 @@ public OutGoing(String reason, LocalDateTime startAt, LocalDateTime endAt, Stude this.student = student; } - public void modifyStatus(Teacher teacher, OutGoingStatus status) { + public void modifyStatus(Teacher teacher, OutGoingStatus status, String rejectReason) { this.status = status; this.teacher = teacher; + this.rejectReason = rejectReason; } public void isApplicant(Student student) { diff --git a/dodam-core/src/main/java/b1nd/dodamcore/outsleeping/application/OutSleepingService.java b/dodam-core/src/main/java/b1nd/dodamcore/outsleeping/application/OutSleepingService.java index 31504b43..f14ec15f 100644 --- a/dodam-core/src/main/java/b1nd/dodamcore/outsleeping/application/OutSleepingService.java +++ b/dodam-core/src/main/java/b1nd/dodamcore/outsleeping/application/OutSleepingService.java @@ -36,11 +36,11 @@ public void apply(ApplyOutSleepingReq req) { } @Transactional - public void modifyStatus(Long id, OutSleepingStatus status) { + public void modifyStatus(Long id, OutSleepingStatus status, String rejectReason) { Teacher teacher = teacherRepository.getByMember(memberSessionHolder.current()); OutSleeping outSleeping = outSleepingRepository.getById(id); - outSleeping.modifyStatus(teacher, status); + outSleeping.modifyStatus(teacher, status, rejectReason); } @Transactional diff --git a/dodam-core/src/main/java/b1nd/dodamcore/outsleeping/domain/entity/OutSleeping.java b/dodam-core/src/main/java/b1nd/dodamcore/outsleeping/domain/entity/OutSleeping.java index 9e39ebf0..411e8327 100644 --- a/dodam-core/src/main/java/b1nd/dodamcore/outsleeping/domain/entity/OutSleeping.java +++ b/dodam-core/src/main/java/b1nd/dodamcore/outsleeping/domain/entity/OutSleeping.java @@ -46,6 +46,8 @@ public class OutSleeping extends BaseEntity { @JoinColumn(name = "fk_teacher_id") private Teacher teacher; + private String rejectReason; + @Builder public OutSleeping(String reason, LocalDate startAt, LocalDate endAt, Student student) { isInvalidPeriod(startAt, endAt); @@ -57,9 +59,10 @@ public OutSleeping(String reason, LocalDate startAt, LocalDate endAt, Student st this.student = student; } - public void modifyStatus(Teacher teacher, OutSleepingStatus status) { + public void modifyStatus(Teacher teacher, OutSleepingStatus status, String rejectReason) { this.status = status; this.teacher = teacher; + this.rejectReason = rejectReason; } public void isApplicant(Student student) {