This commit is contained in:
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user