-
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.
* [fix #142] 앨범 내 사진 조회 최신순으로 정렬 (#143) * [fix #140] 앨범 공유 수락 API 로직 수정 (#144) * [feat #128] 포토부스 관련 API 구현 (#146) * [feat #128] 포토부스 관련 API 구현 * [fix #128] Photo 공유 수락 API 로직 수정 * [chore #128] swagger 업데이트 * [chore #128] 공백 제거 * [fix #147] 포포리즘 공유 API 수정 (#148) * [feat #128] 포토부스 관련 API 구현 * [fix #128] Photo 공유 수락 API 로직 수정 * [chore #128] swagger 업데이트 * [chore #128] 공백 제거 * [fix #147] 포포리즘 공유 API 수정 * [chore #147] swagger 수정 * [hotfix #149] 포포리즘 공유 API request body 수정 (#150) * [hotfix #149] 포포리즘 공유 request body 수정 * [chore #149] 사용하지 않는 import 제거 * [setting #149] banner 추가 * [chore #149] CI 스크립트 수정 * [chore #149] CI prod 스크립트 수정 * [chore #149] cd 스크립트 수정 * [fix #151] 배포 전 버그 수정 (access token 만료 시간 변경, 포포리즘 공유 API 수정) (#152) * [fix #151] Access Token 만료시간 변경 * [fix #151] 사진 upload url 변경 * [fix #151] 포포리즘 공유시에 이미지 저장 url 변경 (#153) * [fix #151] Access Token 만료시간 변경 * [fix #151] 사진 upload url 변경 * [hotfix #151] 포포리즘 저장 url 변경 --------- Co-authored-by: Yunseo Kang <[email protected]>
- Loading branch information
Showing
25 changed files
with
243 additions
and
33 deletions.
There are no files selected for viewing
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
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
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
2 changes: 1 addition & 1 deletion
2
src/main/java/com/pophory/pophoryserver/domain/auth/SocialType.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,5 +1,5 @@ | ||
package com.pophory.pophoryserver.domain.auth; | ||
|
||
public enum SocialType { | ||
KAKAO, APPLE; | ||
KAKAO, APPLE, DEFAULT; | ||
} |
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
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
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
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
55 changes: 55 additions & 0 deletions
55
src/main/java/com/pophory/pophoryserver/domain/pophorysm/PophorysmController.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,55 @@ | ||
package com.pophory.pophoryserver.domain.pophorysm; | ||
|
||
import com.pophory.pophoryserver.domain.pophorysm.dto.request.PophorysmShareRequestDto; | ||
import com.pophory.pophoryserver.domain.s3.UploadType; | ||
import com.pophory.pophoryserver.domain.version.dto.response.PophorysmGetPresignedUrlResponseDto; | ||
import com.pophory.pophoryserver.global.util.MemberUtil; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.Parameter; | ||
import io.swagger.v3.oas.annotations.enums.ParameterIn; | ||
import io.swagger.v3.oas.annotations.media.Content; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponses; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.security.Principal; | ||
|
||
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/v2/pophorysm") | ||
@Tag(name = "[Pophorysm] 포포리즘 관련 API") | ||
public class PophorysmController { | ||
|
||
private final PophorysmService pophorysmService; | ||
|
||
@GetMapping(produces = APPLICATION_JSON_VALUE) | ||
@Operation(summary = "포포리즘 공유를 위한 presigned url 조회") | ||
@Parameter(name = "Authorization", description = "Bearer {access_token}", in = ParameterIn.HEADER, required = true, schema = @Schema(type = "string")) | ||
@ApiResponses(value = { | ||
@ApiResponse(responseCode = "200", description = "포포리즘 공유를 위한 presigned url 조회 성공"), | ||
@ApiResponse(responseCode = "400", description = "presigned url 조회 실패", content = @Content), | ||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) | ||
}) | ||
public ResponseEntity<PophorysmGetPresignedUrlResponseDto> getPophorysmPresignedUrl(@RequestParam("u") String nickname, Principal principal) { | ||
return ResponseEntity.ok(pophorysmService.getSharePresignedUrl(UploadType.PHOTO, nickname, MemberUtil.getMemberId(principal))); | ||
} | ||
|
||
@PostMapping(consumes = APPLICATION_JSON_VALUE) | ||
@Operation(summary = "포포리즘 공유 API") | ||
@Parameter(name = "Authorization", description = "Bearer {access_token}", in = ParameterIn.HEADER, required = true, schema = @Schema(type = "string")) | ||
@ApiResponses(value = { | ||
@ApiResponse(responseCode = "200", description = "포포리즘 공유 성공"), | ||
@ApiResponse(responseCode = "400", description = "포포리즘 공유 실패", content = @Content), | ||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) | ||
}) | ||
public ResponseEntity<Void> sharePhotoByPophorysm(@RequestBody PophorysmShareRequestDto request, Principal principal) { | ||
pophorysmService.sharePhoto(request, MemberUtil.getMemberId(principal)); | ||
return ResponseEntity.ok().build(); | ||
} | ||
} |
97 changes: 97 additions & 0 deletions
97
src/main/java/com/pophory/pophoryserver/domain/pophorysm/PophorysmService.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,97 @@ | ||
package com.pophory.pophoryserver.domain.pophorysm; | ||
|
||
import com.pophory.pophoryserver.domain.album.Album; | ||
import com.pophory.pophoryserver.domain.member.Member; | ||
import com.pophory.pophoryserver.domain.member.MemberJpaRepository; | ||
import com.pophory.pophoryserver.domain.photo.Photo; | ||
import com.pophory.pophoryserver.domain.photo.PhotoJpaRepository; | ||
import com.pophory.pophoryserver.domain.photo.vo.PhotoSizeVO; | ||
import com.pophory.pophoryserver.domain.pophorysm.dto.request.PophorysmShareRequestDto; | ||
import com.pophory.pophoryserver.domain.s3.S3Service; | ||
import com.pophory.pophoryserver.domain.s3.UploadType; | ||
import com.pophory.pophoryserver.domain.studio.Studio; | ||
import com.pophory.pophoryserver.domain.studio.StudioJpaRepository; | ||
import com.pophory.pophoryserver.domain.version.dto.response.PophorysmGetPresignedUrlResponseDto; | ||
import com.pophory.pophoryserver.global.util.PhotoUtil; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.util.UUID; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class PophorysmService { | ||
|
||
private final MemberJpaRepository memberJpaRepository; | ||
private final PhotoJpaRepository photoJpaRepository; | ||
private final StudioJpaRepository studioJpaRepository; | ||
private final S3Service s3Service; | ||
|
||
@Value("${pophorysm.id}") | ||
private Long POPHORYSM_ID; | ||
|
||
@Value("${cloud.aws.CLOUDFRONT}") | ||
private String CLOUD_FRONT_DOMAIN; | ||
|
||
@Transactional(readOnly = true) | ||
public PophorysmGetPresignedUrlResponseDto getSharePresignedUrl(UploadType type, String nickname, Long memberId) { | ||
validatePophoryId(memberId); | ||
String pophoryId = getPophoryIdByMemberNickname(nickname); | ||
String filename = UUID.randomUUID() + ".jpg"; | ||
String key = type.getName() + pophoryId + "member" + "/" + filename; | ||
return PophorysmGetPresignedUrlResponseDto.of(s3Service.getPresignedUrl(key),filename, pophoryId); | ||
} | ||
|
||
@Transactional | ||
public void sharePhoto(PophorysmShareRequestDto request, Long memberId) { | ||
|
||
validatePophoryId(memberId); | ||
Member member = getMemberByNickname(request.getNickname()); | ||
Album album = member.getAlbumList().stream().findFirst().orElseThrow( | ||
() -> new IllegalArgumentException("앨범이 존재하지 않습니다.") | ||
); | ||
if (!album.checkPhotoLimit()) { | ||
throw new IllegalArgumentException("앨범의 사진 개수가 초과되었습니다."); | ||
} | ||
photoJpaRepository.save( | ||
Photo.builder() | ||
.album(member.getAlbumList().get(0)) | ||
.studio(findPophorysmStudio(request.getStudioName())) | ||
.takenAt(PhotoUtil.changeRequestToTakenAt(request.getTakenAt())) | ||
.imageUrl(CLOUD_FRONT_DOMAIN + "/" + UploadType.PHOTO.getName() + member.getPophoryId() + "member" + "/" + request.getFileName()) | ||
.photoSizeVO(PhotoSizeVO.of(request.getWidth(), request.getHeight())) | ||
.build() | ||
); | ||
} | ||
|
||
private Studio findPophorysmStudio(String pophorysmStudio) { | ||
return studioJpaRepository.findByName(pophorysmStudio).orElseThrow( | ||
() -> new IllegalArgumentException("포포리즘 스튜디오가 존재하지 않습니다.")); | ||
|
||
} | ||
|
||
private Member getMemberByNickname(String nickname) { | ||
return memberJpaRepository.findByNickname(nickname).orElseThrow( | ||
() -> new IllegalArgumentException("존재하지 않는 닉네임입니다.")); | ||
} | ||
|
||
private Photo getPhotoById(Long id) { | ||
return photoJpaRepository.findById(id).orElseThrow( | ||
() -> new IllegalArgumentException("존재하지 않는 사진입니다.")); | ||
} | ||
|
||
private String getPophoryIdByMemberNickname(String nickname) { | ||
return memberJpaRepository.findByNickname(nickname).orElseThrow( | ||
() -> new IllegalArgumentException("존재하지 않는 닉네임입니다.") | ||
).getPophoryId(); | ||
} | ||
|
||
|
||
private void validatePophoryId(Long memberId) { | ||
if (!POPHORYSM_ID.equals(memberId)) { | ||
throw new IllegalArgumentException("포포리즘의 사진을 공유할 수 없습니다."); | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...java/com/pophory/pophoryserver/domain/pophorysm/dto/request/PophorysmShareRequestDto.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,31 @@ | ||
package com.pophory.pophoryserver.domain.pophorysm.dto.request; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
|
||
@AllArgsConstructor | ||
@Data | ||
public class PophorysmShareRequestDto { | ||
|
||
@Schema(description = "유저 닉네임", example = "kraken") | ||
private String nickname; | ||
|
||
@Schema(description = "파일 이름", example = "ca4f3c69-a7ac-45ee-a594-d0567a4b66b2.jpg") | ||
private String fileName; | ||
|
||
@Schema(description = "포포리 id", example = "2d3dfa") | ||
private String pophoryId; | ||
|
||
@Schema(description = "사진 가로 길이", example = "600") | ||
private Integer width; | ||
|
||
@Schema(description = "사진 세로 길이", example = "800") | ||
private Integer height; | ||
|
||
@Schema(description = "스튜디오 이름", example = "포포리즘") | ||
private String studioName; | ||
|
||
@Schema(description = "찍은 날짜", example = "2021.06.30") | ||
private String takenAt; | ||
} |
3 changes: 2 additions & 1 deletion
3
src/main/java/com/pophory/pophoryserver/domain/studio/StudioJpaRepository.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,9 +1,10 @@ | ||
package com.pophory.pophoryserver.domain.studio; | ||
|
||
import com.pophory.pophoryserver.domain.member.Member; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.Optional; | ||
|
||
public interface StudioJpaRepository extends JpaRepository<Studio, Long> { | ||
|
||
Optional<Studio> findByName(String name); | ||
} |
Oops, something went wrong.