Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DEPLOY] 운영서버 v1.1.0 수정사항 배포 #153

Merged
merged 2 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public class AlbumController {
private final AlbumService albumService;
private final S3Service s3Service;

private static final String DEFAULT_ALBUM_IMG = "default_img.png";

@PostMapping
@ResponseStatus(HttpStatus.CREATED)
public ApiResponse createAlbum(@Valid @RequestBody final CreateAlbumRequestDto request, final Principal principal, HttpServletResponse response) {
Expand Down Expand Up @@ -70,6 +72,7 @@ public ApiResponse deleteAlbum(@PathVariable final Long albumId, final Principal
@GetMapping
@ResponseStatus(HttpStatus.OK)
public ApiResponse<List<AlbumResponseDto>> getAlbumList(final Principal principal) {
return ApiResponse.success(GET_ALBUM_LIST_SUCCESS, albumService.getAlbumList(getUserFromPrincial(principal)));
String defaultImgUrl = s3Service.getS3ImgUrl(ALBUM_PREFIX.getValue(), DEFAULT_ALBUM_IMG);
return ApiResponse.success(GET_ALBUM_LIST_SUCCESS, albumService.getAlbumList(defaultImgUrl, getUserFromPrincial(principal)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,25 +77,24 @@ public String deleteAlbum(final Long albumId, final Long userId) {
return album.getImgUrl();
}

public List<AlbumResponseDto> getAlbumList(final Long userId) {
public List<AlbumResponseDto> getAlbumList(final String defaultImgUrl, final Long userId) {
User user = getUserById(userId);
Parentchild parentchild = getParentchildByUser(user);
List<Album> albumList = albumRepository.findAllByParentchildOrderByCreatedAtDesc(
parentchild);

// Album을 아직 한번도 등록하지 않은 경우
if (albumList.isEmpty() && !parentchild.isFirstAlbumUpload() && !parentchild.isDeleteSampleAlbum()) {
return List.of(AlbumResponseDto.of(createAlbumExample()));
return List.of(AlbumResponseDto.of(createAlbumExample(defaultImgUrl)));
}

return albumList.stream()
.map(AlbumResponseDto::of)
.collect(Collectors.toList());
}

private Album createAlbumExample() {
return new Album(0L, "사진의 제목을 입력할 수 있어요", "사진에 대해 소개해요",
"https://i1.sndcdn.com/artworks-l2lCmUXC61XR2HM5-gwB8Vg-t500x500.jpg", "직성자"); // TODO 기획 측에서 전달받은 이미지 url로 변경
private Album createAlbumExample(final String defaultImgUrl) {
return new Album(0L, "사진의 제목을 입력할 수 있어요", "사진에 대해 소개해요", defaultImgUrl, "직성자");
}

private User getUserById(Long userId) { // TODO userId -> Parentchild 한번에 가져오기
Expand Down
Loading