-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #146 from lemonssoju/develop-v2
[develop-v2] main merge
- Loading branch information
Showing
10 changed files
with
125 additions
and
74 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
src/main/java/com/lesso/neverland/album/application/AlbumService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.lesso.neverland.album.application; | ||
|
||
import com.lesso.neverland.album.domain.Album; | ||
import com.lesso.neverland.album.dto.AlbumDetailResponse; | ||
import com.lesso.neverland.album.dto.AlbumImageRequest; | ||
import com.lesso.neverland.album.repository.AlbumRepository; | ||
import com.lesso.neverland.comment.dto.CommentDto; | ||
import com.lesso.neverland.common.base.BaseException; | ||
import com.lesso.neverland.common.base.BaseResponse; | ||
import com.lesso.neverland.group.domain.Team; | ||
import com.lesso.neverland.group.repository.GroupRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import java.util.List; | ||
|
||
import static com.lesso.neverland.common.base.BaseResponseStatus.*; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class AlbumService { | ||
private final GroupRepository groupRepository; | ||
private final AlbumRepository albumRepository; | ||
|
||
// 추억 이미지 등록 | ||
public BaseResponse<String> uploadAlbumImage(Long groupIdx, Long albumIdx, AlbumImageRequest albumImageRequest) { | ||
Team group = groupRepository.findById(groupIdx).orElseThrow(() -> new BaseException(INVALID_GROUP_IDX)); | ||
Album album = albumRepository.findById(albumIdx).orElseThrow(() -> new BaseException(INVALID_ALBUM_IDX)); | ||
if (!album.getPuzzle().getTeam().equals(group)) throw new BaseException(NO_GROUP_ALBUM); | ||
|
||
album.saveAlbumImage(albumImageRequest.albumImage()); | ||
albumRepository.save(album); | ||
|
||
return new BaseResponse<>(SUCCESS); | ||
} | ||
|
||
// 앨범 상세 조회 | ||
public BaseResponse<AlbumDetailResponse> getAlbumDetail(Long groupIdx, Long albumIdx) { | ||
Team group = groupRepository.findById(groupIdx).orElseThrow(() -> new BaseException(INVALID_GROUP_IDX)); | ||
Album album = albumRepository.findById(albumIdx).orElseThrow(() -> new BaseException(INVALID_ALBUM_IDX)); | ||
if (!album.getPuzzle().getTeam().equals(group)) throw new BaseException(NO_GROUP_ALBUM); | ||
|
||
List<String> memberList = album.getPuzzle().getPuzzleMembers().stream() | ||
.map(puzzleMember -> puzzleMember.getUser().getProfile().getNickname()).toList(); | ||
|
||
List<CommentDto> commentList = album.getComments().stream() | ||
.map(comment -> new CommentDto( | ||
comment.getCommentIdx(), | ||
comment.getUser().getProfile().getNickname(), | ||
comment.getUser().getProfile().getProfileImage(), | ||
comment.getCreatedDate().toString(), | ||
comment.getContent())).toList(); | ||
|
||
AlbumDetailResponse albumDetailResponse = new AlbumDetailResponse(album.getPuzzle().getTitle(), album.getPuzzle().getPuzzleDate().toString(), | ||
album.getPuzzle().getLocation(), memberList, album.getAlbumImage(), album.getContent(), album.getPuzzle().getPuzzleIdx(), commentList); | ||
return new BaseResponse<>(albumDetailResponse); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/main/java/com/lesso/neverland/album/dto/AlbumDetailResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.lesso.neverland.album.dto; | ||
|
||
import com.lesso.neverland.comment.dto.CommentDto; | ||
|
||
import java.util.List; | ||
|
||
public record AlbumDetailResponse(String title, | ||
String puzzleDate, | ||
String location, | ||
List<String> memberList, | ||
String albumImage, | ||
String description, | ||
Long puzzleIdx, | ||
List<CommentDto> commentList) { | ||
} |
3 changes: 3 additions & 0 deletions
3
src/main/java/com/lesso/neverland/album/dto/AlbumImageRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package com.lesso.neverland.album.dto; | ||
|
||
public record AlbumImageRequest(String albumImage) {} |
30 changes: 30 additions & 0 deletions
30
src/main/java/com/lesso/neverland/album/presentation/AlbumController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.lesso.neverland.album.presentation; | ||
|
||
import com.lesso.neverland.album.application.AlbumService; | ||
import com.lesso.neverland.album.dto.AlbumDetailResponse; | ||
import com.lesso.neverland.album.dto.AlbumImageRequest; | ||
import com.lesso.neverland.common.base.BaseResponse; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import static com.lesso.neverland.common.constants.RequestURI.album; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping(album) | ||
public class AlbumController { | ||
|
||
private final AlbumService albumService; | ||
|
||
// 추억 이미지 등록 | ||
@PostMapping("/{albumIdx}/image") | ||
public BaseResponse<String> uploadAlbumImage(@PathVariable("groupIdx") Long groupIdx, @PathVariable("albumIdx") Long albumIdx, @RequestBody AlbumImageRequest albumImageRequest) { | ||
return albumService.uploadAlbumImage(groupIdx, albumIdx, albumImageRequest); | ||
} | ||
|
||
// 앨범 상세 조회 | ||
@GetMapping("/{albumIdx}") | ||
public BaseResponse<AlbumDetailResponse> getAlbumDetail(@PathVariable("groupIdx") Long groupIdx, @PathVariable("albumIdx") Long albumIdx) { | ||
return albumService.getAlbumDetail(groupIdx, albumIdx); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
package com.lesso.neverland.comment.dto; | ||
|
||
import java.time.LocalDate; | ||
|
||
public record CommentDto(Long commentIdx, | ||
String writer, | ||
String profileImage, | ||
LocalDate createdDate, | ||
String createdDate, | ||
String content) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 0 additions & 52 deletions
52
src/main/java/com/lesso/neverland/common/enums/Contents.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters