Skip to content

Commit

Permalink
Merge pull request #9 from Book-Mile/feat/#7
Browse files Browse the repository at this point in the history
[Feat/#7] 모든 엔티티 생성자 적용
  • Loading branch information
kingjinyong authored Nov 24, 2024
2 parents c9f8e7e + ce73144 commit 086b90b
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 3 deletions.
13 changes: 13 additions & 0 deletions src/main/java/com/bookmile/backend/domain/book/entity/Book.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@
import java.util.ArrayList;
import java.util.List;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

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

@Id
Expand Down Expand Up @@ -54,4 +56,15 @@ public class Book extends BaseEntity {

@Column(nullable = false)
private Boolean isDeleted = false;

public Book(String bookName, Integer page, String thumbNail, String publisher, String description, String link,
Double rating) {
this.bookName = bookName;
this.page = page;
this.thumbNail = thumbNail;
this.publisher = publisher;
this.description = description;
this.link = link;
this.rating = rating;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@
import jakarta.persistence.JoinColumn;
import jakarta.persistence.OneToOne;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
public class CheckPoint {

@Id
Expand All @@ -33,5 +35,11 @@ public class CheckPoint {
@Enumerated(EnumType.STRING)
private Type type;

private String FreeType;
private String freeType;

public CheckPoint(Group group, Type type, String freeType) {
this.group = group;
this.type = type;
this.freeType = freeType;
}
}
15 changes: 15 additions & 0 deletions src/main/java/com/bookmile/backend/domain/group/entity/Group.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
import java.util.ArrayList;
import java.util.List;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

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

@Id
Expand Down Expand Up @@ -57,4 +59,17 @@ public class Group extends BaseEntity {

@Column(nullable = false)
private Boolean isDeleted = false;

public Group(Book book, List<UserGroup> userGroup, CheckPoint checkPoint, String groupName, String description,
Long code, Boolean isOpen, Boolean isEnd) {
this.book = book;
this.userGroup = userGroup;
this.checkPoint = checkPoint;
this.groupName = groupName;
this.description = description;
this.code = code;
this.isOpen = isOpen;
this.isEnd = isEnd;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,25 @@
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

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

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

@Column
@Column(nullable = false)
private String imageUrl;

public Image(String imageUrl) {
this.imageUrl = imageUrl;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@
import java.util.ArrayList;
import java.util.List;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

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

@Id
Expand All @@ -34,4 +36,9 @@ public class Record extends BaseEntity {

@Column(nullable = false)
private Integer currentPage;

public Record(String text, Integer currentPage) {
this.text = text;
this.currentPage = currentPage;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

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

@Id
Expand All @@ -41,4 +43,11 @@ public class Review extends BaseEntity {

@Column(nullable = false)
private Boolean isDeleted = false;

public Review(User user, Book book, Double rating, String text) {
this.user = user;
this.book = book;
this.rating = rating;
this.text = text;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@
import java.util.ArrayList;
import java.util.List;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

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

@Id
Expand Down Expand Up @@ -50,4 +52,11 @@ public void addUserGroup(UserGroup userGroup) {
this.userGroup.add(userGroup);
userGroup.addUser(this);
}

public User(String name, String email, String password, String image) {
this.name = name;
this.email = email;
this.password = password;
this.image = image;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@
import java.util.ArrayList;
import java.util.List;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

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

@Id
Expand Down Expand Up @@ -55,7 +57,9 @@ public void addUser(User user) {
this.user = user;
}

public void addGroup(Group group) {
public UserGroup(User user, Group group, Role role) {
this.user = user;
this.group = group;
this.role = role;
}
}

0 comments on commit 086b90b

Please sign in to comment.