Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] 행사 수정 및 출석체크 상태 변경이 안되는 오류 수정 #172

Merged
merged 3 commits into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down
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
Loading