From 24fca0601ad739fccc073210356f73d006e50ebd Mon Sep 17 00:00:00 2001 From: alsrudrl1220 Date: Sat, 25 May 2024 20:28:49 +0900 Subject: [PATCH 01/28] =?UTF-8?q?[feat]=20BookContentEntity=20Builder=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=EC=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/FTIsland/BE/entity/BookContentEntity.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/BE/src/main/java/com/FTIsland/BE/entity/BookContentEntity.java b/BE/src/main/java/com/FTIsland/BE/entity/BookContentEntity.java index adccdd8..e4c0d1e 100644 --- a/BE/src/main/java/com/FTIsland/BE/entity/BookContentEntity.java +++ b/BE/src/main/java/com/FTIsland/BE/entity/BookContentEntity.java @@ -2,13 +2,16 @@ import com.FTIsland.BE.dto.BookContentDTO; import jakarta.persistence.*; +import lombok.Builder; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.Setter; @Entity @Setter @Getter @Table(name = "bookcontent") +@NoArgsConstructor public class BookContentEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @@ -40,4 +43,12 @@ public static BookContentEntity toBookContentEntity(BookContentDTO bookContentDT return bookContentEntity; } + + @Builder + public BookContentEntity(Integer bookId, Integer page, String korContents, String image){ + this.bookId = bookId; + this.page = page; + this.korContents = korContents; + this.image = image; + } } From bce41afac1f60f309d7479f8fe760320fedfd8ec Mon Sep 17 00:00:00 2001 From: alsrudrl1220 Date: Sat, 25 May 2024 20:30:40 +0900 Subject: [PATCH 02/28] =?UTF-8?q?[feat]=20=EC=A3=BC=EC=84=9D=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EC=9B=90=EB=9E=98=20toEntity=20=EC=9E=84=EC=8B=9C?= =?UTF-8?q?=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FTIsland/BE/entity/BookContentEntity.java | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/BE/src/main/java/com/FTIsland/BE/entity/BookContentEntity.java b/BE/src/main/java/com/FTIsland/BE/entity/BookContentEntity.java index e4c0d1e..8431cd6 100644 --- a/BE/src/main/java/com/FTIsland/BE/entity/BookContentEntity.java +++ b/BE/src/main/java/com/FTIsland/BE/entity/BookContentEntity.java @@ -33,16 +33,17 @@ public class BookContentEntity { @Column private String image; - public static BookContentEntity toBookContentEntity(BookContentDTO bookContentDTO) { - BookContentEntity bookContentEntity = new BookContentEntity(); - bookContentEntity.setBookId(bookContentDTO.getBookId()); - bookContentEntity.setPage(bookContentDTO.getPage()); - bookContentEntity.setKorContents(bookContentDTO.getKorContents()); //나중에 수정 - bookContentEntity.setImage(bookContentDTO.getImage()); - - return bookContentEntity; - - } + // 빌더 패턴 정리 끝나면 삭제 +// public static BookContentEntity toBookContentEntity(BookContentDTO bookContentDTO) { +// BookContentEntity bookContentEntity = new BookContentEntity(); +// bookContentEntity.setBookId(bookContentDTO.getBookId()); +// bookContentEntity.setPage(bookContentDTO.getPage()); +// bookContentEntity.setKorContents(bookContentDTO.getKorContents()); //나중에 수정 +// bookContentEntity.setImage(bookContentDTO.getImage()); +// +// return bookContentEntity; +// +// } @Builder public BookContentEntity(Integer bookId, Integer page, String korContents, String image){ From fc7dde2538b10d3fc44f2be362ee6c3e213e9116 Mon Sep 17 00:00:00 2001 From: alsrudrl1220 Date: Sat, 25 May 2024 20:40:16 +0900 Subject: [PATCH 03/28] =?UTF-8?q?[feat]=20Builder=20=EC=9D=B4=EC=9A=A9?= =?UTF-8?q?=ED=95=9C=20toEntity()=EB=A5=BC=20DTO=EC=97=90=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 --- .../java/com/FTIsland/BE/dto/BookContentDTO.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/BE/src/main/java/com/FTIsland/BE/dto/BookContentDTO.java b/BE/src/main/java/com/FTIsland/BE/dto/BookContentDTO.java index 023107a..8ca030c 100644 --- a/BE/src/main/java/com/FTIsland/BE/dto/BookContentDTO.java +++ b/BE/src/main/java/com/FTIsland/BE/dto/BookContentDTO.java @@ -1,10 +1,7 @@ package com.FTIsland.BE.dto; import com.FTIsland.BE.entity.BookContentEntity; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.ToString; +import lombok.*; import java.util.List; @@ -23,6 +20,7 @@ public class BookContentDTO { private List vocaList; private String image; + @Builder public BookContentDTO(Integer bookId, Integer page, String mainLan, String subLan, String korContents, String mainContents, String subContents, String image){ this.bookId = bookId; this.page = page; @@ -34,6 +32,15 @@ public BookContentDTO(Integer bookId, Integer page, String mainLan, String subLa this.image = image; } + public BookContentEntity toBookContentEntity(){ + return BookContentEntity.builder() + .bookId(bookId) + .page(page) + .korContents(korContents) + .image(image) + .build(); + } + // public static BookContentDTO toBookContentDTO(BookContentEntity bookContentEntity) { // BookContentDTO bookContentDTO = new BookContentDTO(); // bookContentDTO.setBookId(bookContentEntity.getBookId()); From a34dd09d7552e0df46f9be630c5319896f31ff7e Mon Sep 17 00:00:00 2001 From: alsrudrl1220 Date: Sat, 25 May 2024 20:54:50 +0900 Subject: [PATCH 04/28] =?UTF-8?q?[fix]=20Builder=20=ED=8C=A8=ED=84=B4=20?= =?UTF-8?q?=EC=9D=B4=EC=9A=A9=ED=95=B4=EC=84=9C=20BookContentDTO=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=ED=95=98=EB=8A=94=20=EC=BD=94=EB=93=9C?= =?UTF-8?q?=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BE/service/BookContentService.java | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/BE/src/main/java/com/FTIsland/BE/service/BookContentService.java b/BE/src/main/java/com/FTIsland/BE/service/BookContentService.java index db6a244..9ec61fb 100644 --- a/BE/src/main/java/com/FTIsland/BE/service/BookContentService.java +++ b/BE/src/main/java/com/FTIsland/BE/service/BookContentService.java @@ -126,16 +126,17 @@ public List findByBookId(BookContentDTO requestDTO) { // DTO List에 추가 - BookContentDTO bookContentDTO = new BookContentDTO( - ent.getBookId(), - ent.getPage(), - selectedMainLanguage, - selectedSubLanguage, - ent.getKorContents(), - mainText, - subText, - ent.getImage() - ); + BookContentDTO bookContentDTO = new BookContentDTO().builder() + .bookId(ent.getBookId()) + .page(ent.getPage()) + .mainLan(selectedMainLanguage) + .subLan(selectedSubLanguage) + .korContents(ent.getKorContents()) + .mainContents(mainText) + .subContents(subText) + .image(ent.getImage()) + .build(); + bookContentDTO.setVocaList(contentVocaDTOS); bookContentDTOS.add(bookContentDTO); } From 954fb291ab942c894273901757447ec0967e61df Mon Sep 17 00:00:00 2001 From: alsrudrl1220 Date: Sat, 25 May 2024 22:14:19 +0900 Subject: [PATCH 05/28] =?UTF-8?q?[fix]=20bookContent=20package=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20=EB=B0=8F=20controller=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BE/{ => bookContent}/controller/BookContentController.java | 3 +-- BE/src/main/java/com/FTIsland/BE/entity/BookContentEntity.java | 2 +- .../main/java/com/FTIsland/BE/service/BookContentService.java | 2 -- 3 files changed, 2 insertions(+), 5 deletions(-) rename BE/src/main/java/com/FTIsland/BE/{ => bookContent}/controller/BookContentController.java (90%) diff --git a/BE/src/main/java/com/FTIsland/BE/controller/BookContentController.java b/BE/src/main/java/com/FTIsland/BE/bookContent/controller/BookContentController.java similarity index 90% rename from BE/src/main/java/com/FTIsland/BE/controller/BookContentController.java rename to BE/src/main/java/com/FTIsland/BE/bookContent/controller/BookContentController.java index 4822e2c..6cb82e5 100644 --- a/BE/src/main/java/com/FTIsland/BE/controller/BookContentController.java +++ b/BE/src/main/java/com/FTIsland/BE/bookContent/controller/BookContentController.java @@ -1,7 +1,6 @@ -package com.FTIsland.BE.controller; +package com.FTIsland.BE.bookContent.controller; import com.FTIsland.BE.dto.BookContentDTO; -import com.FTIsland.BE.dto.BookInfoDTO; import com.FTIsland.BE.service.BookContentService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/BE/src/main/java/com/FTIsland/BE/entity/BookContentEntity.java b/BE/src/main/java/com/FTIsland/BE/entity/BookContentEntity.java index 8431cd6..b139dae 100644 --- a/BE/src/main/java/com/FTIsland/BE/entity/BookContentEntity.java +++ b/BE/src/main/java/com/FTIsland/BE/entity/BookContentEntity.java @@ -33,7 +33,7 @@ public class BookContentEntity { @Column private String image; - // 빌더 패턴 정리 끝나면 삭제 + // 빌더 패턴 정리 끝나면 삭제 + setter 삭제 // public static BookContentEntity toBookContentEntity(BookContentDTO bookContentDTO) { // BookContentEntity bookContentEntity = new BookContentEntity(); // bookContentEntity.setBookId(bookContentDTO.getBookId()); diff --git a/BE/src/main/java/com/FTIsland/BE/service/BookContentService.java b/BE/src/main/java/com/FTIsland/BE/service/BookContentService.java index 9ec61fb..260aad0 100644 --- a/BE/src/main/java/com/FTIsland/BE/service/BookContentService.java +++ b/BE/src/main/java/com/FTIsland/BE/service/BookContentService.java @@ -123,8 +123,6 @@ public List findByBookId(BookContentDTO requestDTO) { contentVocaDTOS.add(contentVocaDTO); } - - // DTO List에 추가 BookContentDTO bookContentDTO = new BookContentDTO().builder() .bookId(ent.getBookId()) From 7f7f410697bd2b841aa56fbd83def8ff0c862a77 Mon Sep 17 00:00:00 2001 From: alsrudrl1220 Date: Sat, 25 May 2024 22:23:46 +0900 Subject: [PATCH 06/28] =?UTF-8?q?[feat]=20BookContent=EC=97=90=20requestDT?= =?UTF-8?q?O=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bookContent/dto/BookContentRequest.java | 27 +++++++++++++++++++ .../bookContent/dto/BookContentResponse.java | 4 +++ 2 files changed, 31 insertions(+) create mode 100644 BE/src/main/java/com/FTIsland/BE/bookContent/dto/BookContentRequest.java create mode 100644 BE/src/main/java/com/FTIsland/BE/bookContent/dto/BookContentResponse.java diff --git a/BE/src/main/java/com/FTIsland/BE/bookContent/dto/BookContentRequest.java b/BE/src/main/java/com/FTIsland/BE/bookContent/dto/BookContentRequest.java new file mode 100644 index 0000000..2c2a906 --- /dev/null +++ b/BE/src/main/java/com/FTIsland/BE/bookContent/dto/BookContentRequest.java @@ -0,0 +1,27 @@ +package com.FTIsland.BE.bookContent.dto; + +import com.FTIsland.BE.dto.ContentVocaDTO; +import com.FTIsland.BE.entity.BookContentEntity; +import lombok.*; + +import java.util.List; + +@Getter +@Setter +@NoArgsConstructor +@ToString +public class BookContentRequest { + private Integer bookId; // BookInfo에 title 있음. + private String mainLan; + private String subLan; + + @Builder + public BookContentRequest(Integer bookId, String mainLan, String subLan){ + this.bookId = bookId; + this.mainLan = mainLan; + this.subLan = subLan; + } +} + + + diff --git a/BE/src/main/java/com/FTIsland/BE/bookContent/dto/BookContentResponse.java b/BE/src/main/java/com/FTIsland/BE/bookContent/dto/BookContentResponse.java new file mode 100644 index 0000000..7e5773c --- /dev/null +++ b/BE/src/main/java/com/FTIsland/BE/bookContent/dto/BookContentResponse.java @@ -0,0 +1,4 @@ +package com.FTIsland.BE.bookContent.dto; + +public class BookContentResponse { +} From e61efa58f474b9eaeb0792cae3ef278fcdf341cf Mon Sep 17 00:00:00 2001 From: alsrudrl1220 Date: Sat, 25 May 2024 22:25:21 +0900 Subject: [PATCH 07/28] =?UTF-8?q?[fix]=20Controller=EC=97=90=EC=84=9C=20DT?= =?UTF-8?q?O=20->=20Request=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BE/bookContent/controller/BookContentController.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/BE/src/main/java/com/FTIsland/BE/bookContent/controller/BookContentController.java b/BE/src/main/java/com/FTIsland/BE/bookContent/controller/BookContentController.java index 6cb82e5..b675fa3 100644 --- a/BE/src/main/java/com/FTIsland/BE/bookContent/controller/BookContentController.java +++ b/BE/src/main/java/com/FTIsland/BE/bookContent/controller/BookContentController.java @@ -1,5 +1,6 @@ package com.FTIsland.BE.bookContent.controller; +import com.FTIsland.BE.bookContent.dto.BookContentRequest; import com.FTIsland.BE.dto.BookContentDTO; import com.FTIsland.BE.service.BookContentService; import lombok.RequiredArgsConstructor; @@ -20,8 +21,8 @@ public void saveBookContent(){ // DB에 동화 정보 저장 } @PostMapping("/book/content") - public List getBookInfoById(@RequestBody BookContentDTO bookContentDTO){ - return bookContentService.findByBookId(bookContentDTO); // 해당 id의 동화 내용 list + public List getBookInfoById(@RequestBody BookContentRequest bookContentRequest){ + return bookContentService.findByBookId(bookContentRequest); // 해당 id의 동화 내용 list } } From 163e2e3030f86dff47b2826d1d1f463f73d9dbc8 Mon Sep 17 00:00:00 2001 From: alsrudrl1220 Date: Sat, 25 May 2024 22:37:18 +0900 Subject: [PATCH 08/28] =?UTF-8?q?[fix]=20requestDTO=20service=EC=97=90=20?= =?UTF-8?q?=EB=B0=98=EC=98=81=20+=20=EB=B6=88=ED=95=84=EC=9A=94=ED=95=9C?= =?UTF-8?q?=20=EC=BD=94=EB=93=9C=20=EA=B0=84=EA=B2=B0=ED=95=98=EA=B2=8C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BE/service/BookContentService.java | 32 ++++++++----------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/BE/src/main/java/com/FTIsland/BE/service/BookContentService.java b/BE/src/main/java/com/FTIsland/BE/service/BookContentService.java index 260aad0..bfccd83 100644 --- a/BE/src/main/java/com/FTIsland/BE/service/BookContentService.java +++ b/BE/src/main/java/com/FTIsland/BE/service/BookContentService.java @@ -1,5 +1,6 @@ package com.FTIsland.BE.service; +import com.FTIsland.BE.bookContent.dto.BookContentRequest; import com.FTIsland.BE.dto.BookContentDTO; import com.FTIsland.BE.dto.BookInfoDTO; import com.FTIsland.BE.dto.ContentVocaDTO; @@ -73,33 +74,30 @@ public void save() { // 동화 내용 저장 (임시로 만든 method) } } - public List findByBookId(BookContentDTO requestDTO) { + public List findByBookId(BookContentRequest requestDTO) { + // bookId를 통한 BookContentEntity 조회 Integer bookId = requestDTO.getBookId(); - List byBookId = bookContentRepository.findByBookId(bookId); - List bookContentDTOS = new ArrayList<>(); - String selectedMainLanguage = "ko"; - String selectedSubLanguage = "ko"; + // return값 정의 + List bookContentDTOS = new ArrayList<>(); + // 번역 로직 - 한 페이지(한 줄)씩 번역이라서 for문 사용 for(BookContentEntity ent : byBookId){ - // 번역 로직 - // 1. 주, 보조 언어 텍스트 둘 다 한국어를 기본으로 설정 + // 1. 주, 보조 언어 텍스트(내용 한 줄) 둘 다 한국어를 기본으로 설정 String mainText = ent.getKorContents(); String subText = ent.getKorContents(); // 2. 요청한 언어에 맞게 번역 if (!requestDTO.getMainLan().equals("ko")){ // 주 언어 한국어가 아니라면 번역 - selectedMainLanguage = requestDTO.getMainLan(); - mainText = translationService.test(selectedMainLanguage, mainText); + mainText = translationService.test(requestDTO.getMainLan(), mainText); } if (!requestDTO.getSubLan().equals("ko")){ // 보조 언어가 한국어가 아니라면 번역 - selectedSubLanguage = requestDTO.getSubLan(); - subText = translationService.test(selectedSubLanguage, subText); + subText = translationService.test(requestDTO.getSubLan(), subText); } - // 해당 페이지의 vocaId, word, subWord 가져오기 + // 3. 해당 페이지의 vocaId, word, subWord 가져오기 var vocaEntities = vocaRepository.findByBookIdAndPage(ent.getBookId(), ent.getPage()); List contentVocaDTOS = new ArrayList<>(); @@ -111,12 +109,10 @@ public List findByBookId(BookContentDTO requestDTO) { String subWord = entity.getWord(); if (!requestDTO.getMainLan().equals("ko")){ // 주 언어 한국어가 아니라면 번역 - selectedMainLanguage = requestDTO.getMainLan(); - mainWord = translationService.test(selectedMainLanguage, mainWord); + mainWord = translationService.test(requestDTO.getMainLan(), mainWord); } if (!requestDTO.getSubLan().equals("ko")){ // 보조 언어가 한국어가 아니라면 번역 - selectedSubLanguage = requestDTO.getSubLan(); - subWord = translationService.test(selectedSubLanguage, subWord); + subWord = translationService.test(requestDTO.getSubLan(), subWord); } contentVocaDTO.setWord(mainWord); contentVocaDTO.setSubWord(subWord); @@ -127,8 +123,8 @@ public List findByBookId(BookContentDTO requestDTO) { BookContentDTO bookContentDTO = new BookContentDTO().builder() .bookId(ent.getBookId()) .page(ent.getPage()) - .mainLan(selectedMainLanguage) - .subLan(selectedSubLanguage) + .mainLan(requestDTO.getMainLan()) + .subLan(requestDTO.getSubLan()) .korContents(ent.getKorContents()) .mainContents(mainText) .subContents(subText) From c4242670d5e8bf47c31c97d841ae0d21457b3e2b Mon Sep 17 00:00:00 2001 From: alsrudrl1220 Date: Sat, 25 May 2024 22:39:53 +0900 Subject: [PATCH 09/28] =?UTF-8?q?[feat]=20BookContent=EC=97=90=20ResponseD?= =?UTF-8?q?TO=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bookContent/dto/BookContentResponse.java | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/BE/src/main/java/com/FTIsland/BE/bookContent/dto/BookContentResponse.java b/BE/src/main/java/com/FTIsland/BE/bookContent/dto/BookContentResponse.java index 7e5773c..495fc5e 100644 --- a/BE/src/main/java/com/FTIsland/BE/bookContent/dto/BookContentResponse.java +++ b/BE/src/main/java/com/FTIsland/BE/bookContent/dto/BookContentResponse.java @@ -1,4 +1,48 @@ package com.FTIsland.BE.bookContent.dto; +import com.FTIsland.BE.dto.ContentVocaDTO; +import com.FTIsland.BE.entity.BookContentEntity; +import lombok.*; + +import java.util.List; + +@Getter +@Setter +@NoArgsConstructor +@ToString public class BookContentResponse { + private Integer bookId; //bookName도 추가? + private Integer page; + private String mainLan; + private String subLan; + private String korContents; + private String mainContents; + private String subContents; + private List vocaList; + private String image; + + @Builder + public BookContentResponse(Integer bookId, Integer page, String mainLan, String subLan, String korContents, String mainContents, String subContents, String image){ + this.bookId = bookId; + this.page = page; + this.mainLan = mainLan; + this.subLan = subLan; + this.korContents = korContents; + this.mainContents = mainContents; + this.subContents = subContents; + this.image = image; + } + + public BookContentEntity toBookContentEntity(){ + return BookContentEntity.builder() + .bookId(bookId) + .page(page) + .korContents(korContents) + .image(image) + .build(); + } + } + + + From a77fd2580c3b108ec228cd836142880f510ffddc Mon Sep 17 00:00:00 2001 From: alsrudrl1220 Date: Sat, 25 May 2024 22:41:40 +0900 Subject: [PATCH 10/28] =?UTF-8?q?[fix]=20Controller=EC=97=90=EC=84=9C=20Li?= =?UTF-8?q?st=20->=20Response=20=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BE/bookContent/controller/BookContentController.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/BE/src/main/java/com/FTIsland/BE/bookContent/controller/BookContentController.java b/BE/src/main/java/com/FTIsland/BE/bookContent/controller/BookContentController.java index b675fa3..eb1f8f9 100644 --- a/BE/src/main/java/com/FTIsland/BE/bookContent/controller/BookContentController.java +++ b/BE/src/main/java/com/FTIsland/BE/bookContent/controller/BookContentController.java @@ -1,6 +1,7 @@ package com.FTIsland.BE.bookContent.controller; import com.FTIsland.BE.bookContent.dto.BookContentRequest; +import com.FTIsland.BE.bookContent.dto.BookContentResponse; import com.FTIsland.BE.dto.BookContentDTO; import com.FTIsland.BE.service.BookContentService; import lombok.RequiredArgsConstructor; @@ -21,7 +22,7 @@ public void saveBookContent(){ // DB에 동화 정보 저장 } @PostMapping("/book/content") - public List getBookInfoById(@RequestBody BookContentRequest bookContentRequest){ + public List getBookInfoById(@RequestBody BookContentRequest bookContentRequest){ return bookContentService.findByBookId(bookContentRequest); // 해당 id의 동화 내용 list } From 93628b8525acf0aa3992a4becef8f82d34eb642b Mon Sep 17 00:00:00 2001 From: alsrudrl1220 Date: Sat, 25 May 2024 22:44:58 +0900 Subject: [PATCH 11/28] =?UTF-8?q?[fix]=20responseDTO=20service=EC=97=90=20?= =?UTF-8?q?=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FTIsland/BE/controller/QuizController.java | 2 +- .../FTIsland/BE/service/BookContentService.java | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/BE/src/main/java/com/FTIsland/BE/controller/QuizController.java b/BE/src/main/java/com/FTIsland/BE/controller/QuizController.java index 3357c09..6e307a5 100644 --- a/BE/src/main/java/com/FTIsland/BE/controller/QuizController.java +++ b/BE/src/main/java/com/FTIsland/BE/controller/QuizController.java @@ -48,7 +48,7 @@ public List getQuiz(@RequestBody QuizDTO quizDTO){ bookContentDTO.setMainLan(quizDTO.getMainLan()); bookContentDTO.setSubLan(quizDTO.getSubLan()); // 2. content List 조회 - List bookContentDTOS = bookContentService.findByBookId(bookContentDTO); + List bookContentDTOS = bookContentService.findByBookId(bookContentDTO); // **** bookContentDTO : BookContentRequest 형식으로 변경 필요!! **** List bookContentList = new ArrayList<>(); for(BookContentDTO dto : bookContentDTOS){ bookContentList.add(dto.getKorContents()); diff --git a/BE/src/main/java/com/FTIsland/BE/service/BookContentService.java b/BE/src/main/java/com/FTIsland/BE/service/BookContentService.java index bfccd83..9c54d46 100644 --- a/BE/src/main/java/com/FTIsland/BE/service/BookContentService.java +++ b/BE/src/main/java/com/FTIsland/BE/service/BookContentService.java @@ -1,6 +1,7 @@ package com.FTIsland.BE.service; import com.FTIsland.BE.bookContent.dto.BookContentRequest; +import com.FTIsland.BE.bookContent.dto.BookContentResponse; import com.FTIsland.BE.dto.BookContentDTO; import com.FTIsland.BE.dto.BookInfoDTO; import com.FTIsland.BE.dto.ContentVocaDTO; @@ -74,13 +75,13 @@ public void save() { // 동화 내용 저장 (임시로 만든 method) } } - public List findByBookId(BookContentRequest requestDTO) { + public List findByBookId(BookContentRequest requestDTO) { // bookId를 통한 BookContentEntity 조회 Integer bookId = requestDTO.getBookId(); List byBookId = bookContentRepository.findByBookId(bookId); // return값 정의 - List bookContentDTOS = new ArrayList<>(); + List bookContentResponses = new ArrayList<>(); // 번역 로직 - 한 페이지(한 줄)씩 번역이라서 for문 사용 for(BookContentEntity ent : byBookId){ @@ -120,7 +121,7 @@ public List findByBookId(BookContentRequest requestDTO) { } // DTO List에 추가 - BookContentDTO bookContentDTO = new BookContentDTO().builder() + BookContentResponse bookContentResponse = new BookContentResponse().builder() .bookId(ent.getBookId()) .page(ent.getPage()) .mainLan(requestDTO.getMainLan()) @@ -131,13 +132,13 @@ public List findByBookId(BookContentRequest requestDTO) { .image(ent.getImage()) .build(); - bookContentDTO.setVocaList(contentVocaDTOS); - bookContentDTOS.add(bookContentDTO); + bookContentResponse.setVocaList(contentVocaDTOS); + bookContentResponses.add(bookContentResponse); } // page 순으로 정렬 - bookContentDTOS = bookContentDTOS.stream().sorted(Comparator.comparing(BookContentDTO::getPage)).collect(Collectors.toList()); + bookContentResponses = bookContentResponses.stream().sorted(Comparator.comparing(BookContentResponse::getPage)).collect(Collectors.toList()); - return bookContentDTOS; + return bookContentResponses; } } From 1190d3b4050dac198ac6308474cf41374ddd1633 Mon Sep 17 00:00:00 2001 From: alsrudrl1220 Date: Sat, 25 May 2024 22:48:48 +0900 Subject: [PATCH 12/28] =?UTF-8?q?[fix]=20entity=20package=20=EC=98=AE?= =?UTF-8?q?=EA=B8=B0=EA=B8=B0=20+=20setter=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BE/bookContent/dto/BookContentRequest.java | 4 ---- .../BE/bookContent/dto/BookContentResponse.java | 2 +- .../entity/BookContentEntity.java | 15 +-------------- .../java/com/FTIsland/BE/dto/BookContentDTO.java | 2 +- .../BE/repository/BookContentRepository.java | 2 +- .../FTIsland/BE/service/BookContentService.java | 7 +------ 6 files changed, 5 insertions(+), 27 deletions(-) rename BE/src/main/java/com/FTIsland/BE/{ => bookContent}/entity/BookContentEntity.java (58%) diff --git a/BE/src/main/java/com/FTIsland/BE/bookContent/dto/BookContentRequest.java b/BE/src/main/java/com/FTIsland/BE/bookContent/dto/BookContentRequest.java index 2c2a906..1c03be1 100644 --- a/BE/src/main/java/com/FTIsland/BE/bookContent/dto/BookContentRequest.java +++ b/BE/src/main/java/com/FTIsland/BE/bookContent/dto/BookContentRequest.java @@ -1,11 +1,7 @@ package com.FTIsland.BE.bookContent.dto; -import com.FTIsland.BE.dto.ContentVocaDTO; -import com.FTIsland.BE.entity.BookContentEntity; import lombok.*; -import java.util.List; - @Getter @Setter @NoArgsConstructor diff --git a/BE/src/main/java/com/FTIsland/BE/bookContent/dto/BookContentResponse.java b/BE/src/main/java/com/FTIsland/BE/bookContent/dto/BookContentResponse.java index 495fc5e..3e4c68c 100644 --- a/BE/src/main/java/com/FTIsland/BE/bookContent/dto/BookContentResponse.java +++ b/BE/src/main/java/com/FTIsland/BE/bookContent/dto/BookContentResponse.java @@ -1,7 +1,7 @@ package com.FTIsland.BE.bookContent.dto; import com.FTIsland.BE.dto.ContentVocaDTO; -import com.FTIsland.BE.entity.BookContentEntity; +import com.FTIsland.BE.bookContent.entity.BookContentEntity; import lombok.*; import java.util.List; diff --git a/BE/src/main/java/com/FTIsland/BE/entity/BookContentEntity.java b/BE/src/main/java/com/FTIsland/BE/bookContent/entity/BookContentEntity.java similarity index 58% rename from BE/src/main/java/com/FTIsland/BE/entity/BookContentEntity.java rename to BE/src/main/java/com/FTIsland/BE/bookContent/entity/BookContentEntity.java index b139dae..3f4dee5 100644 --- a/BE/src/main/java/com/FTIsland/BE/entity/BookContentEntity.java +++ b/BE/src/main/java/com/FTIsland/BE/bookContent/entity/BookContentEntity.java @@ -1,4 +1,4 @@ -package com.FTIsland.BE.entity; +package com.FTIsland.BE.bookContent.entity; import com.FTIsland.BE.dto.BookContentDTO; import jakarta.persistence.*; @@ -8,7 +8,6 @@ import lombok.Setter; @Entity -@Setter @Getter @Table(name = "bookcontent") @NoArgsConstructor @@ -33,18 +32,6 @@ public class BookContentEntity { @Column private String image; - // 빌더 패턴 정리 끝나면 삭제 + setter 삭제 -// public static BookContentEntity toBookContentEntity(BookContentDTO bookContentDTO) { -// BookContentEntity bookContentEntity = new BookContentEntity(); -// bookContentEntity.setBookId(bookContentDTO.getBookId()); -// bookContentEntity.setPage(bookContentDTO.getPage()); -// bookContentEntity.setKorContents(bookContentDTO.getKorContents()); //나중에 수정 -// bookContentEntity.setImage(bookContentDTO.getImage()); -// -// return bookContentEntity; -// -// } - @Builder public BookContentEntity(Integer bookId, Integer page, String korContents, String image){ this.bookId = bookId; diff --git a/BE/src/main/java/com/FTIsland/BE/dto/BookContentDTO.java b/BE/src/main/java/com/FTIsland/BE/dto/BookContentDTO.java index 8ca030c..c6e14fa 100644 --- a/BE/src/main/java/com/FTIsland/BE/dto/BookContentDTO.java +++ b/BE/src/main/java/com/FTIsland/BE/dto/BookContentDTO.java @@ -1,6 +1,6 @@ package com.FTIsland.BE.dto; -import com.FTIsland.BE.entity.BookContentEntity; +import com.FTIsland.BE.bookContent.entity.BookContentEntity; import lombok.*; import java.util.List; diff --git a/BE/src/main/java/com/FTIsland/BE/repository/BookContentRepository.java b/BE/src/main/java/com/FTIsland/BE/repository/BookContentRepository.java index 83ae640..63030ae 100644 --- a/BE/src/main/java/com/FTIsland/BE/repository/BookContentRepository.java +++ b/BE/src/main/java/com/FTIsland/BE/repository/BookContentRepository.java @@ -1,6 +1,6 @@ package com.FTIsland.BE.repository; -import com.FTIsland.BE.entity.BookContentEntity; +import com.FTIsland.BE.bookContent.entity.BookContentEntity; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; diff --git a/BE/src/main/java/com/FTIsland/BE/service/BookContentService.java b/BE/src/main/java/com/FTIsland/BE/service/BookContentService.java index 9c54d46..ffe3849 100644 --- a/BE/src/main/java/com/FTIsland/BE/service/BookContentService.java +++ b/BE/src/main/java/com/FTIsland/BE/service/BookContentService.java @@ -3,22 +3,17 @@ import com.FTIsland.BE.bookContent.dto.BookContentRequest; import com.FTIsland.BE.bookContent.dto.BookContentResponse; import com.FTIsland.BE.dto.BookContentDTO; -import com.FTIsland.BE.dto.BookInfoDTO; import com.FTIsland.BE.dto.ContentVocaDTO; -import com.FTIsland.BE.entity.BookContentEntity; -import com.FTIsland.BE.entity.BookInfoEntity; +import com.FTIsland.BE.bookContent.entity.BookContentEntity; import com.FTIsland.BE.entity.VocaEntity; import com.FTIsland.BE.repository.BookContentRepository; -import com.FTIsland.BE.repository.BookInfoRepository; import com.FTIsland.BE.repository.VocaRepository; -import com.google.cloud.translate.*; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.Comparator; import java.util.List; -import java.util.Optional; import java.util.stream.Collectors; @Service From 11db4f8d9200046bd4fa2579885144cb00c6e7a7 Mon Sep 17 00:00:00 2001 From: alsrudrl1220 Date: Sat, 25 May 2024 22:49:53 +0900 Subject: [PATCH 13/28] =?UTF-8?q?[fix]=20repository=20package=20=EC=98=AE?= =?UTF-8?q?=EA=B8=B0=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BE/{ => bookContent}/repository/BookContentRepository.java | 2 +- .../main/java/com/FTIsland/BE/service/BookContentService.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename BE/src/main/java/com/FTIsland/BE/{ => bookContent}/repository/BookContentRepository.java (90%) diff --git a/BE/src/main/java/com/FTIsland/BE/repository/BookContentRepository.java b/BE/src/main/java/com/FTIsland/BE/bookContent/repository/BookContentRepository.java similarity index 90% rename from BE/src/main/java/com/FTIsland/BE/repository/BookContentRepository.java rename to BE/src/main/java/com/FTIsland/BE/bookContent/repository/BookContentRepository.java index 63030ae..fd72e15 100644 --- a/BE/src/main/java/com/FTIsland/BE/repository/BookContentRepository.java +++ b/BE/src/main/java/com/FTIsland/BE/bookContent/repository/BookContentRepository.java @@ -1,4 +1,4 @@ -package com.FTIsland.BE.repository; +package com.FTIsland.BE.bookContent.repository; import com.FTIsland.BE.bookContent.entity.BookContentEntity; import org.springframework.data.jpa.repository.JpaRepository; diff --git a/BE/src/main/java/com/FTIsland/BE/service/BookContentService.java b/BE/src/main/java/com/FTIsland/BE/service/BookContentService.java index ffe3849..50eb002 100644 --- a/BE/src/main/java/com/FTIsland/BE/service/BookContentService.java +++ b/BE/src/main/java/com/FTIsland/BE/service/BookContentService.java @@ -6,7 +6,7 @@ import com.FTIsland.BE.dto.ContentVocaDTO; import com.FTIsland.BE.bookContent.entity.BookContentEntity; import com.FTIsland.BE.entity.VocaEntity; -import com.FTIsland.BE.repository.BookContentRepository; +import com.FTIsland.BE.bookContent.repository.BookContentRepository; import com.FTIsland.BE.repository.VocaRepository; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; From d9c3ec2fcfafb8d169bb5223fb57411c0031e9c0 Mon Sep 17 00:00:00 2001 From: alsrudrl1220 Date: Sat, 25 May 2024 22:52:13 +0900 Subject: [PATCH 14/28] =?UTF-8?q?[fix]=20service=20package=EB=A1=9C=20?= =?UTF-8?q?=EC=98=AE=EA=B8=B0=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BE/bookContent/controller/BookContentController.java | 3 +-- .../BE/{ => bookContent}/service/BookContentService.java | 3 ++- .../main/java/com/FTIsland/BE/controller/QuizController.java | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) rename BE/src/main/java/com/FTIsland/BE/{ => bookContent}/service/BookContentService.java (99%) diff --git a/BE/src/main/java/com/FTIsland/BE/bookContent/controller/BookContentController.java b/BE/src/main/java/com/FTIsland/BE/bookContent/controller/BookContentController.java index eb1f8f9..159cd46 100644 --- a/BE/src/main/java/com/FTIsland/BE/bookContent/controller/BookContentController.java +++ b/BE/src/main/java/com/FTIsland/BE/bookContent/controller/BookContentController.java @@ -2,8 +2,7 @@ import com.FTIsland.BE.bookContent.dto.BookContentRequest; import com.FTIsland.BE.bookContent.dto.BookContentResponse; -import com.FTIsland.BE.dto.BookContentDTO; -import com.FTIsland.BE.service.BookContentService; +import com.FTIsland.BE.bookContent.service.BookContentService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.*; diff --git a/BE/src/main/java/com/FTIsland/BE/service/BookContentService.java b/BE/src/main/java/com/FTIsland/BE/bookContent/service/BookContentService.java similarity index 99% rename from BE/src/main/java/com/FTIsland/BE/service/BookContentService.java rename to BE/src/main/java/com/FTIsland/BE/bookContent/service/BookContentService.java index 50eb002..d0722a1 100644 --- a/BE/src/main/java/com/FTIsland/BE/service/BookContentService.java +++ b/BE/src/main/java/com/FTIsland/BE/bookContent/service/BookContentService.java @@ -1,4 +1,4 @@ -package com.FTIsland.BE.service; +package com.FTIsland.BE.bookContent.service; import com.FTIsland.BE.bookContent.dto.BookContentRequest; import com.FTIsland.BE.bookContent.dto.BookContentResponse; @@ -8,6 +8,7 @@ import com.FTIsland.BE.entity.VocaEntity; import com.FTIsland.BE.bookContent.repository.BookContentRepository; import com.FTIsland.BE.repository.VocaRepository; +import com.FTIsland.BE.service.TranslationService; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; diff --git a/BE/src/main/java/com/FTIsland/BE/controller/QuizController.java b/BE/src/main/java/com/FTIsland/BE/controller/QuizController.java index 6e307a5..c522f0a 100644 --- a/BE/src/main/java/com/FTIsland/BE/controller/QuizController.java +++ b/BE/src/main/java/com/FTIsland/BE/controller/QuizController.java @@ -1,9 +1,9 @@ package com.FTIsland.BE.controller; +import com.FTIsland.BE.bookContent.service.BookContentService; import com.FTIsland.BE.dto.BookContentDTO; import com.FTIsland.BE.dto.ChatGptResponse; import com.FTIsland.BE.dto.QuizDTO; -import com.FTIsland.BE.entity.QuizEntity; import com.FTIsland.BE.service.*; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; From 42df7ea07e4c824a3c7e64932afb594d692b0398 Mon Sep 17 00:00:00 2001 From: alsrudrl1220 Date: Sat, 25 May 2024 23:00:12 +0900 Subject: [PATCH 15/28] =?UTF-8?q?[fix]=20quiz=20controller=EC=97=90?= =?UTF-8?q?=EC=93=B0=EC=9D=B4=EB=8A=94=20BookContentDTO=EA=B4=80=EB=A0=A8?= =?UTF-8?q?=20=EB=82=B4=EC=9A=A9=EC=9D=84=20response,=20request=EB=A1=9C?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BE/controller/QuizController.java | 35 ++++++++++--------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/BE/src/main/java/com/FTIsland/BE/controller/QuizController.java b/BE/src/main/java/com/FTIsland/BE/controller/QuizController.java index c522f0a..46284d6 100644 --- a/BE/src/main/java/com/FTIsland/BE/controller/QuizController.java +++ b/BE/src/main/java/com/FTIsland/BE/controller/QuizController.java @@ -1,7 +1,8 @@ package com.FTIsland.BE.controller; +import com.FTIsland.BE.bookContent.dto.BookContentRequest; +import com.FTIsland.BE.bookContent.dto.BookContentResponse; import com.FTIsland.BE.bookContent.service.BookContentService; -import com.FTIsland.BE.dto.BookContentDTO; import com.FTIsland.BE.dto.ChatGptResponse; import com.FTIsland.BE.dto.QuizDTO; import com.FTIsland.BE.service.*; @@ -40,40 +41,40 @@ public List getQuiz(@RequestBody QuizDTO quizDTO){ // 책 - 사용자 레벨 쌍의 조합으로 저장되어있는 생각해보기 질문이 있는지 확인 List savedQuiz = quizService.findQuiz(quizDTO.getBookId(), userLevel); - if(savedQuiz.isEmpty()){ // 없으면 새로 생성 후 저장 + if(savedQuiz.isEmpty()){ // A. 없으면 새로 생성 후 저장 // 책의 contents 조회 - 동화 제목만으로는 버전이 다를 수 있기 때문에 // 1. bookContentService의 findByBookId method를 쓰기 위해 QuizDTO -> BookContentDTO 변환 - BookContentDTO bookContentDTO = new BookContentDTO(); - bookContentDTO.setBookId(quizDTO.getBookId()); - bookContentDTO.setMainLan(quizDTO.getMainLan()); - bookContentDTO.setSubLan(quizDTO.getSubLan()); - // 2. content List 조회 - List bookContentDTOS = bookContentService.findByBookId(bookContentDTO); // **** bookContentDTO : BookContentRequest 형식으로 변경 필요!! **** - List bookContentList = new ArrayList<>(); - for(BookContentDTO dto : bookContentDTOS){ - bookContentList.add(dto.getKorContents()); + BookContentRequest bookContentRequest = new BookContentRequest(); + bookContentRequest.setBookId(quizDTO.getBookId()); + bookContentRequest.setMainLan(quizDTO.getMainLan()); + bookContentRequest.setSubLan(quizDTO.getSubLan()); + + // 2. Content list 조회 및 한 줄로 합쳐진 Content 생성 + List bookContentResponses = bookContentService.findByBookId(bookContentRequest); + List bookContentList = new ArrayList<>(); // 퀴즈의 기반이 될 내용 모음 list + for(BookContentResponse dto : bookContentResponses){ + bookContentList.add(dto.getKorContents()); // 조회한 내용 한 줄씩 추가 } - String bookContents = String.join(" ", bookContentList); - // System.out.println(bookContents); + String bookContents = String.join(" ", bookContentList); // list를 한 줄의 string으로 합치기. - // 퀴즈 생성 + // 3. AI로 퀴즈 생성 ChatGptResponse chatGptResponse = null; chatGptResponse = chatGptService.askQuestion(bookTitle, userLevel, bookContents); String threeQuiz = chatGptResponse.getChoices().get(0).getMessage().getContent(); // System.out.println(threeQuiz); - // 생성된 퀴즈 3개를 파싱하고 저장 + // 4. 생성된 퀴즈 3개를 파싱하고 저장 List quizs = quizService.makeQuiz(threeQuiz); quizService.saveQuiz(quizs, quizDTO.getBookId(), userLevel); - // 해당 퀴즈 리스트를 주언어, 서브언어로 번역 후 반환 + // 5. 해당 퀴즈 리스트를 주언어, 서브언어로 번역 후 반환 return quizService.translationQuiz( quizs, quizDTO.getMainLan(), quizDTO.getSubLan() ); - } else { // 있으면 조회한 질문을 그대로 번역 후 반환 + } else { // B. 있으면 조회한 질문을 그대로 번역 후 반환 return quizService.translationQuiz( savedQuiz, quizDTO.getMainLan(), From 74acfb51f4313223e0db258e50772e179f8c10f3 Mon Sep 17 00:00:00 2001 From: alsrudrl1220 Date: Sat, 25 May 2024 23:35:12 +0900 Subject: [PATCH 16/28] =?UTF-8?q?[feat]=20BookContent=20test=20code=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BE/build.gradle | 9 +++-- .../service/BookContentService.java | 5 +-- .../BE/bookContent/BookContentTest.java | 37 +++++++++++++++++++ 3 files changed, 44 insertions(+), 7 deletions(-) create mode 100644 BE/src/test/java/com/FTIsland/BE/bookContent/BookContentTest.java diff --git a/BE/build.gradle b/BE/build.gradle index 6081ba2..17b969e 100644 --- a/BE/build.gradle +++ b/BE/build.gradle @@ -23,7 +23,6 @@ repositories { dependencies { implementation 'org.springframework.boot:spring-boot-starter-data-jpa' - //implementation 'org.springframework.boot:spring-boot-starter-security' implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.springframework.boot:spring-boot-starter-validation' implementation 'org.springframework.boot:spring-boot-starter-oauth2-client' @@ -35,13 +34,17 @@ dependencies { implementation 'com.google.cloud:google-cloud-translate:2.34.0' implementation group: 'org.springframework.cloud', name: 'spring-cloud-gcp-starter', version: '1.2.5.RELEASE' implementation group: 'org.springframework.cloud', name: 'spring-cloud-gcp-storage', version: '1.2.5.RELEASE' - //testImplementation 'org.springframework.security:spring-security-test' + testImplementation 'org.springframework.security:spring-security-test' compileOnly 'org.projectlombok:lombok' annotationProcessor 'org.projectlombok:lombok' testCompileOnly 'org.projectlombok:lombok' testAnnotationProcessor 'org.projectlombok:lombok' + + // JUnit5 + testImplementation("org.junit.platform:junit-platform-launcher:1.5.2") + testImplementation("org.junit.jupiter:junit-jupiter:5.5.2") } tasks.named('test') { useJUnitPlatform() -} +} \ No newline at end of file diff --git a/BE/src/main/java/com/FTIsland/BE/bookContent/service/BookContentService.java b/BE/src/main/java/com/FTIsland/BE/bookContent/service/BookContentService.java index d0722a1..b47acae 100644 --- a/BE/src/main/java/com/FTIsland/BE/bookContent/service/BookContentService.java +++ b/BE/src/main/java/com/FTIsland/BE/bookContent/service/BookContentService.java @@ -26,7 +26,7 @@ public class BookContentService { public void save() { // 동화 내용 저장 (임시로 만든 method) ArrayList bookContentDTOS = new ArrayList<>(); - + // 금도끼 은도끼 저장 bookContentDTOS.add(new BookContentDTO(1, 0, "","","옛날 어느 마을에 정직하고 마음씨 착한 나무꾼이 살고 있었어요.","", "", "https://storage.googleapis.com/ft-island-image/goldsilver0.webp")); bookContentDTOS.add(new BookContentDTO(1, 1, "","","어느 날 나무꾼이 나무를 베고 있었는데, 도끼가 연못에 빠지고 말았어요.","", "", "https://storage.googleapis.com/ft-island-image/goldsilver1.webp")); @@ -62,9 +62,6 @@ public void save() { // 동화 내용 저장 (임시로 만든 method) bookContentDTOS.add(new BookContentDTO(2, 3, "","","친화력이 좋은 치치는 늑대와 바로 친해졌고, 함께 그림자 놀이를 하며 놀았어요.","", "", "https://storage.googleapis.com/ft-island-image/shadow2.webp")); bookContentDTOS.add(new BookContentDTO(2, 4, "","","여우를 사냥하려고 숲 주변에 있던 사냥꾼이, 치치와 늑대의 그림자를 보고 줄행랑 쳤답니다!","", "", "https://storage.googleapis.com/ft-island-image/shadow3.webp")); - - - for (BookContentDTO bookContentDTO : bookContentDTOS) { BookContentEntity bookContentEntity = BookContentEntity.toBookContentEntity(bookContentDTO); bookContentRepository.save(bookContentEntity); diff --git a/BE/src/test/java/com/FTIsland/BE/bookContent/BookContentTest.java b/BE/src/test/java/com/FTIsland/BE/bookContent/BookContentTest.java new file mode 100644 index 0000000..8200b00 --- /dev/null +++ b/BE/src/test/java/com/FTIsland/BE/bookContent/BookContentTest.java @@ -0,0 +1,37 @@ +package com.FTIsland.BE.bookContent; + +import com.FTIsland.BE.bookContent.dto.BookContentRequest; +import com.FTIsland.BE.bookContent.dto.BookContentResponse; +import com.FTIsland.BE.bookContent.service.BookContentService; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; + +import java.util.List; + +@SpringBootTest +public class BookContentTest { + @Autowired + private BookContentService bookContentService; + + @Test + @DisplayName("책 내용 리스트 반환 동작 테스트") + // 있는 책 요청 했을 때 + public void getBookContent() throws Exception{ + // given + BookContentRequest bookContentRequest = new BookContentRequest().builder() + .bookId(1) + .mainLan("ko") + .subLan("en") + .build(); + + // when + List bookContentResponse = bookContentService.findByBookId(bookContentRequest); + + // then + + } + + // 없는 책 요청 했을 때 +} From 0b59d851e7c388debd53ecb8ffd01b4f622dcd0b Mon Sep 17 00:00:00 2001 From: alsrudrl1220 Date: Sat, 25 May 2024 23:37:37 +0900 Subject: [PATCH 17/28] =?UTF-8?q?[feat]=20seed=20data=20=EA=B4=80=EB=A0=A8?= =?UTF-8?q?=20save()=EC=97=90=20=EC=A3=BC=EC=84=9D=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?-=20=EC=B6=94=ED=9B=84=20=EC=88=98=EC=A0=95=20=EC=98=88?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/FTIsland/BE/bookContent/service/BookContentService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BE/src/main/java/com/FTIsland/BE/bookContent/service/BookContentService.java b/BE/src/main/java/com/FTIsland/BE/bookContent/service/BookContentService.java index b47acae..0a5bde9 100644 --- a/BE/src/main/java/com/FTIsland/BE/bookContent/service/BookContentService.java +++ b/BE/src/main/java/com/FTIsland/BE/bookContent/service/BookContentService.java @@ -24,7 +24,7 @@ public class BookContentService { private final TranslationService translationService; private final VocaRepository vocaRepository; - public void save() { // 동화 내용 저장 (임시로 만든 method) + public void save() { // 동화 내용 저장 (임시로 만든 method) -> seed data 저장하는 구문 작성 후 메서드 삭제 예정 (toEntity 관련 에러 해결) ArrayList bookContentDTOS = new ArrayList<>(); // 금도끼 은도끼 저장 From f4f9d444bd2976ad9122d81c9565d18ccac29acf Mon Sep 17 00:00:00 2001 From: alsrudrl1220 Date: Thu, 30 May 2024 16:05:24 +0900 Subject: [PATCH 18/28] =?UTF-8?q?[feat]=20test=20code=20then=20=EB=B6=80?= =?UTF-8?q?=EB=B6=84=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FTIsland/BE/bookContent/service/BookContentService.java | 4 ++-- .../java/com/FTIsland/BE/bookContent/BookContentTest.java | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/BE/src/main/java/com/FTIsland/BE/bookContent/service/BookContentService.java b/BE/src/main/java/com/FTIsland/BE/bookContent/service/BookContentService.java index 0a5bde9..09ac904 100644 --- a/BE/src/main/java/com/FTIsland/BE/bookContent/service/BookContentService.java +++ b/BE/src/main/java/com/FTIsland/BE/bookContent/service/BookContentService.java @@ -24,7 +24,7 @@ public class BookContentService { private final TranslationService translationService; private final VocaRepository vocaRepository; - public void save() { // 동화 내용 저장 (임시로 만든 method) -> seed data 저장하는 구문 작성 후 메서드 삭제 예정 (toEntity 관련 에러 해결) + public void save() { // 동화 내용 저장 (임시로 만든 method) -> TODO: seed data 저장하는 구문 작성 후 메서드 삭제 예정 (toEntity 관련 에러 해결) ArrayList bookContentDTOS = new ArrayList<>(); // 금도끼 은도끼 저장 @@ -63,7 +63,7 @@ public void save() { // 동화 내용 저장 (임시로 만든 method) -> seed d bookContentDTOS.add(new BookContentDTO(2, 4, "","","여우를 사냥하려고 숲 주변에 있던 사냥꾼이, 치치와 늑대의 그림자를 보고 줄행랑 쳤답니다!","", "", "https://storage.googleapis.com/ft-island-image/shadow3.webp")); for (BookContentDTO bookContentDTO : bookContentDTOS) { - BookContentEntity bookContentEntity = BookContentEntity.toBookContentEntity(bookContentDTO); + BookContentEntity bookContentEntity = BookContentEntity.toBookContentEntity(bookContentDTO); // TODO: seed data 저장 코드 작성 후 없애기 bookContentRepository.save(bookContentEntity); } } diff --git a/BE/src/test/java/com/FTIsland/BE/bookContent/BookContentTest.java b/BE/src/test/java/com/FTIsland/BE/bookContent/BookContentTest.java index 8200b00..d134d2c 100644 --- a/BE/src/test/java/com/FTIsland/BE/bookContent/BookContentTest.java +++ b/BE/src/test/java/com/FTIsland/BE/bookContent/BookContentTest.java @@ -8,8 +8,11 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; + import java.util.List; +import static org.assertj.core.api.Assertions.assertThat; + @SpringBootTest public class BookContentTest { @Autowired @@ -30,6 +33,7 @@ public void getBookContent() throws Exception{ List bookContentResponse = bookContentService.findByBookId(bookContentRequest); // then + assertThat(bookContentResponse).isNotEmpty(); // TODO: DB에 저장된 값과도 비교 } From b28a85fc953e9d4199c088f2a4e71c44479db0b9 Mon Sep 17 00:00:00 2001 From: alsrudrl1220 Date: Thu, 30 May 2024 16:07:33 +0900 Subject: [PATCH 19/28] =?UTF-8?q?[fix]=20=ED=95=84=EC=9A=94=EC=97=86?= =?UTF-8?q?=EB=8A=94=20=EC=96=B4=EB=85=B8=ED=85=8C=EC=9D=B4=EC=85=98=20?= =?UTF-8?q?=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/FTIsland/BE/bookContent/dto/BookContentRequest.java | 1 - .../com/FTIsland/BE/bookContent/dto/BookContentResponse.java | 1 - 2 files changed, 2 deletions(-) diff --git a/BE/src/main/java/com/FTIsland/BE/bookContent/dto/BookContentRequest.java b/BE/src/main/java/com/FTIsland/BE/bookContent/dto/BookContentRequest.java index 1c03be1..e6bff43 100644 --- a/BE/src/main/java/com/FTIsland/BE/bookContent/dto/BookContentRequest.java +++ b/BE/src/main/java/com/FTIsland/BE/bookContent/dto/BookContentRequest.java @@ -3,7 +3,6 @@ import lombok.*; @Getter -@Setter @NoArgsConstructor @ToString public class BookContentRequest { diff --git a/BE/src/main/java/com/FTIsland/BE/bookContent/dto/BookContentResponse.java b/BE/src/main/java/com/FTIsland/BE/bookContent/dto/BookContentResponse.java index 3e4c68c..8e11f29 100644 --- a/BE/src/main/java/com/FTIsland/BE/bookContent/dto/BookContentResponse.java +++ b/BE/src/main/java/com/FTIsland/BE/bookContent/dto/BookContentResponse.java @@ -7,7 +7,6 @@ import java.util.List; @Getter -@Setter @NoArgsConstructor @ToString public class BookContentResponse { From 8fec1d4cc4b532c0d7ad10327beee31010e26d3a Mon Sep 17 00:00:00 2001 From: alsrudrl1220 Date: Wed, 5 Jun 2024 16:43:10 +0900 Subject: [PATCH 20/28] =?UTF-8?q?[fix]=20=ED=8C=A8=ED=82=A4=EC=A7=80=20?= =?UTF-8?q?=EA=B5=AC=EC=A1=B0=20refactor=20:=20book=20>=20bookContent=20>?= =?UTF-8?q?=20contoller,=20service,=20...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bookContent/controller/BookContentController.java | 8 ++++---- .../{ => book}/bookContent/dto/BookContentRequest.java | 2 +- .../bookContent/dto/BookContentResponse.java | 4 ++-- .../bookContent/entity/BookContentEntity.java | 2 +- .../bookContent/repository/BookContentRepository.java | 4 ++-- .../bookContent/service/BookContentService.java | 10 +++++----- .../com/FTIsland/BE/controller/QuizController.java | 6 +++--- .../main/java/com/FTIsland/BE/dto/BookContentDTO.java | 2 +- .../com/FTIsland/BE/bookContent/BookContentTest.java | 6 +++--- 9 files changed, 22 insertions(+), 22 deletions(-) rename BE/src/main/java/com/FTIsland/BE/{ => book}/bookContent/controller/BookContentController.java (73%) rename BE/src/main/java/com/FTIsland/BE/{ => book}/bookContent/dto/BookContentRequest.java (89%) rename BE/src/main/java/com/FTIsland/BE/{ => book}/bookContent/dto/BookContentResponse.java (91%) rename BE/src/main/java/com/FTIsland/BE/{ => book}/bookContent/entity/BookContentEntity.java (94%) rename BE/src/main/java/com/FTIsland/BE/{ => book}/bookContent/repository/BookContentRepository.java (76%) rename BE/src/main/java/com/FTIsland/BE/{ => book}/bookContent/service/BookContentService.java (96%) diff --git a/BE/src/main/java/com/FTIsland/BE/bookContent/controller/BookContentController.java b/BE/src/main/java/com/FTIsland/BE/book/bookContent/controller/BookContentController.java similarity index 73% rename from BE/src/main/java/com/FTIsland/BE/bookContent/controller/BookContentController.java rename to BE/src/main/java/com/FTIsland/BE/book/bookContent/controller/BookContentController.java index 159cd46..39061e3 100644 --- a/BE/src/main/java/com/FTIsland/BE/bookContent/controller/BookContentController.java +++ b/BE/src/main/java/com/FTIsland/BE/book/bookContent/controller/BookContentController.java @@ -1,8 +1,8 @@ -package com.FTIsland.BE.bookContent.controller; +package com.FTIsland.BE.book.bookContent.controller; -import com.FTIsland.BE.bookContent.dto.BookContentRequest; -import com.FTIsland.BE.bookContent.dto.BookContentResponse; -import com.FTIsland.BE.bookContent.service.BookContentService; +import com.FTIsland.BE.book.bookContent.service.BookContentService; +import com.FTIsland.BE.book.bookContent.dto.BookContentRequest; +import com.FTIsland.BE.book.bookContent.dto.BookContentResponse; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.*; diff --git a/BE/src/main/java/com/FTIsland/BE/bookContent/dto/BookContentRequest.java b/BE/src/main/java/com/FTIsland/BE/book/bookContent/dto/BookContentRequest.java similarity index 89% rename from BE/src/main/java/com/FTIsland/BE/bookContent/dto/BookContentRequest.java rename to BE/src/main/java/com/FTIsland/BE/book/bookContent/dto/BookContentRequest.java index e6bff43..937505c 100644 --- a/BE/src/main/java/com/FTIsland/BE/bookContent/dto/BookContentRequest.java +++ b/BE/src/main/java/com/FTIsland/BE/book/bookContent/dto/BookContentRequest.java @@ -1,4 +1,4 @@ -package com.FTIsland.BE.bookContent.dto; +package com.FTIsland.BE.book.bookContent.dto; import lombok.*; diff --git a/BE/src/main/java/com/FTIsland/BE/bookContent/dto/BookContentResponse.java b/BE/src/main/java/com/FTIsland/BE/book/bookContent/dto/BookContentResponse.java similarity index 91% rename from BE/src/main/java/com/FTIsland/BE/bookContent/dto/BookContentResponse.java rename to BE/src/main/java/com/FTIsland/BE/book/bookContent/dto/BookContentResponse.java index 8e11f29..df9e40a 100644 --- a/BE/src/main/java/com/FTIsland/BE/bookContent/dto/BookContentResponse.java +++ b/BE/src/main/java/com/FTIsland/BE/book/bookContent/dto/BookContentResponse.java @@ -1,7 +1,7 @@ -package com.FTIsland.BE.bookContent.dto; +package com.FTIsland.BE.book.bookContent.dto; +import com.FTIsland.BE.book.bookContent.entity.BookContentEntity; import com.FTIsland.BE.dto.ContentVocaDTO; -import com.FTIsland.BE.bookContent.entity.BookContentEntity; import lombok.*; import java.util.List; diff --git a/BE/src/main/java/com/FTIsland/BE/bookContent/entity/BookContentEntity.java b/BE/src/main/java/com/FTIsland/BE/book/bookContent/entity/BookContentEntity.java similarity index 94% rename from BE/src/main/java/com/FTIsland/BE/bookContent/entity/BookContentEntity.java rename to BE/src/main/java/com/FTIsland/BE/book/bookContent/entity/BookContentEntity.java index 3f4dee5..3844813 100644 --- a/BE/src/main/java/com/FTIsland/BE/bookContent/entity/BookContentEntity.java +++ b/BE/src/main/java/com/FTIsland/BE/book/bookContent/entity/BookContentEntity.java @@ -1,4 +1,4 @@ -package com.FTIsland.BE.bookContent.entity; +package com.FTIsland.BE.book.bookContent.entity; import com.FTIsland.BE.dto.BookContentDTO; import jakarta.persistence.*; diff --git a/BE/src/main/java/com/FTIsland/BE/bookContent/repository/BookContentRepository.java b/BE/src/main/java/com/FTIsland/BE/book/bookContent/repository/BookContentRepository.java similarity index 76% rename from BE/src/main/java/com/FTIsland/BE/bookContent/repository/BookContentRepository.java rename to BE/src/main/java/com/FTIsland/BE/book/bookContent/repository/BookContentRepository.java index fd72e15..8a190c5 100644 --- a/BE/src/main/java/com/FTIsland/BE/bookContent/repository/BookContentRepository.java +++ b/BE/src/main/java/com/FTIsland/BE/book/bookContent/repository/BookContentRepository.java @@ -1,6 +1,6 @@ -package com.FTIsland.BE.bookContent.repository; +package com.FTIsland.BE.book.bookContent.repository; -import com.FTIsland.BE.bookContent.entity.BookContentEntity; +import com.FTIsland.BE.book.bookContent.entity.BookContentEntity; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; diff --git a/BE/src/main/java/com/FTIsland/BE/bookContent/service/BookContentService.java b/BE/src/main/java/com/FTIsland/BE/book/bookContent/service/BookContentService.java similarity index 96% rename from BE/src/main/java/com/FTIsland/BE/bookContent/service/BookContentService.java rename to BE/src/main/java/com/FTIsland/BE/book/bookContent/service/BookContentService.java index 09ac904..948e1ee 100644 --- a/BE/src/main/java/com/FTIsland/BE/bookContent/service/BookContentService.java +++ b/BE/src/main/java/com/FTIsland/BE/book/bookContent/service/BookContentService.java @@ -1,12 +1,12 @@ -package com.FTIsland.BE.bookContent.service; +package com.FTIsland.BE.book.bookContent.service; -import com.FTIsland.BE.bookContent.dto.BookContentRequest; -import com.FTIsland.BE.bookContent.dto.BookContentResponse; +import com.FTIsland.BE.book.bookContent.entity.BookContentEntity; +import com.FTIsland.BE.book.bookContent.dto.BookContentRequest; +import com.FTIsland.BE.book.bookContent.dto.BookContentResponse; import com.FTIsland.BE.dto.BookContentDTO; import com.FTIsland.BE.dto.ContentVocaDTO; -import com.FTIsland.BE.bookContent.entity.BookContentEntity; import com.FTIsland.BE.entity.VocaEntity; -import com.FTIsland.BE.bookContent.repository.BookContentRepository; +import com.FTIsland.BE.book.bookContent.repository.BookContentRepository; import com.FTIsland.BE.repository.VocaRepository; import com.FTIsland.BE.service.TranslationService; import lombok.RequiredArgsConstructor; diff --git a/BE/src/main/java/com/FTIsland/BE/controller/QuizController.java b/BE/src/main/java/com/FTIsland/BE/controller/QuizController.java index 46284d6..7d05edd 100644 --- a/BE/src/main/java/com/FTIsland/BE/controller/QuizController.java +++ b/BE/src/main/java/com/FTIsland/BE/controller/QuizController.java @@ -1,8 +1,8 @@ package com.FTIsland.BE.controller; -import com.FTIsland.BE.bookContent.dto.BookContentRequest; -import com.FTIsland.BE.bookContent.dto.BookContentResponse; -import com.FTIsland.BE.bookContent.service.BookContentService; +import com.FTIsland.BE.book.bookContent.dto.BookContentRequest; +import com.FTIsland.BE.book.bookContent.dto.BookContentResponse; +import com.FTIsland.BE.book.bookContent.service.BookContentService; import com.FTIsland.BE.dto.ChatGptResponse; import com.FTIsland.BE.dto.QuizDTO; import com.FTIsland.BE.service.*; diff --git a/BE/src/main/java/com/FTIsland/BE/dto/BookContentDTO.java b/BE/src/main/java/com/FTIsland/BE/dto/BookContentDTO.java index c6e14fa..35fa5ef 100644 --- a/BE/src/main/java/com/FTIsland/BE/dto/BookContentDTO.java +++ b/BE/src/main/java/com/FTIsland/BE/dto/BookContentDTO.java @@ -1,6 +1,6 @@ package com.FTIsland.BE.dto; -import com.FTIsland.BE.bookContent.entity.BookContentEntity; +import com.FTIsland.BE.book.bookContent.entity.BookContentEntity; import lombok.*; import java.util.List; diff --git a/BE/src/test/java/com/FTIsland/BE/bookContent/BookContentTest.java b/BE/src/test/java/com/FTIsland/BE/bookContent/BookContentTest.java index d134d2c..a4f331d 100644 --- a/BE/src/test/java/com/FTIsland/BE/bookContent/BookContentTest.java +++ b/BE/src/test/java/com/FTIsland/BE/bookContent/BookContentTest.java @@ -1,8 +1,8 @@ package com.FTIsland.BE.bookContent; -import com.FTIsland.BE.bookContent.dto.BookContentRequest; -import com.FTIsland.BE.bookContent.dto.BookContentResponse; -import com.FTIsland.BE.bookContent.service.BookContentService; +import com.FTIsland.BE.book.bookContent.dto.BookContentRequest; +import com.FTIsland.BE.book.bookContent.dto.BookContentResponse; +import com.FTIsland.BE.book.bookContent.service.BookContentService; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; From 90c4486bf37b0d685a70c182466cdab577e98dc8 Mon Sep 17 00:00:00 2001 From: alsrudrl1220 Date: Wed, 5 Jun 2024 16:44:44 +0900 Subject: [PATCH 21/28] =?UTF-8?q?[fix]=20package=EB=AA=85=EC=9D=84=20bookC?= =?UTF-8?q?ontent=20->=20content=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/BookContentController.java | 8 ++++---- .../dto/BookContentRequest.java | 2 +- .../dto/BookContentResponse.java | 4 ++-- .../entity/BookContentEntity.java | 4 +--- .../repository/BookContentRepository.java | 4 ++-- .../service/BookContentService.java | 10 +++++----- .../com/FTIsland/BE/controller/QuizController.java | 6 +++--- .../main/java/com/FTIsland/BE/dto/BookContentDTO.java | 2 +- .../com/FTIsland/BE/bookContent/BookContentTest.java | 6 +++--- 9 files changed, 22 insertions(+), 24 deletions(-) rename BE/src/main/java/com/FTIsland/BE/book/{bookContent => content}/controller/BookContentController.java (73%) rename BE/src/main/java/com/FTIsland/BE/book/{bookContent => content}/dto/BookContentRequest.java (89%) rename BE/src/main/java/com/FTIsland/BE/book/{bookContent => content}/dto/BookContentResponse.java (91%) rename BE/src/main/java/com/FTIsland/BE/book/{bookContent => content}/entity/BookContentEntity.java (87%) rename BE/src/main/java/com/FTIsland/BE/book/{bookContent => content}/repository/BookContentRepository.java (76%) rename BE/src/main/java/com/FTIsland/BE/book/{bookContent => content}/service/BookContentService.java (96%) diff --git a/BE/src/main/java/com/FTIsland/BE/book/bookContent/controller/BookContentController.java b/BE/src/main/java/com/FTIsland/BE/book/content/controller/BookContentController.java similarity index 73% rename from BE/src/main/java/com/FTIsland/BE/book/bookContent/controller/BookContentController.java rename to BE/src/main/java/com/FTIsland/BE/book/content/controller/BookContentController.java index 39061e3..68c3872 100644 --- a/BE/src/main/java/com/FTIsland/BE/book/bookContent/controller/BookContentController.java +++ b/BE/src/main/java/com/FTIsland/BE/book/content/controller/BookContentController.java @@ -1,8 +1,8 @@ -package com.FTIsland.BE.book.bookContent.controller; +package com.FTIsland.BE.book.content.controller; -import com.FTIsland.BE.book.bookContent.service.BookContentService; -import com.FTIsland.BE.book.bookContent.dto.BookContentRequest; -import com.FTIsland.BE.book.bookContent.dto.BookContentResponse; +import com.FTIsland.BE.book.content.service.BookContentService; +import com.FTIsland.BE.book.content.dto.BookContentRequest; +import com.FTIsland.BE.book.content.dto.BookContentResponse; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.*; diff --git a/BE/src/main/java/com/FTIsland/BE/book/bookContent/dto/BookContentRequest.java b/BE/src/main/java/com/FTIsland/BE/book/content/dto/BookContentRequest.java similarity index 89% rename from BE/src/main/java/com/FTIsland/BE/book/bookContent/dto/BookContentRequest.java rename to BE/src/main/java/com/FTIsland/BE/book/content/dto/BookContentRequest.java index 937505c..9451c04 100644 --- a/BE/src/main/java/com/FTIsland/BE/book/bookContent/dto/BookContentRequest.java +++ b/BE/src/main/java/com/FTIsland/BE/book/content/dto/BookContentRequest.java @@ -1,4 +1,4 @@ -package com.FTIsland.BE.book.bookContent.dto; +package com.FTIsland.BE.book.content.dto; import lombok.*; diff --git a/BE/src/main/java/com/FTIsland/BE/book/bookContent/dto/BookContentResponse.java b/BE/src/main/java/com/FTIsland/BE/book/content/dto/BookContentResponse.java similarity index 91% rename from BE/src/main/java/com/FTIsland/BE/book/bookContent/dto/BookContentResponse.java rename to BE/src/main/java/com/FTIsland/BE/book/content/dto/BookContentResponse.java index df9e40a..d83969e 100644 --- a/BE/src/main/java/com/FTIsland/BE/book/bookContent/dto/BookContentResponse.java +++ b/BE/src/main/java/com/FTIsland/BE/book/content/dto/BookContentResponse.java @@ -1,6 +1,6 @@ -package com.FTIsland.BE.book.bookContent.dto; +package com.FTIsland.BE.book.content.dto; -import com.FTIsland.BE.book.bookContent.entity.BookContentEntity; +import com.FTIsland.BE.book.content.entity.BookContentEntity; import com.FTIsland.BE.dto.ContentVocaDTO; import lombok.*; diff --git a/BE/src/main/java/com/FTIsland/BE/book/bookContent/entity/BookContentEntity.java b/BE/src/main/java/com/FTIsland/BE/book/content/entity/BookContentEntity.java similarity index 87% rename from BE/src/main/java/com/FTIsland/BE/book/bookContent/entity/BookContentEntity.java rename to BE/src/main/java/com/FTIsland/BE/book/content/entity/BookContentEntity.java index 3844813..573b022 100644 --- a/BE/src/main/java/com/FTIsland/BE/book/bookContent/entity/BookContentEntity.java +++ b/BE/src/main/java/com/FTIsland/BE/book/content/entity/BookContentEntity.java @@ -1,11 +1,9 @@ -package com.FTIsland.BE.book.bookContent.entity; +package com.FTIsland.BE.book.content.entity; -import com.FTIsland.BE.dto.BookContentDTO; import jakarta.persistence.*; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; -import lombok.Setter; @Entity @Getter diff --git a/BE/src/main/java/com/FTIsland/BE/book/bookContent/repository/BookContentRepository.java b/BE/src/main/java/com/FTIsland/BE/book/content/repository/BookContentRepository.java similarity index 76% rename from BE/src/main/java/com/FTIsland/BE/book/bookContent/repository/BookContentRepository.java rename to BE/src/main/java/com/FTIsland/BE/book/content/repository/BookContentRepository.java index 8a190c5..9b12258 100644 --- a/BE/src/main/java/com/FTIsland/BE/book/bookContent/repository/BookContentRepository.java +++ b/BE/src/main/java/com/FTIsland/BE/book/content/repository/BookContentRepository.java @@ -1,6 +1,6 @@ -package com.FTIsland.BE.book.bookContent.repository; +package com.FTIsland.BE.book.content.repository; -import com.FTIsland.BE.book.bookContent.entity.BookContentEntity; +import com.FTIsland.BE.book.content.entity.BookContentEntity; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; diff --git a/BE/src/main/java/com/FTIsland/BE/book/bookContent/service/BookContentService.java b/BE/src/main/java/com/FTIsland/BE/book/content/service/BookContentService.java similarity index 96% rename from BE/src/main/java/com/FTIsland/BE/book/bookContent/service/BookContentService.java rename to BE/src/main/java/com/FTIsland/BE/book/content/service/BookContentService.java index 948e1ee..b8b2ae9 100644 --- a/BE/src/main/java/com/FTIsland/BE/book/bookContent/service/BookContentService.java +++ b/BE/src/main/java/com/FTIsland/BE/book/content/service/BookContentService.java @@ -1,12 +1,12 @@ -package com.FTIsland.BE.book.bookContent.service; +package com.FTIsland.BE.book.content.service; -import com.FTIsland.BE.book.bookContent.entity.BookContentEntity; -import com.FTIsland.BE.book.bookContent.dto.BookContentRequest; -import com.FTIsland.BE.book.bookContent.dto.BookContentResponse; +import com.FTIsland.BE.book.content.entity.BookContentEntity; +import com.FTIsland.BE.book.content.dto.BookContentRequest; +import com.FTIsland.BE.book.content.dto.BookContentResponse; import com.FTIsland.BE.dto.BookContentDTO; import com.FTIsland.BE.dto.ContentVocaDTO; import com.FTIsland.BE.entity.VocaEntity; -import com.FTIsland.BE.book.bookContent.repository.BookContentRepository; +import com.FTIsland.BE.book.content.repository.BookContentRepository; import com.FTIsland.BE.repository.VocaRepository; import com.FTIsland.BE.service.TranslationService; import lombok.RequiredArgsConstructor; diff --git a/BE/src/main/java/com/FTIsland/BE/controller/QuizController.java b/BE/src/main/java/com/FTIsland/BE/controller/QuizController.java index 7d05edd..52f49a4 100644 --- a/BE/src/main/java/com/FTIsland/BE/controller/QuizController.java +++ b/BE/src/main/java/com/FTIsland/BE/controller/QuizController.java @@ -1,8 +1,8 @@ package com.FTIsland.BE.controller; -import com.FTIsland.BE.book.bookContent.dto.BookContentRequest; -import com.FTIsland.BE.book.bookContent.dto.BookContentResponse; -import com.FTIsland.BE.book.bookContent.service.BookContentService; +import com.FTIsland.BE.book.content.dto.BookContentRequest; +import com.FTIsland.BE.book.content.dto.BookContentResponse; +import com.FTIsland.BE.book.content.service.BookContentService; import com.FTIsland.BE.dto.ChatGptResponse; import com.FTIsland.BE.dto.QuizDTO; import com.FTIsland.BE.service.*; diff --git a/BE/src/main/java/com/FTIsland/BE/dto/BookContentDTO.java b/BE/src/main/java/com/FTIsland/BE/dto/BookContentDTO.java index 35fa5ef..33e28b9 100644 --- a/BE/src/main/java/com/FTIsland/BE/dto/BookContentDTO.java +++ b/BE/src/main/java/com/FTIsland/BE/dto/BookContentDTO.java @@ -1,6 +1,6 @@ package com.FTIsland.BE.dto; -import com.FTIsland.BE.book.bookContent.entity.BookContentEntity; +import com.FTIsland.BE.book.content.entity.BookContentEntity; import lombok.*; import java.util.List; diff --git a/BE/src/test/java/com/FTIsland/BE/bookContent/BookContentTest.java b/BE/src/test/java/com/FTIsland/BE/bookContent/BookContentTest.java index a4f331d..bcb4fb3 100644 --- a/BE/src/test/java/com/FTIsland/BE/bookContent/BookContentTest.java +++ b/BE/src/test/java/com/FTIsland/BE/bookContent/BookContentTest.java @@ -1,8 +1,8 @@ package com.FTIsland.BE.bookContent; -import com.FTIsland.BE.book.bookContent.dto.BookContentRequest; -import com.FTIsland.BE.book.bookContent.dto.BookContentResponse; -import com.FTIsland.BE.book.bookContent.service.BookContentService; +import com.FTIsland.BE.book.content.dto.BookContentRequest; +import com.FTIsland.BE.book.content.dto.BookContentResponse; +import com.FTIsland.BE.book.content.service.BookContentService; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; From 293b1f914c932d66da2f24f3e328de4b8b975806 Mon Sep 17 00:00:00 2001 From: alsrudrl1220 Date: Wed, 5 Jun 2024 16:52:27 +0900 Subject: [PATCH 22/28] =?UTF-8?q?[fix]=20=ED=95=84=EC=9A=94=EC=97=86?= =?UTF-8?q?=EB=8A=94=20=EC=96=B4=EB=85=B8=ED=85=8C=EC=9D=B4=EC=85=98=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/FTIsland/BE/book/content/dto/BookContentRequest.java | 1 - .../com/FTIsland/BE/book/content/dto/BookContentResponse.java | 1 - 2 files changed, 2 deletions(-) diff --git a/BE/src/main/java/com/FTIsland/BE/book/content/dto/BookContentRequest.java b/BE/src/main/java/com/FTIsland/BE/book/content/dto/BookContentRequest.java index 9451c04..c05118a 100644 --- a/BE/src/main/java/com/FTIsland/BE/book/content/dto/BookContentRequest.java +++ b/BE/src/main/java/com/FTIsland/BE/book/content/dto/BookContentRequest.java @@ -4,7 +4,6 @@ @Getter @NoArgsConstructor -@ToString public class BookContentRequest { private Integer bookId; // BookInfo에 title 있음. private String mainLan; diff --git a/BE/src/main/java/com/FTIsland/BE/book/content/dto/BookContentResponse.java b/BE/src/main/java/com/FTIsland/BE/book/content/dto/BookContentResponse.java index d83969e..c6ee629 100644 --- a/BE/src/main/java/com/FTIsland/BE/book/content/dto/BookContentResponse.java +++ b/BE/src/main/java/com/FTIsland/BE/book/content/dto/BookContentResponse.java @@ -8,7 +8,6 @@ @Getter @NoArgsConstructor -@ToString public class BookContentResponse { private Integer bookId; //bookName도 추가? private Integer page; From 47863248ea8dc985cd4b8edd2769317d3a44c78f Mon Sep 17 00:00:00 2001 From: alsrudrl1220 Date: Wed, 5 Jun 2024 16:54:22 +0900 Subject: [PATCH 23/28] =?UTF-8?q?[fix]=20=EC=9D=BC=EA=B4=80=EC=84=B1?= =?UTF-8?q?=EC=9D=84=20=EC=9C=84=ED=95=B4=20*=EB=A1=9C=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FTIsland/BE/book/content/entity/BookContentEntity.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/BE/src/main/java/com/FTIsland/BE/book/content/entity/BookContentEntity.java b/BE/src/main/java/com/FTIsland/BE/book/content/entity/BookContentEntity.java index 573b022..9e92906 100644 --- a/BE/src/main/java/com/FTIsland/BE/book/content/entity/BookContentEntity.java +++ b/BE/src/main/java/com/FTIsland/BE/book/content/entity/BookContentEntity.java @@ -1,9 +1,7 @@ package com.FTIsland.BE.book.content.entity; import jakarta.persistence.*; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; +import lombok.*; @Entity @Getter From ad1996ac29cf30086ad7d355a3ca720d1b797406 Mon Sep 17 00:00:00 2001 From: alsrudrl1220 Date: Wed, 5 Jun 2024 17:02:00 +0900 Subject: [PATCH 24/28] =?UTF-8?q?[feat]=20builder=EC=97=90=20vocaList=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 --- .../com/FTIsland/BE/book/content/dto/BookContentResponse.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/BE/src/main/java/com/FTIsland/BE/book/content/dto/BookContentResponse.java b/BE/src/main/java/com/FTIsland/BE/book/content/dto/BookContentResponse.java index c6ee629..bf4ec25 100644 --- a/BE/src/main/java/com/FTIsland/BE/book/content/dto/BookContentResponse.java +++ b/BE/src/main/java/com/FTIsland/BE/book/content/dto/BookContentResponse.java @@ -20,7 +20,7 @@ public class BookContentResponse { private String image; @Builder - public BookContentResponse(Integer bookId, Integer page, String mainLan, String subLan, String korContents, String mainContents, String subContents, String image){ + public BookContentResponse(Integer bookId, Integer page, String mainLan, String subLan, String korContents, String mainContents, String subContents, List vocaList, String image){ this.bookId = bookId; this.page = page; this.mainLan = mainLan; @@ -28,6 +28,7 @@ public BookContentResponse(Integer bookId, Integer page, String mainLan, String this.korContents = korContents; this.mainContents = mainContents; this.subContents = subContents; + this.vocaList = vocaList; this.image = image; } From a158c17808a2ffe000402bbc4b3b026f2872c9f5 Mon Sep 17 00:00:00 2001 From: alsrudrl1220 Date: Wed, 5 Jun 2024 17:03:39 +0900 Subject: [PATCH 25/28] =?UTF-8?q?[fix]=20set=20=EB=8C=80=EC=8B=A0=20builde?= =?UTF-8?q?r=EB=A1=9C=20=EA=B0=99=EC=9D=B4=20vocaList=EB=A5=BC=20=EB=8B=B4?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FTIsland/BE/book/content/service/BookContentService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BE/src/main/java/com/FTIsland/BE/book/content/service/BookContentService.java b/BE/src/main/java/com/FTIsland/BE/book/content/service/BookContentService.java index b8b2ae9..02028f0 100644 --- a/BE/src/main/java/com/FTIsland/BE/book/content/service/BookContentService.java +++ b/BE/src/main/java/com/FTIsland/BE/book/content/service/BookContentService.java @@ -122,10 +122,10 @@ public List findByBookId(BookContentRequest requestDTO) { .korContents(ent.getKorContents()) .mainContents(mainText) .subContents(subText) + .vocaList(contentVocaDTOS) .image(ent.getImage()) .build(); - bookContentResponse.setVocaList(contentVocaDTOS); bookContentResponses.add(bookContentResponse); } From 6b75b9638ea90193a0053cf57c824e4c753fae43 Mon Sep 17 00:00:00 2001 From: alsrudrl1220 Date: Wed, 5 Jun 2024 17:16:16 +0900 Subject: [PATCH 26/28] =?UTF-8?q?[fix]=20builder=20=ED=8C=A8=ED=84=B4?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/FTIsland/BE/controller/QuizController.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/BE/src/main/java/com/FTIsland/BE/controller/QuizController.java b/BE/src/main/java/com/FTIsland/BE/controller/QuizController.java index 52f49a4..736472b 100644 --- a/BE/src/main/java/com/FTIsland/BE/controller/QuizController.java +++ b/BE/src/main/java/com/FTIsland/BE/controller/QuizController.java @@ -44,10 +44,11 @@ public List getQuiz(@RequestBody QuizDTO quizDTO){ if(savedQuiz.isEmpty()){ // A. 없으면 새로 생성 후 저장 // 책의 contents 조회 - 동화 제목만으로는 버전이 다를 수 있기 때문에 // 1. bookContentService의 findByBookId method를 쓰기 위해 QuizDTO -> BookContentDTO 변환 - BookContentRequest bookContentRequest = new BookContentRequest(); - bookContentRequest.setBookId(quizDTO.getBookId()); - bookContentRequest.setMainLan(quizDTO.getMainLan()); - bookContentRequest.setSubLan(quizDTO.getSubLan()); + BookContentRequest bookContentRequest = new BookContentRequest().builder() + .bookId(quizDTO.getBookId()) + .mainLan(quizDTO.getMainLan()) + .subLan(quizDTO.getSubLan()) + .build(); // 2. Content list 조회 및 한 줄로 합쳐진 Content 생성 List bookContentResponses = bookContentService.findByBookId(bookContentRequest); From b30cd141190371a3e621b14ad0ed35cce531a0d2 Mon Sep 17 00:00:00 2001 From: alsrudrl1220 Date: Wed, 5 Jun 2024 17:17:36 +0900 Subject: [PATCH 27/28] =?UTF-8?q?[fix]=20=EC=A3=BC=EC=84=9D=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BE/src/main/java/com/FTIsland/BE/controller/QuizController.java | 1 - 1 file changed, 1 deletion(-) diff --git a/BE/src/main/java/com/FTIsland/BE/controller/QuizController.java b/BE/src/main/java/com/FTIsland/BE/controller/QuizController.java index 736472b..9b9af6b 100644 --- a/BE/src/main/java/com/FTIsland/BE/controller/QuizController.java +++ b/BE/src/main/java/com/FTIsland/BE/controller/QuizController.java @@ -62,7 +62,6 @@ public List getQuiz(@RequestBody QuizDTO quizDTO){ ChatGptResponse chatGptResponse = null; chatGptResponse = chatGptService.askQuestion(bookTitle, userLevel, bookContents); String threeQuiz = chatGptResponse.getChoices().get(0).getMessage().getContent(); - // System.out.println(threeQuiz); // 4. 생성된 퀴즈 3개를 파싱하고 저장 List quizs = quizService.makeQuiz(threeQuiz); From 0eba41f812f16a5a2cc7d0762e89b1e478cfcd9e Mon Sep 17 00:00:00 2001 From: alsrudrl1220 Date: Wed, 5 Jun 2024 17:22:23 +0900 Subject: [PATCH 28/28] =?UTF-8?q?[fix]=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=ED=81=B4=EB=9E=98=EC=8A=A4=20=EC=9D=B4=EB=A6=84=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{BookContentTest.java => BookContentServiceTest.java} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename BE/src/test/java/com/FTIsland/BE/bookContent/{BookContentTest.java => BookContentServiceTest.java} (97%) diff --git a/BE/src/test/java/com/FTIsland/BE/bookContent/BookContentTest.java b/BE/src/test/java/com/FTIsland/BE/bookContent/BookContentServiceTest.java similarity index 97% rename from BE/src/test/java/com/FTIsland/BE/bookContent/BookContentTest.java rename to BE/src/test/java/com/FTIsland/BE/bookContent/BookContentServiceTest.java index bcb4fb3..bad3d89 100644 --- a/BE/src/test/java/com/FTIsland/BE/bookContent/BookContentTest.java +++ b/BE/src/test/java/com/FTIsland/BE/bookContent/BookContentServiceTest.java @@ -14,7 +14,7 @@ import static org.assertj.core.api.Assertions.assertThat; @SpringBootTest -public class BookContentTest { +public class BookContentServiceTest { @Autowired private BookContentService bookContentService;