mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-06-08 19:17:40 +08:00
fix: add log
This commit is contained in:
@@ -22,6 +22,7 @@ import com.openisle.repository.PostSubscriptionRepository;
|
|||||||
import com.openisle.repository.NotificationRepository;
|
import com.openisle.repository.NotificationRepository;
|
||||||
import com.openisle.model.Role;
|
import com.openisle.model.Role;
|
||||||
import com.openisle.exception.RateLimitException;
|
import com.openisle.exception.RateLimitException;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.scheduling.TaskScheduler;
|
import org.springframework.scheduling.TaskScheduler;
|
||||||
@@ -44,6 +45,7 @@ import java.util.concurrent.ScheduledFuture;
|
|||||||
|
|
||||||
import jakarta.annotation.PostConstruct;
|
import jakarta.annotation.PostConstruct;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class PostService {
|
public class PostService {
|
||||||
private final PostRepository postRepository;
|
private final PostRepository postRepository;
|
||||||
@@ -224,6 +226,7 @@ public class PostService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void finalizeLottery(Long postId) {
|
private void finalizeLottery(Long postId) {
|
||||||
|
log.info("start to finalizeLottery for {}", postId);
|
||||||
scheduledFinalizations.remove(postId);
|
scheduledFinalizations.remove(postId);
|
||||||
lotteryPostRepository.findById(postId).ifPresent(lp -> {
|
lotteryPostRepository.findById(postId).ifPresent(lp -> {
|
||||||
List<User> participants = new ArrayList<>(lp.getParticipants());
|
List<User> participants = new ArrayList<>(lp.getParticipants());
|
||||||
@@ -233,6 +236,7 @@ public class PostService {
|
|||||||
Collections.shuffle(participants);
|
Collections.shuffle(participants);
|
||||||
int winnersCount = Math.min(lp.getPrizeCount(), participants.size());
|
int winnersCount = Math.min(lp.getPrizeCount(), participants.size());
|
||||||
java.util.Set<User> winners = new java.util.HashSet<>(participants.subList(0, winnersCount));
|
java.util.Set<User> winners = new java.util.HashSet<>(participants.subList(0, winnersCount));
|
||||||
|
log.info("winner count {}", winnersCount);
|
||||||
lp.setWinners(winners);
|
lp.setWinners(winners);
|
||||||
lotteryPostRepository.save(lp);
|
lotteryPostRepository.save(lp);
|
||||||
for (User w : winners) {
|
for (User w : winners) {
|
||||||
|
|||||||
@@ -94,7 +94,7 @@
|
|||||||
<div v-if="loggedIn && !hasJoined && !lotteryEnded" class="join-prize-button" @click="joinLottery">
|
<div v-if="loggedIn && !hasJoined && !lotteryEnded" class="join-prize-button" @click="joinLottery">
|
||||||
<div class="join-prize-button-text">参与抽奖</div>
|
<div class="join-prize-button-text">参与抽奖</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="hasJoined" class="join-prize-button disabled">
|
<div v-else-if="hasJoined" class="join-prize-button-disabled">
|
||||||
<div class="join-prize-button-text">已参与</div>
|
<div class="join-prize-button-text">已参与</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -1197,16 +1197,17 @@ export default {
|
|||||||
background-color: var(--primary-color-hover);
|
background-color: var(--primary-color-hover);
|
||||||
}
|
}
|
||||||
|
|
||||||
.join-prize-button.disabled {
|
.join-prize-button-disabled {
|
||||||
background-color: var(--background-color-disabled);
|
margin-left: 10px;
|
||||||
|
background-color: var(--primary-color);
|
||||||
|
color: white;
|
||||||
|
padding: 5px 10px;
|
||||||
|
border-radius: 8px;
|
||||||
|
background-color: var(--primary-color-disabled);
|
||||||
|
opacity: 0.5;
|
||||||
cursor: not-allowed;
|
cursor: not-allowed;
|
||||||
}
|
}
|
||||||
|
|
||||||
.join-prize-button.disabled:hover {
|
|
||||||
background-color: var(--background-color-disabled);
|
|
||||||
cursor: not-allowed;
|
|
||||||
}
|
|
||||||
|
|
||||||
.prize-member-avatar {
|
.prize-member-avatar {
|
||||||
width: 30px;
|
width: 30px;
|
||||||
height: 30px;
|
height: 30px;
|
||||||
|
|||||||
Reference in New Issue
Block a user