From 9c097510d262f8788b712669728ac89b3f8acfa9 Mon Sep 17 00:00:00 2001 From: phonil Date: Mon, 18 Dec 2023 18:03:13 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=97=AC=EB=9F=AC=20=EB=A1=A4=EB=A7=81?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=ED=8D=BC=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/RollingPaperService.java | 106 +++++++++++++----- .../dto/request/RollingPaperReq.java | 6 + .../dto/response/RollingPaperRes.java | 17 ++- .../domain/room/application/RoomService.java | 1 + 4 files changed, 98 insertions(+), 32 deletions(-) diff --git a/src/main/java/com/rollingpaperserver/domain/rollingPaper/application/RollingPaperService.java b/src/main/java/com/rollingpaperserver/domain/rollingPaper/application/RollingPaperService.java index 4a5670b..5079d04 100644 --- a/src/main/java/com/rollingpaperserver/domain/rollingPaper/application/RollingPaperService.java +++ b/src/main/java/com/rollingpaperserver/domain/rollingPaper/application/RollingPaperService.java @@ -88,44 +88,92 @@ public ResponseEntity writeRollingPaper(Long userId, RollingPaperReq rollingP User user = userWithRoomAndWaitingRoom.get(); - RollingPaper rollingPaper = null; - - // Description : RollingPaperType == ROLLING_PAPER - if (rollingPaperReq.getRollingPaperType() == RollingPaperType.ROLLING_PAPER) { - rollingPaper = RollingPaper.builder() - .rollingPaperType(rollingPaperReq.getRollingPaperType()) - .location_x(rollingPaperReq.getLocation_x()) - .location_y(rollingPaperReq.getLocation_y()) - .rotation(rollingPaperReq.getRotation()) - .width(rollingPaperReq.getWidth()) - .height(rollingPaperReq.getHeight()) - .scaleX(rollingPaperReq.getScaleX()) - .scaleY(rollingPaperReq.getScaleY()) - .text(rollingPaperReq.getText()) - .fontFamily(rollingPaperReq.getFontFamily()) - .user(user) - .build(); - - } else { // Description : RollingPaperType == IMAGE - rollingPaper = RollingPaper.builder() - .rollingPaperType(rollingPaperReq.getRollingPaperType()) - .imageName(rollingPaperReq.getImageName()) - .sizeX(rollingPaperReq.getSizeX()) - .sizeY(rollingPaperReq.getSizeY()) - .user(user) - .build(); +// RollingPaper rollingPaper = null; + List ids = new ArrayList<>(); + + List rollingPaperList = rollingPaperReq.getRollingPaperList(); + for (RollingPaperReq paperReq : rollingPaperList) { + + // Description : RollingPaperType == ROLLING_PAPER + if (paperReq.getRollingPaperType() == RollingPaperType.ROLLING_PAPER) { + RollingPaper rollingPaper = RollingPaper.builder() + .rollingPaperType(paperReq.getRollingPaperType()) + .location_x(paperReq.getLocation_x()) + .location_y(paperReq.getLocation_y()) + .rotation(paperReq.getRotation()) + .width(paperReq.getWidth()) + .height(paperReq.getHeight()) + .scaleX(paperReq.getScaleX()) + .scaleY(paperReq.getScaleY()) + .text(paperReq.getText()) + .fontFamily(paperReq.getFontFamily()) + .user(user) + .build(); - } + rollingPaperRepository.save(rollingPaper); + ids.add(rollingPaper.getId()); + + } else { // Description : RollingPaperType == IMAGE - rollingPaperRepository.save(rollingPaper); + RollingPaper rollingPaper = RollingPaper.builder() + .rollingPaperType(paperReq.getRollingPaperType()) + .imageName(paperReq.getImageName()) + .sizeX(paperReq.getSizeX()) + .sizeY(paperReq.getSizeY()) + .user(user) + .build(); + + rollingPaperRepository.save(rollingPaper); + ids.add(rollingPaper.getId()); + + } + + } RollingPaperRes rollingPaperRes = RollingPaperRes.builder() - .rollingPaperId(rollingPaper.getId()) + .rollingPaperIds(ids) .message("롤링페이퍼가 작성되었습니다.") .build(); return ResponseEntity.ok(rollingPaperRes); + +// // Description : RollingPaperType == ROLLING_PAPER +// if (rollingPaperReq.getRollingPaperType() == RollingPaperType.ROLLING_PAPER) { +// rollingPaper = RollingPaper.builder() +// .rollingPaperType(rollingPaperReq.getRollingPaperType()) +// .location_x(rollingPaperReq.getLocation_x()) +// .location_y(rollingPaperReq.getLocation_y()) +// .rotation(rollingPaperReq.getRotation()) +// .width(rollingPaperReq.getWidth()) +// .height(rollingPaperReq.getHeight()) +// .scaleX(rollingPaperReq.getScaleX()) +// .scaleY(rollingPaperReq.getScaleY()) +// .text(rollingPaperReq.getText()) +// .fontFamily(rollingPaperReq.getFontFamily()) +// .user(user) +// .build(); +// +// } else { // Description : RollingPaperType == IMAGE +// rollingPaper = RollingPaper.builder() +// .rollingPaperType(rollingPaperReq.getRollingPaperType()) +// .imageName(rollingPaperReq.getImageName()) +// .sizeX(rollingPaperReq.getSizeX()) +// .sizeY(rollingPaperReq.getSizeY()) +// .user(user) +// .build(); +// +// } + +// rollingPaperRepository.save(rollingPaper); + +// RollingPaperRes rollingPaperRes = RollingPaperRes.builder() +// .rollingPaperId(rollingPaper.getId()) +// .message("롤링페이퍼가 작성되었습니다.") +// .build(); +// +// return ResponseEntity.ok(rollingPaperRes); + } } diff --git a/src/main/java/com/rollingpaperserver/domain/rollingPaper/dto/request/RollingPaperReq.java b/src/main/java/com/rollingpaperserver/domain/rollingPaper/dto/request/RollingPaperReq.java index 6c336a5..8c003e0 100644 --- a/src/main/java/com/rollingpaperserver/domain/rollingPaper/dto/request/RollingPaperReq.java +++ b/src/main/java/com/rollingpaperserver/domain/rollingPaper/dto/request/RollingPaperReq.java @@ -8,6 +8,9 @@ import lombok.NoArgsConstructor; import org.springframework.lang.Nullable; +import java.util.ArrayList; +import java.util.List; + @NoArgsConstructor(access = AccessLevel.PROTECTED) @Data public class RollingPaperReq { @@ -53,4 +56,7 @@ public class RollingPaperReq { @Nullable private Double sizeY; + + private List rollingPaperList = new ArrayList<>(); + } diff --git a/src/main/java/com/rollingpaperserver/domain/rollingPaper/dto/response/RollingPaperRes.java b/src/main/java/com/rollingpaperserver/domain/rollingPaper/dto/response/RollingPaperRes.java index 2555e88..e6b8688 100644 --- a/src/main/java/com/rollingpaperserver/domain/rollingPaper/dto/response/RollingPaperRes.java +++ b/src/main/java/com/rollingpaperserver/domain/rollingPaper/dto/response/RollingPaperRes.java @@ -8,17 +8,28 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.util.ArrayList; +import java.util.List; + @NoArgsConstructor(access = AccessLevel.PROTECTED) @Data public class RollingPaperRes { - private Long rollingPaperId; +// private Long rollingPaperId; + + private List rollingPaperIds = new ArrayList<>(); private String message; +// @Builder +// public RollingPaperRes(Long rollingPaperId, String message) { +// this.rollingPaperId = rollingPaperId; +// this.message = message; +// } + @Builder - public RollingPaperRes(Long rollingPaperId, String message) { - this.rollingPaperId = rollingPaperId; + public RollingPaperRes(List rollingPaperIds, String message) { + this.rollingPaperIds = rollingPaperIds; this.message = message; } } diff --git a/src/main/java/com/rollingpaperserver/domain/room/application/RoomService.java b/src/main/java/com/rollingpaperserver/domain/room/application/RoomService.java index c1ae5dc..386e6d9 100644 --- a/src/main/java/com/rollingpaperserver/domain/room/application/RoomService.java +++ b/src/main/java/com/rollingpaperserver/domain/room/application/RoomService.java @@ -73,6 +73,7 @@ public ResponseEntity createRoom(String url) { // Description : 대기 방 삭제 waitingRoomRepository.delete(waitingRoom); + // Description : 소켓으로 url 전달 webSocketEventListener.sendUrl(url); CreateRoomRes createRoomRes = CreateRoomRes.builder()