Skip to content

Commit

Permalink
refactor: User 엔티티의 인증 정보와 신고 정보 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
1o18z committed Oct 23, 2023
1 parent 18093ad commit e8fe5fd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 23 deletions.
24 changes: 3 additions & 21 deletions src/main/java/coffeemeet/server/user/domain/ReportInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,22 @@
import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import java.time.LocalDateTime;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@Embeddable
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class ReportInfo {

private static final int REPORT_MIN_COUNT = 0;

@Column(nullable = false)
private int reportedCount;

@Column(nullable = false)
private LocalDateTime sanctionPeriod;

public ReportInfo(int reportedCount, LocalDateTime sanctionPeriod) {
validateReportedCount(reportedCount);
validateSanctionPeriod(sanctionPeriod);
this.reportedCount = reportedCount;
this.sanctionPeriod = sanctionPeriod;
}

private void validateReportedCount(int reportedCount) {
if (reportedCount < REPORT_MIN_COUNT) {
throw new IllegalArgumentException("올바르지 않은 신고횟수입니다.");
}
}

private void validateSanctionPeriod(LocalDateTime sanctionPeriod) {
if (sanctionPeriod == null) {
throw new IllegalArgumentException("올바르지 않은 제재 기간입니다.");
}
public ReportInfo() {
this.reportedCount = REPORT_MIN_COUNT;
this.sanctionPeriod = null;
}

}
5 changes: 3 additions & 2 deletions src/main/java/coffeemeet/server/user/domain/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@ public class User extends AdvancedBaseEntity {
private Profile profile;

@ManyToOne
@JoinColumn(name = "chatting_room_id", nullable = false)
@JoinColumn(name = "chatting_room_id")
private ChattingRoom chattingRoom;

@Embedded
@Column(nullable = false)
private Certification certification;

@Embedded
Expand All @@ -56,6 +55,8 @@ public User(
) {
this.oauthInfo = oauthInfo;
this.profile = profile;
this.certification = new Certification();
this.reportInfo = new ReportInfo();
}

public void updateBusinessCardUrl(String newBusinessCardUrl) {
Expand Down

0 comments on commit e8fe5fd

Please sign in to comment.