return the user DTO instead of the full user
Some checks failed
Deploy API / docker (17, 3.8.5) (push) Failing after 37s

This commit is contained in:
Lee 2024-08-01 06:55:42 +01:00
parent 1a13c08da8
commit 0f7a890e44
4 changed files with 46 additions and 3 deletions

View File

@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping(value = "/")
public class RootController {
/**
* A GET mapping to show the
* A GET mapping to show the welcome message.
*/
@ResponseBody
@GetMapping(value = "/")

View File

@ -2,6 +2,7 @@ package cc.fascinated.controller;
import cc.fascinated.exception.impl.BadRequestException;
import cc.fascinated.model.user.User;
import cc.fascinated.model.user.UserDTO;
import cc.fascinated.services.UserService;
import lombok.NonNull;
import org.springframework.beans.factory.annotation.Autowired;
@ -33,7 +34,7 @@ public class UserController {
*/
@ResponseBody
@GetMapping(value = "/{id}")
public ResponseEntity<User> getUser(@PathVariable String id) {
return ResponseEntity.ok(userService.getUser(id));
public ResponseEntity<UserDTO> getUser(@PathVariable String id) {
return ResponseEntity.ok(userService.getUser(id).getAsDTO());
}
}

View File

@ -43,4 +43,13 @@ public class User {
* </p>
*/
public boolean hasLoggedIn;
/**
* Converts the User object to a UserDTO object.
*
* @return The UserDTO object.
*/
public UserDTO getAsDTO() {
return new UserDTO(id, username, steamId);
}
}

View File

@ -0,0 +1,33 @@
package cc.fascinated.model.user;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.data.annotation.Id;
import java.util.UUID;
/**
* @author Fascinated (fascinated7)
*/
@AllArgsConstructor
@Getter
public class UserDTO {
/**
* The ID of the user.
*/
@Id
private final UUID id;
/**
* The username of the user.
* <p>
* Usually their Steam name.
* </p>
*/
private String username;
/**
* The ID of the users steam profile.
*/
private String steamId;
}