REQ-3201: 预设按钮幂等控制

This commit is contained in:
yanglin 2024-12-19 12:30:09 +08:00
parent 0b31cc123f
commit 8c04600a8e
2 changed files with 6 additions and 5 deletions

View File

@ -177,7 +177,7 @@ public class CardManager {
CardLogger updateCardLogger = cardLoggers.createLogger(CardRequestContext.create(request));
execTransactional(() -> {
ArrayList<Card> updates = new ArrayList<>(cards.size());
for (Card card : cardDao.getCardsForUpdate(cards)) {
for (Card card : cardDao.reloadCardsForUpdate(cards)) {
if (card.getCardState() == CardState.COMPLETED)
continue;
updateCardLogger.addCard(card);

View File

@ -78,19 +78,20 @@ public class CardDao extends ServiceImpl<CardMapper, Card> {
updateBatchById(updates);
}
public List<Card> getCardsForUpdate(List<Card> cards) {
public List<Card> reloadCardsForUpdate(List<Card> cards) {
if (CollectionUtils.isEmpty(cards))
return Collections.emptyList();
return lambdaQuery()
return DeleteAwareInterceptor.execute(() -> lambdaQuery()
.in(Card::getId, collectCardIdsSorted(cards))
.last("FOR UPDATE")
.list();
.list());
}
public List<Card> reloadCards(List<Card> cards) {
if (CollectionUtils.isEmpty(cards))
return Collections.emptyList();
return DeleteAwareInterceptor.execute(()-> listByIds(collectCardIdsSorted(cards)));
return DeleteAwareInterceptor.execute(() ->
listByIds(collectCardIdsSorted(cards)));
}
public void deleteCards(List<Card> cards) {