Skip to content

Commit

Permalink
#7 - Feat: user2 글 2개 작성(Init 데이터 추가)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahah525 committed Oct 18, 2022
1 parent 3c13e28 commit a8d79a7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.example.mutbooks.app.base.initData;

import com.example.mutbooks.app.member.service.MemberService;
import com.example.mutbooks.app.post.service.PostService;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand All @@ -10,9 +11,9 @@
@Profile("dev")
public class DevInitData implements InitDataBefore {
@Bean
CommandLineRunner initData(MemberService memberService) {
CommandLineRunner initData(MemberService memberService, PostService postService) {
return args -> {
before(memberService);
before(memberService, postService);
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,19 @@
import com.example.mutbooks.app.member.entity.Member;
import com.example.mutbooks.app.member.form.JoinForm;
import com.example.mutbooks.app.member.service.MemberService;
import com.example.mutbooks.app.post.form.WriteForm;
import com.example.mutbooks.app.post.service.PostService;

public interface InitDataBefore {
default void before(MemberService memberService) {
// 일반 회원
Member member1 = memberService.join(new JoinForm("user1", "1234", null, "[email protected]"));
default void before(MemberService memberService, PostService postService) {
// 작가 회원
Member member2 = memberService.join(new JoinForm("user2", "1234", "작가", "[email protected]"));
Member member1 = memberService.join(new JoinForm("user1", "1234", "작가", "[email protected]"));
// 일반 회원
Member member2 = memberService.join(new JoinForm("user2", "1234", null, "[email protected]"));

// 글 작성
postService.write(member1, new WriteForm("제목1", "원문 내용1", null));
postService.write(member1, new WriteForm("제목2", "원문 내용2", null));

}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.example.mutbooks.app.base.initData;

import com.example.mutbooks.app.member.service.MemberService;
import com.example.mutbooks.app.post.service.PostService;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand All @@ -10,9 +11,9 @@
@Profile("test")
public class TestInitData implements InitDataBefore {
@Bean
CommandLineRunner initData(MemberService memberService) {
CommandLineRunner initData(MemberService memberService, PostService postService) {
return args -> {
before(memberService);
before(memberService, postService);
};
}
}

0 comments on commit a8d79a7

Please sign in to comment.