-
Notifications
You must be signed in to change notification settings - Fork 0
[feat] 다솜소식 API 구현 #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9a6709d
feat: 다솜소식 API 구현
dohy-eon 7382b30
feat: 코드중복 수정 및 BaseEntity 상속
dohy-eon 38def04
feat: 개별조회 추가
dohy-eon f936cc3
feat: setter -> builder() 패턴으로 변경
dohy-eon 6db6309
feat: NewsRequestDto에 생성자 추가 + 테스트케이스 작성
dohy-eon c173492
refactor: final 삭제 및 setter 제거
dohy-eon 4bd898a
feat: 다솜소식 수정, 삭제기능 추가
dohy-eon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
16 changes: 8 additions & 8 deletions
16
src/main/java/dmu/dasom/api/domain/news/dto/NewsRequestDto.java
This file contains hidden or 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,24 +1,24 @@ | ||
| package dmu.dasom.api.domain.news.dto; | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import jakarta.validation.constraints.NotNull; | ||
| import jakarta.validation.constraints.NotBlank; | ||
| import jakarta.validation.constraints.Size; | ||
| import lombok.Getter; | ||
| import lombok.Setter; | ||
|
|
||
| @Getter | ||
| @Setter | ||
| @Schema(description = "뉴스 요청 DTO") | ||
| @Schema(name = "NewsRequestDto", description = "뉴스 생성 요청 DTO") | ||
| public class NewsRequestDto { | ||
|
|
||
| @NotBlank | ||
| @Size(max = 100) | ||
| @Schema(description = "뉴스 제목", example = "새로운 뉴스 제목") | ||
| @NotNull | ||
| private String title; | ||
|
|
||
| @NotBlank | ||
| @Schema(description = "뉴스 내용", example = "새로운 뉴스 내용") | ||
| @NotNull | ||
| private String content; | ||
|
|
||
| @Schema(description = "뉴스 이미지 URL", example = "http://example.com/new-image.jpg") | ||
| @Size(max = 255) | ||
| @Schema(description = "뉴스 이미지 URL", example = "http://example.com/image.jpg", nullable = true) | ||
| private String imageUrl; | ||
|
|
||
| } |
This file contains hidden or 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
42 changes: 25 additions & 17 deletions
42
src/main/java/dmu/dasom/api/domain/news/entity/NewsEntity.java
This file contains hidden or 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,40 +1,48 @@ | ||
| package dmu.dasom.api.domain.news.entity; | ||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import jakarta.persistence.Entity; | ||
| import jakarta.persistence.GeneratedValue; | ||
| import jakarta.persistence.GenerationType; | ||
| import jakarta.persistence.Id; | ||
|
|
||
| import dmu.dasom.api.domain.common.BaseEntity; | ||
| import dmu.dasom.api.domain.common.Status; | ||
| import dmu.dasom.api.domain.news.dto.NewsResponseDto; | ||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import jakarta.persistence.*; | ||
| import jakarta.validation.constraints.NotNull; | ||
| import lombok.Getter; | ||
| import lombok.Setter; | ||
|
|
||
| import java.time.LocalDateTime; | ||
| import lombok.*; | ||
|
|
||
| @Getter | ||
| @Setter | ||
|
||
| @Entity | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| @Builder | ||
| @Schema(description = "뉴스 엔티티") | ||
| public class NewsEntity { | ||
| public class NewsEntity extends BaseEntity { | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| @Schema(description = "뉴스 ID", example = "1") | ||
| private Long id; | ||
|
|
||
| @Schema(description = "뉴스 제목", example = "뉴스 예제 제목") | ||
| @NotNull | ||
| @Schema(description = "뉴스 제목", example = "뉴스 예제 제목") | ||
| @Column(nullable = false, length = 100) | ||
| private String title; | ||
|
|
||
| @Schema(description = "뉴스 내용", example = "뉴스 예제 내용") | ||
| @NotNull | ||
| @Column(columnDefinition = "TEXT") | ||
| @Schema(description = "뉴스 내용", example = "뉴스 예제 내용") | ||
| @Column(columnDefinition = "TEXT", nullable = false) | ||
| private String content; | ||
|
|
||
| @Schema(description = "뉴스 작성일", example = "2025-02-14T12:00:00") | ||
| private LocalDateTime createdAt; | ||
|
|
||
| @Schema(description = "뉴스 이미지 URL", example = "http://example.com/image.jpg") | ||
| @Column(length = 255) | ||
| private String imageUrl; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이미지는 외부 DB에 저장하는 건가요? |
||
| } | ||
|
|
||
| // 🔹 뉴스 상태 업데이트 | ||
| public void updateStatus(Status status) { | ||
| super.updateStatus(status); | ||
| } | ||
|
|
||
| // 🔹 NewsEntity → NewsResponseDto 변환 | ||
| public NewsResponseDto toResponseDto() { | ||
| return new NewsResponseDto(id, title, content, getCreatedAt(), imageUrl); | ||
| } | ||
| } | ||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DTO를 불변 객체로 만들 필요는 없으므로 필드에 final 키워드는 빼는 것이 좋아보입니다