From 42a73d6f698c273e8ecce079a7f17d1ff6a50b80 Mon Sep 17 00:00:00 2001 From: ahah525 Date: Mon, 24 Oct 2022 15:47:44 +0900 Subject: [PATCH] =?UTF-8?q?#7=20-=20Feat:=201=EB=B2=88=20=ED=9A=8C?= =?UTF-8?q?=EC=9B=90=EC=9D=B4=201=EB=B2=88=20=ED=95=B4=EC=8B=9C=ED=83=9C?= =?UTF-8?q?=EA=B7=B8=20=ED=82=A4=EC=9B=8C=EB=93=9C=EB=A5=BC=20=EC=84=A0?= =?UTF-8?q?=ED=83=9D=ED=95=98=EC=97=AC=20=EB=8F=84=EC=84=9C=201,=202?= =?UTF-8?q?=EB=B2=88=20=EA=B8=80=EC=9D=84=20=EB=8F=84=EC=84=9C=EB=A1=9C=20?= =?UTF-8?q?=EB=93=B1=EB=A1=9D=ED=95=98=EB=8A=94=20Product=20InitData=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 --- .../example/mutbooks/app/base/initData/DevInitData.java | 5 +++-- .../mutbooks/app/base/initData/InitDataBefore.java | 9 +++++++-- .../example/mutbooks/app/base/initData/TestInitData.java | 5 +++-- .../example/mutbooks/app/product/form/ProductForm.java | 2 ++ 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/2Week_Mission/mutbooks/src/main/java/com/example/mutbooks/app/base/initData/DevInitData.java b/2Week_Mission/mutbooks/src/main/java/com/example/mutbooks/app/base/initData/DevInitData.java index 2fab546..808c896 100644 --- a/2Week_Mission/mutbooks/src/main/java/com/example/mutbooks/app/base/initData/DevInitData.java +++ b/2Week_Mission/mutbooks/src/main/java/com/example/mutbooks/app/base/initData/DevInitData.java @@ -2,6 +2,7 @@ import com.example.mutbooks.app.member.service.MemberService; import com.example.mutbooks.app.post.service.PostService; +import com.example.mutbooks.app.product.service.ProductService; import org.springframework.boot.CommandLineRunner; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -11,9 +12,9 @@ @Profile("dev") public class DevInitData implements InitDataBefore { @Bean - CommandLineRunner initData(MemberService memberService, PostService postService) { + CommandLineRunner initData(MemberService memberService, PostService postService, ProductService productService) { return args -> { - before(memberService, postService); + before(memberService, postService, productService); }; } } \ No newline at end of file diff --git a/2Week_Mission/mutbooks/src/main/java/com/example/mutbooks/app/base/initData/InitDataBefore.java b/2Week_Mission/mutbooks/src/main/java/com/example/mutbooks/app/base/initData/InitDataBefore.java index 8926753..13f0286 100644 --- a/2Week_Mission/mutbooks/src/main/java/com/example/mutbooks/app/base/initData/InitDataBefore.java +++ b/2Week_Mission/mutbooks/src/main/java/com/example/mutbooks/app/base/initData/InitDataBefore.java @@ -5,9 +5,11 @@ import com.example.mutbooks.app.member.service.MemberService; import com.example.mutbooks.app.post.form.WriteForm; import com.example.mutbooks.app.post.service.PostService; +import com.example.mutbooks.app.product.form.ProductForm; +import com.example.mutbooks.app.product.service.ProductService; public interface InitDataBefore { - default void before(MemberService memberService, PostService postService) { + default void before(MemberService memberService, PostService postService, ProductService productService) { // 작가 회원 Member member1 = memberService.join(new JoinForm("user1", "1234", "작가", "user1@test.com")); // 일반 회원 @@ -15,6 +17,9 @@ default void before(MemberService memberService, PostService postService) { // 글 작성 postService.write(member1, new WriteForm("제목1", "안녕하세요1", "","#판타지 #소설 #판타지 #SF")); - postService.write(member1, new WriteForm("제목2", "안녕하세요2", "", null)); + postService.write(member1, new WriteForm("제목2", "안녕하세요2", "", "#판타지 #로맨스")); + + // 1번 회원이 1번(판타지) 글 키워드 선택 -> 1, 2번 글 도서 등록 + productService.create(member1, new ProductForm("해리포터", "판타지 소설입니다.", 10000, 1L, "#판타지 #소설")); } } diff --git a/2Week_Mission/mutbooks/src/main/java/com/example/mutbooks/app/base/initData/TestInitData.java b/2Week_Mission/mutbooks/src/main/java/com/example/mutbooks/app/base/initData/TestInitData.java index b2fd2af..c086c86 100644 --- a/2Week_Mission/mutbooks/src/main/java/com/example/mutbooks/app/base/initData/TestInitData.java +++ b/2Week_Mission/mutbooks/src/main/java/com/example/mutbooks/app/base/initData/TestInitData.java @@ -2,6 +2,7 @@ import com.example.mutbooks.app.member.service.MemberService; import com.example.mutbooks.app.post.service.PostService; +import com.example.mutbooks.app.product.service.ProductService; import org.springframework.boot.CommandLineRunner; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -11,9 +12,9 @@ @Profile("test") public class TestInitData implements InitDataBefore { @Bean - CommandLineRunner initData(MemberService memberService, PostService postService) { + CommandLineRunner initData(MemberService memberService, PostService postService, ProductService productService) { return args -> { - before(memberService, postService); + before(memberService, postService, productService); }; } } \ No newline at end of file diff --git a/2Week_Mission/mutbooks/src/main/java/com/example/mutbooks/app/product/form/ProductForm.java b/2Week_Mission/mutbooks/src/main/java/com/example/mutbooks/app/product/form/ProductForm.java index 7b3b8c7..e20c69c 100644 --- a/2Week_Mission/mutbooks/src/main/java/com/example/mutbooks/app/product/form/ProductForm.java +++ b/2Week_Mission/mutbooks/src/main/java/com/example/mutbooks/app/product/form/ProductForm.java @@ -1,5 +1,6 @@ package com.example.mutbooks.app.product.form; +import lombok.AllArgsConstructor; import lombok.Getter; import lombok.Setter; @@ -8,6 +9,7 @@ @Getter @Setter +@AllArgsConstructor public class ProductForm { @NotEmpty(message = "도서명을 입력해주세요.") private String subject;