Skip to content

Commit

Permalink
좋아요 리스트
Browse files Browse the repository at this point in the history
  • Loading branch information
Johyunik committed Dec 4, 2023
1 parent 8e95c9a commit 21cdfab
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.weatherfit.board.dto;

import com.weatherfit.board.domain.LikeEntity;
import lombok.*;
import java.util.List;

Expand All @@ -19,6 +20,7 @@ public class BoardDetailResponseDTO {
private boolean status;
private List<ImageDTO> images;
private List<CommentResponseDTO> comments;
private List<LikeEntity> likelist;



Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.weatherfit.board.dto;


import com.weatherfit.board.domain.LikeEntity;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
Expand All @@ -20,4 +21,5 @@ public class BoardListResponseDTO {
private List<String> category;
private List<String> hashTag;
private String weatherIcon;
private List<LikeEntity> likelist;
}
7 changes: 5 additions & 2 deletions src/main/java/com/weatherfit/board/service/BoardService.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public List<BoardListResponseDTO> findAll() {
.hashTag(board.getHashTag())
.category(board.getCategory())
.temperature(board.getTemperature())
.likelist(board.getLikelist())
.weatherIcon(board.getWeatherIcon());

if (!board.getImages().isEmpty()) {
Expand All @@ -70,6 +71,7 @@ public List<BoardListResponseDTO> findDate() {
.hashTag(board.getHashTag())
.category(board.getCategory())
.temperature(board.getTemperature())
.likelist(board.getLikelist())
.weatherIcon(board.getWeatherIcon());

if (!board.getImages().isEmpty()) {
Expand All @@ -94,6 +96,7 @@ public List<BoardListResponseDTO> findLike() {
.hashTag(board.getHashTag())
.category(board.getCategory())
.temperature(board.getTemperature())
.likelist(board.getLikelist())
.weatherIcon(board.getWeatherIcon());

if (!board.getImages().isEmpty()) {
Expand All @@ -119,6 +122,8 @@ public List<BoardListResponseDTO> findNickname(String nickName) {
.hashTag(board.getHashTag())
.category(board.getCategory())
.temperature(board.getTemperature())
.likelist(board.getLikelist())

.weatherIcon(board.getWeatherIcon());

if (!board.getImages().isEmpty()) {
Expand Down Expand Up @@ -168,15 +173,13 @@ public void patchBoard(int boardId, String boardJson, MultipartFile[] images, St
for (MultipartFile image : images) {
String imageUrl = imageService.saveImage(image);

// 이미지 URL이 DB에 이미 존재하는지 확인합니다.
if (!imageRepository.existsByImageUrl(imageUrl)) {
ImageEntity imageEntity = ImageEntity.builder()
.imageUrl(imageUrl)
.boardId(originalBoard)
.build();
imageRepository.save(imageEntity);

// 기존 게시글의 이미지 목록에 새로운 이미지를 추가합니다.
originalBoard.getImages().add(imageEntity);
}
}
Expand Down

0 comments on commit 21cdfab

Please sign in to comment.