summaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/blog/web/dto
diff options
context:
space:
mode:
authorrealtradam <[email protected]>2024-07-23 20:16:26 -0400
committerrealtradam <[email protected]>2024-07-23 20:16:26 -0400
commit56c59e3b98fe554c4e1484e208e4be5c30f09a04 (patch)
tree7f30db6e58f8f4376b4152d51140b6dd5c41cda4 /src/main/java/com/blog/web/dto
parent5e2eab6f32bc76918aa17791b688d1df27d6ddfc (diff)
downloadspring-blog-56c59e3b98fe554c4e1484e208e4be5c30f09a04.tar.gz
spring-blog-56c59e3b98fe554c4e1484e208e4be5c30f09a04.zip
convert all articles endpoint to json
Diffstat (limited to 'src/main/java/com/blog/web/dto')
-rw-r--r--src/main/java/com/blog/web/dto/ArticlePublicDto.java96
1 files changed, 96 insertions, 0 deletions
diff --git a/src/main/java/com/blog/web/dto/ArticlePublicDto.java b/src/main/java/com/blog/web/dto/ArticlePublicDto.java
new file mode 100644
index 0000000..3ced6d2
--- /dev/null
+++ b/src/main/java/com/blog/web/dto/ArticlePublicDto.java
@@ -0,0 +1,96 @@
+package com.blog.web.dto;
+
+import com.blog.web.models.Article;
+
+import java.time.LocalDateTime;
+
+public class ArticlePublicDto {
+ private Long id;
+ private String title;
+ private String photoUrl;
+ private String content;
+ private LocalDateTime createdOn;
+ private LocalDateTime updatedOn;
+ private String createdBy;
+
+ public ArticlePublicDto(long id, String title, String photoUrl, String content, String createdBy, LocalDateTime createdOn, LocalDateTime updatedOn) {
+ this.id = id;
+ this.title = title;
+ this.photoUrl = photoUrl;
+ this.content = content;
+ this.createdBy = createdBy;
+ this.createdOn = createdOn;
+ this.updatedOn = updatedOn;
+ }
+
+ public ArticlePublicDto() {
+ }
+
+ ;
+
+ public ArticlePublicDto(Article article) {
+ this.id = article.getId();
+ this.title = article.getTitle();
+ this.photoUrl = article.getPhotoUrl();
+ this.content = article.getContent();
+ this.createdBy = article.getCreatedBy().getUsername();
+ this.createdOn = article.getCreatedOn();
+ this.updatedOn = article.getUpdatedOn();
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle( String title) {
+ this.title = title;
+ }
+
+ public String getPhotoUrl() {
+ return photoUrl;
+ }
+
+ public void setPhotoUrl(String photoUrl) {
+ this.photoUrl = photoUrl;
+ }
+
+ public String getContent() {
+ return content;
+ }
+
+ public void setContent( String content) {
+ this.content = content;
+ }
+
+ public LocalDateTime getCreatedOn() {
+ return createdOn;
+ }
+
+ public void setCreatedOn(LocalDateTime createdOn) {
+ this.createdOn = createdOn;
+ }
+
+ public LocalDateTime getUpdatedOn() {
+ return updatedOn;
+ }
+
+ public void setUpdatedOn(LocalDateTime updatedOn) {
+ this.updatedOn = updatedOn;
+ }
+
+ public String getCreatedBy() {
+ return createdBy;
+ }
+
+ public void setCreatedBy(String createdBy) {
+ this.createdBy = createdBy;
+ }
+}