diff --git a/eeos/src/main/java/com/blackcompany/eeos/program/application/model/converter/ProgramRequestConverter.java b/eeos/src/main/java/com/blackcompany/eeos/program/application/model/converter/ProgramRequestConverter.java index a0686e2a..54f06c13 100644 --- a/eeos/src/main/java/com/blackcompany/eeos/program/application/model/converter/ProgramRequestConverter.java +++ b/eeos/src/main/java/com/blackcompany/eeos/program/application/model/converter/ProgramRequestConverter.java @@ -40,6 +40,7 @@ public ProgramModel from(Long memberId, CommandProgramRequest source, Long progr .id(programId) .title(source.getTitle()) .content(source.getContent()) + .githubUrl(source.getProgramGithubUrl()) .programDate(DateConverter.toEpochSecond(source.getDeadLine())) .programCategory(ProgramCategory.find(source.getCategory())) .programType(ProgramType.find(source.getType())) diff --git a/eeos/src/main/java/com/blackcompany/eeos/target/application/model/AttendModel.java b/eeos/src/main/java/com/blackcompany/eeos/target/application/model/AttendModel.java index 771e1b4c..b45dc640 100644 --- a/eeos/src/main/java/com/blackcompany/eeos/target/application/model/AttendModel.java +++ b/eeos/src/main/java/com/blackcompany/eeos/target/application/model/AttendModel.java @@ -35,6 +35,14 @@ public String getStatus() { return status.getStatus(); } + public boolean isAttended(){ + return (!this.status.equals(AttendStatus.NONRESPONSE) && !this.status.equals(AttendStatus.NONRELATED)); + } + + public boolean isRelated() { + return !this.status.equals(AttendStatus.NONRELATED); + } + public static AttendModel of() { return AttendModel.builder().status(AttendStatus.NONRELATED).build(); } @@ -52,7 +60,6 @@ public static AttendModel of(Long memberId, Long programId) { } private void validateChange(String afterStatus) { - canChange(); isSameBeforeStatus(afterStatus); } @@ -60,16 +67,6 @@ private void validateChangeByManager(String beforeStatus) { isSameBeforeStatus(beforeStatus); } - private void canChange() { - if (AttendStatus.isSame(status.getStatus(), AttendStatus.NONRELATED)) { - throw new DeniedSaveAttendException(); - } - - if (!AttendStatus.isSame(status.getStatus(), AttendStatus.NONRESPONSE)) { - throw new DeniedChangeAttendException(); - } - } - private void isSameBeforeStatus(String status) { if (!AttendStatus.isSame(status, this.status)) { return; diff --git a/eeos/src/main/java/com/blackcompany/eeos/target/application/service/AttendService.java b/eeos/src/main/java/com/blackcompany/eeos/target/application/service/AttendService.java index 33220b3e..6dda6829 100644 --- a/eeos/src/main/java/com/blackcompany/eeos/target/application/service/AttendService.java +++ b/eeos/src/main/java/com/blackcompany/eeos/target/application/service/AttendService.java @@ -20,6 +20,8 @@ import com.blackcompany.eeos.target.application.dto.converter.ChangeAttendStatusConverter; import com.blackcompany.eeos.target.application.dto.converter.QueryAttendActiveStatusConverter; import com.blackcompany.eeos.target.application.dto.converter.QueryAttendStatusResponseConverter; +import com.blackcompany.eeos.target.application.exception.DeniedChangeAttendException; +import com.blackcompany.eeos.target.application.exception.DeniedSaveAttendException; import com.blackcompany.eeos.target.application.exception.NotFoundAttendException; import com.blackcompany.eeos.target.application.exception.NotStartAttendException; import com.blackcompany.eeos.target.application.model.AttendModel; @@ -88,8 +90,11 @@ public QueryAttendStatusResponse findAttendInfo(final Long programId, final Stri @Override public ChangeAttendStatusResponse changeStatus(final Long memberId, final Long programId) { AttendModel model = getAttend(memberId, programId); + ProgramModel program = findProgram(programId); + validateAttend(program, model); + AttendModel changedModel = model.changeStatus(program.getAttendMode().getMode()); AttendEntity updated = attendRepository.save(attendEntityConverter.toEntity(changedModel)); @@ -124,8 +129,10 @@ public QueryAttendActiveStatusResponse getAttendInfo(Long programId, String acti return queryAttendActiveStatusConverter.of(response); } - private void validateAttend(ProgramModel model) { - if (model.getAttendMode().equals(ProgramAttendMode.END)) throw new NotStartAttendException(); + private void validateAttend(ProgramModel programModel, AttendModel attendModel) { + if (programModel.getAttendMode().equals(ProgramAttendMode.END)) throw new NotStartAttendException(); + if(attendModel.isAttended()) throw new DeniedChangeAttendException(); + if(!attendModel.isRelated()) throw new DeniedSaveAttendException(); } private ProgramModel findProgram(final Long programId) {