Skip to content

Commit

Permalink
fix: 마감순 정렬 추가 요청 시 에러 발생 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
Yiseull committed Apr 2, 2024
1 parent f93a31c commit 0431b63
Showing 1 changed file with 26 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,24 +160,36 @@ private BooleanExpression lessThanNextCursorId(
return null;
}

if (sortCondition == VoteSortCondition.CLOSED) {
return generateCursorId(sortCondition).gt(nextCursorId);
}

return generateCursorId(sortCondition).lt(nextCursorId);
}

private StringExpression generateCursorId(final VoteSortCondition sortCondition) {
if (sortCondition == VoteSortCondition.POPULARITY) {
final NumberExpression<Long> popularity = getVoterCount();

return StringExpressions.lpad(
popularity.stringValue(), 8, '0'
).concat(StringExpressions.lpad(
vote.id.stringValue(), 8, '0'
));
switch (sortCondition) {
case POPULARITY -> {
return StringExpressions.lpad(
getVoterCount().stringValue(), 8, '0'
).concat(StringExpressions.lpad(
vote.id.stringValue(), 8, '0'
));
}
case CLOSED -> {
return Expressions.stringTemplate(
"DATE_FORMAT({0}, {1})", vote.endTime, ConstantImpl.create("%Y%m%d%H%i%s")
).concat(StringExpressions.lpad(
vote.id.stringValue(), 8, '0'
));
}
default -> {
return Expressions.stringTemplate(
"DATE_FORMAT({0}, {1})", vote.startTime, ConstantImpl.create("%Y%m%d%H%i%s")
).concat(StringExpressions.lpad(
vote.id.stringValue(), 8, '0'
));
}
}

return Expressions.stringTemplate(
"DATE_FORMAT({0}, {1})", vote.startTime, ConstantImpl.create("%Y%m%d%H%i%s")
).concat(StringExpressions.lpad(
vote.id.stringValue(), 8, '0'
));
}
}

0 comments on commit 0431b63

Please sign in to comment.