Skip to content

Commit f148618

Browse files
Merge pull request #189 from lemonssoju/develop-v2
[develop-v2] main merge
2 parents a6f1bba + a8cd5c2 commit f148618

File tree

5 files changed

+34
-10
lines changed

5 files changed

+34
-10
lines changed

src/main/java/com/lesso/neverland/album/application/AlbumService.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.springframework.web.multipart.MultipartFile;
1515

1616
import java.io.IOException;
17+
import java.util.ArrayList;
1718
import java.util.Comparator;
1819
import java.util.List;
1920

@@ -47,23 +48,32 @@ public BaseResponse<AlbumDetailResponse> getAlbumDetail(Long groupIdx, Long albu
4748
Album album = albumRepository.findById(albumIdx).orElseThrow(() -> new BaseException(INVALID_ALBUM_IDX));
4849
if (!album.getPuzzle().getTeam().equals(group)) throw new BaseException(NO_GROUP_ALBUM);
4950

50-
List<String> memberList = album.getPuzzle().getPuzzleMembers().stream()
51-
.map(puzzleMember -> puzzleMember.getUser().getProfile().getNickname()).toList();
52-
5351
List<CommentDto> commentList = album.getComments().stream()
5452
.filter(comment -> "active".equals(comment.getStatus()))
5553
.map(comment -> new CommentDto(
5654
comment.getCommentIdx(),
5755
comment.getUser().getProfile().getNickname(),
5856
comment.getUser().getProfile().getProfileImage(),
5957
comment.getCreatedDate().toString(),
60-
comment.getContent())).toList();
58+
comment.getContent()))
59+
.toList();
6160

6261
AlbumDetailResponse albumDetailResponse = new AlbumDetailResponse(album.getPuzzle().getTitle(), album.getPuzzle().getPuzzleDate().toString(),
63-
album.getPuzzle().getLocation().getLocation(), memberList, album.getAlbumImage(), album.getContent(), album.getPuzzle().getPuzzleIdx(), commentList);
62+
album.getPuzzle().getLocation().getLocation(), getMemberList(album), album.getAlbumImage(), album.getContent(), album.getPuzzle().getPuzzleIdx(), commentList);
6463
return new BaseResponse<>(albumDetailResponse);
6564
}
6665

66+
private List<String> getMemberList(Album album) {
67+
List<String> memberList = new ArrayList<>();
68+
memberList.add(album.getPuzzle().getUser().getProfile().getNickname());
69+
70+
memberList.addAll(
71+
album.getPuzzle().getPuzzleMembers().stream()
72+
.map(puzzleMember -> puzzleMember.getUser().getProfile().getNickname())
73+
.toList());
74+
return memberList;
75+
}
76+
6777
// 앨범 목록 조회(sortType="time", "location")
6878
public BaseResponse<?> getAlbumList(Long groupIdx, String sortType) {
6979
Team group = groupRepository.findById(groupIdx).orElseThrow(() -> new BaseException(INVALID_GROUP_IDX));

src/main/java/com/lesso/neverland/album/dto/AlbumByTimeDto.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.lesso.neverland.album.domain.Album;
44

5+
import java.util.ArrayList;
56
import java.util.List;
67

78
public record AlbumByTimeDto(Long albumIdx,
@@ -11,16 +12,26 @@ public record AlbumByTimeDto(Long albumIdx,
1112
String puzzleDate,
1213
Integer puzzlerCount,
1314
List<String> puzzlerImageList) {
15+
16+
1417
public static AlbumByTimeDto from(Album album) {
18+
List<String> puzzlerImageList = new ArrayList<>();
19+
puzzlerImageList.add(album.getPuzzle().getUser().getProfile().getProfileImage());
20+
21+
puzzlerImageList.addAll(
22+
album.getPuzzle().getPuzzleMembers().stream()
23+
.map(puzzleMember -> puzzleMember.getUser().getProfile().getProfileImage())
24+
.limit(2)
25+
.toList());
26+
1527
return new AlbumByTimeDto(
1628
album.getAlbumIdx(),
1729
album.getPuzzle().getTitle(),
1830
album.getContent(),
1931
album.getAlbumImage(),
2032
album.getPuzzle().getPuzzleDate().toString(),
2133
album.getPuzzle().getPuzzleMembers().size(),
22-
album.getPuzzle().getPuzzleMembers().stream()
23-
.map(puzzleMember -> puzzleMember.getUser().getProfile().getProfileImage()).toList()
34+
puzzlerImageList
2435
);
2536
}
2637
}

src/main/java/com/lesso/neverland/group/application/GroupService.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,14 @@ private List<String> getMemberImageList(Team group) {
112112

113113
List<String> memberImages = group.getUserTeams().stream()
114114
.filter(userTeam -> "active".equals(userTeam.getStatus()))
115+
.filter(userTeam -> !userTeam.getUser().equals(group.getAdmin()))
115116
.map(userTeam -> userTeam.getUser().getProfile().getProfileImage())
116-
.limit(2).toList();
117+
.limit(2)
118+
.toList();
117119
imageList.addAll(memberImages);
118120
return imageList;
119121
}
120122

121-
122123
// [관리자] 그룹 수정 화면 조회
123124
public BaseResponse<GroupEditViewResponse> getGroupEditView(Long groupIdx) {
124125
Team group = groupRepository.findById(groupIdx).orElseThrow(() -> new BaseException(INVALID_GROUP_IDX));

src/main/java/com/lesso/neverland/puzzle/application/PuzzleService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public BaseResponse<CreatePuzzleResponse> createPuzzle(Long groupIdx, MultipartF
146146

147147
LocalDate puzzleDate = convertToLocalDate(createPuzzleRequest.puzzleDate());
148148
Puzzle newPuzzle = createPuzzle(createPuzzleRequest, group, writer, puzzleDate);
149-
if (!image.isEmpty()) {
149+
if (image != null && !image.isEmpty()) {
150150
String imagePath = imageService.uploadImage("puzzle", image);
151151
newPuzzle.addPuzzleImage(imagePath);
152152
}

src/main/java/com/lesso/neverland/puzzle/domain/Puzzle.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import java.util.ArrayList;
1414
import java.util.List;
1515

16+
import static com.lesso.neverland.common.constants.Constants.ACTIVE;
1617
import static com.lesso.neverland.common.constants.Constants.INACTIVE;
1718

1819
@Entity
@@ -62,6 +63,7 @@ public Puzzle(User user, Team team, String title, String content, LocalDate puzz
6263
this.content = content;
6364
this.puzzleDate = puzzleDate;
6465
this.location = location;
66+
this.setStatus(ACTIVE);
6567
}
6668

6769
public void setUser(User user) {

0 commit comments

Comments
 (0)