Public Access
Small fixed
This commit is contained in:
1 parent
3159736c16
commit
73dfeb4e7d
4 files changed
+24
-4
No files matched your search
@@ -1,6 +1,7 @@
|
||||
package auth_service.modules.stats.api;
|
||||
|
||||
import auth_service.modules.stats.api.dto.PublicStatsDto;
|
||||
import auth_service.modules.stats.api.mapper.ApiMapper;
|
||||
import auth_service.modules.stats.service.PublicStatsService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@@ -17,6 +18,6 @@ public class PublicStatsController {
|
||||
|
||||
@GetMapping("/public")
|
||||
public ResponseEntity<PublicStatsDto> getPublicStats() {
|
||||
return ResponseEntity.ok(publicStatsService.getPublicStats());
|
||||
return ResponseEntity.ok(ApiMapper.toApi(publicStatsService.getPublicStats()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package auth_service.modules.stats.api.mapper;
|
||||
|
||||
import auth_service.modules.stats.api.dto.PublicStatsDto;
|
||||
import auth_service.modules.stats.model.PublicStats;
|
||||
|
||||
public abstract class ApiMapper {
|
||||
private ApiMapper() {
|
||||
}
|
||||
|
||||
public static PublicStatsDto toApi(PublicStats stats) {
|
||||
return new PublicStatsDto(stats.totalUsers(), stats.usersWithSteamLinked());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package auth_service.modules.stats.model;
|
||||
|
||||
public record PublicStats(
|
||||
long totalUsers,
|
||||
long usersWithSteamLinked
|
||||
) {}
|
||||
@@ -1,6 +1,6 @@
|
||||
package auth_service.modules.stats.service;
|
||||
|
||||
import auth_service.modules.stats.api.dto.PublicStatsDto;
|
||||
import auth_service.modules.stats.model.PublicStats;
|
||||
import auth_service.modules.stats.repo.StatsRepository;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
@@ -13,8 +13,8 @@ public class PublicStatsService {
|
||||
private final StatsRepository statsRepository;
|
||||
|
||||
@Cacheable(value = "publicStats", key = "'global'")
|
||||
public PublicStatsDto getPublicStats() {
|
||||
return new PublicStatsDto(
|
||||
public PublicStats getPublicStats() {
|
||||
return new PublicStats(
|
||||
statsRepository.countTotalUsers(),
|
||||
statsRepository.countUsersWithSteamLinked()
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user