Endpoint to get own XP
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good

This commit is contained in:
2026-02-03 20:19:47 +01:00
parent 60d335f16d
commit e2a6b5919a
2 changed files with 21 additions and 0 deletions
@@ -237,4 +237,19 @@ public class UserController {
.cacheControl(CacheControl.maxAge(365, TimeUnit.DAYS))
.body(imageData);
}
@Operation(summary = "Get the users own xp", description = "A user can get their own xp.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "XP successfully retrieved",
content = @Content(mediaType = "application/json")),
@ApiResponse(responseCode = "403", description = "Not authorized",
content = @Content(mediaType = "application/json")),
@ApiResponse(responseCode = "404", description = "The user does not exist",
content = @Content(mediaType = "application/json"))
})
@GetMapping("/getTotalXP")
public ResponseEntity<Long> getTotalXP() {
Long xp = userService.getTotalXP();
return ResponseEntity.ok().body(xp);
}
}
@@ -1,5 +1,6 @@
package SuMoC.backend.user.service;
import SuMoC.backend.gamification.Timeframe;
import SuMoC.backend.images.ImageBase64Util;
import SuMoC.backend.security.dtos.LoginResponseDTO;
import SuMoC.backend.security.services.TokenService;
@@ -251,4 +252,9 @@ public class UserService {
return ImageBase64Util.encode(user.getProfileImage().getImageData());
}
public Long getTotalXP() {
User sender = currentUser.get();
return sender.getStats().getStatValue(Timeframe.TOTAL,"XP");
}
}