Add interfaces for Document.java and User.java

This commit is contained in:
Mika Bomm 2024-09-01 17:29:23 +02:00
parent 11f61080f0
commit c121d62fb4
4 changed files with 217 additions and 0 deletions

View file

@ -0,0 +1,90 @@
package com.mixel.docusphere.entity;
import jakarta.persistence.*;
import java.util.UUID;
import java.time.LocalDateTime;
@Entity
@Table(name = "Documents")
public class Document {
@Id
@GeneratedValue(strategy = GenerationType.UUID)
@Column(name = "DocumentID", updatable = false, nullable = false)
private UUID documentId;
@Column(name = "Name", nullable = false)
private String name;
@Column(name = "S3Path", nullable = false)
private String s3Path;
@ManyToOne
@JoinColumn(name = "UserID", nullable = false)
private User user;
@Column(name = "CreatedAt", nullable = false, updatable = false)
private LocalDateTime createdAt;
@Column(name = "UpdatedAt", nullable = false)
private LocalDateTime updatedAt;
@PrePersist
protected void onCreate() {
createdAt = LocalDateTime.now();
updatedAt = LocalDateTime.now();
}
@PreUpdate
protected void onUpdate() {
updatedAt = LocalDateTime.now();
}
// Getters and Setters
public UUID getDocumentId() {
return documentId;
}
public void setDocumentId(UUID documentId) {
this.documentId = documentId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getS3Path() {
return s3Path;
}
public void setS3Path(String s3Path) {
this.s3Path = s3Path;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public LocalDateTime getCreatedAt() {
return createdAt;
}
public void setCreatedAt(LocalDateTime createdAt) {
this.createdAt = createdAt;
}
public LocalDateTime getUpdatedAt() {
return updatedAt;
}
public void setUpdatedAt(LocalDateTime updatedAt) {
this.updatedAt = updatedAt;
}
}

View file

@ -0,0 +1,111 @@
package com.mixel.docusphere.entity;
import jakarta.persistence.*;
import java.time.LocalDateTime;
import java.util.UUID;
@Entity
@Table(name = "Users")
public class User {
@Id
@GeneratedValue(strategy = GenerationType.UUID)
@Column(name = "UserID", updatable = false, nullable = false)
private UUID userId;
@Column(name = "Username", nullable = false, unique = true)
private String username;
@Column(name = "Name", nullable = false)
private String name;
@Column(name = "Email", nullable = false, unique = true)
private String email;
@Column(name = "PasswordHash", nullable = false)
private String passwordHash;
@Column(name = "PasswordSalt", nullable = false)
private String passwordSalt;
@Column(name = "CreatedAt", nullable = false, updatable = false)
private LocalDateTime createdAt;
@Column(name = "UpdatedAt", nullable = false)
private LocalDateTime updatedAt;
@PrePersist
protected void onCreate() {
createdAt = LocalDateTime.now();
updatedAt = LocalDateTime.now();
}
@PreUpdate
protected void onUpdate() {
updatedAt = LocalDateTime.now();
}
// Getters and Setters
public UUID getUserId() {
return userId;
}
public void setUserId(UUID userId) {
this.userId = userId;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPasswordHash() {
return passwordHash;
}
public void setPasswordHash(String passwordHash) {
this.passwordHash = passwordHash;
}
public String getPasswordSalt() {
return passwordSalt;
}
public void setPasswordSalt(String passwordSalt) {
this.passwordSalt = passwordSalt;
}
public LocalDateTime getCreatedAt() {
return createdAt;
}
public void setCreatedAt(LocalDateTime createdAt) {
this.createdAt = createdAt;
}
public LocalDateTime getUpdatedAt() {
return updatedAt;
}
public void setUpdatedAt(LocalDateTime updatedAt) {
this.updatedAt = updatedAt;
}
}

View file

@ -0,0 +1,8 @@
package com.mixel.docusphere.repository;
import com.mixel.docusphere.entity.Document;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.UUID;
public interface DocumentRepository extends JpaRepository<Document, UUID> {
}

View file

@ -0,0 +1,8 @@
package com.mixel.docusphere.repository;
import com.mixel.docusphere.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.UUID;
public interface UserRepository extends JpaRepository<User, UUID> {
}