diff --git a/src/main/java/com/pi/ati/ort/back/classes/RegisterRequest.java b/src/main/java/com/pi/ati/ort/back/classes/RegisterRequest.java index 61c3c67..f87ea28 100644 --- a/src/main/java/com/pi/ati/ort/back/classes/RegisterRequest.java +++ b/src/main/java/com/pi/ati/ort/back/classes/RegisterRequest.java @@ -4,14 +4,16 @@ public class RegisterRequest { private String name; private String username; private String password; + private String role; public RegisterRequest() { } - public RegisterRequest(String name, String username, String password) { + public RegisterRequest(String name, String username, String password, String role) { this.name = name; this.username = username; this.password = password; + this.role = role; } public String getName() { @@ -37,4 +39,12 @@ public String getPassword() { public void setPassword(String password) { this.password = password; } + + public String getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } } diff --git a/src/main/java/com/pi/ati/ort/back/controllers/AuthController.java b/src/main/java/com/pi/ati/ort/back/controllers/AuthController.java index 3ace0cf..839e159 100644 --- a/src/main/java/com/pi/ati/ort/back/controllers/AuthController.java +++ b/src/main/java/com/pi/ati/ort/back/controllers/AuthController.java @@ -46,6 +46,7 @@ public ResponseEntity register(@Valid @RequestBody RegisterRequest registe user.setName(registerRequest.getName()); user.setUsername(registerRequest.getUsername()); user.setPassword(registerRequest.getPassword()); + user.setRole(User.Role.valueOf(registerRequest.getRole())); bimClient.registerUser(user.getUsername(), user.getPassword(), user.getName()); User createdUser = userService.createUser(user); diff --git a/src/main/java/com/pi/ati/ort/back/entities/Model.java b/src/main/java/com/pi/ati/ort/back/entities/Model.java index bfba71a..13d4f73 100644 --- a/src/main/java/com/pi/ati/ort/back/entities/Model.java +++ b/src/main/java/com/pi/ati/ort/back/entities/Model.java @@ -3,6 +3,8 @@ import jakarta.persistence.*; import jakarta.validation.constraints.NotNull; +import java.util.Date; + @Entity @Table(name = "models") public class Model { @@ -19,6 +21,8 @@ public class Model { private Byte file; @NotNull private Long size; + @NotNull + private Date created_at = new Date(); public Model() { } @@ -97,4 +101,12 @@ public Long getBimId() { public void setBimId(Long bimId) { this.bimId = bimId; } + + public Date getCreated_at() { + return created_at; + } + + public void setCreated_at(Date created_at) { + this.created_at = created_at; + } } diff --git a/src/main/java/com/pi/ati/ort/back/entities/User.java b/src/main/java/com/pi/ati/ort/back/entities/User.java index 640c3f1..80c0edf 100644 --- a/src/main/java/com/pi/ati/ort/back/entities/User.java +++ b/src/main/java/com/pi/ati/ort/back/entities/User.java @@ -3,6 +3,8 @@ import jakarta.persistence.*; import jakarta.validation.constraints.NotNull; +import java.util.Date; + @Entity @Table(name = "users") public class User { @@ -16,14 +18,25 @@ public class User { private String username; @NotNull private String password; + @Enumerated(EnumType.STRING) + private Role role; + @NotNull + private Date created_at = new Date(); public User() { } - public User(Long id, String username, String password) { + public enum Role { + USER, + ADMIN + } + + public User(Long id, String name, String username, String password, Role role) { this.id = id; + this.name = name; this.username = username; this.password = password; + this.role = role; } public Long getId() { @@ -58,6 +71,22 @@ public void setPassword(String password) { this.password = password; } + public Role getRole() { + return role; + } + + public void setRole(Role role) { + this.role = role; + } + + public Date getCreated_at() { + return created_at; + } + + public void setCreated_at(Date created_at) { + this.created_at = created_at; + } + @Override public String toString() { return "User{" + @@ -65,6 +94,8 @@ public String toString() { ", name='" + name + '\'' + ", username='" + username + '\'' + ", password='" + password + '\'' + + ", role=" + role + + ", created_at=" + created_at + '}'; } }