Skip to content
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
12 changes: 12 additions & 0 deletions src/main/java/issueissyu/backend/domain/issue/entity/IssuePin.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,16 @@ public class IssuePin extends BaseEntity {
public void incrementPetitionCount() {
this.petitionCount++;
}

public void markInProgressIfBeforeProgress() {
if (this.issuePinState == IssuePinState.BEFORE_PROGRESS) {
this.issuePinState = IssuePinState.IN_PROGRESS;
}
}

public void markResolvedIfInProgress() {
if (this.issuePinState == IssuePinState.IN_PROGRESS) {
this.issuePinState = IssuePinState.RESOLVED;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ public GoNowResDTO participateGoNow(Long pinId, String uid) {
throw ProblemSolverException.of(IssueErrorCode.GO_NOW_400_1);
}

issuePin.markInProgressIfBeforeProgress();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

issuePin.getIssuePinState() == IssuePinState.RESOLVED state check is missing. imagine an issue that is already resolved, new solvers should not be allowed to participate. import and add a check before proceeding.

also, markInProgressIfBeforeProgress() should be called before saveAndFlush to keep the state consistent.

        if (issuePin.getIssuePinState() == issueissyu.backend.domain.issue.enums.IssuePinState.RESOLVED) {
            throw ProblemSolverException.of(IssueErrorCode.GO_NOW_400_1);
        }
        issuePin.markInProgressIfBeforeProgress();


return GoNowResDTO.builder()
.pinId(pinId)
.problemSolverId(saved.getProblemSolverId())
Expand Down Expand Up @@ -198,6 +200,8 @@ public ProblemSolverCheckResDTO resolveCitizenVerification(Long problemSolverId,
solver.markResolved();
problemSolverRepository.save(solver);

solver.getIssuePin().markResolvedIfInProgress();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

calling markResolvedIfInProgress() after saving the solver is a bit inconsistent. since the method is @transactional, dirty checking will save it, but it is better to modify all states before calling save, or even better, remove the explicit save call and rely on dirty checking.


return ProblemSolverCheckResDTO.builder()
.problemSolveState(ProblemSolveState.RESOLVED.name())
.build();
Expand Down
Loading