Skip to content

Commit

Permalink
feat: 심야자습/외출/외박 거절사유 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
suw0n committed Apr 4, 2024
1 parent de0cd93 commit 985e3fc
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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("심야자습 대기 성공");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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("외출 대기 성공");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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("외박 대기 성공");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public class NightStudy extends BaseEntity {
@JoinColumn(name = "fk_teacher_id")
private Teacher teacher;

private String rejectReason;

@NotNull
private LocalDate startAt;

Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) {
Expand Down

0 comments on commit 985e3fc

Please sign in to comment.