Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nabi-NO-JIRA-fix : 이미지 다중 업로드 에러 로직 제거 #50

Merged
merged 3 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ public CardResponseDTO<CardCreateResponseDTO> createCard(
Item savedItem = itemRepository.save(item);
Card savedCard = cardRepository.save(card);

if (!cardImageBatchRepository.saveAll(newCardImages)) {
throw new BaseException(ErrorCode.BATCH_INSERT_ERROR);
}
cardImageBatchRepository.saveAll(newCardImages);

CardCreateResponseDTO cardCreateResponseDTO = CardCreateResponseDTO.of(
savedCard,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ public class CardImageBatchRepository {

private static final String sql = "INSERT INTO card_images (created_date, modified_date, image_url, card_id) VALUES (?, ?, ?, ?)";

private static final Integer SUCCESS_SIGNAL = 1;

@Transactional
public boolean saveAll(List<CardImage> cardImages) {
int[][] result = jdbcTemplate.batchUpdate(sql,
public void saveAll(List<CardImage> cardImages) {
jdbcTemplate.batchUpdate(
sql,
cardImages,
cardImages.size(),
(PreparedStatement preparedStatement, CardImage cardImage) -> {
Expand All @@ -32,13 +31,5 @@ public boolean saveAll(List<CardImage> cardImages) {
preparedStatement.setString(3, cardImage.getImageUrl());
preparedStatement.setLong(4, cardImage.getCard().getCardId());
});

for (int[] value : result) {
if (value[0] != SUCCESS_SIGNAL) {
return false;
}
}

return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

public record HistoryListReadPagingResponseDTO(
List<HistoryListReadResponseDTO> historyList,
String cursorId
String nextCursorId
) {
}