From 245970a969930718ae6a6f9d7aaa1a6154da0b07 Mon Sep 17 00:00:00 2001 From: seokyeong Date: Tue, 22 Aug 2023 20:55:56 +0900 Subject: [PATCH 1/5] =?UTF-8?q?[ADD]=20=EB=B2=88=ED=98=B8=20=EC=8A=A4?= =?UTF-8?q?=ED=8B=B0=EC=BB=A4=20=EC=8A=A4=ED=82=A4=EB=A7=88=20=EC=84=A4?= =?UTF-8?q?=EA=B3=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/sticker/domain/Sticker.java | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/main/java/site/katchup/katchupserver/api/sticker/domain/Sticker.java diff --git a/src/main/java/site/katchup/katchupserver/api/sticker/domain/Sticker.java b/src/main/java/site/katchup/katchupserver/api/sticker/domain/Sticker.java new file mode 100644 index 0000000..f1bb224 --- /dev/null +++ b/src/main/java/site/katchup/katchupserver/api/sticker/domain/Sticker.java @@ -0,0 +1,42 @@ +package site.katchup.katchupserver.api.sticker.domain; + +import jakarta.persistence.*; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import site.katchup.katchupserver.api.screenshot.domain.Screenshot; +import site.katchup.katchupserver.common.domain.BaseEntity; + +import static jakarta.persistence.FetchType.LAZY; +import static jakarta.persistence.GenerationType.IDENTITY; +import static lombok.AccessLevel.PROTECTED; + +@Entity +@Getter +@NoArgsConstructor(access = PROTECTED) +public class Sticker extends BaseEntity { + @Id + @GeneratedValue(strategy = IDENTITY) + private Long id; + + @Column(name = "sticker_order") + private Integer order; + + @Column(name = "x_coordinate") + private Float x; + + @Column(name = "y_coordinate") + private Float y; + + @ManyToOne(fetch = LAZY) + @JoinColumn(name = "screenshot_id") + private Screenshot screenshot; + + @Builder + public Sticker(Integer order, Float x, Float y, Screenshot screenshot) { + this.order = order; + this.x = x; + this.y = y; + this.screenshot = screenshot; + } +} \ No newline at end of file From 3a898edca0df92028d70d5bb97b369e209f3f48d Mon Sep 17 00:00:00 2001 From: seokyeong Date: Tue, 22 Aug 2023 20:56:50 +0900 Subject: [PATCH 2/5] =?UTF-8?q?[DEL]=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20stickerOrder=20column=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/screenshot/domain/Screenshot.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/site/katchup/katchupserver/api/screenshot/domain/Screenshot.java b/src/main/java/site/katchup/katchupserver/api/screenshot/domain/Screenshot.java index 66552f0..38ebb36 100644 --- a/src/main/java/site/katchup/katchupserver/api/screenshot/domain/Screenshot.java +++ b/src/main/java/site/katchup/katchupserver/api/screenshot/domain/Screenshot.java @@ -5,9 +5,14 @@ import lombok.Getter; import lombok.NoArgsConstructor; import site.katchup.katchupserver.api.card.domain.Card; +import site.katchup.katchupserver.api.sticker.domain.Sticker; import site.katchup.katchupserver.common.domain.BaseEntity; +import static jakarta.persistence.CascadeType.ALL; import static jakarta.persistence.FetchType.LAZY; + +import java.util.ArrayList; +import java.util.List; import java.util.UUID; import static lombok.AccessLevel.PROTECTED; @@ -19,9 +24,6 @@ public class Screenshot extends BaseEntity { @Id private UUID id; - @Column(name="sticker_order", columnDefinition = "integer default 0") - private int stickerOrder; - @Column(nullable = false) private String url; @@ -29,10 +31,12 @@ public class Screenshot extends BaseEntity { @JoinColumn(name = "card_id") private Card card; + @OneToMany(mappedBy = "screenshot", cascade = ALL) + private List sticker = new ArrayList<>(); + @Builder public Screenshot(UUID id, String url, Card card) { this.id = id; - this.stickerOrder = 0; this.url = url; this.card = card; } From 0082f448d0cbba645396fa352037555c26cacdcd Mon Sep 17 00:00:00 2001 From: seokyeong Date: Tue, 22 Aug 2023 20:57:21 +0900 Subject: [PATCH 3/5] =?UTF-8?q?[DEL]=20=EB=B9=88=20=EC=A4=84=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../site/katchup/katchupserver/common/response/ErrorCode.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/site/katchup/katchupserver/common/response/ErrorCode.java b/src/main/java/site/katchup/katchupserver/common/response/ErrorCode.java index ef44299..4233848 100644 --- a/src/main/java/site/katchup/katchupserver/common/response/ErrorCode.java +++ b/src/main/java/site/katchup/katchupserver/common/response/ErrorCode.java @@ -38,7 +38,6 @@ public enum ErrorCode { NOT_FOUND_KEYWORD("KW-306"), NOT_FOUND_SCREENSHOT("SS-307"), - /** * 500 SERVER_ERROR */ @@ -47,5 +46,4 @@ public enum ErrorCode { IMAGE_UPLOAD_EXCEPTION("SS-403"); private final String code; - } From 63ae0bd8e6859df609f8f1e52bbdb4bc4952d5f3 Mon Sep 17 00:00:00 2001 From: seokyeong Date: Tue, 22 Aug 2023 20:58:28 +0900 Subject: [PATCH 4/5] =?UTF-8?q?[FEAT]=20=EC=B9=B4=EB=93=9C=20=EC=A0=80?= =?UTF-8?q?=EC=9E=A5=20=EC=8B=9C=20=EB=B2=88=ED=98=B8=20=EC=8A=A4=ED=8B=B0?= =?UTF-8?q?=EC=BB=A4=EB=8F=84=20=EC=A0=80=EC=9E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/request/CardCreateRequestDto.java | 3 ++- .../card/service/Impl/CardServiceImpl.java | 20 +++++++++++++++---- .../request/ScreenshotCreateRequestDto.java | 6 ++++++ .../response/ScreenshotGetResponseDto.java | 3 +-- .../sticker/dto/StickerCreateRequestDto.java | 20 +++++++++++++++++++ .../sticker/repository/StickerRepository.java | 7 +++++++ 6 files changed, 52 insertions(+), 7 deletions(-) create mode 100644 src/main/java/site/katchup/katchupserver/api/sticker/dto/StickerCreateRequestDto.java create mode 100644 src/main/java/site/katchup/katchupserver/api/sticker/repository/StickerRepository.java diff --git a/src/main/java/site/katchup/katchupserver/api/card/dto/request/CardCreateRequestDto.java b/src/main/java/site/katchup/katchupserver/api/card/dto/request/CardCreateRequestDto.java index 51cc0a4..93c19da 100644 --- a/src/main/java/site/katchup/katchupserver/api/card/dto/request/CardCreateRequestDto.java +++ b/src/main/java/site/katchup/katchupserver/api/card/dto/request/CardCreateRequestDto.java @@ -5,6 +5,7 @@ import lombok.AllArgsConstructor; import lombok.Getter; import site.katchup.katchupserver.api.screenshot.dto.request.ScreenshotCreateRequestDto; +import site.katchup.katchupserver.api.sticker.dto.StickerCreateRequestDto; import java.util.List; @@ -20,8 +21,8 @@ public class CardCreateRequestDto { @NotNull(message = "CD-113") private List keywordIdList; private List screenshotList; + private StickerCreateRequestDto stickerList; private String note; @NotBlank(message = "CD-114") private String content; - } diff --git a/src/main/java/site/katchup/katchupserver/api/card/service/Impl/CardServiceImpl.java b/src/main/java/site/katchup/katchupserver/api/card/service/Impl/CardServiceImpl.java index 980b751..b2c9de6 100644 --- a/src/main/java/site/katchup/katchupserver/api/card/service/Impl/CardServiceImpl.java +++ b/src/main/java/site/katchup/katchupserver/api/card/service/Impl/CardServiceImpl.java @@ -21,13 +21,15 @@ import site.katchup.katchupserver.api.screenshot.dto.request.ScreenshotCreateRequestDto; import site.katchup.katchupserver.api.screenshot.dto.response.ScreenshotGetResponseDto; import site.katchup.katchupserver.api.screenshot.repository.ScreenshotRepository; +import site.katchup.katchupserver.api.sticker.domain.Sticker; +import site.katchup.katchupserver.api.sticker.dto.StickerCreateRequestDto; +import site.katchup.katchupserver.api.sticker.repository.StickerRepository; import site.katchup.katchupserver.api.subTask.domain.SubTask; import site.katchup.katchupserver.api.subTask.repository.SubTaskRepository; import site.katchup.katchupserver.api.task.domain.Task; import site.katchup.katchupserver.api.task.repository.TaskRepository; import site.katchup.katchupserver.api.trash.domain.Trash; import site.katchup.katchupserver.api.trash.repository.TrashRepository; -import site.katchup.katchupserver.common.util.S3Util; import java.util.*; import java.util.stream.Collectors; @@ -45,7 +47,7 @@ public class CardServiceImpl implements CardService { private final TaskRepository taskRepository; private final ScreenshotRepository screenshotRepository; private final KeywordRepository keywordRepository; - private final S3Util s3Util; + private final StickerRepository stickerRepository; @Override public List getCardList(Long taskId) { @@ -100,7 +102,6 @@ public void createCard(CardCreateRequestDto requestDto) { } for (ScreenshotCreateRequestDto screenshotInfo : requestDto.getScreenshotList()) { - Screenshot newScreenshot = Screenshot.builder() .id(screenshotInfo.getScreenshotUUID()) .url(screenshotInfo.getScreenshotUrl()) @@ -108,6 +109,17 @@ public void createCard(CardCreateRequestDto requestDto) { .build(); screenshotRepository.save(newScreenshot); + + for (StickerCreateRequestDto stickerInfo : screenshotInfo.getStickerList()) { + + Sticker newSticker = Sticker.builder() + .order(stickerInfo.getOrder()) + .x(stickerInfo.getX()) + .y(stickerInfo.getY()) + .screenshot(newScreenshot) + .build(); + stickerRepository.save(newSticker); + } } } @@ -159,7 +171,7 @@ private List getKeywordDtoList(Long cardId) { private List getScreenshotDtoList(Long cardId) { return cardRepository.findByIdOrThrow(cardId).getScreenshots().stream() .map(screenshot -> ScreenshotGetResponseDto - .of(screenshot.getId(), screenshot.getStickerOrder(), screenshot.getUrl()) + .of(screenshot.getId(), screenshot.getUrl()) ).collect(Collectors.toList()); } diff --git a/src/main/java/site/katchup/katchupserver/api/screenshot/dto/request/ScreenshotCreateRequestDto.java b/src/main/java/site/katchup/katchupserver/api/screenshot/dto/request/ScreenshotCreateRequestDto.java index 7332fdf..9f6d06b 100644 --- a/src/main/java/site/katchup/katchupserver/api/screenshot/dto/request/ScreenshotCreateRequestDto.java +++ b/src/main/java/site/katchup/katchupserver/api/screenshot/dto/request/ScreenshotCreateRequestDto.java @@ -4,7 +4,9 @@ import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Getter; +import site.katchup.katchupserver.api.sticker.dto.StickerCreateRequestDto; +import java.util.List; import java.util.UUID; @Getter @@ -14,7 +16,11 @@ public class ScreenshotCreateRequestDto { @Schema(description = "업로드하는 스크린샷 고유 UUID", example = "ddwd-wdwd-wdwd-wdwdwdwd") @NotNull private UUID screenshotUUID; + @Schema(description = "스크린샷 url", example = "https://abde.s3.ap-northeast-2.amazonaws.com/1.png") @NotNull private String screenshotUrl; + + @Schema(description = "번호 스티커") + private List stickerList; } diff --git a/src/main/java/site/katchup/katchupserver/api/screenshot/dto/response/ScreenshotGetResponseDto.java b/src/main/java/site/katchup/katchupserver/api/screenshot/dto/response/ScreenshotGetResponseDto.java index 46fe995..9848985 100644 --- a/src/main/java/site/katchup/katchupserver/api/screenshot/dto/response/ScreenshotGetResponseDto.java +++ b/src/main/java/site/katchup/katchupserver/api/screenshot/dto/response/ScreenshotGetResponseDto.java @@ -11,8 +11,7 @@ public class ScreenshotGetResponseDto { @Schema(description = "스크린샷 고유 id", example = "ddwd-wdwd-wdwd-wdwdwdwd") private UUID id; - @Schema(description = "스티커 순서", example = "1") - private int stickerOrder; + @Schema(description = "스크린샷 url", example = "https://abde.s3.ap-northeast-2.amazonaws.com/1.png") private String url; } diff --git a/src/main/java/site/katchup/katchupserver/api/sticker/dto/StickerCreateRequestDto.java b/src/main/java/site/katchup/katchupserver/api/sticker/dto/StickerCreateRequestDto.java new file mode 100644 index 0000000..e51ab2d --- /dev/null +++ b/src/main/java/site/katchup/katchupserver/api/sticker/dto/StickerCreateRequestDto.java @@ -0,0 +1,20 @@ +package site.katchup.katchupserver.api.sticker.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.persistence.Column; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +@Schema(description = "번호 스티커 추가 요청 DTO") +public class StickerCreateRequestDto { + @Schema(description = "스티커 번호", example = "2") + private Integer order; + + @Schema(description = "스티커 X좌표", example = "300") + private Float x; + + @Schema(description = "스티커 Y좌표", example = "400") + private Float y; +} diff --git a/src/main/java/site/katchup/katchupserver/api/sticker/repository/StickerRepository.java b/src/main/java/site/katchup/katchupserver/api/sticker/repository/StickerRepository.java new file mode 100644 index 0000000..7a58b31 --- /dev/null +++ b/src/main/java/site/katchup/katchupserver/api/sticker/repository/StickerRepository.java @@ -0,0 +1,7 @@ +package site.katchup.katchupserver.api.sticker.repository; + +import org.springframework.data.jpa.repository.JpaRepository; +import site.katchup.katchupserver.api.sticker.domain.Sticker; + +public interface StickerRepository extends JpaRepository { +} From 896f5fe48d2c0a741aab4ca8b15dfd8d08160d48 Mon Sep 17 00:00:00 2001 From: Seokyeong Date: Tue, 22 Aug 2023 21:13:56 +0900 Subject: [PATCH 5/5] =?UTF-8?q?[FIX]=20=EB=B9=8C=EB=93=9C=EC=98=A4?= =?UTF-8?q?=EB=A5=98=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../katchupserver/api/screenshot/domain/ScreenshotTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/java/site/katchup/katchupserver/api/screenshot/domain/ScreenshotTest.java b/src/test/java/site/katchup/katchupserver/api/screenshot/domain/ScreenshotTest.java index aae37c1..5ba5bb4 100644 --- a/src/test/java/site/katchup/katchupserver/api/screenshot/domain/ScreenshotTest.java +++ b/src/test/java/site/katchup/katchupserver/api/screenshot/domain/ScreenshotTest.java @@ -40,6 +40,5 @@ public void successSaveScreenshot() { // Then Assertions.assertNotNull(savedScreenshot.getId()); Assertions.assertEquals(savedScreenshot.getId(), uuid); - Assertions.assertEquals(savedScreenshot.getStickerOrder(), 0); } } \ No newline at end of file