Update admin UI overhaul, scores , tooltip/version fixes
This commit is contained in:
@@ -55,6 +55,7 @@ public class AdminSystemController extends BaseController {
|
||||
private final UpgradeLogRepository upgradeLogRepository;
|
||||
private final AuditLogRepository auditLogRepository;
|
||||
private final AuditLogService auditLogService;
|
||||
private final com.yaoyuan.jiscuss.service.IScoreService scoreService;
|
||||
|
||||
public AdminSystemController(
|
||||
UsersRepository usersRepository,
|
||||
@@ -65,7 +66,8 @@ public class AdminSystemController extends BaseController {
|
||||
UserRoleRepository userRoleRepository,
|
||||
UpgradeLogRepository upgradeLogRepository,
|
||||
AuditLogRepository auditLogRepository,
|
||||
AuditLogService auditLogService) {
|
||||
AuditLogService auditLogService,
|
||||
com.yaoyuan.jiscuss.service.IScoreService scoreService) {
|
||||
this.usersRepository = usersRepository;
|
||||
this.discussionsRepository = discussionsRepository;
|
||||
this.postsRepository = postsRepository;
|
||||
@@ -75,6 +77,7 @@ public class AdminSystemController extends BaseController {
|
||||
this.upgradeLogRepository = upgradeLogRepository;
|
||||
this.auditLogRepository = auditLogRepository;
|
||||
this.auditLogService = auditLogService;
|
||||
this.scoreService = scoreService;
|
||||
}
|
||||
|
||||
@GetMapping("/admin/home")
|
||||
@@ -294,6 +297,27 @@ public class AdminSystemController extends BaseController {
|
||||
return "admin/themes";
|
||||
}
|
||||
|
||||
/** 积分管理 — list all users sorted by score desc. */
|
||||
@GetMapping("/admin/scores")
|
||||
public String scores(HttpServletRequest request, ModelMap map) {
|
||||
fillCommon(request, map, "scores");
|
||||
List<User> users = usersRepository.findAll(Sort.by(Sort.Direction.DESC, "score"));
|
||||
map.put("users", users);
|
||||
return "admin/scores";
|
||||
}
|
||||
|
||||
/** Manually adjust a user's score (admin operation). */
|
||||
@PostMapping("/admin/scores/{id}/adjust")
|
||||
public String adjustScore(@PathVariable Integer id,
|
||||
@RequestParam int delta,
|
||||
HttpServletRequest request) {
|
||||
UserInfo operator = getUserInfo(request);
|
||||
scoreService.addScore(id, delta);
|
||||
auditLogService.log(operator, "score_adjust", "user", id,
|
||||
"score " + (delta >= 0 ? "+" : "") + delta);
|
||||
return "redirect:/admin/scores";
|
||||
}
|
||||
|
||||
private void fillCommon(HttpServletRequest request, ModelMap map, String active) {
|
||||
UserInfo user = getUserInfo(request);
|
||||
map.put("adminName", user == null ? "admin" : user.getUsername());
|
||||
@@ -327,13 +351,30 @@ public class AdminSystemController extends BaseController {
|
||||
result.put("java", System.getProperty("java.version"));
|
||||
result.put("spring", implVersion("org.springframework.core.SpringVersion"));
|
||||
result.put("hibernate", implVersion("org.hibernate.Version"));
|
||||
result.put("flyway", implVersion("org.flywaydb.core.Flyway"));
|
||||
result.put("druid", implVersion("com.alibaba.druid.pool.DruidDataSource"));
|
||||
result.put("flyway", mavenVersion("org.flywaydb", "flyway-core",
|
||||
implVersion("org.flywaydb.core.Flyway")));
|
||||
result.put("druid", mavenVersion("com.alibaba", "druid-spring-boot-3-starter",
|
||||
mavenVersion("com.alibaba", "druid",
|
||||
implVersion("com.alibaba.druid.pool.DruidDataSource"))));
|
||||
result.put("ehcache", implVersion("org.ehcache.CacheManager"));
|
||||
result.put("springdoc", implVersion("org.springdoc.core.configuration.SpringDocConfiguration"));
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Read version from META-INF/maven pom.properties (works in fat JARs). Falls back to {@code fallback}. */
|
||||
private String mavenVersion(String groupId, String artifactId, String fallback) {
|
||||
String path = "/META-INF/maven/" + groupId + "/" + artifactId + "/pom.properties";
|
||||
try (java.io.InputStream is = getClass().getResourceAsStream(path)) {
|
||||
if (is != null) {
|
||||
java.util.Properties props = new java.util.Properties();
|
||||
props.load(is);
|
||||
String v = props.getProperty("version");
|
||||
if (v != null && !v.isBlank()) return v;
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
return fallback;
|
||||
}
|
||||
|
||||
private String implVersion(String className) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName(className);
|
||||
|
||||
Reference in New Issue
Block a user