Skip to content

Commit

Permalink
[FIX] 행사 수정 및 출석체크 상태 변경이 안되는 오류 수정 (#172)
Browse files Browse the repository at this point in the history
  • Loading branch information
rlajm1203 authored Oct 12, 2024
1 parent 41118b6 commit b922383
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -52,24 +60,13 @@ public static AttendModel of(Long memberId, Long programId) {
}

private void validateChange(String afterStatus) {
canChange();
isSameBeforeStatus(afterStatus);
}

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

0 comments on commit b922383

Please sign in to comment.