新增未读日志数量查询接口及服务实现

在系统模块的作业日志功能中,新增了一个获取当前登录用户可查看日志未读数量的接口。该接口通过调用LogReadService的新方法`getUnRead`来获取未读日志的数量。服务端的实现通过查询数据库中用户的阅读状态,统计出未读日志的数量并返回。
This commit is contained in:
furongxin 2024-09-14 10:59:58 +08:00
parent e8d15070c2
commit b2effbec4e
3 changed files with 23 additions and 0 deletions

View File

@ -209,6 +209,14 @@ public class LogInstanceController {
return success(readUserVO);
}
@GetMapping("/get-unRead")
@Operation(summary = "获取当前登录用户可查看日志未读的数量")
@PreAuthorize("@ss.hasPermission('system:view-log:query')")
public CommonResult<Long> unRead() {
return success(logReadService.getUnRead(getLoginUserId()));
}
@GetMapping("/export-excel")
@Operation(summary = "导出日志实例 Excel")
@PreAuthorize("@ss.hasPermission('system:log-instance:export')")

View File

@ -49,4 +49,11 @@ public interface LogReadService {
* @return 阅读状态
*/
Boolean isReadByLogId(Long logId);
/**
* 获取当前登录用户可查看日志未读的数量
* @param userId 用户编号
* @return 未读数量
*/
Long getUnRead(Long userId);
}

View File

@ -86,4 +86,12 @@ public class LogReadServiceImpl implements LogReadService{
return count > 0L;
}
@Override
public Long getUnRead(Long userId) {
return logReadMapper.selectCount(new LambdaQueryWrapperX<LogReadDo>()
.eq(LogReadDo::getReadUserId, userId)
.eq(LogReadDo::getReadStatus, 0));
}
}