-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #64 from real-world-study/jinyoungchoi95-issue63
[jinyoungchoi95-issue63] Article 단일조회 /수정 / 삭제 기능 구현
- Loading branch information
Showing
20 changed files
with
787 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/main/java/com/study/realworld/article/controller/request/ArticleUpdateRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/main/java/com/study/realworld/article/domain/ArticleRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,13 @@ | ||
package com.study.realworld.article.domain; | ||
|
||
import com.study.realworld.user.domain.User; | ||
import java.util.Optional; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface ArticleRepository extends JpaRepository<Article, Long> { | ||
|
||
Optional<Article> findByArticleContentSlugTitleSlug(Slug slug); | ||
|
||
Optional<Article> findByAuthorAndArticleContentSlugTitleSlug(User author, Slug slug); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/main/java/com/study/realworld/article/service/model/ArticleUpdateModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.study.realworld.article.service.model; | ||
|
||
import com.study.realworld.article.domain.Body; | ||
import com.study.realworld.article.domain.Description; | ||
import com.study.realworld.article.domain.Title; | ||
import java.util.Optional; | ||
|
||
public class ArticleUpdateModel { | ||
|
||
private final Title title; | ||
private final Description description; | ||
private final Body body; | ||
|
||
public ArticleUpdateModel(Title title, Description description, Body body) { | ||
this.title = title; | ||
this.description = description; | ||
this.body = body; | ||
} | ||
|
||
public Optional<Title> getTitle() { | ||
return Optional.ofNullable(title); | ||
} | ||
|
||
public Optional<Description> getDescription() { | ||
return Optional.ofNullable(description); | ||
} | ||
|
||
public Optional<Body> getBody() { | ||
return Optional.ofNullable(body); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.