Merge pull request #507 from nagisa77/feature/stats

fix: stat problems
This commit is contained in:
Tim
2025-08-12 10:21:08 +08:00
committed by GitHub
3 changed files with 10 additions and 2 deletions

View File

@@ -121,6 +121,7 @@ public class SecurityConfig {
.requestMatchers(HttpMethod.POST, "/api/tags/**").authenticated()
.requestMatchers(HttpMethod.DELETE, "/api/categories/**").hasAuthority("ADMIN")
.requestMatchers(HttpMethod.DELETE, "/api/tags/**").hasAuthority("ADMIN")
.requestMatchers(HttpMethod.GET, "/api/stats/**").hasAuthority("ADMIN")
.requestMatchers("/api/admin/**").hasAuthority("ADMIN")
.anyRequest().authenticated()
)

View File

@@ -20,7 +20,15 @@ public class StatService {
private Map<LocalDate, Long> toDateMap(LocalDate start, LocalDate end, java.util.List<Object[]> list) {
Map<LocalDate, Long> result = new LinkedHashMap<>();
for (var obj : list) {
LocalDate d = (LocalDate) obj[0];
Object dateObj = obj[0];
LocalDate d;
if (dateObj instanceof java.sql.Date sqlDate) {
d = sqlDate.toLocalDate();
} else if (dateObj instanceof LocalDate localDate) {
d = localDate;
} else {
d = LocalDate.parse(dateObj.toString());
}
Long c = ((Number) obj[1]).longValue();
result.put(d, c);
}

View File

@@ -103,6 +103,5 @@ onMounted(loadData)
max-width: var(--page-max-width);
background-color: var(--background-color);
margin: 0 auto;
height: 100%;
}
</style>