Complete core functions #9

Merged
FatttSnake merged 171 commits from FatttSnake into dev 2024-02-23 11:56:35 +08:00
3 changed files with 15 additions and 15 deletions
Showing only changes of commit 1743b3d3d6 - Show all commits

View File

@@ -6,21 +6,21 @@ import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
import top.fatweb.api.entity.common.ResponseResult
import top.fatweb.api.service.system.IStatisticsService
import top.fatweb.api.service.system.IStatisticService
import top.fatweb.api.vo.system.*
/**
* Statistics controller
* Statistic controller
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
* @see IStatisticsService
* @see IStatisticService
*/
@Tag(name = "统计接口", description = "系统信息统计相关接口")
@RequestMapping("/system/statistics")
@RequestMapping("/system/statistic")
@RestController
class StatisticsController(
private val statisticsService: IStatisticsService
class StatisticController(
private val statisticService: IStatisticService
) {
/**
* Get software information
@@ -33,7 +33,7 @@ class StatisticsController(
*/
@Operation(summary = "获取软件信息")
@GetMapping("/software")
fun software(): ResponseResult<SoftwareInfoVo> = ResponseResult.success(data = statisticsService.software())
fun software(): ResponseResult<SoftwareInfoVo> = ResponseResult.success(data = statisticService.software())
/**
* Get hardware information
@@ -46,7 +46,7 @@ class StatisticsController(
*/
@Operation(summary = "获取硬件信息")
@GetMapping("/hardware")
fun hardware(): ResponseResult<HardwareInfoVo> = ResponseResult.success(data = statisticsService.hardware())
fun hardware(): ResponseResult<HardwareInfoVo> = ResponseResult.success(data = statisticService.hardware())
/**
* Get CPU information
@@ -59,7 +59,7 @@ class StatisticsController(
*/
@Operation(summary = "获取 CPU 信息")
@GetMapping("/cpu")
fun cpu(): ResponseResult<CpuInfoVo> = ResponseResult.success(data = statisticsService.cpu())
fun cpu(): ResponseResult<CpuInfoVo> = ResponseResult.success(data = statisticService.cpu())
/**
* Get storage information
@@ -72,5 +72,5 @@ class StatisticsController(
*/
@Operation(summary = "获取存储信息")
@GetMapping("/storage")
fun storage(): ResponseResult<StorageInfoVo> = ResponseResult.success(data = statisticsService.storage())
fun storage(): ResponseResult<StorageInfoVo> = ResponseResult.success(data = statisticService.storage())
}

View File

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

View File

@@ -4,7 +4,7 @@ import org.springframework.stereotype.Service
import oshi.SystemInfo
import oshi.hardware.CentralProcessor
import top.fatweb.api.properties.ServerProperties
import top.fatweb.api.service.system.IStatisticsService
import top.fatweb.api.service.system.IStatisticService
import top.fatweb.api.util.ByteUtil
import top.fatweb.api.vo.system.*
import java.time.LocalDateTime
@@ -13,13 +13,13 @@ import java.util.*
import java.util.concurrent.TimeUnit
/**
* Statistics service implement
* Statistic service implement
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@Service
class StatisticsServiceImpl : IStatisticsService {
class StatisticServiceImpl : IStatisticService {
private val systemProperties: Properties = System.getProperties()
private val systemInfo: SystemInfo = SystemInfo()
private val runtime: Runtime = Runtime.getRuntime()