Refactor to use SpringJPA

This commit is contained in:
Max W.
2025-01-17 00:20:32 +01:00
parent 7ebd6a2587
commit ed30a5f712
16 changed files with 200 additions and 333 deletions

View File

@@ -0,0 +1,6 @@
package de.w665.biblenotes.db.entity;
public enum Role {
ADMINISTRATOR,
USER
}

View File

@@ -0,0 +1,37 @@
package de.w665.biblenotes.db.entity;
import jakarta.persistence.*;
import lombok.*;
import java.time.LocalDateTime;
@Entity
@Table(name = "users")
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(nullable = false, unique = true)
private String username;
@Column(nullable = false)
private String password;
@Column(nullable = false, unique = true)
private String email;
@Enumerated(EnumType.STRING)
@Column(nullable = false)
private Role role;
@Column(nullable = false)
private LocalDateTime createdAt;
@Column(nullable = false)
private LocalDateTime updatedAt;
}

View File

@@ -0,0 +1,28 @@
package de.w665.biblenotes.db.entity;
import jakarta.persistence.*;
import lombok.*;
import java.time.LocalDateTime;
import java.util.Date;
@Entity
@Table(name = "user_logins")
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class UserLogin {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(nullable = false)
private Long userId;
@Column(nullable = false)
private LocalDateTime loginTime;
@Column(nullable = false)
private String loginIp;
}