Skip to content

Commit ac10bee

Browse files
committed
refactor: 속성 관련 검증로직 수정
1 parent e7a3993 commit ac10bee

File tree

2 files changed

+8
-27
lines changed

2 files changed

+8
-27
lines changed

src/main/java/dmu/dasom/api/domain/news/dto/NewsRequestDto.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@
1313
@Schema(name = "NewsRequestDto", description = "뉴스 생성 요청 DTO")
1414
public class NewsRequestDto {
1515

16-
@NotBlank
17-
@Size(max = 100)
16+
@NotBlank(message = "뉴스 제목은 필수입니다.")
17+
@Size(max = 100, message = "뉴스 제목은 최대 100자입니다.")
1818
@Schema(description = "뉴스 제목", example = "새로운 뉴스 제목")
1919
private String title;
2020

21-
@NotBlank
21+
@NotBlank(message = "뉴스 내용은 필수입니다.")
2222
@Schema(description = "뉴스 내용", example = "새로운 뉴스 내용")
2323
private String content;
2424

25-
@Size(max = 255)
25+
@Size(max = 255, message = "이미지 URL은 최대 255자입니다.")
2626
@Schema(description = "뉴스 이미지 URL", example = "http://example.com/image.jpg", nullable = true)
2727
private String imageUrl;
2828
}

src/main/java/dmu/dasom/api/domain/news/entity/NewsEntity.java

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
import dmu.dasom.api.domain.news.dto.NewsResponseDto;
66
import io.swagger.v3.oas.annotations.media.Schema;
77
import jakarta.persistence.*;
8-
import jakarta.validation.constraints.NotBlank;
9-
import jakarta.validation.constraints.NotNull;
10-
import jakarta.validation.constraints.Size;
118
import lombok.*;
129

1310
@Getter
@@ -24,20 +21,17 @@ public class NewsEntity extends BaseEntity {
2421
@Schema(description = "뉴스 ID", example = "1")
2522
private Long id;
2623

27-
@NotNull
28-
@Schema(description = "뉴스 제목", example = "뉴스 예제 제목")
2924
@Column(nullable = false, length = 100)
25+
@Schema(description = "뉴스 제목", example = "뉴스 예제 제목")
3026
private String title;
3127

3228
@Lob
33-
@NotNull
34-
@Schema(description = "뉴스 내용", example = "뉴스 예제 내용")
3529
@Column(nullable = false)
30+
@Schema(description = "뉴스 내용", example = "뉴스 예제 내용")
3631
private String content;
3732

38-
39-
@Schema(description = "뉴스 이미지 URL", example = "http://example.com/image.jpg")
4033
@Column(length = 255)
34+
@Schema(description = "뉴스 이미지 URL", example = "http://example.com/image.jpg")
4135
private String imageUrl;
4236

4337
// 뉴스 상태 업데이트
@@ -50,21 +44,8 @@ public NewsResponseDto toResponseDto() {
5044
return new NewsResponseDto(id, title, content, getCreatedAt(), imageUrl);
5145
}
5246

53-
//수정기능
47+
// 수정
5448
public void update(String title, String content, String imageUrl) {
55-
if (title == null || title.isBlank()) {
56-
throw new IllegalArgumentException("제목은 필수입니다");
57-
}
58-
if (title.length() > 100) {
59-
throw new IllegalArgumentException("제목은 100자까지");
60-
}
61-
if (content == null || content.isBlank()) {
62-
throw new IllegalArgumentException("내용은 필수입니다");
63-
}
64-
if (imageUrl != null && imageUrl.length() > 255) {
65-
throw new IllegalArgumentException("이미지 URL은 255자까지");
66-
}
67-
6849
this.title = title;
6950
this.content = content;
7051
this.imageUrl = imageUrl;

0 commit comments

Comments
 (0)