Skip to content

Commit b14db56

Browse files
committed
reafctor: ReportTagetType enum 별도 클래스로 분리
1 parent a29548a commit b14db56

File tree

5 files changed

+15
-9
lines changed

5 files changed

+15
-9
lines changed

src/main/java/com/example/log4u/domain/reports/dto/ReportCreateRequestDto.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import org.hibernate.validator.constraints.Length;
44

55
import com.example.log4u.domain.reports.entity.Report;
6+
import com.example.log4u.domain.reports.reportTargetType.ReportTargetType;
67
import com.example.log4u.domain.reports.reportType.ReportType;
78

89
import jakarta.validation.constraints.NotBlank;
@@ -16,7 +17,7 @@ public record ReportCreateRequestDto(
1617
@Length(min = 2)
1718
String content
1819
) {
19-
public Report toEntity(long reporterId, Report.ReportTargetType reportTargetType, Long targetId) {
20+
public Report toEntity(long reporterId, ReportTargetType reportTargetType, Long targetId) {
2021
return Report.builder()
2122
.reporterId(reporterId)
2223
.reportTargetType(reportTargetType)

src/main/java/com/example/log4u/domain/reports/entity/Report.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import org.springframework.data.annotation.CreatedDate;
66
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
77

8+
import com.example.log4u.domain.reports.reportTargetType.ReportTargetType;
89
import com.example.log4u.domain.reports.reportType.ReportType;
910

1011
import jakarta.persistence.Entity;
@@ -28,16 +29,11 @@
2829
@Entity
2930
@EntityListeners(AuditingEntityListener.class)
3031
public class Report {
31-
public enum ReportTargetType {
32-
DIARY,
33-
COMMENT
34-
}
35-
3632
@Id
3733
@GeneratedValue(strategy = GenerationType.IDENTITY)
3834
private Long id;
3935

40-
private long reporterId;
36+
private Long reporterId;
4137

4238
@Enumerated(EnumType.STRING)
4339
private ReportTargetType reportTargetType;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package com.example.log4u.domain.reports.reportTargetType;
2+
3+
public enum ReportTargetType {
4+
DIARY,
5+
COMMENT
6+
}

src/main/java/com/example/log4u/domain/reports/service/ReportService.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import com.example.log4u.domain.reports.dto.ReportCreateRequestDto;
77
import com.example.log4u.domain.reports.entity.Report;
8+
import com.example.log4u.domain.reports.reportTargetType.ReportTargetType;
89
import com.example.log4u.domain.reports.repository.ReportRepository;
910

1011
import lombok.RequiredArgsConstructor;
@@ -19,15 +20,15 @@ public void createDiaryReport(
1920
long reporterId,
2021
ReportCreateRequestDto reportCreateRequestDto,
2122
Long diaryId) {
22-
Report report = reportCreateRequestDto.toEntity(reporterId, Report.ReportTargetType.DIARY, diaryId);
23+
Report report = reportCreateRequestDto.toEntity(reporterId, ReportTargetType.DIARY, diaryId);
2324
reportRepository.save(report);
2425
}
2526

2627
public void createCommentReport(
2728
long reporterId,
2829
ReportCreateRequestDto reportCreateRequestDto,
2930
Long commentId) {
30-
Report report = reportCreateRequestDto.toEntity(reporterId, Report.ReportTargetType.COMMENT, commentId);
31+
Report report = reportCreateRequestDto.toEntity(reporterId, ReportTargetType.COMMENT, commentId);
3132
reportRepository.save(report);
3233
}
3334
}

src/main/java/com/example/log4u/domain/supports/entity/Support.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import lombok.Builder;
1818
import lombok.Getter;
1919
import lombok.NoArgsConstructor;
20+
import lombok.Setter;
2021

2122
@Builder
2223
@Getter
@@ -41,6 +42,7 @@ public class Support {
4142
@CreatedDate
4243
private LocalDateTime createdAt;
4344

45+
@Setter
4446
private String answerContent;
4547

4648
private LocalDateTime answeredAt;

0 commit comments

Comments
 (0)