fix: stat problems

This commit is contained in:
Tim
2025-08-12 10:19:40 +08:00
parent 84c1833923
commit 9878c12e33
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);
}