API: show the whole user
Some checks failed
Deploy API / docker (17, 3.8.5) (push) Failing after 36s

This commit is contained in:
Lee 2024-08-01 16:44:32 +01:00
parent 7b1d4a73a5
commit f68fb48726
5 changed files with 10 additions and 49 deletions

View File

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

View File

@ -2,6 +2,7 @@ package cc.fascinated.model.score;
import cc.fascinated.model.leaderboard.Leaderboard;
import cc.fascinated.model.user.ScoreSaberAccount;
import cc.fascinated.model.user.User;
import lombok.AllArgsConstructor;
import lombok.Getter;
@ -74,9 +75,9 @@ public class ScoreResponse {
private Double accuracy;
/**
* The ID of the player who set the score.
* The user who set the score.
*/
private ScoreSaberAccount player;
private User user;
/**
* The ID of the leaderboard.

View File

@ -1,5 +1,6 @@
package cc.fascinated.model.user;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
@ -47,19 +48,11 @@ public class User {
* If they haven't logged in, we don't want to track their profiles.
* </p>
*/
@JsonIgnore
public boolean hasLoggedIn;
/**
* The user's ScoreSaber account token.
* The user's ScoreSaber account.
*/
public ScoreSaberAccount scoresaberAccount;
/**
* Converts the User object to a UserDTO object.
*
* @return The UserDTO object.
*/
public UserDTO getAsDTO() {
return new UserDTO(id, username, steamId);
}
}

View File

@ -1,33 +0,0 @@
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;
}

View File

@ -89,7 +89,7 @@ public class TrackedScoreService {
trackedScore.getBadCuts(),
trackedScore.getMaxCombo(),
trackedScore.getAccuracy(),
user.getScoresaberAccount(),
user,
leaderboard,
trackedScore.getTimestamp()
));