Skip to content

Commit

Permalink
#28 [Fix] 북마크 기능 추가 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
JSoi committed Jul 29, 2022
1 parent 049bf17 commit ff80ea6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ public BookmarkInfoDto(Bookmark bookmark){
this.bookmarkId = bookmark.getId();
this.storeId = (int) bookmark.getStoreId().getId();

if(bookmark.getStoreId().getStoreImageList() == null) {
if(!bookmark.getStoreId().getStoreImageList().isEmpty()) {
this.storeImageList = bookmark.getStoreId().getStoreImageList().get(0).getStoreImageUrl();

} else if(bookmark.getStoreId().getStoreImageList() != null) {
} else if(bookmark.getStoreId().getStoreImageList().isEmpty()) {
this.storeImageList = "";
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
Expand Down Expand Up @@ -56,6 +57,7 @@ public void bookmarkDelete(int bookmarkId, String socialId) {

}

@Transactional
public List<BookmarkInfoDto> bookmarkTop(String socialId, Pageable pageable) {

User user = userRepository.findBySocialId(socialId);
Expand All @@ -64,22 +66,7 @@ public List<BookmarkInfoDto> bookmarkTop(String socialId, Pageable pageable) {

List<BookmarkInfoDto> bookmarkList = new ArrayList<>();
for(Bookmark bookmark: bookmarkPage){
Optional<Store> store = storeRepository.findById(bookmark.getStoreId().getId());
List<StoreImage> storeImageList = storeImgRepository.findAllByStoreId(store.get().getId());

BookmarkInfoDto bookmarkInfoDto = BookmarkInfoDto
.builder()
.bookmarkId(bookmark.getId())
.name(store.get().getName())
.phoneNumber(store.get().getPhoneNumber())
.category(store.get().getCategory())
.address(store.get().getAddress())
.pointAvg(Math.round(store.get().getPointAvg()*10)/10.0)
.storeId((int) store.get().getId())
.storeImageList(!storeImageList.isEmpty() ? storeImageList.get(0).getStoreImageUrl():"")
.build();

// BookmarkInfoDto bookmarkInfoDto = new BookmarkInfoDto(bookmark);
BookmarkInfoDto bookmarkInfoDto = new BookmarkInfoDto(bookmark);
bookmarkList.add(bookmarkInfoDto);
}

Expand Down

0 comments on commit ff80ea6

Please sign in to comment.