Create DTOs for the entities and added some fixme's

This commit is contained in:
Mika Bomm 2024-09-01 22:34:20 +02:00
parent 94b3fec5e2
commit e3defefef3
5 changed files with 61 additions and 1 deletions

View file

@ -1,5 +1,6 @@
package com.mixel.docusphere.controller;
import com.mixel.docusphere.dto.UserDTO;
import com.mixel.docusphere.entity.User;
import com.mixel.docusphere.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
@ -33,10 +34,16 @@ public class UserController {
}
@PostMapping
public User createUser(@RequestBody User user) {
public User createUser(@RequestBody UserDTO userDTO) {
User user = new User();
user.setUsername(userDTO.getUsername());
user.setName(userDTO.getName());
user.setEmail(userDTO.getEmail());
user.setPasswordHash(userDTO.getPassword());
return userService.save(user);
}
// FIXME: Use DTO instead of entity
@PutMapping("/{id}")
public ResponseEntity<User> updateUser(@PathVariable UUID id, @RequestBody User userDetails) {
Optional<User> user = userService.findById(id);

View file

@ -0,0 +1,6 @@
package com.mixel.docusphere.dto;
// FIXME: Implement document DTO
public class DocumentDTO {
}

View file

@ -0,0 +1,41 @@
package com.mixel.docusphere.dto;
public class UserDTO {
private String username;
private String name;
private String email;
private String password;
// Getters and Setters
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 getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}

View file

@ -15,6 +15,9 @@ public class Document {
@Column(name = "Name", nullable = false)
private String name;
@Column(name = "Description", nullable = true)
private String description;
@Column(name = "S3Path", nullable = false)
private String s3Path;

View file

@ -1,5 +1,6 @@
package com.mixel.docusphere.entity;
import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.*;
import java.time.LocalDateTime;
import java.util.UUID;
@ -21,9 +22,11 @@ public class User {
@Column(name = "Email", nullable = false, unique = true)
private String email;
@JsonIgnore
@Column(name = "PasswordHash", nullable = false)
private String passwordHash;
@JsonIgnore
@Column(name = "PasswordSalt", nullable = false)
private String passwordSalt;