Skip to content

Commit

Permalink
[BE] 아이템 등록시간 버그 수정 (#352)
Browse files Browse the repository at this point in the history
  • Loading branch information
lvalentine6 committed Jul 21, 2023
2 parents f7f66ef + 43648d4 commit eb538d8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public ResponseDto<ItemDetailReturnDto> showItemDetail(HttpServletRequest httpSe
ItemIdxDto itemIdxDto) {
ItemDetailReturnDto itemDetailReturnDto = itemService.showItemDetail(httpServletRequest,
itemIdxDto.getItemIdx());
log.info("DTO 날짜값 : " + itemDetailReturnDto.getLastModifiedAt());
return ResponseDto.of(RESPONSE_SUCCESS, itemDetailReturnDto);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package codesquad.secondhand.dto.item;

import java.sql.Date;
import java.time.LocalDateTime;
import java.util.List;

import org.joda.time.DateTime;

import codesquad.secondhand.dto.category.CategoryWithoutImageDto;
import codesquad.secondhand.entity.Item;
import lombok.Getter;
Expand Down
1 change: 1 addition & 0 deletions be/src/main/java/codesquad/secondhand/entity/Item.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public class Item {
private LocalDateTime postedAt;

@LastModifiedDate
@Setter
@Column(name = "last_modified_at")
private LocalDateTime lastModifiedAt;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static codesquad.secondhand.exception.code.ItemErrorCode.*;
import static codesquad.secondhand.exception.code.MemberErrorCode.*;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -166,6 +167,8 @@ public ItemDetailReturnDto showItemDetail(HttpServletRequest httpServletRequest,
Item item = itemRepository.findById(itemIdx)
.orElseThrow();

LocalDateTime localDateTime = item.getLastModifiedAt();

Long memberIdx;
if (httpServletRequest.getAttribute("memberIdx") == null) {
memberIdx = -1L;
Expand All @@ -191,6 +194,7 @@ public ItemDetailReturnDto showItemDetail(HttpServletRequest httpServletRequest,
List<String> imageUrl = itemImageRepository.findAllByItemItemIdx(itemIdx).stream()
.map(ItemImage::getImageUrl).collect(Collectors.toList());

item.setLastModifiedAt(localDateTime);
return ItemDetailReturnDto.of(item, sellerDto, categoryWithoutImageDto, chatRooms, interest, interestChecked,
imageUrl);
}
Expand Down

0 comments on commit eb538d8

Please sign in to comment.