Skip to content

Commit 310839d

Browse files
committed
feat: 로컬 환경에서는 검열 생략 및 VoteStatus를 OPEN으로 저장 (#79)
1 parent d043965 commit 310839d

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/main/java/com/moa/moa_server/domain/vote/entity/Vote.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,15 @@ public enum VoteType {
7575
}
7676

7777
public static Vote createUserVote(User user, Group group, String content, String imageUrl,
78-
LocalDateTime closedAt, boolean anonymous, boolean adminVote) {
78+
LocalDateTime closedAt, boolean anonymous, VoteStatus status, boolean adminVote) {
7979
return Vote.builder()
8080
.user(user)
8181
.group(group)
8282
.content(content)
8383
.imageUrl(imageUrl)
8484
.closedAt(closedAt)
8585
.anonymous(anonymous)
86-
.voteStatus(VoteStatus.PENDING)
86+
.voteStatus(status)
8787
.adminVote(adminVote)
8888
.voteType(VoteType.USER)
8989
.lastAnonymousNumber(0)

src/main/java/com/moa/moa_server/domain/vote/service/VoteService.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,14 @@ public Long createVote(Long userId, VoteCreateRequest request) {
9191
VoteValidator.validateImageUrl(request.imageUrl());
9292
String imageUrl = request.imageUrl().isBlank() ? null : request.imageUrl().trim();
9393

94+
// 투표 종료 시간 변환
9495
ZonedDateTime koreaTime = request.closedAt().atZone(ZoneId.of("Asia/Seoul"));
9596
LocalDateTime utcTime = koreaTime.withZoneSameInstant(ZoneOffset.UTC).toLocalDateTime();
9697
VoteValidator.validateClosedAt(utcTime);
9798

99+
// VoteStatus 결정
100+
Vote.VoteStatus status = "local".equals(activeProfile) ? Vote.VoteStatus.OPEN : Vote.VoteStatus.PENDING;
101+
98102
// Vote 생성 및 저장
99103
Vote vote = Vote.createUserVote(
100104
user,
@@ -103,6 +107,7 @@ public Long createVote(Long userId, VoteCreateRequest request) {
103107
imageUrl,
104108
request.closedAt(),
105109
request.anonymous(),
110+
status,
106111
adminVote
107112
);
108113
voteRepository.save(vote);

0 commit comments

Comments
 (0)