|
33 | 33 | import com.moa.moa_server.domain.vote.util.VoteValidator; |
34 | 34 | import jakarta.annotation.Nullable; |
35 | 35 | import lombok.RequiredArgsConstructor; |
| 36 | +import org.springframework.beans.factory.annotation.Value; |
36 | 37 | import org.springframework.dao.DataIntegrityViolationException; |
37 | 38 | import org.springframework.stereotype.Service; |
38 | 39 | import org.springframework.transaction.annotation.Transactional; |
39 | 40 |
|
| 41 | +import java.time.LocalDateTime; |
| 42 | +import java.time.ZoneId; |
| 43 | +import java.time.ZoneOffset; |
| 44 | +import java.time.ZonedDateTime; |
40 | 45 | import java.util.List; |
41 | 46 | import java.util.Optional; |
42 | 47 | import java.util.stream.Stream; |
|
45 | 50 | @RequiredArgsConstructor |
46 | 51 | public class VoteService { |
47 | 52 |
|
| 53 | + @Value("${spring.profiles.active:}") |
| 54 | + private String activeProfile; |
| 55 | + |
48 | 56 | private static final int DEFAULT_PAGE_SIZE = 10; |
49 | 57 | private static final int DEFAULT_UNAUTHENTICATED_PAGE_SIZE = 3; |
50 | 58 |
|
@@ -82,22 +90,27 @@ public Long createVote(Long userId, VoteCreateRequest request) { |
82 | 90 | VoteValidator.validateContent(request.content()); |
83 | 91 | VoteValidator.validateImageUrl(request.imageUrl()); |
84 | 92 | String imageUrl = request.imageUrl().isBlank() ? null : request.imageUrl().trim(); |
85 | | - VoteValidator.validateClosedAt(request.closedAt()); |
| 93 | + |
| 94 | + ZonedDateTime koreaTime = request.closedAt().atZone(ZoneId.of("Asia/Seoul")); |
| 95 | + LocalDateTime utcTime = koreaTime.withZoneSameInstant(ZoneOffset.UTC).toLocalDateTime(); |
| 96 | + VoteValidator.validateClosedAt(utcTime); |
86 | 97 |
|
87 | 98 | // Vote 생성 및 저장 |
88 | 99 | Vote vote = Vote.createUserVote( |
89 | 100 | user, |
90 | 101 | group, |
91 | 102 | request.content(), |
92 | 103 | imageUrl, |
93 | | - request.closedAt().minusHours(9), |
| 104 | + request.closedAt(), |
94 | 105 | request.anonymous(), |
95 | 106 | adminVote |
96 | 107 | ); |
97 | 108 | voteRepository.save(vote); |
98 | 109 |
|
99 | | - // AI 서버로 검열 요청 |
100 | | - voteModerationService.requestModeration(vote.getId(), vote.getContent()); |
| 110 | + // AI 서버로 검열 요청 (로컬 환경 제외) |
| 111 | + if (!"local".equals(activeProfile)) { |
| 112 | + voteModerationService.requestModeration(vote.getId(), vote.getContent()); |
| 113 | + } |
101 | 114 |
|
102 | 115 | return vote.getId(); |
103 | 116 | } |
|
0 commit comments