Skip to content

Commit

Permalink
[#63] feat: ArticleController article update 기능 구현 및 테스트
Browse files Browse the repository at this point in the history
  • Loading branch information
jinyoungchoi95 committed Oct 24, 2021
1 parent 15f17cf commit 7c4cb44
Showing 1 changed file with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.study.realworld.article.controller.request;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.study.realworld.article.domain.Body;
import com.study.realworld.article.domain.Description;
import com.study.realworld.article.domain.Title;
import com.study.realworld.article.service.model.ArticleUpdateModel;
import java.util.Optional;

@JsonTypeName(value = "article")
@JsonTypeInfo(include = JsonTypeInfo.As.WRAPPER_OBJECT, use = JsonTypeInfo.Id.NAME)
public class ArticleUpdateRequest {

@JsonProperty("title")
private String title;

@JsonProperty("description")
private String description;

@JsonProperty("body")
private String body;

ArticleUpdateRequest() {
}

public ArticleUpdateModel toArticleUpdateModel() {
return new ArticleUpdateModel(
Optional.ofNullable(title).map(Title::of).orElse(null),
Optional.ofNullable(description).map(Description::of).orElse(null),
Optional.ofNullable(body).map(Body::of).orElse(null)
);
}

}

0 comments on commit 7c4cb44

Please sign in to comment.