-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #72 from JimTheCat/CU-8696y76jy_EPIC---API-v3_King…
…a-Traczyk feature: Creating database models with reverse database engineering provided by jpa buddy
- Loading branch information
Showing
58 changed files
with
2,217 additions
and
318 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package meowhub.backend.constants; | ||
|
||
public enum Genders { | ||
FEMALE, MALE, OTHER | ||
} |
5 changes: 5 additions & 0 deletions
5
backend/src/main/java/meowhub/backend/constants/PrivacySettings.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package meowhub.backend.constants; | ||
|
||
public enum PrivacySettings { | ||
PUBLIC, FRIENDS_ONLY, PRIVATE | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package meowhub.backend.constants; | ||
|
||
public enum Roles { | ||
ROLE_USER, ROLE_ADMIN | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
backend/src/main/java/meowhub/backend/jpa_buddy/Chatroom.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package meowhub.backend.jpa_buddy; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.FetchType; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import jakarta.persistence.OneToMany; | ||
import jakarta.persistence.Table; | ||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.validation.constraints.Size; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
import org.hibernate.annotations.ColumnDefault; | ||
import org.hibernate.annotations.OnDelete; | ||
import org.hibernate.annotations.OnDeleteAction; | ||
|
||
import java.time.LocalDate; | ||
import java.util.LinkedHashSet; | ||
import java.util.Set; | ||
|
||
@Getter | ||
@Setter | ||
@Entity | ||
@Table(name = "CHATROOMS", schema = "mh_chats") | ||
public class Chatroom { | ||
@Id | ||
@Size(max = 36) | ||
@ColumnDefault("sys_guid()") | ||
@GeneratedValue(strategy = GenerationType.UUID) | ||
@Column(name = "ID", nullable = false, length = 36) | ||
private String id; | ||
|
||
@NotNull | ||
@ManyToOne(fetch = FetchType.LAZY, optional = false) | ||
@OnDelete(action = OnDeleteAction.RESTRICT) | ||
@JoinColumn(name = "SENDER_ID", nullable = false) | ||
private User sender; | ||
|
||
@NotNull | ||
@ManyToOne(fetch = FetchType.LAZY, optional = false) | ||
@OnDelete(action = OnDeleteAction.RESTRICT) | ||
@JoinColumn(name = "RECEIVER_ID", nullable = false) | ||
private User receiver; | ||
|
||
@Size(max = 20) | ||
@Column(name = "SENDER_NICK", length = 20) | ||
private String senderNick; | ||
|
||
@Size(max = 20) | ||
@Column(name = "RECEIVER_NICK", length = 20) | ||
private String receiverNick; | ||
|
||
@Column(name = "CREATED_AT") | ||
private LocalDate createdAt; | ||
|
||
@Size(max = 36) | ||
@Column(name = "CREATED_BY", length = 36) | ||
private String createdBy; | ||
|
||
@Column(name = "MODIFIED_AT") | ||
private LocalDate modifiedAt; | ||
|
||
@Size(max = 36) | ||
@Column(name = "MODIFIED_BY", length = 36) | ||
private String modifiedBy; | ||
|
||
@OneToMany(mappedBy = "chatroom") | ||
private Set<ChatroomMessage> chatroomMessages = new LinkedHashSet<>(); | ||
|
||
} |
80 changes: 80 additions & 0 deletions
80
backend/src/main/java/meowhub/backend/jpa_buddy/ChatroomMessage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package meowhub.backend.jpa_buddy; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.FetchType; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import jakarta.persistence.OneToMany; | ||
import jakarta.persistence.Table; | ||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.validation.constraints.Size; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
import org.hibernate.annotations.ColumnDefault; | ||
import org.hibernate.annotations.OnDelete; | ||
import org.hibernate.annotations.OnDeleteAction; | ||
|
||
import java.time.LocalDate; | ||
import java.util.LinkedHashSet; | ||
import java.util.Set; | ||
|
||
@Getter | ||
@Setter | ||
@Entity | ||
@Table(name = "CHATROOM_MESSAGES", schema = "mh_chats") | ||
public class ChatroomMessage { | ||
@Id | ||
@Size(max = 36) | ||
@ColumnDefault("sys_guid()") | ||
@GeneratedValue(strategy = GenerationType.UUID) | ||
@Column(name = "ID", nullable = false, length = 36) | ||
private String id; | ||
|
||
@NotNull | ||
@ManyToOne(fetch = FetchType.LAZY, optional = false) | ||
@OnDelete(action = OnDeleteAction.RESTRICT) | ||
@JoinColumn(name = "CHATROOM_ID", nullable = false) | ||
private Chatroom chatroom; | ||
|
||
@NotNull | ||
@ManyToOne(fetch = FetchType.LAZY, optional = false) | ||
@OnDelete(action = OnDeleteAction.RESTRICT) | ||
@JoinColumn(name = "AUTHOR_ID", nullable = false) | ||
private User author; | ||
|
||
@Size(max = 2000) | ||
@NotNull | ||
@Column(name = "MESSAGE", nullable = false, length = 2000) | ||
private String message; | ||
|
||
@NotNull | ||
@Column(name = "MSG_DATE", nullable = false) | ||
private LocalDate msgDate; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@OnDelete(action = OnDeleteAction.RESTRICT) | ||
@JoinColumn(name = "ANSWERED_MESSAGE_ID") | ||
private ChatroomMessage answeredMessage; | ||
|
||
@Column(name = "CREATED_AT") | ||
private LocalDate createdAt; | ||
|
||
@Size(max = 36) | ||
@Column(name = "CREATED_BY", length = 36) | ||
private String createdBy; | ||
|
||
@Column(name = "MODIFIED_AT") | ||
private LocalDate modifiedAt; | ||
|
||
@Size(max = 36) | ||
@Column(name = "MODIFIED_BY", length = 36) | ||
private String modifiedBy; | ||
|
||
@OneToMany(mappedBy = "answeredMessage") | ||
private Set<ChatroomMessage> chatroomMessages = new LinkedHashSet<>(); | ||
|
||
} |
78 changes: 78 additions & 0 deletions
78
backend/src/main/java/meowhub/backend/jpa_buddy/Comment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package meowhub.backend.jpa_buddy; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.FetchType; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import jakarta.persistence.OneToMany; | ||
import jakarta.persistence.Table; | ||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.validation.constraints.Size; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
import org.hibernate.annotations.ColumnDefault; | ||
import org.hibernate.annotations.OnDelete; | ||
import org.hibernate.annotations.OnDeleteAction; | ||
|
||
import java.time.LocalDate; | ||
import java.util.LinkedHashSet; | ||
import java.util.Set; | ||
|
||
@Getter | ||
@Setter | ||
@Entity | ||
@Table(name = "COMMENTS", schema = "mh_posts") | ||
public class Comment { | ||
@Id | ||
@Size(max = 36) | ||
@ColumnDefault("sys_guid()") | ||
@GeneratedValue(strategy = GenerationType.UUID) | ||
@Column(name = "ID", nullable = false, length = 36) | ||
private String id; | ||
|
||
@NotNull | ||
@ManyToOne(fetch = FetchType.LAZY, optional = false) | ||
@OnDelete(action = OnDeleteAction.RESTRICT) | ||
@JoinColumn(name = "POST_ID", nullable = false) | ||
private Post post; | ||
|
||
@NotNull | ||
@ManyToOne(fetch = FetchType.LAZY, optional = false) | ||
@OnDelete(action = OnDeleteAction.RESTRICT) | ||
@JoinColumn(name = "USER_ID", nullable = false) | ||
private User user; | ||
|
||
@Size(max = 2000) | ||
@Column(name = "VALUE", length = 2000) | ||
private String value; | ||
|
||
@Column(name = "\"index\"") | ||
private Long index; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@OnDelete(action = OnDeleteAction.RESTRICT) | ||
@JoinColumn(name = "ANSWERED_COMMENT_ID") | ||
private Comment answeredComment; | ||
|
||
@Column(name = "CREATED_AT") | ||
private LocalDate createdAt; | ||
|
||
@Size(max = 36) | ||
@Column(name = "CREATED_BY", length = 36) | ||
private String createdBy; | ||
|
||
@Column(name = "MODIFIED_AT") | ||
private LocalDate modifiedAt; | ||
|
||
@Size(max = 36) | ||
@Column(name = "MODIFIED_BY", length = 36) | ||
private String modifiedBy; | ||
|
||
@OneToMany(mappedBy = "answeredComment") | ||
private Set<Comment> comments = new LinkedHashSet<>(); | ||
|
||
} |
60 changes: 60 additions & 0 deletions
60
backend/src/main/java/meowhub/backend/jpa_buddy/Gender.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package meowhub.backend.jpa_buddy; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.OneToMany; | ||
import jakarta.persistence.Table; | ||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.validation.constraints.Size; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import meowhub.backend.constants.Genders; | ||
import org.hibernate.annotations.ColumnDefault; | ||
|
||
import java.time.LocalDate; | ||
import java.util.LinkedHashSet; | ||
import java.util.Set; | ||
|
||
@Getter | ||
@Setter | ||
@Entity | ||
@NoArgsConstructor | ||
@Table(name = "GENDERS", schema = "mh_users") | ||
public class Gender { | ||
@Id | ||
@Size(max = 36) | ||
@ColumnDefault("sys_guid()") | ||
@GeneratedValue(strategy = GenerationType.UUID) | ||
@Column(name = "ID", nullable = false, length = 36) | ||
private String id; | ||
|
||
@Size(max = 20) | ||
@NotNull | ||
@Column(name = "CODE", nullable = false, length = 20) | ||
private String code; | ||
|
||
@Column(name = "CREATED_AT") | ||
private LocalDate createdAt; | ||
|
||
@Size(max = 36) | ||
@Column(name = "CREATED_BY", length = 36) | ||
private String createdBy; | ||
|
||
@Column(name = "MODIFIED_AT") | ||
private LocalDate modifiedAt; | ||
|
||
@Size(max = 36) | ||
@Column(name = "MODIFIED_BY", length = 36) | ||
private String modifiedBy; | ||
|
||
@OneToMany(mappedBy = "gender") | ||
private Set<User> users = new LinkedHashSet<>(); | ||
|
||
public Gender(Genders genders) { | ||
this.code = genders.name(); | ||
} | ||
} |
Oops, something went wrong.