Skip to content

Commit

Permalink
fix : search api add likeList
Browse files Browse the repository at this point in the history
  • Loading branch information
papicc45 committed Apr 5, 2024
1 parent 8eff01a commit e9f88a4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/main/java/com/example/board/domain/BoardEntity.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.example.board.domain;

import com.example.board.dto.LikeDTO;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import com.example.board.dto.ImageDTO;
import com.example.board.repository.BaseEntity;
Expand Down Expand Up @@ -62,4 +63,16 @@ public ImageDTO entityToDTO(ImageEntity imageEntity) {
.imageUrl(imageEntity.getImageUrl())
.build();
}

public List<LikeDTO> likeEntityToDTO(List<LikeEntity> likeEntityList) {
List<LikeDTO> list = new ArrayList<>();
for(LikeEntity entity : likeEntityList) {
list.add(LikeDTO.builder()
.likeId(entity.getLikeId())
.nickName(entity.getNickName())
.build()
);
}
return list;
}
}
2 changes: 2 additions & 0 deletions src/main/java/com/example/board/dto/BoardSearchDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@ public class BoardSearchDTO {
private ImageDTO images;
private List<String> category;
private List<String> hashTag;

private List<LikeDTO> likeList;
private String weatherIcon;
}
1 change: 1 addition & 0 deletions src/main/java/com/example/board/service/BoardService.java
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ public List<BoardSearchDTO> search(List<String> categories, List<String> hashTag
.category(board.getCategory())
.temperature(board.getTemperature())
.hashTag(board.getHashTag())
.likeList(board.likeEntityToDTO(board.getLikelist()))
.likeCount(likeService.countLikes(board.getBoardId()))
.images(board.entityToDTO(board.getImages().get(0)))
.weatherIcon(board.getWeatherIcon())
Expand Down

0 comments on commit e9f88a4

Please sign in to comment.