Skip to content

Commit

Permalink
[#126] refactor: Post 관련 파라미터 순서 조정
Browse files Browse the repository at this point in the history
  • Loading branch information
shin-mallang committed Dec 3, 2023
1 parent 6433b35 commit 95b9f2e
Show file tree
Hide file tree
Showing 40 changed files with 189 additions and 276 deletions.
3 changes: 1 addition & 2 deletions src/main/java/com/mallang/post/application/DraftService.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ public void update(UpdateDraftCommand command) {
draft.validateWriter(member);
draft.update(
command.title(),
command.bodyText(),
command.intro(), command.bodyText(),
command.postThumbnailImageName(),
command.intro(),
category,
command.tags()
);
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/com/mallang/post/application/PostService.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,8 @@ public void update(UpdatePostCommand command) {
post.update(
new PostVisibilityPolicy(command.visibility(), command.password()),
command.title(),
command.bodyText(),
command.intro(), command.bodyText(),
command.postThumbnailImageName(),
command.intro(),
category,
command.tags()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ public record CreateDraftCommand(
Long memberId,
String blogName,
String title,
String intro,
String bodyText,
@Nullable String postThumbnailImageName,
String intro,
@Nullable Long categoryId,
List<String> tags
) {
public Draft toDraft(Member member, Blog blog, @Nullable Category category) {
return Draft.builder()
.blog(blog)
.title(title)
.intro(intro)
.bodyText(bodyText)
.postThumbnailImageName(postThumbnailImageName)
.postIntro(intro)
.category(category)
.tags(tags)
.writer(member)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ public record CreatePostCommand(
Long memberId,
String blogName,
String title,
String intro,
String bodyText,
@Nullable String postThumbnailImageName,
String intro,
Visibility visibility,
@Nullable String password,
@Nullable Long categoryId,
Expand All @@ -34,7 +34,7 @@ public Post toPost(Member member, PostId postId, Blog blog, @Nullable Category c
.writer(member)
.visibilityPolish(new PostVisibilityPolicy(visibility, password))
.category(category)
.postIntro(intro)
.intro(intro)
.tags(tags)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ public record UpdateDraftCommand(
Long memberId,
Long draftId,
String title,
String intro,
String bodyText,
@Nullable String postThumbnailImageName,
String intro,
@Nullable Long categoryId,
List<String> tags
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ public record UpdatePostCommand(
Long postId,
String blogName,
String title,
String intro,
String bodyText,
@Nullable String postThumbnailImageName,
String intro,
Visibility visibility,
String password,
@Nullable String password,
@Nullable Long categoryId,
List<String> tags
) {
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/com/mallang/post/domain/Post.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,31 +50,31 @@ public Post(
Blog blog,
PostVisibilityPolicy visibilityPolish,
String title,
String intro,
String bodyText,
String postThumbnailImageName,
String postIntro,
@Nullable String postThumbnailImageName,
@Nullable Category category,
List<String> tags,
Member writer
) {
this.id = id;
this.blog = blog;
this.visibilityPolish = visibilityPolish;
this.content = new PostContent(title, bodyText, postThumbnailImageName, postIntro, category, tags, writer);
this.content = new PostContent(title, intro, bodyText, postThumbnailImageName, category, tags, writer);
blog.validateOwner(writer);
}

public void update(
PostVisibilityPolicy visibility,
String title,
String bodyText,
String postThumbnailImageName,
String intro,
String bodyText,
@Nullable String postThumbnailImageName,
@Nullable Category category,
List<String> tags
) {
this.visibilityPolish = visibility;
this.content.update(title, bodyText, postThumbnailImageName, intro, category, tags);
this.content.update(title, intro, bodyText, postThumbnailImageName, category, tags);
}

public void delete() {
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/mallang/post/domain/PostContent.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ public class PostContent {
@Builder
public PostContent(
String title,
String bodyText,
String postThumbnailImageName,
String postIntro,
Category category,
String bodyText,
@Nullable String postThumbnailImageName,
@Nullable Category category,
List<String> tags,
Member writer
) {
Expand All @@ -69,9 +69,9 @@ public PostContent(

public void update(
String title,
String bodyText,
String postThumbnailImageName,
String postIntro,
String bodyText,
@Nullable String postThumbnailImageName,
@Nullable Category category,
List<String> tags
) {
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/com/mallang/post/domain/draft/Draft.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,27 +47,27 @@ public class Draft extends CommonRootEntity<Long> {
public Draft(
Blog blog,
String title,
String intro,
String bodyText,
String postThumbnailImageName,
String postIntro,
@Nullable String postThumbnailImageName,
@Nullable Category category,
List<String> tags,
Member writer
) {
this.blog = blog;
this.content = new PostContent(title, bodyText, postThumbnailImageName, postIntro, category, tags, writer);
this.content = new PostContent(title, intro, bodyText, postThumbnailImageName, category, tags, writer);
blog.validateOwner(writer);
}

public void update(
String title,
String bodyText,
String postThumbnailImageName,
String intro,
String bodyText,
@Nullable String postThumbnailImageName,
@Nullable Category category,
List<String> tags
) {
this.content.update(title, bodyText, postThumbnailImageName, intro, category, tags);
this.content.update(title, intro, bodyText, postThumbnailImageName, category, tags);
}

public void removeCategory() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
public record CreateDraftRequest(
String blogName,
String title,
String intro,
String bodyText,
@Nullable String postThumbnailImageName,
String intro,
@Nullable Long categoryId,
List<String> tags
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
public record CreatePostRequest(
String blogName,
String title,
String intro,
String bodyText,
@Nullable String postThumbnailImageName,
String intro,
Visibility visibility,
@Nullable String password,
@Nullable Long categoryId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

public record UpdateDraftRequest(
String title,
String intro,
String bodyText,
@Nullable String postThumbnailImageName,
String intro,
@Nullable Long categoryId,
List<String> tags
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
public record UpdatePostRequest(
String blogName,
String title,
String intro,
String bodyText,
@Nullable String postThumbnailImageName,
String intro,
Visibility visibility,
String password,
@Nullable String password,
@Nullable Long categoryId,
List<String> tags
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public record PostSearchResponse(
Long id,
String blogName,
String title,
String bodyText,
String intro,
String bodyText,
@Nullable String postThumbnailImageName,
Visibility visibility,
int likeCount,
Expand Down Expand Up @@ -46,8 +46,7 @@ public static PostSearchResponse protectedPost(Post post) {
post.getId().getPostId(),
post.getBlog().getName(),
post.getTitle(),
"보호되어 있는 글입니다.",
"보호되어 있는 글입니다.",
"보호되어 있는 글입니다.", "보호되어 있는 글입니다.",
"",
post.getVisibilityPolish().getVisibility(),
0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public record StaredPostResponse(
Long postId,
String blogName,
String title,
String bodyText,
String intro,
String bodyText,
@Nullable String postThumbnailImageName,
Visibility visibility,
LocalDateTime postCreatedDate,
Expand Down Expand Up @@ -53,8 +53,7 @@ public static StaredPostResponse protectedPost(PostStar postStar) {
post.getId().getPostId(),
post.getBlog().getName(),
post.getTitle(),
"보호되어 있는 글입니다.",
"보호되어 있는 글입니다.",
"보호되어 있는 글입니다.", "보호되어 있는 글입니다.",
"",
post.getVisibilityPolish().getVisibility(),
post.getCreatedDate(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,8 @@ void setUp() {
CreatePostRequest 포스트_생성_요청 = new CreatePostRequest(
말랑_블로그_이름,
"제목",
"내용",
"인트로", "내용",
null,
"인트로",
PUBLIC,
null,
JPA_카테고리_ID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,8 @@ protected void setUp() {
공개_포스트를_비공개로_바꾸는_요청 = new UpdatePostRequest(
말랑_블로그_이름,
"보호로 변경",
"보호",
"인트로", "보호",
null,
"인트로",
PRIVATE,
null,
null,
Expand Down
18 changes: 6 additions & 12 deletions src/test/java/com/mallang/acceptance/post/DraftAcceptanceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,8 @@ protected void setUp() {
임시_글_생성_요청 = new CreateDraftRequest(
말랑_블로그_이름,
"첫 임시_글",
"첫 임시_글이네요.",
"첫 임시_글 인트로", "첫 임시_글이네요.",
"임시_글 썸네일 이름",
"첫 임시_글 인트로",
Spring_카테고리_ID,
List.of("태그1", "태그2")
);
Expand All @@ -83,9 +82,8 @@ class 임시_글_저장_API {
CreateDraftRequest createDraftRequest = new CreateDraftRequest(
말랑_블로그_이름,
"첫 임시_글",
"첫 임시_글이네요.",
"첫 임시_글 인트로", "첫 임시_글이네요.",
"임시_글 썸네일 이름",
"첫 임시_글 인트로",
Spring_카테고리_ID,
List.of("태그1", "태그2")
);
Expand All @@ -107,9 +105,8 @@ class 임시_글_수정_API {
var 임시_글_ID = ID를_추출한다(임시_글_생성_요청(말랑_세션_ID, 임시_글_생성_요청));
UpdateDraftRequest 임시_글_수정_요청 = new UpdateDraftRequest(
"업데이트 제목",
"업데이트 내용",
"업데이트 인트로", "업데이트 내용",
"업데이트 임시_글 썸네일 이름",
"업데이트 인트로",
Spring_카테고리_ID,
List.of("태그1", "태그2")
);
Expand All @@ -127,9 +124,8 @@ class 임시_글_수정_API {
var 임시_글_ID = ID를_추출한다(임시_글_생성_요청(말랑_세션_ID, 임시_글_생성_요청));
UpdateDraftRequest 임시_글_수정_요청 = new UpdateDraftRequest(
"업데이트 제목",
"업데이트 내용",
"업데이트 인트로", "업데이트 내용",
"업데이트 임시_글 썸네일 이름",
"업데이트 인트로",
Spring_카테고리_ID,
List.of("태그1", "태그2")
);
Expand Down Expand Up @@ -179,18 +175,16 @@ class 임시_글_목록_조회_API {
CreateDraftRequest 임시_글_1_생성_요청 = new CreateDraftRequest(
말랑_블로그_이름,
"임시 글 1",
"첫 임시 글이네요.",
"첫 임시 글 인트로", "첫 임시 글이네요.",
"임시 글 썸네일 이름",
"첫 임시 글 인트로",
Spring_카테고리_ID,
List.of("태그1", "태그2")
);
CreateDraftRequest 임시_글_2_생성_요청 = new CreateDraftRequest(
말랑_블로그_이름,
"임시 글 2",
"두번째",
"임시 글 2 인트로", "두번째",
"임시 글 썸네일 이름",
"임시 글 2 인트로",
null,
Collections.emptyList()
);
Expand Down
Loading

0 comments on commit 95b9f2e

Please sign in to comment.