Skip to content

Commit

Permalink
Merge pull request #9 from depth-rolling-paper/develop
Browse files Browse the repository at this point in the history
feat: 여러 롤링페이퍼 작성
  • Loading branch information
phonil authored Dec 18, 2023
2 parents f2f4abd + 9c09751 commit a3c04ff
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Long> ids = new ArrayList<>();

List<RollingPaperReq> 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);

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -53,4 +56,7 @@ public class RollingPaperReq {

@Nullable
private Double sizeY;

private List<RollingPaperReq> rollingPaperList = new ArrayList<>();

}
Original file line number Diff line number Diff line change
Expand Up @@ -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<Long> 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<Long> rollingPaperIds, String message) {
this.rollingPaperIds = rollingPaperIds;
this.message = message;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public ResponseEntity<?> createRoom(String url) {
// Description : 대기 방 삭제
waitingRoomRepository.delete(waitingRoom);

// Description : 소켓으로 url 전달
webSocketEventListener.sendUrl(url);

CreateRoomRes createRoomRes = CreateRoomRes.builder()
Expand Down

0 comments on commit a3c04ff

Please sign in to comment.