Create DTOs for the entities and added some fixme's
This commit is contained in:
parent
94b3fec5e2
commit
e3defefef3
5 changed files with 61 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
||||||
package com.mixel.docusphere.controller;
|
package com.mixel.docusphere.controller;
|
||||||
|
|
||||||
|
import com.mixel.docusphere.dto.UserDTO;
|
||||||
import com.mixel.docusphere.entity.User;
|
import com.mixel.docusphere.entity.User;
|
||||||
import com.mixel.docusphere.service.UserService;
|
import com.mixel.docusphere.service.UserService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -33,10 +34,16 @@ public class UserController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping
|
@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);
|
return userService.save(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: Use DTO instead of entity
|
||||||
@PutMapping("/{id}")
|
@PutMapping("/{id}")
|
||||||
public ResponseEntity<User> updateUser(@PathVariable UUID id, @RequestBody User userDetails) {
|
public ResponseEntity<User> updateUser(@PathVariable UUID id, @RequestBody User userDetails) {
|
||||||
Optional<User> user = userService.findById(id);
|
Optional<User> user = userService.findById(id);
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
package com.mixel.docusphere.dto;
|
||||||
|
|
||||||
|
// FIXME: Implement document DTO
|
||||||
|
public class DocumentDTO {
|
||||||
|
|
||||||
|
}
|
41
server/src/main/java/com/mixel/docusphere/dto/UserDTO.java
Normal file
41
server/src/main/java/com/mixel/docusphere/dto/UserDTO.java
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,6 +15,9 @@ public class Document {
|
||||||
@Column(name = "Name", nullable = false)
|
@Column(name = "Name", nullable = false)
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
@Column(name = "Description", nullable = true)
|
||||||
|
private String description;
|
||||||
|
|
||||||
@Column(name = "S3Path", nullable = false)
|
@Column(name = "S3Path", nullable = false)
|
||||||
private String s3Path;
|
private String s3Path;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.mixel.docusphere.entity;
|
package com.mixel.docusphere.entity;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
@ -21,9 +22,11 @@ public class User {
|
||||||
@Column(name = "Email", nullable = false, unique = true)
|
@Column(name = "Email", nullable = false, unique = true)
|
||||||
private String email;
|
private String email;
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
@Column(name = "PasswordHash", nullable = false)
|
@Column(name = "PasswordHash", nullable = false)
|
||||||
private String passwordHash;
|
private String passwordHash;
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
@Column(name = "PasswordSalt", nullable = false)
|
@Column(name = "PasswordSalt", nullable = false)
|
||||||
private String passwordSalt;
|
private String passwordSalt;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue