-
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.
Browse files
Browse the repository at this point in the history
Feat/#58 Album API
- Loading branch information
Showing
41 changed files
with
804 additions
and
36 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
core/src/main/java/com/pocket/core/exception/album/AlbumCustomException.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,18 @@ | ||
package com.pocket.core.exception.album; | ||
|
||
import com.pocket.core.exception.common.BaseErrorCode; | ||
import lombok.Getter; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
|
||
@Getter | ||
@ResponseStatus(HttpStatus.BAD_REQUEST) | ||
public class AlbumCustomException extends RuntimeException { | ||
|
||
private final BaseErrorCode errorCode; | ||
|
||
public AlbumCustomException(BaseErrorCode errorCode) { | ||
this.errorCode = errorCode; | ||
} | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
core/src/main/java/com/pocket/core/exception/album/AlbumErrorCode.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,24 @@ | ||
package com.pocket.core.exception.album; | ||
|
||
import com.pocket.core.exception.common.ApiResponse; | ||
import com.pocket.core.exception.common.BaseErrorCode; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import org.springframework.http.HttpStatus; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum AlbumErrorCode implements BaseErrorCode { | ||
ALBUM_NOT_FOUND(HttpStatus.BAD_REQUEST, "400", "해당 앨범이 존재하지 않습니다."); | ||
|
||
private final HttpStatus httpStatus; | ||
private final String code; | ||
private final String message; | ||
|
||
@Override | ||
public ApiResponse<Void> getErrorResponse() { | ||
return ApiResponse.onFailure(code, message); | ||
} | ||
|
||
|
||
} |
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
14 changes: 14 additions & 0 deletions
14
domain/src/main/java/com/pocket/domain/dto/album/AlbumHashtagResponseDto.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,14 @@ | ||
package com.pocket.domain.dto.album; | ||
|
||
import java.util.List; | ||
|
||
public record AlbumHashtagResponseDto( | ||
String photoUrl, | ||
List<String> hashtags, | ||
Integer year, | ||
Integer month, | ||
Integer date, | ||
String memo, | ||
boolean isLiked | ||
) { | ||
} |
9 changes: 9 additions & 0 deletions
9
domain/src/main/java/com/pocket/domain/dto/album/AlbumResponseDto.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,9 @@ | ||
package com.pocket.domain.dto.album; | ||
|
||
public record AlbumResponseDto( | ||
Long albumId, | ||
String photoUrl, | ||
boolean like | ||
) { | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
domain/src/main/java/com/pocket/domain/dto/album/NearAlbumInfo.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,10 @@ | ||
package com.pocket.domain.dto.album; | ||
|
||
import com.pocket.domain.entity.photobooth.PhotoBoothBrand; | ||
|
||
public record NearAlbumInfo( | ||
String photoUrl, | ||
double x, | ||
double y | ||
) { | ||
} |
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
7 changes: 7 additions & 0 deletions
7
domain/src/main/java/com/pocket/domain/port/album/AlbumDeletePort.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,7 @@ | ||
package com.pocket.domain.port.album; | ||
|
||
public interface AlbumDeletePort { | ||
|
||
void deleteAlbum(Long albumId); | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
domain/src/main/java/com/pocket/domain/port/album/AlbumFavoritePort.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,11 @@ | ||
package com.pocket.domain.port.album; | ||
|
||
import com.pocket.domain.dto.album.AlbumResponseDto; | ||
|
||
import java.util.List; | ||
|
||
public interface AlbumFavoritePort { | ||
|
||
List<AlbumResponseDto> getFavoriteAlbums(String userEmail); | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
domain/src/main/java/com/pocket/domain/port/album/AlbumGetByBrandPort.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,11 @@ | ||
package com.pocket.domain.port.album; | ||
|
||
import com.pocket.domain.dto.album.AlbumResponseDto; | ||
|
||
import java.util.List; | ||
|
||
public interface AlbumGetByBrandPort { | ||
|
||
List<AlbumResponseDto> getAlbumByBrand(String brandName, String userEmail); | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
domain/src/main/java/com/pocket/domain/port/album/AlbumGetByDatePort.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,11 @@ | ||
package com.pocket.domain.port.album; | ||
|
||
import com.pocket.domain.dto.album.AlbumResponseDto; | ||
|
||
import java.util.List; | ||
|
||
public interface AlbumGetByDatePort { | ||
|
||
List<AlbumResponseDto> getAlbumByDate(Integer year, Integer month, String userEmail); | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
domain/src/main/java/com/pocket/domain/port/album/AlbumGetByLocationPort.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,11 @@ | ||
package com.pocket.domain.port.album; | ||
|
||
import com.pocket.domain.dto.album.NearAlbumInfo; | ||
|
||
import java.util.List; | ||
|
||
public interface AlbumGetByLocationPort { | ||
|
||
List<NearAlbumInfo> getAlbumByLocation(double currentLat, double currentLon, String userEmail); | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
domain/src/main/java/com/pocket/domain/port/album/AlbumHashtagPort.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,11 @@ | ||
package com.pocket.domain.port.album; | ||
|
||
import com.pocket.domain.dto.album.AlbumHashtagResponseDto; | ||
|
||
import java.util.List; | ||
|
||
public interface AlbumHashtagPort { | ||
|
||
List<AlbumHashtagResponseDto> getAlbumByHashtag(String hashtag, String userEmail); | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
domain/src/main/java/com/pocket/domain/port/album/AlbumLikePort.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,7 @@ | ||
package com.pocket.domain.port.album; | ||
|
||
public interface AlbumLikePort { | ||
|
||
void likeAlbum(Long albumId); | ||
|
||
} |
91 changes: 86 additions & 5 deletions
91
domain/src/main/java/com/pocket/domain/service/album/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 |
---|---|---|
@@ -1,20 +1,101 @@ | ||
package com.pocket.domain.service.album; | ||
|
||
import com.pocket.core.aop.annotation.DomainService; | ||
import com.pocket.domain.dto.album.AlbumRegisterRequestDto; | ||
import com.pocket.domain.dto.album.AlbumRegisterResponseDto; | ||
import com.pocket.domain.port.album.AlbumRegisterPort; | ||
import com.pocket.domain.usecase.album.AlbumRegisterUseCase; | ||
import com.pocket.domain.dto.album.*; | ||
import com.pocket.domain.port.album.*; | ||
import com.pocket.domain.port.file.FileDownloadPort; | ||
import com.pocket.domain.usecase.album.*; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
@DomainService | ||
@RequiredArgsConstructor | ||
public class AlbumService implements AlbumRegisterUseCase { | ||
public class AlbumService implements AlbumRegisterUseCase, AlbumLikeUseCase, AlbumGetByDateUseCase, AlbumGetByBrandUseCase, AlbumGetByLocationUseCase, AlbumDeleteUseCase, AlbumHashtagUseCase, AlbumFavoriteUseCase | ||
{ | ||
|
||
private final FileDownloadPort fileDownloadPort; | ||
private final AlbumRegisterPort albumRegisterPort; | ||
private final AlbumLikePort albumLikePort; | ||
private final AlbumGetByDatePort albumGetByDatePort; | ||
private final AlbumGetByBrandPort albumGetByBrandPort; | ||
private final AlbumGetByLocationPort albumGetByLocationPort; | ||
private final AlbumDeletePort albumDeletePort; | ||
private final AlbumHashtagPort albumHashtagPort; | ||
private final AlbumFavoritePort albumFavoritePort; | ||
|
||
public AlbumRegisterResponseDto registerPhotoResponse(AlbumRegisterRequestDto albumRegisterRequestDto, String name) { | ||
return albumRegisterPort.registerPhoto(albumRegisterRequestDto, name); | ||
} | ||
|
||
@Override | ||
public void likeAlbum(Long albumId) { | ||
albumLikePort.likeAlbum(albumId); | ||
} | ||
|
||
@Override | ||
public List<AlbumResponseDto> getAlbumByDate(Integer year, Integer month, String userEmail) { | ||
List<AlbumResponseDto> albumResponseDtos = albumGetByDatePort.getAlbumByDate(year, month, userEmail); | ||
|
||
return albumResponseDtos.stream() | ||
.map(dto -> { | ||
String presignedUrl = dto.photoUrl().isEmpty() ? "" : fileDownloadPort.getDownloadPresignedUrl(dto.photoUrl()); | ||
return new AlbumResponseDto(dto.albumId(), presignedUrl, dto.like()); | ||
}) | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
|
||
@Override | ||
public List<AlbumResponseDto> getAlbumByBrand(String brandName, String userEmail) { | ||
List<AlbumResponseDto> albumResponseDtos = albumGetByBrandPort.getAlbumByBrand(brandName, userEmail); | ||
|
||
return albumResponseDtos.stream() | ||
.map(dto -> { | ||
String presignedUrl = dto.photoUrl().isEmpty() ? "" : fileDownloadPort.getDownloadPresignedUrl(dto.photoUrl()); | ||
return new AlbumResponseDto(dto.albumId(), presignedUrl, dto.like()); | ||
}) | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
public List<NearAlbumInfo> getAlbumByLocation(double currentLat, double currentLon, String userEmail) { | ||
List<NearAlbumInfo> nearAlbumInfos = albumGetByLocationPort.getAlbumByLocation(currentLat, currentLon, userEmail); | ||
|
||
return nearAlbumInfos.stream() | ||
.map(dto -> { | ||
String presignedUrl = dto.photoUrl().isEmpty() ? "" : fileDownloadPort.getDownloadPresignedUrl(dto.photoUrl()); | ||
return new NearAlbumInfo(presignedUrl, dto.x(), dto.y()); | ||
}) | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
public void deleteAlbum(Long albumId) { | ||
albumDeletePort.deleteAlbum(albumId); | ||
} | ||
|
||
@Override | ||
public List<AlbumHashtagResponseDto> getAlbumByHashtag(String hashtag, String userEmail) { | ||
List<AlbumHashtagResponseDto> albumHashtagResponseDtos = albumHashtagPort.getAlbumByHashtag(hashtag, userEmail); | ||
|
||
return albumHashtagResponseDtos.stream() | ||
.map(dto -> { | ||
String presignedUrl = dto.photoUrl().isEmpty() ? "" : fileDownloadPort.getDownloadPresignedUrl(dto.photoUrl()); | ||
return new AlbumHashtagResponseDto(presignedUrl, dto.hashtags(), dto.year(), dto.month(), dto.date(), dto.memo(), dto.isLiked()); | ||
}) | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
|
||
@Override | ||
public List<AlbumResponseDto> getFavoriteAlbums(String userEmail) { | ||
List<AlbumResponseDto> albumResponseDtos = albumFavoritePort.getFavoriteAlbums(userEmail); | ||
|
||
return albumResponseDtos.stream() | ||
.map(dto -> { | ||
String presignedUrl = dto.photoUrl().isEmpty() ? "" : fileDownloadPort.getDownloadPresignedUrl(dto.photoUrl()); | ||
return new AlbumResponseDto(dto.albumId(), presignedUrl, dto.like()); | ||
}) | ||
.collect(Collectors.toList()); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
domain/src/main/java/com/pocket/domain/usecase/album/AlbumDeleteUseCase.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,7 @@ | ||
package com.pocket.domain.usecase.album; | ||
|
||
public interface AlbumDeleteUseCase { | ||
|
||
void deleteAlbum(Long albumId); | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
domain/src/main/java/com/pocket/domain/usecase/album/AlbumFavoriteUseCase.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,11 @@ | ||
package com.pocket.domain.usecase.album; | ||
|
||
import com.pocket.domain.dto.album.AlbumResponseDto; | ||
|
||
import java.util.List; | ||
|
||
public interface AlbumFavoriteUseCase { | ||
|
||
List<AlbumResponseDto> getFavoriteAlbums(String userEmail); | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
domain/src/main/java/com/pocket/domain/usecase/album/AlbumGetByBrandUseCase.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,11 @@ | ||
package com.pocket.domain.usecase.album; | ||
|
||
import com.pocket.domain.dto.album.AlbumResponseDto; | ||
|
||
import java.util.List; | ||
|
||
public interface AlbumGetByBrandUseCase { | ||
|
||
List<AlbumResponseDto> getAlbumByBrand(String brandName, String userEmail); | ||
|
||
} |
Oops, something went wrong.