Rename statistic to statistics

This commit is contained in:
2023-12-20 11:32:47 +08:00
parent b2b4ac5302
commit 60353906ad
14 changed files with 83 additions and 66 deletions

View File

@@ -1,6 +0,0 @@
package top.fatweb.api.service.system
import com.baomidou.mybatisplus.extension.service.IService
import top.fatweb.api.entity.system.StatisticLog
interface IStatisticLogService : IService<StatisticLog>

View File

@@ -0,0 +1,6 @@
package top.fatweb.api.service.system
import com.baomidou.mybatisplus.extension.service.IService
import top.fatweb.api.entity.system.StatisticsLog
interface IStatisticsLogService : IService<StatisticsLog>

View File

@@ -5,12 +5,12 @@ import top.fatweb.api.param.system.OnlineInfoGetParam
import top.fatweb.api.vo.system.*
/**
* Statistic service interface
* Statistics service interface
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
interface IStatisticService {
interface IStatisticsService {
/**
* Get software information
*

View File

@@ -1,12 +0,0 @@
package top.fatweb.api.service.system.impl
import com.baomidou.dynamic.datasource.annotation.DS
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
import org.springframework.stereotype.Service
import top.fatweb.api.entity.system.StatisticLog
import top.fatweb.api.mapper.system.StatisticLogMapper
import top.fatweb.api.service.system.IStatisticLogService
@DS("sqlite")
@Service
class StatisticLogServiceImpl : ServiceImpl<StatisticLogMapper, StatisticLog>(), IStatisticLogService

View File

@@ -0,0 +1,12 @@
package top.fatweb.api.service.system.impl
import com.baomidou.dynamic.datasource.annotation.DS
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
import org.springframework.stereotype.Service
import top.fatweb.api.entity.system.StatisticsLog
import top.fatweb.api.mapper.system.StatisticsLogMapper
import top.fatweb.api.service.system.IStatisticsLogService
@DS("sqlite")
@Service
class StatisticsLogServiceImpl : ServiceImpl<StatisticsLogMapper, StatisticsLog>(), IStatisticsLogService

View File

@@ -6,14 +6,14 @@ import org.springframework.stereotype.Service
import oshi.SystemInfo
import oshi.hardware.CentralProcessor
import top.fatweb.api.entity.system.EventLog
import top.fatweb.api.entity.system.StatisticLog
import top.fatweb.api.entity.system.StatisticsLog
import top.fatweb.api.param.system.ActiveInfoGetParam
import top.fatweb.api.param.system.OnlineInfoGetParam
import top.fatweb.api.properties.SecurityProperties
import top.fatweb.api.properties.ServerProperties
import top.fatweb.api.service.system.IEventLogService
import top.fatweb.api.service.system.IStatisticLogService
import top.fatweb.api.service.system.IStatisticService
import top.fatweb.api.service.system.IStatisticsLogService
import top.fatweb.api.service.system.IStatisticsService
import top.fatweb.api.util.ByteUtil
import top.fatweb.api.util.RedisUtil
import top.fatweb.api.vo.system.*
@@ -25,17 +25,17 @@ import java.util.*
import java.util.concurrent.TimeUnit
/**
* Statistic service implement
* Statistics service implement
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@Service
class StatisticServiceImpl(
class StatisticsServiceImpl(
private val redisUtil: RedisUtil,
private val statisticLogService: IStatisticLogService,
private val statisticsLogService: IStatisticsLogService,
private val eventLogService: IEventLogService
) : IStatisticService {
) : IStatisticsService {
private val systemProperties: Properties = System.getProperties()
private val systemInfo: SystemInfo = SystemInfo()
private val runtime: Runtime = Runtime.getRuntime()
@@ -160,13 +160,13 @@ class StatisticServiceImpl(
)
override fun online(onlineInfoGetParam: OnlineInfoGetParam?): OnlineInfoVo {
val history: List<OnlineInfoVo.HistoryVo> = statisticLogService.list(
KtQueryWrapper(StatisticLog())
.select(StatisticLog::value, StatisticLog::recordTime)
.eq(StatisticLog::key, StatisticLog.KeyItem.ONLINE_USERS_COUNT)
val history: List<OnlineInfoVo.HistoryVo> = statisticsLogService.list(
KtQueryWrapper(StatisticsLog())
.select(StatisticsLog::value, StatisticsLog::recordTime)
.eq(StatisticsLog::key, StatisticsLog.KeyItem.ONLINE_USERS_COUNT)
.between(
onlineInfoGetParam?.scope != OnlineInfoGetParam.Scope.ALL,
StatisticLog::recordTime,
StatisticsLog::recordTime,
LocalDateTime.now(ZoneOffset.UTC).run {
when (onlineInfoGetParam?.scope) {
OnlineInfoGetParam.Scope.DAY -> minusDays(1)