REQ-3282: 更新卡片失败时,回滚数据

This commit is contained in:
yanglin 2024-12-23 14:26:02 +08:00
parent 21ea172e92
commit 716ae6d401

View File

@ -252,17 +252,22 @@ public class CardManager {
UpdateStateResult update(UpdateBuilder builder) {
if (CollectionUtils.isEmpty(cards))
return UpdateStateResult.EMPTY_CARDS;
return execTransactional(() -> {
for (Card card : cardDao.reloadCardsForUpdate(cards))
builder.buildUpdate(card);
if (CollectionUtils.isEmpty(updates))
return UpdateStateResult.NO_UPDATE;
cardDao.updateBatchById(updates);
rebuildCardContent();
updateCardLogger.reloadAndLogCards(String.format("%s:enqueue", operation));
updateMessages();
return UpdateStateResult.SUCCESS;
});
try {
return execTransactional(() -> {
for (Card card : cardDao.reloadCardsForUpdate(cards))
builder.buildUpdate(card);
if (CollectionUtils.isEmpty(updates))
return UpdateStateResult.NO_UPDATE;
cardDao.updateBatchById(updates);
rebuildCardContent();
updateCardLogger.reloadAndLogCards(String.format("%s:enqueue", operation));
updateMessages();
return UpdateStateResult.SUCCESS;
});
} catch (Exception e) {
updateCardLogger.reloadAndLogCards(String.format("%s:fail", operation), e);
throw e;
}
}
Card createUpdate(Card card) {