diff --git a/src/main/java/ddingdong/ddingdongBE/domain/fixzone/controller/dto/request/CreateFixZoneRequest.java b/src/main/java/ddingdong/ddingdongBE/domain/fixzone/controller/dto/request/CreateFixZoneRequest.java index 6dcae821..9bfe62b5 100644 --- a/src/main/java/ddingdong/ddingdongBE/domain/fixzone/controller/dto/request/CreateFixZoneRequest.java +++ b/src/main/java/ddingdong/ddingdongBE/domain/fixzone/controller/dto/request/CreateFixZoneRequest.java @@ -1,6 +1,7 @@ package ddingdong.ddingdongBE.domain.fixzone.controller.dto.request; import ddingdong.ddingdongBE.domain.fixzone.service.dto.command.CreateFixZoneCommand; +import ddingdong.ddingdongBE.domain.fixzone.service.dto.command.CreateFixZoneCommand.ImageInfo; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotNull; import java.util.List; @@ -12,8 +13,8 @@ public record CreateFixZoneRequest( @NotNull @Schema(description = "내용") String content, - @Schema(description = "픽스존 이미지 식별자 목록", example = "[\"0192c828-ffce-7ee8-94a8-d9d4c8cdec00\", \"0192c828-ffce-7ee8-94a8-d9d4c8cdec00\"]") - List fixZoneImageIds + @Schema(description = "픽스존 이미지 정보 목록") + List images ) { public CreateFixZoneCommand toCommand(Long userId) { @@ -21,8 +22,19 @@ public CreateFixZoneCommand toCommand(Long userId) { userId, title, content, - fixZoneImageIds + images.stream() + .map(image -> new ImageInfo(image.id, image.order())) + .toList() ); } + public record ImageInfoRequest( + @Schema(description = "이미지 식별자", example = "0192c828-ffce-7ee8-94a8-d9d4c8cdec00") + String id, + @Schema(description = "이미지 순서", example = "1") + int order + ) { + + } + } diff --git a/src/main/java/ddingdong/ddingdongBE/domain/fixzone/controller/dto/request/UpdateFixZoneRequest.java b/src/main/java/ddingdong/ddingdongBE/domain/fixzone/controller/dto/request/UpdateFixZoneRequest.java index 2bbe0d96..75c081ce 100644 --- a/src/main/java/ddingdong/ddingdongBE/domain/fixzone/controller/dto/request/UpdateFixZoneRequest.java +++ b/src/main/java/ddingdong/ddingdongBE/domain/fixzone/controller/dto/request/UpdateFixZoneRequest.java @@ -1,6 +1,7 @@ package ddingdong.ddingdongBE.domain.fixzone.controller.dto.request; import ddingdong.ddingdongBE.domain.fixzone.service.dto.command.UpdateFixZoneCommand; +import ddingdong.ddingdongBE.domain.fixzone.service.dto.command.UpdateFixZoneCommand.ImageInfo; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotNull; import java.util.List; @@ -12,8 +13,8 @@ public record UpdateFixZoneRequest( @NotNull @Schema(description = "내용") String content, - @Schema(description = "픽스존 이미지 식별자 목록", example = "[\"0192c828-ffce-7ee8-94a8-d9d4c8cdec00\", \"0192c828-ffce-7ee8-94a8-d9d4c8cdec00\"]") - List fixZoneImageIds + @Schema(description = "픽스존 이미지 정보 목록") + List images ) { public UpdateFixZoneCommand toCommand(Long fixZoneId) { @@ -21,8 +22,19 @@ public UpdateFixZoneCommand toCommand(Long fixZoneId) { fixZoneId, title, content, - fixZoneImageIds + images.stream() + .map(image -> new ImageInfo(image.id(), image.order())) + .toList() ); } + public record ImageInfoRequest( + @Schema(description = "이미지 식별자", example = "0192c828-ffce-7ee8-94a8-d9d4c8cdec00") + String id, + @Schema(description = "이미지 순서", example = "1") + int order + ) { + + } + } diff --git a/src/main/java/ddingdong/ddingdongBE/domain/fixzone/controller/dto/response/AdminFixZoneResponse.java b/src/main/java/ddingdong/ddingdongBE/domain/fixzone/controller/dto/response/AdminFixZoneResponse.java index c9d17be9..ef050d27 100644 --- a/src/main/java/ddingdong/ddingdongBE/domain/fixzone/controller/dto/response/AdminFixZoneResponse.java +++ b/src/main/java/ddingdong/ddingdongBE/domain/fixzone/controller/dto/response/AdminFixZoneResponse.java @@ -4,6 +4,7 @@ import ddingdong.ddingdongBE.domain.fixzone.service.dto.query.AdminFixZoneQuery; import ddingdong.ddingdongBE.domain.fixzone.service.dto.query.AdminFixZoneQuery.FixZoneCommentQuery; import ddingdong.ddingdongBE.file.service.dto.query.UploadedFileUrlQuery; +import ddingdong.ddingdongBE.file.service.dto.query.UploadedFileUrlWithOrderQuery; import io.swagger.v3.oas.annotations.media.Schema; import java.time.LocalDateTime; import java.util.List; @@ -54,17 +55,19 @@ public static AdminFixZoneResponse from(AdminFixZoneQuery query) { description = "어드민 - 픽스존 이미지 URL 조회 응답" ) record FixZoneImageUrlResponse( + @Schema(description = "이미지 순서", example = "1") + int order, @Schema(description = "원본 url", example = "url") String originUrl, @Schema(description = "cdn url", example = "url") String cdnUrl ) { - public static FixZoneImageUrlResponse from(UploadedFileUrlQuery query) { + public static FixZoneImageUrlResponse from(UploadedFileUrlWithOrderQuery query) { if (query == null) { return null; } - return new FixZoneImageUrlResponse(query.originUrl(), query.cdnUrl()); + return new FixZoneImageUrlResponse(query.order(), query.originUrl(), query.cdnUrl()); } } diff --git a/src/main/java/ddingdong/ddingdongBE/domain/fixzone/controller/dto/response/CentralFixZoneResponse.java b/src/main/java/ddingdong/ddingdongBE/domain/fixzone/controller/dto/response/CentralFixZoneResponse.java index 2ac0e383..732ce296 100644 --- a/src/main/java/ddingdong/ddingdongBE/domain/fixzone/controller/dto/response/CentralFixZoneResponse.java +++ b/src/main/java/ddingdong/ddingdongBE/domain/fixzone/controller/dto/response/CentralFixZoneResponse.java @@ -4,6 +4,7 @@ import ddingdong.ddingdongBE.domain.fixzone.service.dto.query.CentralFixZoneQuery; import ddingdong.ddingdongBE.domain.fixzone.service.dto.query.CentralFixZoneQuery.FixZoneCommentQuery; import ddingdong.ddingdongBE.file.service.dto.query.UploadedFileUrlQuery; +import ddingdong.ddingdongBE.file.service.dto.query.UploadedFileUrlWithOrderQuery; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Schema; import java.time.LocalDateTime; @@ -57,17 +58,19 @@ public static CentralFixZoneResponse from(CentralFixZoneQuery query) { record FixZoneImageUrlResponse( @Schema(description = "파일 식별자", example = "0192c828-ffce-7ee8-94a8-d9d4c8cdec00l") String id, + @Schema(description = "이미지 순서", example = "1") + int order, @Schema(description = "원본 url", example = "url") String originUrl, @Schema(description = "cdn url", example = "url") String cdnUrl ) { - public static FixZoneImageUrlResponse from(UploadedFileUrlQuery query) { + public static FixZoneImageUrlResponse from(UploadedFileUrlWithOrderQuery query) { if (query == null) { return null; } - return new FixZoneImageUrlResponse(query.id(), query.originUrl(), query.cdnUrl()); + return new FixZoneImageUrlResponse(query.id(), query.order(), query.originUrl(), query.cdnUrl()); } } diff --git a/src/main/java/ddingdong/ddingdongBE/domain/fixzone/service/FacadeAdminFixZoneServiceImpl.java b/src/main/java/ddingdong/ddingdongBE/domain/fixzone/service/FacadeAdminFixZoneServiceImpl.java index a632dc50..d34c6eb5 100644 --- a/src/main/java/ddingdong/ddingdongBE/domain/fixzone/service/FacadeAdminFixZoneServiceImpl.java +++ b/src/main/java/ddingdong/ddingdongBE/domain/fixzone/service/FacadeAdminFixZoneServiceImpl.java @@ -8,6 +8,7 @@ import ddingdong.ddingdongBE.domain.fixzone.service.dto.query.AdminFixZoneQuery; import ddingdong.ddingdongBE.file.service.S3FileService; import ddingdong.ddingdongBE.file.service.dto.query.UploadedFileUrlQuery; +import ddingdong.ddingdongBE.file.service.dto.query.UploadedFileUrlWithOrderQuery; import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -32,10 +33,11 @@ public List getAll() { @Override public AdminFixZoneQuery getFixZone(Long fixZoneId) { FixZone fixZone = fixZoneService.getById(fixZoneId); - List imageUrlQueries = fileMetaDataService + List imageUrlQueries = fileMetaDataService .getCoupledAllByDomainTypeAndEntityId(DomainType.FIX_ZONE_IMAGE, fixZoneId) .stream() - .map(fileMetaData -> s3FileService.getUploadedFileUrl(fileMetaData.getFileKey())) + .map(fileMetaData -> UploadedFileUrlWithOrderQuery.of( + s3FileService.getUploadedFileUrl(fileMetaData.getFileKey()), fileMetaData.getOrder())) .toList(); Club club = fixZone.getClub(); UploadedFileUrlQuery clubProfileImageQuery = fileMetaDataService diff --git a/src/main/java/ddingdong/ddingdongBE/domain/fixzone/service/FacadeCentralFixZoneServiceImpl.java b/src/main/java/ddingdong/ddingdongBE/domain/fixzone/service/FacadeCentralFixZoneServiceImpl.java index 4badf125..02835228 100644 --- a/src/main/java/ddingdong/ddingdongBE/domain/fixzone/service/FacadeCentralFixZoneServiceImpl.java +++ b/src/main/java/ddingdong/ddingdongBE/domain/fixzone/service/FacadeCentralFixZoneServiceImpl.java @@ -4,6 +4,7 @@ import ddingdong.ddingdongBE.domain.club.service.ClubService; import ddingdong.ddingdongBE.domain.filemetadata.entity.DomainType; import ddingdong.ddingdongBE.domain.filemetadata.service.FileMetaDataService; +import ddingdong.ddingdongBE.domain.filemetadata.service.dto.FileMetaDataIdOrderDto; import ddingdong.ddingdongBE.domain.fixzone.entity.FixZone; import ddingdong.ddingdongBE.domain.fixzone.service.dto.command.CreateFixZoneCommand; import ddingdong.ddingdongBE.domain.fixzone.service.dto.command.UpdateFixZoneCommand; @@ -11,6 +12,7 @@ import ddingdong.ddingdongBE.domain.fixzone.service.dto.query.CentralMyFixZoneListQuery; import ddingdong.ddingdongBE.file.service.S3FileService; import ddingdong.ddingdongBE.file.service.dto.query.UploadedFileUrlQuery; +import ddingdong.ddingdongBE.file.service.dto.query.UploadedFileUrlWithOrderQuery; import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -32,7 +34,16 @@ public Long create(CreateFixZoneCommand command) { Club club = clubService.getByUserId(command.userId()); FixZone createdFixZone = command.toEntity(club); Long createdFixZoneId = fixZoneService.save(createdFixZone); - fileMetaDataService.updateStatusToCoupled(command.fixZoneImageIds(), DomainType.FIX_ZONE_IMAGE, createdFixZoneId); + + List imageFileMetaDataIdOrderDtos = command.imageInfos().stream() + .map(imageInfo -> FileMetaDataIdOrderDto.of(imageInfo.imagId(), imageInfo.order())) + .toList(); + + fileMetaDataService.updateStatusToCoupledWithOrder( + imageFileMetaDataIdOrderDtos, + DomainType.FIX_ZONE_IMAGE, + createdFixZoneId + ); return createdFixZoneId; } @@ -49,10 +60,11 @@ public List getMyFixZones(Long userId) { public CentralFixZoneQuery getFixZone(Long fixZoneId) { FixZone fixZone = fixZoneService.getById(fixZoneId); Club club = fixZone.getClub(); - List imageUrlQueries = fileMetaDataService + List imageUrlQueries = fileMetaDataService .getCoupledAllByDomainTypeAndEntityId(DomainType.FIX_ZONE_IMAGE, fixZoneId) .stream() - .map(fileMetaData -> s3FileService.getUploadedFileUrl(fileMetaData.getFileKey())) + .map(fileMetaData -> UploadedFileUrlWithOrderQuery.of( + s3FileService.getUploadedFileUrl(fileMetaData.getFileKey()), fileMetaData.getOrder())) .toList(); UploadedFileUrlQuery clubProfileImageKey = fileMetaDataService @@ -69,7 +81,10 @@ public CentralFixZoneQuery getFixZone(Long fixZoneId) { public Long update(UpdateFixZoneCommand command) { FixZone fixZone = fixZoneService.getById(command.fixZoneId()); fixZone.update(command.toEntity()); - fileMetaDataService.update(command.fixZoneImageIds(), DomainType.FIX_ZONE_IMAGE, fixZone.getId()); + List imageFileMetaDataIdOrderDtos = command.imageInfos().stream() + .map(imageInfo -> FileMetaDataIdOrderDto.of(imageInfo.imagId(), imageInfo.order())) + .toList(); + fileMetaDataService.updateWithOrder(imageFileMetaDataIdOrderDtos, DomainType.FIX_ZONE_IMAGE, fixZone.getId()); return fixZone.getId(); } diff --git a/src/main/java/ddingdong/ddingdongBE/domain/fixzone/service/dto/command/CreateFixZoneCommand.java b/src/main/java/ddingdong/ddingdongBE/domain/fixzone/service/dto/command/CreateFixZoneCommand.java index 764c2374..a942a71b 100644 --- a/src/main/java/ddingdong/ddingdongBE/domain/fixzone/service/dto/command/CreateFixZoneCommand.java +++ b/src/main/java/ddingdong/ddingdongBE/domain/fixzone/service/dto/command/CreateFixZoneCommand.java @@ -8,7 +8,7 @@ public record CreateFixZoneCommand( Long userId, String title, String content, - List fixZoneImageIds + List imageInfos ) { public FixZone toEntity(Club club) { @@ -20,4 +20,11 @@ public FixZone toEntity(Club club) { .build(); } + public record ImageInfo( + String imagId, + int order + ) { + + } + } diff --git a/src/main/java/ddingdong/ddingdongBE/domain/fixzone/service/dto/command/UpdateFixZoneCommand.java b/src/main/java/ddingdong/ddingdongBE/domain/fixzone/service/dto/command/UpdateFixZoneCommand.java index 29b2d929..92733aee 100644 --- a/src/main/java/ddingdong/ddingdongBE/domain/fixzone/service/dto/command/UpdateFixZoneCommand.java +++ b/src/main/java/ddingdong/ddingdongBE/domain/fixzone/service/dto/command/UpdateFixZoneCommand.java @@ -7,7 +7,7 @@ public record UpdateFixZoneCommand( Long fixZoneId, String title, String content, - List fixZoneImageIds + List imageInfos ) { public FixZone toEntity() { @@ -17,4 +17,11 @@ public FixZone toEntity() { .build(); } + public record ImageInfo( + String imagId, + int order + ) { + + } + } diff --git a/src/main/java/ddingdong/ddingdongBE/domain/fixzone/service/dto/query/AdminFixZoneQuery.java b/src/main/java/ddingdong/ddingdongBE/domain/fixzone/service/dto/query/AdminFixZoneQuery.java index 71b1fa63..e640e97f 100644 --- a/src/main/java/ddingdong/ddingdongBE/domain/fixzone/service/dto/query/AdminFixZoneQuery.java +++ b/src/main/java/ddingdong/ddingdongBE/domain/fixzone/service/dto/query/AdminFixZoneQuery.java @@ -3,6 +3,7 @@ import ddingdong.ddingdongBE.domain.fixzone.entity.FixZone; import ddingdong.ddingdongBE.domain.fixzone.entity.FixZoneComment; import ddingdong.ddingdongBE.file.service.dto.query.UploadedFileUrlQuery; +import ddingdong.ddingdongBE.file.service.dto.query.UploadedFileUrlWithOrderQuery; import java.time.LocalDateTime; import java.util.List; @@ -14,13 +15,13 @@ public record AdminFixZoneQuery( String content, boolean isCompleted, LocalDateTime requestedAt, - List imageUrlQueries, + List imageUrlQueries, List fixZoneCommentQueries ) { public static AdminFixZoneQuery of( FixZone fixZone, - List fixZoneImageUrlQueries, + List fixZoneImageUrlQueries, UploadedFileUrlQuery commenterProfileImageUrlQuery) { return new AdminFixZoneQuery( fixZone.getId(), diff --git a/src/main/java/ddingdong/ddingdongBE/domain/fixzone/service/dto/query/CentralFixZoneQuery.java b/src/main/java/ddingdong/ddingdongBE/domain/fixzone/service/dto/query/CentralFixZoneQuery.java index 6812d997..3b68ab10 100644 --- a/src/main/java/ddingdong/ddingdongBE/domain/fixzone/service/dto/query/CentralFixZoneQuery.java +++ b/src/main/java/ddingdong/ddingdongBE/domain/fixzone/service/dto/query/CentralFixZoneQuery.java @@ -3,6 +3,7 @@ import ddingdong.ddingdongBE.domain.fixzone.entity.FixZone; import ddingdong.ddingdongBE.domain.fixzone.entity.FixZoneComment; import ddingdong.ddingdongBE.file.service.dto.query.UploadedFileUrlQuery; +import ddingdong.ddingdongBE.file.service.dto.query.UploadedFileUrlWithOrderQuery; import java.time.LocalDateTime; import java.util.List; @@ -14,13 +15,13 @@ public record CentralFixZoneQuery( String content, boolean isCompleted, LocalDateTime requestedAt, - List imageUrlQueries, + List imageUrlQueries, List fixZoneCommentQueries ) { public static CentralFixZoneQuery of( FixZone fixZone, - List fixZoneImageUrlQueries, + List fixZoneImageUrlQueries, UploadedFileUrlQuery commenterProfileImageUrlQuery) { return new CentralFixZoneQuery( fixZone.getId(),