-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
✨ [FEAT] 소식, 댓글 생성 API 작성
- Loading branch information
Showing
5 changed files
with
149 additions
and
5 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
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
37 changes: 37 additions & 0 deletions
37
src/main/java/com/carely/backend/dto/news/CreateCommentDTO.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,37 @@ | ||
package com.carely.backend.dto.news; | ||
|
||
import com.carely.backend.domain.News; | ||
import com.carely.backend.domain.NewsComment; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@Getter | ||
public class CreateCommentDTO { | ||
@NotNull | ||
private String content; | ||
|
||
@Getter | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class Res { | ||
private Long commentId; | ||
private String content; | ||
private String writer; | ||
private LocalDateTime createdAt; | ||
|
||
public static CreateCommentDTO.Res toDTO(NewsComment news) { | ||
return CreateCommentDTO.Res.builder() | ||
.writer(news.getWriter().getUsername()) | ||
.content(news.getContent()) | ||
.createdAt(news.getCreatedAt()) | ||
.build(); | ||
} | ||
|
||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/com/carely/backend/dto/news/CreateNewsDTO.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,42 @@ | ||
package com.carely.backend.dto.news; | ||
|
||
import com.carely.backend.domain.News; | ||
import com.carely.backend.domain.enums.UserType; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@Getter | ||
public class CreateNewsDTO { | ||
@NotNull | ||
private String title; | ||
|
||
@NotNull | ||
private String content; | ||
|
||
@Getter | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class Res { | ||
private Long newsId; | ||
private String title; | ||
private String content; | ||
private String writer; | ||
private LocalDateTime createdAt; | ||
|
||
public static Res toDTO(News news) { | ||
return Res.builder() | ||
.writer(news.getWriter().getUsername()) | ||
.title(news.getTitle()) | ||
.content(news.getContent()) | ||
.createdAt(news.getCreatedAt()) | ||
.build(); | ||
} | ||
|
||
} | ||
} |
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