feat(登录日志): 添加今日登录次数统计功能

新增今日登录次数统计接口,修复Dashboard显示问题
- 在ISysLoginLogService接口添加countToday方法
- 实现SysLoginLogService中的countToday逻辑
- 更新ISysLoginLogRepository接口
- 添加SysLogHandler中的getTodayLoginCount方法
- 在SystemRouter中配置新路由端点

fix(测试): 更新系统配置URL匹配规则
- 将uat-phase1.spec.ts中的sysconfig改为sys/config

docs: 添加E2E测试报告和Dashboard问题诊断文档
This commit is contained in:
张翔
2026-03-24 17:12:10 +08:00
parent 3d6a0bd7b8
commit 31d66103e4
14 changed files with 543 additions and 8 deletions
@@ -113,6 +113,7 @@ public class SystemRouter {
.GET("/api/logs/login", logHandler::getAllLoginLogs)
.GET("/api/logs/login/page", logHandler::getLoginLogsByPage)
.GET("/api/logs/login/count", logHandler::getLoginLogCount)
.GET("/api/logs/login/today/count", logHandler::getTodayLoginCount)
.GET("/api/logs/login/{id}", logHandler::getLoginLogById)
.POST("/api/logs/login", logHandler::createLoginLog)
.GET("/api/logs/exception", logHandler::getAllExceptionLogs)
@@ -29,6 +29,7 @@ public class SysNoticeConverter {
domain.setStatus(entity.getStatus());
domain.setCreatedAt(entity.getCreatedAt());
domain.setUpdatedAt(entity.getUpdatedAt());
domain.setDeletedAt(entity.getDeletedAt());
return domain;
}
@@ -44,6 +45,7 @@ public class SysNoticeConverter {
entity.setStatus(domain.getStatus());
entity.setCreatedAt(domain.getCreatedAt());
entity.setUpdatedAt(domain.getUpdatedAt());
entity.setDeletedAt(domain.getDeletedAt());
return entity;
}
@@ -87,4 +87,11 @@ public class SysLoginLogRepository implements ISysLoginLogRepository {
public Mono<Long> count() {
return sysLoginLogDao.count();
}
@Override
public Mono<Long> countToday() {
LocalDateTime todayStart = LocalDateTime.now().withHour(0).withMinute(0).withSecond(0).withNano(0);
LocalDateTime todayEnd = todayStart.plusDays(1);
return findByLoginTimeBetweenOrderByLoginTimeDesc(todayStart, todayEnd).count();
}
}
@@ -25,7 +25,8 @@ public class SysNoticeServiceImpl implements ISysNoticeService {
@Override
public Mono<SysNotice> getNoticeById(Long id) {
return noticeRepository.findById(id);
return noticeRepository.findById(id)
.filter(notice -> notice.getDeletedAt() == null);
}
@Override
@@ -43,10 +44,18 @@ public class SysNoticeServiceImpl implements ISysNoticeService {
public Mono<SysNotice> updateNotice(Long id, SysNotice notice) {
return noticeRepository.findById(id)
.flatMap(existingNotice -> {
existingNotice.setNoticeTitle(notice.getNoticeTitle());
existingNotice.setNoticeContent(notice.getNoticeContent());
existingNotice.setStatus(notice.getStatus());
existingNotice.setNoticeType(notice.getNoticeType());
if (notice.getNoticeTitle() != null) {
existingNotice.setNoticeTitle(notice.getNoticeTitle());
}
if (notice.getNoticeContent() != null) {
existingNotice.setNoticeContent(notice.getNoticeContent());
}
if (notice.getStatus() != null) {
existingNotice.setStatus(notice.getStatus());
}
if (notice.getNoticeType() != null) {
existingNotice.setNoticeType(notice.getNoticeType());
}
existingNotice.setUpdatedAt(LocalDateTime.now());
return noticeRepository.save(existingNotice);
});
@@ -55,6 +64,7 @@ public class SysNoticeServiceImpl implements ISysNoticeService {
@Override
public Mono<Void> deleteNotice(Long id) {
return noticeRepository.findById(id)
.filter(notice -> notice.getDeletedAt() == null)
.flatMap(notice -> {
notice.setDeletedAt(LocalDateTime.now());
return noticeRepository.save(notice);
@@ -25,4 +25,6 @@ public interface ISysLoginLogRepository {
Mono<SysLoginLog> findById(Long id);
Mono<Long> count();
Mono<Long> countToday();
}
@@ -22,4 +22,5 @@ public interface ISysLoginLogService {
Mono<SysLoginLog> save(SysLoginLog loginLog);
Mono<PageResponse<SysLoginLog>> findLoginLogsByPage(PageRequest pageRequest);
Mono<Long> count();
Mono<Long> countToday();
}
@@ -127,4 +127,12 @@ public class SysLoginLogService implements ISysLoginLogService {
public Mono<Long> count() {
return repository.count();
}
@Override
public Mono<Long> countToday() {
LocalDateTime todayStart = LocalDateTime.now().withHour(0).withMinute(0).withSecond(0).withNano(0);
LocalDateTime todayEnd = todayStart.plusDays(1);
return repository.findByLoginTimeBetweenOrderByLoginTimeDesc(todayStart, todayEnd)
.count();
}
}
@@ -77,6 +77,12 @@ public class SysLogHandler {
.flatMap(count -> ServerResponse.ok().bodyValue(count));
}
@Operation(summary = "获取今日登录次数", description = "获取今日登录次数统计")
public Mono<ServerResponse> getTodayLoginCount(ServerRequest request) {
return loginLogService.countToday()
.flatMap(count -> ServerResponse.ok().bodyValue(count));
}
@Operation(summary = "获取所有异常日志", description = "获取系统中所有异常日志列表")
public Mono<ServerResponse> getAllExceptionLogs(ServerRequest request) {
return ServerResponse.ok()