Skip to content

Commit

Permalink
[FEAT] add report domains and refactor schema
Browse files Browse the repository at this point in the history
  • Loading branch information
nogamsung committed Feb 19, 2024
1 parent d4e9d38 commit da83071
Show file tree
Hide file tree
Showing 7 changed files with 518 additions and 122 deletions.
47 changes: 47 additions & 0 deletions src/main/java/com/gabojait/gabojaitspring/domain/report/Block.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.gabojait.gabojaitspring.domain.report;

import com.gabojait.gabojaitspring.domain.base.BaseEntity;
import com.gabojait.gabojaitspring.domain.user.User;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.time.LocalDate;

@Getter
@Entity
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Block extends BaseEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "block_id")
private Long id;

@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REMOVE)
@JoinColumn(name = "user_id", nullable = false)
private User user;

@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REMOVE)
@JoinColumn(name = "blocker_id", nullable = false)
private User blocker;

@Column(nullable = false)
private LocalDate startAt;

@Column(nullable = false)
private LocalDate endAt;

@Builder
private Block(LocalDate startAt,
LocalDate endAt,
User user,
User blocker) {
this.startAt = startAt;
this.endAt = endAt;
this.user = user;
this.blocker = blocker;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.gabojait.gabojaitspring.domain.report;

import com.gabojait.gabojaitspring.domain.base.BaseEntity;
import com.gabojait.gabojaitspring.domain.user.User;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

import javax.persistence.*;

@Getter
@Entity
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Report extends BaseEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "report_id")
private Long id;

@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REMOVE)
@JoinColumn(name = "user_id", nullable = false)
private User user;

@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REMOVE)
@JoinColumn(name = "reporter_id", nullable = false)
private User reporter;

@Column(length = 100, nullable = false)
private String reason;

@Builder
private Report(String reason, User user, User reporter) {
this.reason = reason;
this.user = user;
this.reporter = reporter;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package com.gabojait.gabojaitspring.domain.report;

import com.gabojait.gabojaitspring.domain.base.BaseEntity;
import com.gabojait.gabojaitspring.domain.user.User;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.time.LocalDate;

@Getter
@Entity
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Suspend extends BaseEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "suspend_id")
private Long id;

@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REMOVE)
@JoinColumn(name = "user_id", nullable = false)
private User user;

@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REMOVE)
@JoinColumn(name = "admin_id", nullable = false)
private User admin;

@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REMOVE)
@JoinColumn(name = "report_id")
private Report report;

@Column(length = 100)
private String reason;

@Column(nullable = false)
private LocalDate startAt;

@Column(nullable = false)
private LocalDate endAt;

@Builder
private Suspend(String reason,
LocalDate startAt,
LocalDate endAt,
User user,
User admin,
Report report) {
this.reason = reason;
this.startAt = startAt;
this.endAt = endAt;
this.user = user;
this.admin = admin;
this.report = report;
}
}
Loading

0 comments on commit da83071

Please sign in to comment.