From c0239e52d74b4f63337e73535e472d375bf8d153 Mon Sep 17 00:00:00 2001 From: ghvfgfcht Date: Wed, 1 May 2024 18:00:26 +0900 Subject: [PATCH 01/30] =?UTF-8?q?:sparkles:=20FEAT.=20CustomCharacter=20En?= =?UTF-8?q?tity=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../faceSwap/entity/CustomCharacter.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/main/java/fairytale/tbd/domain/faceSwap/entity/CustomCharacter.java diff --git a/src/main/java/fairytale/tbd/domain/faceSwap/entity/CustomCharacter.java b/src/main/java/fairytale/tbd/domain/faceSwap/entity/CustomCharacter.java new file mode 100644 index 0000000..303d52d --- /dev/null +++ b/src/main/java/fairytale/tbd/domain/faceSwap/entity/CustomCharacter.java @@ -0,0 +1,38 @@ +package fairytale.tbd.domain.faceSwap.entity; + +import fairytale.tbd.domain.user.entity.User; +import jakarta.persistence.*; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Entity +@Getter +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class CustomCharacter { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long customId; + + private String customURL; + + @OneToOne + @JoinColumn(name = "userId") + private User userId; + + @OneToOne + @JoinColumn(name = "storyBookId") + private OriginalStoryBook originalStoryBookId; + + public void setUserId(User userId) { + this.userId = userId; + } + + public void setOriginalStoryBookId(OriginalStoryBook originalStoryBookId){ + this.originalStoryBookId = originalStoryBookId; + } +} From da14e1474466c0e23ffca078ab2d93956207ce9e Mon Sep 17 00:00:00 2001 From: ghvfgfcht Date: Wed, 1 May 2024 18:00:57 +0900 Subject: [PATCH 02/30] =?UTF-8?q?:sparkles:=20FEAT.=20CustomCharacterRepos?= =?UTF-8?q?itory=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../faceSwap/repository/CustomCharacterRepository.java | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 src/main/java/fairytale/tbd/domain/faceSwap/repository/CustomCharacterRepository.java diff --git a/src/main/java/fairytale/tbd/domain/faceSwap/repository/CustomCharacterRepository.java b/src/main/java/fairytale/tbd/domain/faceSwap/repository/CustomCharacterRepository.java new file mode 100644 index 0000000..d0c2368 --- /dev/null +++ b/src/main/java/fairytale/tbd/domain/faceSwap/repository/CustomCharacterRepository.java @@ -0,0 +1,7 @@ +package fairytale.tbd.domain.faceSwap.repository; + +import fairytale.tbd.domain.faceSwap.entity.CustomCharacter; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface CustomCharacterRepository extends JpaRepository { +} From 905013588a6be2ee031c17b2c3bc1ea24a408b87 Mon Sep 17 00:00:00 2001 From: ghvfgfcht Date: Wed, 1 May 2024 18:01:17 +0900 Subject: [PATCH 03/30] =?UTF-8?q?:sparkles:=20FEAT.=20FaceSwapRequestDto?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tbd/domain/faceSwap/web/dto/FaceSwapRequestDto.java | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 src/main/java/fairytale/tbd/domain/faceSwap/web/dto/FaceSwapRequestDto.java diff --git a/src/main/java/fairytale/tbd/domain/faceSwap/web/dto/FaceSwapRequestDto.java b/src/main/java/fairytale/tbd/domain/faceSwap/web/dto/FaceSwapRequestDto.java new file mode 100644 index 0000000..06e79f3 --- /dev/null +++ b/src/main/java/fairytale/tbd/domain/faceSwap/web/dto/FaceSwapRequestDto.java @@ -0,0 +1,4 @@ +package fairytale.tbd.domain.faceSwap.web.dto; + +public class FaceSwapRequestDto { +} From b8325623431fb84d146b636cafed71bc59da3c2d Mon Sep 17 00:00:00 2001 From: ghvfgfcht Date: Wed, 1 May 2024 18:01:29 +0900 Subject: [PATCH 04/30] =?UTF-8?q?:sparkles:=20FEAT.=20FaceSwapResponseDto?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tbd/domain/faceSwap/web/dto/FaceSwapResponseDto.java | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 src/main/java/fairytale/tbd/domain/faceSwap/web/dto/FaceSwapResponseDto.java diff --git a/src/main/java/fairytale/tbd/domain/faceSwap/web/dto/FaceSwapResponseDto.java b/src/main/java/fairytale/tbd/domain/faceSwap/web/dto/FaceSwapResponseDto.java new file mode 100644 index 0000000..48f096e --- /dev/null +++ b/src/main/java/fairytale/tbd/domain/faceSwap/web/dto/FaceSwapResponseDto.java @@ -0,0 +1,4 @@ +package fairytale.tbd.domain.faceSwap.web.dto; + +public class FaceSwapResponseDto { +} From c68764339d9c41345d0e98af5796092fa15be988 Mon Sep 17 00:00:00 2001 From: ghvfgfcht Date: Wed, 1 May 2024 18:01:42 +0900 Subject: [PATCH 05/30] =?UTF-8?q?:sparkles:=20FEAT.=20FaceSwapRestControll?= =?UTF-8?q?er=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/FaceSwapRestController.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/main/java/fairytale/tbd/domain/faceSwap/web/controller/FaceSwapRestController.java diff --git a/src/main/java/fairytale/tbd/domain/faceSwap/web/controller/FaceSwapRestController.java b/src/main/java/fairytale/tbd/domain/faceSwap/web/controller/FaceSwapRestController.java new file mode 100644 index 0000000..f5c75ab --- /dev/null +++ b/src/main/java/fairytale/tbd/domain/faceSwap/web/controller/FaceSwapRestController.java @@ -0,0 +1,27 @@ +package fairytale.tbd.domain.faceSwap.web.controller; + +import fairytale.tbd.domain.faceSwap.service.PhotoUploadServiceImpl; +import fairytale.tbd.domain.user.entity.User; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + +import java.io.IOException; + +@Slf4j +@RestController +@RequestMapping("/fjaceSwap") +@RequiredArgsConstructor +public class FaceSwapRestController { + + private final PhotoUploadServiceImpl photoUploadService; + + @PostMapping("/uploadImg") + public void uploadImg(@RequestParam MultipartFile file) throws IOException{ + photoUploadService.savePhotos(file); + } +} From 2c48b684479349da59ed6630fa883221417d763d Mon Sep 17 00:00:00 2001 From: ghvfgfcht Date: Wed, 1 May 2024 18:01:58 +0900 Subject: [PATCH 06/30] =?UTF-8?q?:sparkles:=20FEAT.=20OriginalCharacter=20?= =?UTF-8?q?Entity=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../faceSwap/entity/OriginalCharacter.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/main/java/fairytale/tbd/domain/faceSwap/entity/OriginalCharacter.java diff --git a/src/main/java/fairytale/tbd/domain/faceSwap/entity/OriginalCharacter.java b/src/main/java/fairytale/tbd/domain/faceSwap/entity/OriginalCharacter.java new file mode 100644 index 0000000..b928fe5 --- /dev/null +++ b/src/main/java/fairytale/tbd/domain/faceSwap/entity/OriginalCharacter.java @@ -0,0 +1,38 @@ +package fairytale.tbd.domain.faceSwap.entity; + +import fairytale.tbd.domain.user.entity.User; +import jakarta.persistence.*; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Entity +@Getter +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class OriginalCharacter { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long originId; + + private String originalURL; + + @ManyToOne + @JoinColumn(name = "storyBookId") + private OriginalStoryBook originalStoryBook; + + @ManyToOne + @JoinColumn(name = "userId") + private User user; + + public void setOriginalStoryBook(OriginalStoryBook originalStoryBook){ + this.originalStoryBook = originalStoryBook; + } + + public void setUser(User user){ + this.user = user; + } +} From 502225ddb6439349fbae8634427bc8e13f213e71 Mon Sep 17 00:00:00 2001 From: ghvfgfcht Date: Wed, 1 May 2024 18:02:10 +0900 Subject: [PATCH 07/30] =?UTF-8?q?:sparkles:=20FEAT.=20OriginalCharacterRep?= =?UTF-8?q?ository=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../faceSwap/repository/OriginalCharacterRepository.java | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 src/main/java/fairytale/tbd/domain/faceSwap/repository/OriginalCharacterRepository.java diff --git a/src/main/java/fairytale/tbd/domain/faceSwap/repository/OriginalCharacterRepository.java b/src/main/java/fairytale/tbd/domain/faceSwap/repository/OriginalCharacterRepository.java new file mode 100644 index 0000000..8704481 --- /dev/null +++ b/src/main/java/fairytale/tbd/domain/faceSwap/repository/OriginalCharacterRepository.java @@ -0,0 +1,7 @@ +package fairytale.tbd.domain.faceSwap.repository; + +import fairytale.tbd.domain.faceSwap.entity.OriginalCharacter; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface OriginalCharacterRepository extends JpaRepository { +} From 9087301c4cbe695891e596dc813d156b94da3242 Mon Sep 17 00:00:00 2001 From: ghvfgfcht Date: Wed, 1 May 2024 18:02:27 +0900 Subject: [PATCH 08/30] =?UTF-8?q?:sparkles:=20FEAT.=20OriginalStoryBook=20?= =?UTF-8?q?Entity=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../faceSwap/entity/OriginalStoryBook.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/main/java/fairytale/tbd/domain/faceSwap/entity/OriginalStoryBook.java diff --git a/src/main/java/fairytale/tbd/domain/faceSwap/entity/OriginalStoryBook.java b/src/main/java/fairytale/tbd/domain/faceSwap/entity/OriginalStoryBook.java new file mode 100644 index 0000000..df19661 --- /dev/null +++ b/src/main/java/fairytale/tbd/domain/faceSwap/entity/OriginalStoryBook.java @@ -0,0 +1,24 @@ +package fairytale.tbd.domain.faceSwap.entity; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Entity +@Getter +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class OriginalStoryBook { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long storyBookId; + + private String title; +} From 94546ceb66b3d49468a0930272fbe806d1d7f79c Mon Sep 17 00:00:00 2001 From: ghvfgfcht Date: Wed, 1 May 2024 18:02:58 +0900 Subject: [PATCH 09/30] =?UTF-8?q?:sparkles:=20FEAT.=20PhotoUploadService?= =?UTF-8?q?=20Interface=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tbd/domain/faceSwap/service/PhotoUploadService.java | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 src/main/java/fairytale/tbd/domain/faceSwap/service/PhotoUploadService.java diff --git a/src/main/java/fairytale/tbd/domain/faceSwap/service/PhotoUploadService.java b/src/main/java/fairytale/tbd/domain/faceSwap/service/PhotoUploadService.java new file mode 100644 index 0000000..0704d4b --- /dev/null +++ b/src/main/java/fairytale/tbd/domain/faceSwap/service/PhotoUploadService.java @@ -0,0 +1,7 @@ +package fairytale.tbd.domain.faceSwap.service; + +import org.springframework.web.multipart.MultipartFile; + +public interface PhotoUploadService { + public void savePhotos(MultipartFile file); +} From b9b2680b4ccca4b6d28297160f232f86d346bffc Mon Sep 17 00:00:00 2001 From: ghvfgfcht Date: Wed, 1 May 2024 18:03:15 +0900 Subject: [PATCH 10/30] =?UTF-8?q?:sparkles:=20FEAT.=20PhotoUploadService?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/PhotoUploadServiceImpl.java | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/main/java/fairytale/tbd/domain/faceSwap/service/PhotoUploadServiceImpl.java diff --git a/src/main/java/fairytale/tbd/domain/faceSwap/service/PhotoUploadServiceImpl.java b/src/main/java/fairytale/tbd/domain/faceSwap/service/PhotoUploadServiceImpl.java new file mode 100644 index 0000000..e408c63 --- /dev/null +++ b/src/main/java/fairytale/tbd/domain/faceSwap/service/PhotoUploadServiceImpl.java @@ -0,0 +1,40 @@ +package fairytale.tbd.domain.faceSwap.service; + +import fairytale.tbd.domain.faceSwap.entity.CustomCharacter; +import fairytale.tbd.domain.faceSwap.entity.Uuid; +import fairytale.tbd.domain.faceSwap.repository.CustomCharacterRepository; +import fairytale.tbd.domain.faceSwap.repository.UuidRepository; +import fairytale.tbd.global.aws.s3.AmazonS3Manager; +import org.springframework.transaction.annotation.Transactional; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; + +import java.io.IOException; +import java.util.UUID; + +@Slf4j +@Service +@RequiredArgsConstructor +@Transactional(readOnly = true) +public class PhotoUploadServiceImpl { + + private final UuidRepository uuidRepository; + private final CustomCharacterRepository customCharacterRepository; + private final AmazonS3Manager amazonS3Manager; + + public void savePhotos(MultipartFile file) throws IOException{ + try{ + String uuid = UUID.randomUUID().toString(); + + Uuid saveUuid = uuidRepository.save(Uuid.builder().uuid(uuid).build()); + + byte[] imageData = file.getBytes(); + + String imgURL = amazonS3Manager.uploadFile(saveUuid.getUuid(), file); + } catch (IOException e) { + throw new RuntimeException(e); + } + } +} From 57ce5fa2b97312d225100cb9bad31767e2e19a27 Mon Sep 17 00:00:00 2001 From: ghvfgfcht Date: Wed, 1 May 2024 18:03:35 +0900 Subject: [PATCH 11/30] =?UTF-8?q?:sparkles:=20FEAT.=20Uuid=20Entity=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tbd/domain/faceSwap/entity/Uuid.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/main/java/fairytale/tbd/domain/faceSwap/entity/Uuid.java diff --git a/src/main/java/fairytale/tbd/domain/faceSwap/entity/Uuid.java b/src/main/java/fairytale/tbd/domain/faceSwap/entity/Uuid.java new file mode 100644 index 0000000..849e973 --- /dev/null +++ b/src/main/java/fairytale/tbd/domain/faceSwap/entity/Uuid.java @@ -0,0 +1,18 @@ +package fairytale.tbd.domain.faceSwap.entity; + +import jakarta.persistence.*; +import lombok.*; +@Entity +@Getter +@Builder +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor(access = AccessLevel.PROTECTED) + +public class Uuid { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long uuidId; + + @Column(unique = true) + private String uuid; +} \ No newline at end of file From 0562654b4e7ddc6c1490aa1436b3e7624062c6c9 Mon Sep 17 00:00:00 2001 From: ghvfgfcht Date: Wed, 1 May 2024 18:03:48 +0900 Subject: [PATCH 12/30] =?UTF-8?q?:sparkles:=20FEAT.=20UuidRepository=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tbd/domain/faceSwap/repository/UuidRepository.java | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 src/main/java/fairytale/tbd/domain/faceSwap/repository/UuidRepository.java diff --git a/src/main/java/fairytale/tbd/domain/faceSwap/repository/UuidRepository.java b/src/main/java/fairytale/tbd/domain/faceSwap/repository/UuidRepository.java new file mode 100644 index 0000000..3fe33c4 --- /dev/null +++ b/src/main/java/fairytale/tbd/domain/faceSwap/repository/UuidRepository.java @@ -0,0 +1,7 @@ +package fairytale.tbd.domain.faceSwap.repository; + +import fairytale.tbd.domain.faceSwap.entity.Uuid; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface UuidRepository extends JpaRepository { +} From 65c3dd0f2c83b012a2834f168ec5b4b0f4d0c97f Mon Sep 17 00:00:00 2001 From: ghvfgfcht Date: Wed, 1 May 2024 18:07:15 +0900 Subject: [PATCH 13/30] =?UTF-8?q?:art:=20CHORE.=20URL=20=EC=98=A4=ED=83=80?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/faceSwap/web/controller/FaceSwapRestController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/fairytale/tbd/domain/faceSwap/web/controller/FaceSwapRestController.java b/src/main/java/fairytale/tbd/domain/faceSwap/web/controller/FaceSwapRestController.java index f5c75ab..23a9e7c 100644 --- a/src/main/java/fairytale/tbd/domain/faceSwap/web/controller/FaceSwapRestController.java +++ b/src/main/java/fairytale/tbd/domain/faceSwap/web/controller/FaceSwapRestController.java @@ -14,7 +14,7 @@ @Slf4j @RestController -@RequestMapping("/fjaceSwap") +@RequestMapping("/faceSwap") @RequiredArgsConstructor public class FaceSwapRestController { From 213930aa1f92550c536114ad919a192f7536da18 Mon Sep 17 00:00:00 2001 From: ghvfgfcht Date: Thu, 2 May 2024 19:17:53 +0900 Subject: [PATCH 14/30] =?UTF-8?q?:sparkles:=20FEAT.=20Photo=20upload=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../faceSwap/service/PhotoUploadService.java | 6 ++++- .../service/PhotoUploadServiceImpl.java | 25 +++++++++++-------- .../controller/FaceSwapRestController.java | 16 ++++++------ .../web/dto/FaceDetectRequestDto.java | 12 +++++++++ 4 files changed, 41 insertions(+), 18 deletions(-) create mode 100644 src/main/java/fairytale/tbd/domain/faceSwap/web/dto/FaceDetectRequestDto.java diff --git a/src/main/java/fairytale/tbd/domain/faceSwap/service/PhotoUploadService.java b/src/main/java/fairytale/tbd/domain/faceSwap/service/PhotoUploadService.java index 0704d4b..a70bb27 100644 --- a/src/main/java/fairytale/tbd/domain/faceSwap/service/PhotoUploadService.java +++ b/src/main/java/fairytale/tbd/domain/faceSwap/service/PhotoUploadService.java @@ -1,7 +1,11 @@ package fairytale.tbd.domain.faceSwap.service; +import fairytale.tbd.domain.faceSwap.web.dto.FaceDetectRequestDto; +import fairytale.tbd.domain.faceSwap.web.dto.PhotoUploadRequestDto; import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; + public interface PhotoUploadService { - public void savePhotos(MultipartFile file); + FaceDetectRequestDto savePhotos(MultipartFile photoUploadRequestDto) throws IOException; } diff --git a/src/main/java/fairytale/tbd/domain/faceSwap/service/PhotoUploadServiceImpl.java b/src/main/java/fairytale/tbd/domain/faceSwap/service/PhotoUploadServiceImpl.java index e408c63..89a3c69 100644 --- a/src/main/java/fairytale/tbd/domain/faceSwap/service/PhotoUploadServiceImpl.java +++ b/src/main/java/fairytale/tbd/domain/faceSwap/service/PhotoUploadServiceImpl.java @@ -1,9 +1,8 @@ package fairytale.tbd.domain.faceSwap.service; -import fairytale.tbd.domain.faceSwap.entity.CustomCharacter; import fairytale.tbd.domain.faceSwap.entity.Uuid; -import fairytale.tbd.domain.faceSwap.repository.CustomCharacterRepository; import fairytale.tbd.domain.faceSwap.repository.UuidRepository; +import fairytale.tbd.domain.faceSwap.web.dto.FaceDetectRequestDto; import fairytale.tbd.global.aws.s3.AmazonS3Manager; import org.springframework.transaction.annotation.Transactional; import lombok.RequiredArgsConstructor; @@ -18,23 +17,29 @@ @Service @RequiredArgsConstructor @Transactional(readOnly = true) -public class PhotoUploadServiceImpl { +public class PhotoUploadServiceImpl implements PhotoUploadService { private final UuidRepository uuidRepository; - private final CustomCharacterRepository customCharacterRepository; private final AmazonS3Manager amazonS3Manager; - public void savePhotos(MultipartFile file) throws IOException{ - try{ - String uuid = UUID.randomUUID().toString(); + @Override + @Transactional + public FaceDetectRequestDto savePhotos(MultipartFile file) throws IOException { + String imgURL = ""; + String uuid = UUID.randomUUID().toString(); + try { Uuid saveUuid = uuidRepository.save(Uuid.builder().uuid(uuid).build()); - byte[] imageData = file.getBytes(); - - String imgURL = amazonS3Manager.uploadFile(saveUuid.getUuid(), file); + imgURL = amazonS3Manager.uploadFile(saveUuid.getUuid(), file); } catch (IOException e) { throw new RuntimeException(e); } + + FaceDetectRequestDto faceDetectRequestDto = new FaceDetectRequestDto(); + faceDetectRequestDto.setImgURL(imgURL); + + return faceDetectRequestDto; } + } diff --git a/src/main/java/fairytale/tbd/domain/faceSwap/web/controller/FaceSwapRestController.java b/src/main/java/fairytale/tbd/domain/faceSwap/web/controller/FaceSwapRestController.java index 23a9e7c..500828f 100644 --- a/src/main/java/fairytale/tbd/domain/faceSwap/web/controller/FaceSwapRestController.java +++ b/src/main/java/fairytale/tbd/domain/faceSwap/web/controller/FaceSwapRestController.java @@ -1,13 +1,13 @@ package fairytale.tbd.domain.faceSwap.web.controller; import fairytale.tbd.domain.faceSwap.service.PhotoUploadServiceImpl; +import fairytale.tbd.domain.faceSwap.web.dto.FaceDetectRequestDto; +import fairytale.tbd.domain.faceSwap.web.dto.PhotoUploadRequestDto; import fairytale.tbd.domain.user.entity.User; +import fairytale.tbd.global.response.ApiResponse; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import java.io.IOException; @@ -21,7 +21,9 @@ public class FaceSwapRestController { private final PhotoUploadServiceImpl photoUploadService; @PostMapping("/uploadImg") - public void uploadImg(@RequestParam MultipartFile file) throws IOException{ - photoUploadService.savePhotos(file); + public ApiResponse uploadImg(/*@LoginUser User user,*/ @ModelAttribute MultipartFile photoUploadRequestDto) throws IOException{ + FaceDetectRequestDto faceDetectRequestDto = photoUploadService.savePhotos(photoUploadRequestDto); + log.info("Face detect request : {}", faceDetectRequestDto); + return ApiResponse.onSuccess(faceDetectRequestDto); } -} +} \ No newline at end of file diff --git a/src/main/java/fairytale/tbd/domain/faceSwap/web/dto/FaceDetectRequestDto.java b/src/main/java/fairytale/tbd/domain/faceSwap/web/dto/FaceDetectRequestDto.java new file mode 100644 index 0000000..6d41695 --- /dev/null +++ b/src/main/java/fairytale/tbd/domain/faceSwap/web/dto/FaceDetectRequestDto.java @@ -0,0 +1,12 @@ +package fairytale.tbd.domain.faceSwap.web.dto; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class FaceDetectRequestDto { + + private String imgURL; + +} From 9ca17241233be251d28a3ca430e4321820787981 Mon Sep 17 00:00:00 2001 From: ghvfgfcht Date: Fri, 3 May 2024 16:13:19 +0900 Subject: [PATCH 15/30] =?UTF-8?q?CHORE.=20FaceSwapRestController=20uploadI?= =?UTF-8?q?mg=20method=20=EB=A7=A4=EA=B0=9C=EB=B3=80=EC=88=98=20=EC=9D=B4?= =?UTF-8?q?=EB=A6=84=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/FaceSwapRestController.java | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/main/java/fairytale/tbd/domain/faceSwap/web/controller/FaceSwapRestController.java b/src/main/java/fairytale/tbd/domain/faceSwap/web/controller/FaceSwapRestController.java index 500828f..b5e2614 100644 --- a/src/main/java/fairytale/tbd/domain/faceSwap/web/controller/FaceSwapRestController.java +++ b/src/main/java/fairytale/tbd/domain/faceSwap/web/controller/FaceSwapRestController.java @@ -1,9 +1,14 @@ package fairytale.tbd.domain.faceSwap.web.controller; +import fairytale.tbd.domain.faceSwap.service.FaceDetectApiServiceImpl; +import fairytale.tbd.domain.faceSwap.service.FaceSwapApiServiceImpl; import fairytale.tbd.domain.faceSwap.service.PhotoUploadServiceImpl; import fairytale.tbd.domain.faceSwap.web.dto.FaceDetectRequestDto; -import fairytale.tbd.domain.faceSwap.web.dto.PhotoUploadRequestDto; +import fairytale.tbd.domain.faceSwap.web.dto.FaceDetectResponseDto; +import fairytale.tbd.domain.faceSwap.web.dto.FaceSwapRequestDto; +import fairytale.tbd.domain.faceSwap.web.dto.FaceSwapResponseDto; import fairytale.tbd.domain.user.entity.User; +import fairytale.tbd.global.annotation.LoginUser; import fairytale.tbd.global.response.ApiResponse; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -19,11 +24,20 @@ public class FaceSwapRestController { private final PhotoUploadServiceImpl photoUploadService; + private final FaceDetectApiServiceImpl faceDetectApiService; + private final FaceSwapApiServiceImpl faceSwapApiService; @PostMapping("/uploadImg") - public ApiResponse uploadImg(/*@LoginUser User user,*/ @ModelAttribute MultipartFile photoUploadRequestDto) throws IOException{ - FaceDetectRequestDto faceDetectRequestDto = photoUploadService.savePhotos(photoUploadRequestDto); + public ApiResponse uploadImg(@LoginUser User user, @ModelAttribute MultipartFile file) throws IOException{ + FaceDetectRequestDto faceDetectRequestDto = photoUploadService.savePhotos(user, file); log.info("Face detect request : {}", faceDetectRequestDto); return ApiResponse.onSuccess(faceDetectRequestDto); } + +/* @GetMapping("/createCharacter") + public ApiResponse detectFace(FaceDetectRequestDto faceDetectRequestDto) throws IOException { + FaceDetectResponseDto faceDetectResponseDto = faceDetectApiService.getOptFromFaceDetectApi(faceDetectRequestDto); + + return ApiResponse.onSuccess(); + }*/ } \ No newline at end of file From afd47c2c4e718174eee1b0a333e5e7ebf489f6f8 Mon Sep 17 00:00:00 2001 From: ghvfgfcht Date: Fri, 3 May 2024 21:38:14 +0900 Subject: [PATCH 16/30] =?UTF-8?q?:heavy=5Fplus=5Fsign:=20ADD.=20Face=20Swa?= =?UTF-8?q?p=20API=20=EC=82=AC=EC=9A=A9=EC=97=90=20=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20=EC=9D=98=EC=A1=B4=EC=84=B1=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 70 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 43 insertions(+), 27 deletions(-) diff --git a/build.gradle b/build.gradle index c4c5f8b..77e42d2 100644 --- a/build.gradle +++ b/build.gradle @@ -1,52 +1,68 @@ plugins { - id 'java' - id 'org.springframework.boot' version '3.2.4' - id 'io.spring.dependency-management' version '1.1.4' + id 'java' + id 'org.springframework.boot' version '3.2.4' + id 'io.spring.dependency-management' version '1.1.4' } group = 'fairytale' version = '0.0.1-SNAPSHOT' java { - sourceCompatibility = '17' + sourceCompatibility = '17' } // build 이름 변경 -jar { - archiveBaseName = 'fairytale' - version = '0.0.1-SNAPSHOT' - enabled = false +jar{ + archiveBaseName = 'fairytale' + version = '0.0.1-SNAPSHOT' + enabled = false } configurations { - compileOnly { - extendsFrom annotationProcessor - } + compileOnly { + extendsFrom annotationProcessor + } } repositories { - mavenCentral() + mavenCentral() } dependencies { - implementation 'org.springframework.boot:spring-boot-starter-data-jpa' - implementation 'org.springframework.boot:spring-boot-starter-validation' - implementation 'org.springframework.boot:spring-boot-starter-web' + implementation 'org.springframework.boot:spring-boot-starter-data-jpa' + implementation 'org.springframework.boot:spring-boot-starter-validation' + implementation 'org.springframework.boot:spring-boot-starter-web' - //logging - implementation 'org.springframework.boot:spring-boot-starter-log4j2' - modules { - module("org.springframework.boot:spring-boot-starter-logging") { - replacedBy("org.springframework.boot:spring-boot-starter-log4j2") - } - } + //logging + implementation 'org.springframework.boot:spring-boot-starter-log4j2' + modules { + module("org.springframework.boot:spring-boot-starter-logging") { + replacedBy("org.springframework.boot:spring-boot-starter-log4j2") + } + } - // ElevenLabs API - implementation('net.andrewcpu:elevenlabs-api:2.7.8') + // ElevenLabs API + implementation ('net.andrewcpu:elevenlabs-api:2.7.8') - // AWS - implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE' + // AWS + implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE' + compileOnly 'org.projectlombok:lombok' + runtimeOnly 'com.mysql:mysql-connector-j' + annotationProcessor 'org.projectlombok:lombok' + testImplementation 'org.springframework.boot:spring-boot-starter-test' + + // Face Swap API + implementation 'com.squareup.okhttp3:okhttp:3.10.0' + implementation 'org.json:json:20200518' + + // Face Swap API + implementation 'com.squareup.okhttp3:okhttp:3.10.0' + implementation 'org.json:json:20200518' + + // Face Swap API + implementation 'com.squareup.okhttp3:okhttp:3.10.0' + implementation 'org.json:json:20200518' // Spring Security OAUTH 2.1 implementation 'org.springframework.boot:spring-boot-starter-security' @@ -62,5 +78,5 @@ dependencies { } tasks.named('test') { - useJUnitPlatform() + useJUnitPlatform() } From f59559868ad87628c637911efca51da4407e31ea Mon Sep 17 00:00:00 2001 From: ghvfgfcht Date: Fri, 3 May 2024 21:42:51 +0900 Subject: [PATCH 17/30] =?UTF-8?q?:art:=20RENAME.=20CustomCharacter=20?= =?UTF-8?q?=EC=97=B0=EA=B4=80=EA=B4=80=EA=B3=84=20=EB=B3=80=EA=B2=BD=20Ori?= =?UTF-8?q?ginalStoryBook=20->=20Fairytale?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../faceSwap/entity/CustomCharacter.java | 12 ++++++---- .../faceSwap/entity/OriginalStoryBook.java | 24 ------------------- 2 files changed, 7 insertions(+), 29 deletions(-) delete mode 100644 src/main/java/fairytale/tbd/domain/faceSwap/entity/OriginalStoryBook.java diff --git a/src/main/java/fairytale/tbd/domain/faceSwap/entity/CustomCharacter.java b/src/main/java/fairytale/tbd/domain/faceSwap/entity/CustomCharacter.java index 303d52d..d9e8616 100644 --- a/src/main/java/fairytale/tbd/domain/faceSwap/entity/CustomCharacter.java +++ b/src/main/java/fairytale/tbd/domain/faceSwap/entity/CustomCharacter.java @@ -1,5 +1,6 @@ package fairytale.tbd.domain.faceSwap.entity; +import fairytale.tbd.domain.fairytale.entity.Fairytale; import fairytale.tbd.domain.user.entity.User; import jakarta.persistence.*; import lombok.AllArgsConstructor; @@ -24,15 +25,16 @@ public class CustomCharacter { @JoinColumn(name = "userId") private User userId; - @OneToOne - @JoinColumn(name = "storyBookId") - private OriginalStoryBook originalStoryBookId; + + @ManyToOne + @JoinColumn(name = "fairytale_id") + private Fairytale fairytaleId; public void setUserId(User userId) { this.userId = userId; } - public void setOriginalStoryBookId(OriginalStoryBook originalStoryBookId){ - this.originalStoryBookId = originalStoryBookId; + public void setFairytaleId(Fairytale fairytaleId) { + this.fairytaleId = fairytaleId; } } diff --git a/src/main/java/fairytale/tbd/domain/faceSwap/entity/OriginalStoryBook.java b/src/main/java/fairytale/tbd/domain/faceSwap/entity/OriginalStoryBook.java deleted file mode 100644 index df19661..0000000 --- a/src/main/java/fairytale/tbd/domain/faceSwap/entity/OriginalStoryBook.java +++ /dev/null @@ -1,24 +0,0 @@ -package fairytale.tbd.domain.faceSwap.entity; - -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; - -@Entity -@Getter -@Builder -@AllArgsConstructor -@NoArgsConstructor -public class OriginalStoryBook { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long storyBookId; - - private String title; -} From 67f87f33c95c549ca2bff01946d77cc3295db4ac Mon Sep 17 00:00:00 2001 From: ghvfgfcht Date: Fri, 3 May 2024 21:44:51 +0900 Subject: [PATCH 18/30] =?UTF-8?q?:sparkles:=20FEAT.=20FaceDetectApiService?= =?UTF-8?q?=20=ED=8C=8C=EC=9D=BC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/faceSwap/service/FaceDetectApiService.java | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/main/java/fairytale/tbd/domain/faceSwap/service/FaceDetectApiService.java diff --git a/src/main/java/fairytale/tbd/domain/faceSwap/service/FaceDetectApiService.java b/src/main/java/fairytale/tbd/domain/faceSwap/service/FaceDetectApiService.java new file mode 100644 index 0000000..423ff2a --- /dev/null +++ b/src/main/java/fairytale/tbd/domain/faceSwap/service/FaceDetectApiService.java @@ -0,0 +1,10 @@ +package fairytale.tbd.domain.faceSwap.service; + +import fairytale.tbd.domain.faceSwap.web.dto.FaceDetectRequestDto; +import fairytale.tbd.domain.faceSwap.web.dto.FaceDetectResponseDto; + +import java.io.IOException; + +public interface FaceDetectApiService { + FaceDetectResponseDto getOptFromFaceDetectApi(FaceDetectRequestDto faceDetectRequestDto) throws IOException; +} From 9afc46ae27a2af9fd57fd6665908daa1a4791e75 Mon Sep 17 00:00:00 2001 From: ghvfgfcht Date: Fri, 3 May 2024 21:48:55 +0900 Subject: [PATCH 19/30] =?UTF-8?q?:sparkles:=20FEAT.=20FaceDetect=20API=20?= =?UTF-8?q?=EC=9A=94=EC=B2=AD=20=EA=B8=B0=EB=8A=A5=20FaceDetectApiServiceI?= =?UTF-8?q?mpl=20=ED=8C=8C=EC=9D=BC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/FaceDetectApiServiceImpl.java | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 src/main/java/fairytale/tbd/domain/faceSwap/service/FaceDetectApiServiceImpl.java diff --git a/src/main/java/fairytale/tbd/domain/faceSwap/service/FaceDetectApiServiceImpl.java b/src/main/java/fairytale/tbd/domain/faceSwap/service/FaceDetectApiServiceImpl.java new file mode 100644 index 0000000..4ffae6f --- /dev/null +++ b/src/main/java/fairytale/tbd/domain/faceSwap/service/FaceDetectApiServiceImpl.java @@ -0,0 +1,85 @@ +package fairytale.tbd.domain.faceSwap.service; + +import fairytale.tbd.domain.faceSwap.web.dto.FaceDetectRequestDto; +import fairytale.tbd.domain.faceSwap.web.dto.FaceDetectResponseDto; +import fairytale.tbd.domain.faceSwap.web.dto.FaceSwapRequestDto; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import okhttp3.*; +import org.json.JSONObject; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.io.IOException; +import java.util.logging.LogManager; +import java.util.logging.Logger; + + +@Service +@RequiredArgsConstructor +@Transactional(readOnly = true) +public class FaceDetectApiServiceImpl implements FaceDetectApiService{ + + @Value("${face.akool.apikey}") + private static String apiKey; + + + @Override + public FaceDetectResponseDto getOptFromFaceDetectApi(FaceDetectRequestDto faceDetectRequestDto) throws IOException { + + + String landmarkStr = ""; + + OkHttpClient client = new OkHttpClient(); + + MediaType mediaType = MediaType.parse("application/json"); + + String requestBodyJson = "{\n" + + " \"single_face\": true, \n" + + " \"image_url\": \"" + faceDetectRequestDto.getImgURL() + "\"\n" + + "}"; + + RequestBody body = RequestBody.create(mediaType, requestBodyJson); + + Request request = new Request.Builder() + .url("https://sg3.akool.com/detect") + .method("POST", body) + .addHeader("Authorization", "Bearer " + apiKey) + .addHeader("Content-Type", "application/json") + .build(); + + try (Response response = client.newCall(request).execute()){ + + if(!response.isSuccessful()){ + throw new IOException("Unexpected code " + response); + } + + String responseData = response.body().string(); + + JSONObject jsonObject = new JSONObject(responseData); + + int errCode = jsonObject.getInt("error_code"); + String errorMsg = jsonObject.getString("error_msg"); + + if(errCode!=0 || !errorMsg.equals("SUCCESS")){ + throw new IOException("Error! \n" + + "error code : " + + errCode + "\n" + + "error massage : " + + errorMsg + "\n"); + } + + landmarkStr = jsonObject.getString("landmarks_str"); + } catch (IOException e) { + + e.printStackTrace(); + + } + + return FaceDetectResponseDto.builder() + .photoUrl(faceDetectRequestDto.getImgURL()) + .opt(landmarkStr) + .build(); + } +} From cd5f44979e5b42cd8a3e41f9b4dd7e8c851c66e8 Mon Sep 17 00:00:00 2001 From: ghvfgfcht Date: Fri, 3 May 2024 21:49:50 +0900 Subject: [PATCH 20/30] =?UTF-8?q?:sparkles:=20FEAT.=20FaceDetectConverter?= =?UTF-8?q?=20=ED=81=B4=EB=9E=98=EC=8A=A4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tbd/domain/faceSwap/converter/FaceDetectConverter.java | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 src/main/java/fairytale/tbd/domain/faceSwap/converter/FaceDetectConverter.java diff --git a/src/main/java/fairytale/tbd/domain/faceSwap/converter/FaceDetectConverter.java b/src/main/java/fairytale/tbd/domain/faceSwap/converter/FaceDetectConverter.java new file mode 100644 index 0000000..aa7266c --- /dev/null +++ b/src/main/java/fairytale/tbd/domain/faceSwap/converter/FaceDetectConverter.java @@ -0,0 +1,6 @@ +package fairytale.tbd.domain.faceSwap.converter; + +import fairytale.tbd.domain.faceSwap.web.dto.FaceDetectRequestDto; + +public class FaceDetectConverter { +} \ No newline at end of file From 294019a876d2e728f476401f26c0122b5cb1efc7 Mon Sep 17 00:00:00 2001 From: ghvfgfcht Date: Fri, 3 May 2024 21:53:58 +0900 Subject: [PATCH 21/30] =?UTF-8?q?:art:=20ADD.=20@ToString=20=EC=96=B4?= =?UTF-8?q?=EB=85=B8=ED=85=8C=EC=9D=B4=EC=85=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tbd/domain/faceSwap/web/dto/FaceDetectRequestDto.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/fairytale/tbd/domain/faceSwap/web/dto/FaceDetectRequestDto.java b/src/main/java/fairytale/tbd/domain/faceSwap/web/dto/FaceDetectRequestDto.java index 6d41695..2b563cd 100644 --- a/src/main/java/fairytale/tbd/domain/faceSwap/web/dto/FaceDetectRequestDto.java +++ b/src/main/java/fairytale/tbd/domain/faceSwap/web/dto/FaceDetectRequestDto.java @@ -2,11 +2,13 @@ import lombok.Getter; import lombok.Setter; +import lombok.ToString; @Getter @Setter +@ToString public class FaceDetectRequestDto { private String imgURL; -} +} \ No newline at end of file From 2337d681bbb26b4e6217bb4ea6bf5b6ab4757267 Mon Sep 17 00:00:00 2001 From: ghvfgfcht Date: Fri, 3 May 2024 21:55:38 +0900 Subject: [PATCH 22/30] =?UTF-8?q?:sparkles:=20FEAT.=20FaceDetectResponseDt?= =?UTF-8?q?o=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../faceSwap/web/dto/FaceDetectResponseDto.java | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/main/java/fairytale/tbd/domain/faceSwap/web/dto/FaceDetectResponseDto.java diff --git a/src/main/java/fairytale/tbd/domain/faceSwap/web/dto/FaceDetectResponseDto.java b/src/main/java/fairytale/tbd/domain/faceSwap/web/dto/FaceDetectResponseDto.java new file mode 100644 index 0000000..d944b0c --- /dev/null +++ b/src/main/java/fairytale/tbd/domain/faceSwap/web/dto/FaceDetectResponseDto.java @@ -0,0 +1,11 @@ +package fairytale.tbd.domain.faceSwap.web.dto; + +import lombok.Builder; +import lombok.Getter; + +@Getter +@Builder +public class FaceDetectResponseDto { + private String photoUrl; + private String opt; +} \ No newline at end of file From ffb76cfb0286215be6956e50cc2dbc3caa2c0a38 Mon Sep 17 00:00:00 2001 From: ghvfgfcht Date: Fri, 3 May 2024 21:56:47 +0900 Subject: [PATCH 23/30] =?UTF-8?q?:sparkles:=20FEAT.=20FaceSwapApiService?= =?UTF-8?q?=20=EC=9D=B8=ED=84=B0=ED=8E=98=EC=9D=B4=EC=8A=A4=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tbd/domain/faceSwap/service/FaceSwapApiService.java | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src/main/java/fairytale/tbd/domain/faceSwap/service/FaceSwapApiService.java diff --git a/src/main/java/fairytale/tbd/domain/faceSwap/service/FaceSwapApiService.java b/src/main/java/fairytale/tbd/domain/faceSwap/service/FaceSwapApiService.java new file mode 100644 index 0000000..47e4307 --- /dev/null +++ b/src/main/java/fairytale/tbd/domain/faceSwap/service/FaceSwapApiService.java @@ -0,0 +1,8 @@ +package fairytale.tbd.domain.faceSwap.service; + +import fairytale.tbd.domain.faceSwap.web.dto.FaceDetectResponseDto; +import fairytale.tbd.domain.faceSwap.web.dto.FaceSwapResponseDto; + +public interface FaceSwapApiService { + /*FaceSwapResponseDto*/void getFaceSwapImg(FaceDetectResponseDto faceDetectResponseDto); +} From 093cf8aa0ff129b9f4f4038136154d7d897ae84c Mon Sep 17 00:00:00 2001 From: ghvfgfcht Date: Fri, 3 May 2024 21:57:25 +0900 Subject: [PATCH 24/30] =?UTF-8?q?:sparkles:=20FEAT.=20FaceSwapApiServiceIm?= =?UTF-8?q?pl=20=ED=81=B4=EB=9E=98=EC=8A=A4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/FaceSwapApiServiceImpl.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/main/java/fairytale/tbd/domain/faceSwap/service/FaceSwapApiServiceImpl.java diff --git a/src/main/java/fairytale/tbd/domain/faceSwap/service/FaceSwapApiServiceImpl.java b/src/main/java/fairytale/tbd/domain/faceSwap/service/FaceSwapApiServiceImpl.java new file mode 100644 index 0000000..ae433a8 --- /dev/null +++ b/src/main/java/fairytale/tbd/domain/faceSwap/service/FaceSwapApiServiceImpl.java @@ -0,0 +1,24 @@ +package fairytale.tbd.domain.faceSwap.service; + +import fairytale.tbd.domain.faceSwap.web.dto.FaceDetectResponseDto; +import fairytale.tbd.domain.faceSwap.web.dto.FaceSwapRequestDto; +import fairytale.tbd.domain.faceSwap.web.dto.FaceSwapResponseDto; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Slf4j +@Service +@RequiredArgsConstructor +@Transactional(readOnly = true) +public class FaceSwapApiServiceImpl implements FaceSwapApiService{ + + // 여기에서 originalCharacter, customCharacter 둘 다에 사용할 수 있게끔 한다. + @Override + @Transactional + public void getFaceSwapImg(FaceDetectResponseDto faceDetectResponseDto){ + FaceSwapRequestDto.FaceSwapRequest faceSwapRequest = new FaceSwapRequestDto.FaceSwapRequest(); + + } +} \ No newline at end of file From de298acf12ccae95ce6611032f042d80378a8d98 Mon Sep 17 00:00:00 2001 From: ghvfgfcht Date: Fri, 3 May 2024 21:59:00 +0900 Subject: [PATCH 25/30] =?UTF-8?q?:sparkles:=20FEAT.=20FaceSwapRequestDto?= =?UTF-8?q?=20=ED=81=B4=EB=9E=98=EC=8A=A4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../faceSwap/web/dto/FaceSwapRequestDto.java | 52 ++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/src/main/java/fairytale/tbd/domain/faceSwap/web/dto/FaceSwapRequestDto.java b/src/main/java/fairytale/tbd/domain/faceSwap/web/dto/FaceSwapRequestDto.java index 06e79f3..2a71abc 100644 --- a/src/main/java/fairytale/tbd/domain/faceSwap/web/dto/FaceSwapRequestDto.java +++ b/src/main/java/fairytale/tbd/domain/faceSwap/web/dto/FaceSwapRequestDto.java @@ -1,4 +1,54 @@ package fairytale.tbd.domain.faceSwap.web.dto; +import lombok.*; + public class FaceSwapRequestDto { -} + + @Getter + @Setter + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class FaceSwapRequest { + + private SourceImage sourseImage; + + private TargetImage targetImage; + + // 1 means open, 0 means close + private int faceEnhance; + + private String modifyImage; + + private String webHookUrl; + + } + + // Original Image + @Getter + @Setter + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class SourceImage { + + private String sourcePath; + + private String sourceOpts; + + } + + // User Image + @Getter + @Setter + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class TargetImage { + + private String targetPath; + + private String targetOpts; + + } +} \ No newline at end of file From e91a1bfb516da339b8af879c8c477595e7af74ba Mon Sep 17 00:00:00 2001 From: ghvfgfcht Date: Fri, 3 May 2024 21:59:43 +0900 Subject: [PATCH 26/30] =?UTF-8?q?:sparkles:=20FEAT.=20FaceSwapResponseDto?= =?UTF-8?q?=20=ED=81=B4=EB=9E=98=EC=8A=A4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tbd/domain/faceSwap/web/dto/FaceSwapResponseDto.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/fairytale/tbd/domain/faceSwap/web/dto/FaceSwapResponseDto.java b/src/main/java/fairytale/tbd/domain/faceSwap/web/dto/FaceSwapResponseDto.java index 48f096e..398f841 100644 --- a/src/main/java/fairytale/tbd/domain/faceSwap/web/dto/FaceSwapResponseDto.java +++ b/src/main/java/fairytale/tbd/domain/faceSwap/web/dto/FaceSwapResponseDto.java @@ -1,4 +1,11 @@ package fairytale.tbd.domain.faceSwap.web.dto; +import lombok.Builder; +import lombok.Getter; + +@Getter +@Builder public class FaceSwapResponseDto { -} + private Long fairytaleID; + +} \ No newline at end of file From 8555cac659d4de7354c497d37ce97642e023796a Mon Sep 17 00:00:00 2001 From: ghvfgfcht Date: Fri, 3 May 2024 22:00:24 +0900 Subject: [PATCH 27/30] =?UTF-8?q?:sparkles:=20FEAT.=20FaceDetectApi=20?= =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8=EB=A5=BC=20=EC=9C=84=ED=95=9C=20?= =?UTF-8?q?=EB=A9=94=EC=84=9C=EB=93=9C=20test=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/FaceSwapRestController.java | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/main/java/fairytale/tbd/domain/faceSwap/web/controller/FaceSwapRestController.java b/src/main/java/fairytale/tbd/domain/faceSwap/web/controller/FaceSwapRestController.java index b5e2614..426fad9 100644 --- a/src/main/java/fairytale/tbd/domain/faceSwap/web/controller/FaceSwapRestController.java +++ b/src/main/java/fairytale/tbd/domain/faceSwap/web/controller/FaceSwapRestController.java @@ -11,18 +11,19 @@ import fairytale.tbd.global.annotation.LoginUser; import fairytale.tbd.global.response.ApiResponse; import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import java.io.IOException; -@Slf4j @RestController @RequestMapping("/faceSwap") @RequiredArgsConstructor public class FaceSwapRestController { + private final Logger LOGGER = LogManager.getLogger(FaceSwapRestController.class); private final PhotoUploadServiceImpl photoUploadService; private final FaceDetectApiServiceImpl faceDetectApiService; private final FaceSwapApiServiceImpl faceSwapApiService; @@ -30,14 +31,26 @@ public class FaceSwapRestController { @PostMapping("/uploadImg") public ApiResponse uploadImg(@LoginUser User user, @ModelAttribute MultipartFile file) throws IOException{ FaceDetectRequestDto faceDetectRequestDto = photoUploadService.savePhotos(user, file); - log.info("Face detect request : {}", faceDetectRequestDto); return ApiResponse.onSuccess(faceDetectRequestDto); } -/* @GetMapping("/createCharacter") - public ApiResponse detectFace(FaceDetectRequestDto faceDetectRequestDto) throws IOException { - FaceDetectResponseDto faceDetectResponseDto = faceDetectApiService.getOptFromFaceDetectApi(faceDetectRequestDto); - return ApiResponse.onSuccess(); - }*/ + @PostMapping("/test") + public ApiResponse test(@RequestBody FaceDetectRequestDto faceDetectRequestDto){ + + LOGGER.info("Face detect request : {}", faceDetectRequestDto); + + + FaceDetectResponseDto optFromFaceDetectApi = null; + + try{ + optFromFaceDetectApi = faceDetectApiService.getOptFromFaceDetectApi(faceDetectRequestDto); + } + catch( Exception e){ + e.printStackTrace(); + } + + + return ApiResponse.onSuccess(optFromFaceDetectApi); + } } \ No newline at end of file From 33676d95b638845c23061b6e589577f79824c51a Mon Sep 17 00:00:00 2001 From: ghvfgfcht Date: Fri, 3 May 2024 22:02:16 +0900 Subject: [PATCH 28/30] =?UTF-8?q?:art:=20CHORE.=20OriginalStoryBook=20?= =?UTF-8?q?=ED=8C=8C=EC=9D=BC=20=EC=82=AD=EC=A0=9C=20=ED=9B=84=20Fairytale?= =?UTF-8?q?=20=EB=A1=9C=20=EC=B0=B8=EC=A1=B0=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/faceSwap/entity/OriginalCharacter.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/fairytale/tbd/domain/faceSwap/entity/OriginalCharacter.java b/src/main/java/fairytale/tbd/domain/faceSwap/entity/OriginalCharacter.java index b928fe5..4bbca20 100644 --- a/src/main/java/fairytale/tbd/domain/faceSwap/entity/OriginalCharacter.java +++ b/src/main/java/fairytale/tbd/domain/faceSwap/entity/OriginalCharacter.java @@ -1,5 +1,6 @@ package fairytale.tbd.domain.faceSwap.entity; +import fairytale.tbd.domain.fairytale.entity.Fairytale; import fairytale.tbd.domain.user.entity.User; import jakarta.persistence.*; import lombok.AllArgsConstructor; @@ -21,18 +22,19 @@ public class OriginalCharacter { private String originalURL; @ManyToOne - @JoinColumn(name = "storyBookId") - private OriginalStoryBook originalStoryBook; + @JoinColumn(name = "fairytale_id") + private Fairytale fairytaleId; @ManyToOne @JoinColumn(name = "userId") private User user; - public void setOriginalStoryBook(OriginalStoryBook originalStoryBook){ - this.originalStoryBook = originalStoryBook; - } - public void setUser(User user){ this.user = user; } + + public void setFairytaleId(Fairytale fairytaleId) { + this.fairytaleId = fairytaleId; + } + } From 30ca62abdeb147c6d0a263bcbef0efd655e03077 Mon Sep 17 00:00:00 2001 From: ghvfgfcht Date: Fri, 3 May 2024 22:03:36 +0900 Subject: [PATCH 29/30] =?UTF-8?q?:sparkles:=20FEAT.=20PhotoUploadService?= =?UTF-8?q?=20savePhotos=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EB=A7=A4?= =?UTF-8?q?=EA=B0=9C=EB=B3=80=EC=88=98=20user=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tbd/domain/faceSwap/service/PhotoUploadService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/fairytale/tbd/domain/faceSwap/service/PhotoUploadService.java b/src/main/java/fairytale/tbd/domain/faceSwap/service/PhotoUploadService.java index a70bb27..3f14b28 100644 --- a/src/main/java/fairytale/tbd/domain/faceSwap/service/PhotoUploadService.java +++ b/src/main/java/fairytale/tbd/domain/faceSwap/service/PhotoUploadService.java @@ -1,11 +1,11 @@ package fairytale.tbd.domain.faceSwap.service; import fairytale.tbd.domain.faceSwap.web.dto.FaceDetectRequestDto; -import fairytale.tbd.domain.faceSwap.web.dto.PhotoUploadRequestDto; +import fairytale.tbd.domain.user.entity.User; import org.springframework.web.multipart.MultipartFile; import java.io.IOException; public interface PhotoUploadService { - FaceDetectRequestDto savePhotos(MultipartFile photoUploadRequestDto) throws IOException; + FaceDetectRequestDto savePhotos(User userId, MultipartFile photoUploadRequestDto) throws IOException; } From ae75f31ebd771d4c915299aaafa848b01dd3b829 Mon Sep 17 00:00:00 2001 From: ghvfgfcht Date: Fri, 3 May 2024 22:03:51 +0900 Subject: [PATCH 30/30] =?UTF-8?q?:sparkles:=20FEAT.=20savePhotos=20?= =?UTF-8?q?=EB=A9=94=EC=84=9C=EB=93=9C=20=EB=A7=A4=EA=B0=9C=EB=B3=80?= =?UTF-8?q?=EC=88=98=20user=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tbd/domain/faceSwap/service/PhotoUploadServiceImpl.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/fairytale/tbd/domain/faceSwap/service/PhotoUploadServiceImpl.java b/src/main/java/fairytale/tbd/domain/faceSwap/service/PhotoUploadServiceImpl.java index 89a3c69..dcb2d8d 100644 --- a/src/main/java/fairytale/tbd/domain/faceSwap/service/PhotoUploadServiceImpl.java +++ b/src/main/java/fairytale/tbd/domain/faceSwap/service/PhotoUploadServiceImpl.java @@ -3,6 +3,7 @@ import fairytale.tbd.domain.faceSwap.entity.Uuid; import fairytale.tbd.domain.faceSwap.repository.UuidRepository; import fairytale.tbd.domain.faceSwap.web.dto.FaceDetectRequestDto; +import fairytale.tbd.domain.user.entity.User; import fairytale.tbd.global.aws.s3.AmazonS3Manager; import org.springframework.transaction.annotation.Transactional; import lombok.RequiredArgsConstructor; @@ -24,7 +25,7 @@ public class PhotoUploadServiceImpl implements PhotoUploadService { @Override @Transactional - public FaceDetectRequestDto savePhotos(MultipartFile file) throws IOException { + public FaceDetectRequestDto savePhotos(User userId, MultipartFile file) throws IOException { String imgURL = ""; String uuid = UUID.randomUUID().toString(); @@ -42,4 +43,4 @@ public FaceDetectRequestDto savePhotos(MultipartFile file) throws IOException { return faceDetectRequestDto; } -} +} \ No newline at end of file