diff --git a/API/src/main/java/cc/fascinated/controller/RootController.java b/API/src/main/java/cc/fascinated/controller/RootController.java index 25a1f4b..7fccbda 100644 --- a/API/src/main/java/cc/fascinated/controller/RootController.java +++ b/API/src/main/java/cc/fascinated/controller/RootController.java @@ -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 = "/") diff --git a/API/src/main/java/cc/fascinated/controller/UserController.java b/API/src/main/java/cc/fascinated/controller/UserController.java index 9fbf861..e2f9f5b 100644 --- a/API/src/main/java/cc/fascinated/controller/UserController.java +++ b/API/src/main/java/cc/fascinated/controller/UserController.java @@ -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 getUser(@PathVariable String id) { - return ResponseEntity.ok(userService.getUser(id)); + public ResponseEntity getUser(@PathVariable String id) { + return ResponseEntity.ok(userService.getUser(id).getAsDTO()); } } diff --git a/API/src/main/java/cc/fascinated/model/user/User.java b/API/src/main/java/cc/fascinated/model/user/User.java index 776f343..192d062 100644 --- a/API/src/main/java/cc/fascinated/model/user/User.java +++ b/API/src/main/java/cc/fascinated/model/user/User.java @@ -43,4 +43,13 @@ public class User { *

*/ public boolean hasLoggedIn; + + /** + * Converts the User object to a UserDTO object. + * + * @return The UserDTO object. + */ + public UserDTO getAsDTO() { + return new UserDTO(id, username, steamId); + } } diff --git a/API/src/main/java/cc/fascinated/model/user/UserDTO.java b/API/src/main/java/cc/fascinated/model/user/UserDTO.java new file mode 100644 index 0000000..55dc862 --- /dev/null +++ b/API/src/main/java/cc/fascinated/model/user/UserDTO.java @@ -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. + *

+ * Usually their Steam name. + *

+ */ + private String username; + + /** + * The ID of the users steam profile. + */ + private String steamId; +}