Skip to content

Commit

Permalink
Merge pull request #64 from YAPP-Github/feature/MAFOO-111
Browse files Browse the repository at this point in the history
[MAFOO-111] feat: 앨범 공유 관련 API(CUD)를 만들었어요
  • Loading branch information
gmkim20713 authored Nov 21, 2024
2 parents 2bba7a5 + 316c8cf commit 7ea131f
Show file tree
Hide file tree
Showing 69 changed files with 1,276 additions and 280 deletions.
39 changes: 28 additions & 11 deletions photo-service/src/main/java/kr/mafoo/photo/api/AlbumApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@
import kr.mafoo.photo.annotation.ULID;
import kr.mafoo.photo.controller.dto.request.AlbumCreateRequest;
import kr.mafoo.photo.controller.dto.request.AlbumUpdateDisplayIndexRequest;
import kr.mafoo.photo.controller.dto.request.AlbumUpdateRequest;
import kr.mafoo.photo.controller.dto.request.AlbumUpdateNameAndTypeRequest;
import kr.mafoo.photo.controller.dto.request.AlbumUpdateOwnershipRequest;
import kr.mafoo.photo.controller.dto.response.AlbumResponse;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

@Validated
@Tag(name = "앨범 관련 API", description = "앨범 조회, 생성, 수정, 삭제 등 API")
@Tag(name = "앨범 관련 API", description = "앨범 조회, 생성, 변경, 삭제 등 API")
@RequestMapping("/v1/albums")
public interface AlbumApi {
@Operation(summary = "앨범 n건 조회", description = "앨범 목록을 조회합니다.")
@Operation(summary = "사용자 별 앨범 목록 조회", description = "사용자 별 앨범 목록을 조회합니다.")
@GetMapping
Flux<AlbumResponse> getAlbums(
Flux<AlbumResponse> getAlbumListByMember(
@RequestMemberId
String memberId
);
Expand Down Expand Up @@ -49,9 +50,9 @@ Mono<AlbumResponse> createAlbum(
AlbumCreateRequest request
);

@Operation(summary = "앨범 변경", description = "앨범의 속성을 변경합니다.")
@Operation(summary = "앨범 속성(이름, 종류) 변경", description = "앨범의 속성(이름, 종류)을 변경합니다.")
@PutMapping("/{albumId}")
Mono<AlbumResponse> updateAlbum(
Mono<AlbumResponse> updateAlbumNameAndType(
@RequestMemberId
String memberId,

Expand All @@ -62,12 +63,28 @@ Mono<AlbumResponse> updateAlbum(

@Valid
@RequestBody
AlbumUpdateRequest request
AlbumUpdateNameAndTypeRequest request
);

@Operation(summary = "앨범 표기 순서 변경", description = "앨범의 표기 순서를 변경합니다.")
@PatchMapping("/{albumId}/display-index")
Mono<AlbumResponse> updateAlbumDisplayIndex(
// @Operation(summary = "[DEPRECATED] 앨범 표시 순서 변경", description = "앨범의 표시 순서를 변경합니다.")
// @PatchMapping("/{albumId}/display-index")
// Mono<AlbumResponse> updateAlbumDisplayIndex(
// @RequestMemberId
// String memberId,
//
// @ULID
// @Parameter(description = "앨범 ID", example = "test_album_id")
// @PathVariable
// String albumId,
//
// @Valid
// @RequestBody
// AlbumUpdateDisplayIndexRequest request
// );

@Operation(summary = "앨범 소유자 변경", description = "앨범의 소유자를 변경합니다.")
@PatchMapping("/{albumId}/ownership")
Mono<AlbumResponse> updateAlbumOwnerShip(
@RequestMemberId
String memberId,

Expand All @@ -78,7 +95,7 @@ Mono<AlbumResponse> updateAlbumDisplayIndex(

@Valid
@RequestBody
AlbumUpdateDisplayIndexRequest request
AlbumUpdateOwnershipRequest request
);

@Operation(summary = "앨범 삭제", description = "앨범을 삭제합니다.")
Expand Down
22 changes: 11 additions & 11 deletions photo-service/src/main/java/kr/mafoo/photo/api/PhotoApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
public interface PhotoApi {
@Operation(summary = "사진 조회", description = "사진 목록을 조회합니다.")
@GetMapping
Flux<PhotoResponse> getPhotos(
Flux<PhotoResponse> getPhotoListByAlbum(
@RequestMemberId
String memberId,

Expand All @@ -37,35 +37,35 @@ Flux<PhotoResponse> getPhotos(

@Operation(summary = "(수정 이전) QR 사진 업로드", description = "QR을 사용해 사진을 업로드합니다.")
@PostMapping(value = "")
Mono<PhotoResponse> uploadQrPhotoOriginal(
Mono<PhotoResponse> createPhotoWithQrUrlOriginal(
@RequestMemberId
String memberId,

@Valid
@RequestBody
PhotoQrUploadRequest request
PhotoCreateWithQrUrlRequest request
);

@Operation(summary = "QR 사진 업로드", description = "QR을 사용해 사진을 업로드합니다.")
@PostMapping(value = "/qr")
Mono<PhotoResponse> uploadQrPhoto(
Mono<PhotoResponse> createPhotoWithQrUrl(
@RequestMemberId
String memberId,

@Valid
@RequestBody
PhotoQrUploadRequest request
PhotoCreateWithQrUrlRequest request
);

@Operation(summary = "파일(url) 사진 n건 업로드", description = "파일(url)을 사용해 사진을 업로드합니다.")
@PostMapping(value = "/file-urls")
Flux<PhotoResponse> uploadFileUrlPhoto(
Flux<PhotoResponse> createPhotoBulkWithFileUrls(
@RequestMemberId
String memberId,

@Valid
@RequestBody
PhotoFileUrlUploadRequest request
PhotoCreateBulkWithFileUrlsRequest request
);

@Operation(summary = "사진 파일로 업로드", description = "사진을 직접 업로드합니다.")
Expand All @@ -78,9 +78,9 @@ Flux<PhotoResponse> uploadPhoto(
Flux<FilePart> request
);

@Operation(summary = "사진 앨범 단건 수정", description = "사진 한 개를 다른 앨범으로 이동시킵니다.")
@Operation(summary = "사진 앨범 설정", description = "사진의 초기 앨범 정보를 설정합니다.")
@PatchMapping(value = "/{photoId}/album")
Mono<PhotoResponse> updatePhotoAlbum(
Mono<PhotoResponse> setPhotoAlbum(
@RequestMemberId
String memberId,

Expand All @@ -91,7 +91,7 @@ Mono<PhotoResponse> updatePhotoAlbum(

@Valid
@RequestBody
PhotoUpdateAlbumIdRequest request
PhotoSetAlbumRequest request
);

@Operation(summary = "사진 앨범 n건 수정", description = "사진 여러 개를 다른 앨범으로 이동시킵니다.")
Expand All @@ -102,7 +102,7 @@ Flux<PhotoResponse> updatePhotoBulkAlbum(

@Valid
@RequestBody
PhotoBulkUpdateAlbumIdRequest request
PhotoUpdateBulkAlbumRequest request
);

@Operation(summary = "사진 표시 순서 변경", description = "사진의 표시 순서를 변경합니다.")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package kr.mafoo.photo.api;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import kr.mafoo.photo.annotation.RequestMemberId;
import kr.mafoo.photo.annotation.ULID;
import kr.mafoo.photo.controller.dto.request.SharedMemberCreateRequest;
import kr.mafoo.photo.controller.dto.request.SharedMemberUpdatePermissionRequest;
import kr.mafoo.photo.controller.dto.request.SharedMemberUpdateStatusRequest;
import kr.mafoo.photo.controller.dto.response.SharedMemberResponse;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Mono;

@Validated
@Tag(name = "공유 사용자 관련 API", description = "공유 사용자 조회, 생성, 변경, 삭제 등 API")
@RequestMapping("/v1/shared-members")
public interface SharedMemberApi {

@Operation(summary = "공유 사용자 생성", description = "공유 사용자를 생성합니다.")
@PostMapping
Mono<SharedMemberResponse> createSharedMember(
@RequestMemberId
String memberId,

@Valid
@RequestBody
SharedMemberCreateRequest request
);

@Operation(summary = "공유 사용자 상태 변경", description = "공유 사용자의 상태를 변경합니다.")
@PatchMapping("/{sharedMemberId}/status")
Mono<SharedMemberResponse> updateSharedMemberStatus(
@RequestMemberId
String memberId,

@ULID
@Parameter(description = "공유 사용자 ID", example = "test_shared_member_id")
@PathVariable
String sharedMemberId,

@Valid
@RequestBody
SharedMemberUpdateStatusRequest request
);

@Operation(summary = "공유 사용자 권한 변경", description = "공유 사용자의 권한을 변경합니다.")
@PatchMapping("/{sharedMemberId}/permission")
Mono<SharedMemberResponse> updateSharedMemberPermission(
@RequestMemberId
String memberId,

@ULID
@Parameter(description = "공유 사용자 ID", example = "test_shared_member_id")
@PathVariable
String sharedMemberId,

@Valid
@RequestBody
SharedMemberUpdatePermissionRequest request
);

@Operation(summary = "공유 사용자 삭제", description = "공유 사용자를 삭제합니다.")
@DeleteMapping("{sharedMemberId}")
Mono<Void> deleteSharedMember(
@RequestMemberId
String memberId,

@ULID
@Parameter(description = "공유 사용자 ID", example = "test_shared_member_id")
@PathVariable
String sharedMemberId
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import kr.mafoo.photo.api.AlbumApi;
import kr.mafoo.photo.controller.dto.request.AlbumCreateRequest;
import kr.mafoo.photo.controller.dto.request.AlbumUpdateDisplayIndexRequest;
import kr.mafoo.photo.controller.dto.request.AlbumUpdateRequest;
import kr.mafoo.photo.controller.dto.request.AlbumUpdateNameAndTypeRequest;
import kr.mafoo.photo.controller.dto.request.AlbumUpdateOwnershipRequest;
import kr.mafoo.photo.controller.dto.response.AlbumResponse;
import kr.mafoo.photo.domain.AlbumType;
import kr.mafoo.photo.service.AlbumService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RestController;
Expand All @@ -15,14 +15,15 @@
@RequiredArgsConstructor
@RestController
public class AlbumController implements AlbumApi {

private final AlbumService albumService;

@Override
public Flux<AlbumResponse> getAlbums(
public Flux<AlbumResponse> getAlbumListByMember(
String memberId
) {
return albumService
.findAllByOwnerMemberId(memberId)
.findAlbumListByMemberId(memberId)
.map(AlbumResponse::fromEntity);
}

Expand All @@ -32,7 +33,7 @@ public Mono<AlbumResponse> getAlbum(
String albumId
) {
return albumService
.findByAlbumId(albumId, memberId)
.findAlbumById(albumId, memberId)
.map(AlbumResponse::fromEntity);
}

Expand All @@ -41,36 +42,50 @@ public Mono<AlbumResponse> createAlbum(
String memberId,
AlbumCreateRequest request
){
AlbumType type = AlbumType.valueOf(request.type());
return albumService
.createNewAlbum(memberId, request.name(), type)
.addAlbum(memberId, request.name(), request.type())
.map(AlbumResponse::fromEntity);
}

// tmp. deprecated
// @Override
// public Mono<AlbumResponse> updateAlbumDisplayIndex(
// String memberId,
// String albumId,
// AlbumUpdateDisplayIndexRequest request
// ) {
// return Mono.empty();
// }

@Override
public Mono<AlbumResponse> updateAlbum(String memberId, String albumId, AlbumUpdateRequest request) {
AlbumType albumType = AlbumType.valueOf(request.type());
public Mono<AlbumResponse> updateAlbumNameAndType(
String memberId,
String albumId,
AlbumUpdateNameAndTypeRequest request
) {
return albumService
.updateAlbumName(albumId, request.name(), memberId)
.then(albumService.updateAlbumType(albumId, albumType, memberId))
.modifyAlbumNameAndType(albumId, request.name(), request.type(), memberId)
.map(AlbumResponse::fromEntity);
}

@Override
public Mono<AlbumResponse> updateAlbumDisplayIndex(String memberId, String albumId, AlbumUpdateDisplayIndexRequest request) {
public Mono<AlbumResponse> updateAlbumOwnerShip(
String memberId,
String albumId,
AlbumUpdateOwnershipRequest request
) {
return albumService
.moveAlbumDisplayIndex(albumId, memberId, request.newDisplayIndex())
.map(AlbumResponse::fromEntity);
.modifyAlbumOwnership(albumId, request.newOwnerMemberId(), memberId)
.map(AlbumResponse::fromEntity);
}


@Override
public Mono<Void> deleteAlbum(
String memberId,
String albumId
){
return albumService
.deleteAlbumById(albumId, memberId);
.removeAlbum(albumId, memberId);
}

}
Loading

0 comments on commit 7ea131f

Please sign in to comment.