命名Review

v1.4.1
Parker 4 years ago
parent 1134a927ff
commit 1c2fb46b47

@ -60,7 +60,7 @@ public class SystemHardwareInfo implements Serializable {
private List<SysFile> sysFiles = Lists.newLinkedList();
public void copyTo() throws Exception {
public void copyTo() {
SystemInfo si = new SystemInfo();
HardwareAbstractionLayer hal = si.getHardware();
OperatingSystem operatingSystem = si.getOperatingSystem();
@ -76,26 +76,26 @@ public class SystemHardwareInfo implements Serializable {
}
public void copyToCupInfo() throws Exception {
public void copyToCupInfo() {
SystemInfo si = new SystemInfo();
HardwareAbstractionLayer hal = si.getHardware();
setCpuInfo(hal.getProcessor());
}
public void copyToMemInfo() throws Exception {
public void copyToMemInfo() {
SystemInfo si = new SystemInfo();
HardwareAbstractionLayer hal = si.getHardware();
setMemInfo(hal.getMemory());
}
public void copyToSysInfo() throws Exception {
public void copyToSysInfo() {
SystemInfo si = new SystemInfo();
setSysInfo(si.getOperatingSystem());
}
public void copyToJvmInfo() throws Exception {
public void copyToJvmInfo() {
SystemInfo si = new SystemInfo();
HardwareAbstractionLayer hal = si.getHardware();
setJvmInfo();
}
public void copyToSysFilesInfo() throws Exception {
public void copyToSysFilesInfo() {
SystemInfo si = new SystemInfo();
setSysFiles(si.getOperatingSystem());
}

@ -15,16 +15,36 @@ import java.util.List;
*/
public interface IMonitorService {
Sys getSysInfo() throws Exception;
CPU getCpuInfo() throws Exception;
Mem getMemInfo() throws Exception;
JVM getJVMInfo() throws Exception;
List<SysFile> getSysFiles() throws Exception;
/**
*
* @return
*/
Sys getSysInfo();
/**
* CPU
* @return
*/
CPU getCpuInfo();
/**
*
* @return
*/
Mem getMemInfo();
/**
* JVM
* @return
*/
JVM getJVMInfo();
/**
*
* @return
*/
List<SysFile> getSysFiles();
}

@ -19,48 +19,38 @@ import java.util.List;
@Service
public class MonitorServiceImpl implements IMonitorService {
/**
*
* @return
* @throws Exception
*/
@Override
public Sys getSysInfo() throws Exception {
public Sys getSysInfo() {
SystemHardwareInfo systemHardwareInfo = new SystemHardwareInfo();
systemHardwareInfo.copyToSysInfo();
return systemHardwareInfo.getSys();
}
/**
* CPU
* @return
* @throws Exception
*/
@Override
public CPU getCpuInfo() throws Exception {
public CPU getCpuInfo() {
SystemHardwareInfo systemHardwareInfo = new SystemHardwareInfo();
systemHardwareInfo.copyToCupInfo();
return systemHardwareInfo.getCpu();
}
@Override
public Mem getMemInfo() throws Exception {
public Mem getMemInfo() {
SystemHardwareInfo systemHardwareInfo = new SystemHardwareInfo();
systemHardwareInfo.copyToMemInfo();
return systemHardwareInfo.getMem();
}
@Override
public JVM getJVMInfo() throws Exception {
public JVM getJVMInfo() {
SystemHardwareInfo systemHardwareInfo = new SystemHardwareInfo();
systemHardwareInfo.copyToJvmInfo();
return systemHardwareInfo.getJvm();
}
@Override
public List<SysFile> getSysFiles() throws Exception {
public List<SysFile> getSysFiles() {
SystemHardwareInfo systemHardwareInfo = new SystemHardwareInfo();
systemHardwareInfo.copyToSysFilesInfo();
return systemHardwareInfo.getSysFiles();

@ -4,6 +4,7 @@
*/
package org.opsli.modulars.system.monitor.web;
import com.google.common.collect.Maps;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
@ -36,8 +37,8 @@ public class MonitorController {
@RequiresPermissions("system_monitor_select")
@RequestMapping("/getSystemInfo")
@ApiOperation(value = "当前服务器信息", notes = "当前服务器信息")
public ResultVo<?> getSystemInfo() throws Exception {
Map<String,Object> map = new HashMap<>();
public ResultVo<?> getSystemInfo() {
Map<String,Object> map = Maps.newHashMapWithExpectedSize(5);
//服务器信息
map.put("systemInfo",iMonitorService.getSysInfo());
//CPU信息
@ -58,8 +59,9 @@ public class MonitorController {
@RequiresPermissions("system_monitor_select")
@RequestMapping("/getCpuInfo")
@ApiOperation(value = "当前CPU信息", notes = "当前CPU信息")
public ResultVo<?> getCpuInfo(HttpServletRequest request) throws Exception {
return ResultVo.success(iMonitorService.getCpuInfo());
public ResultVo<?> getCpuInfo() {
return ResultVo.success(
iMonitorService.getCpuInfo());
}
/**
@ -69,8 +71,9 @@ public class MonitorController {
@RequiresPermissions("system_monitor_select")
@RequestMapping("/getMemInfo")
@ApiOperation(value = "当前内存信息", notes = "当前内存信息")
public ResultVo<?> getMemInfo(HttpServletRequest request) throws Exception {
return ResultVo.success(iMonitorService.getMemInfo());
public ResultVo<?> getMemInfo() {
return ResultVo.success(
iMonitorService.getMemInfo());
}
/**
@ -80,8 +83,9 @@ public class MonitorController {
@RequiresPermissions("system_monitor_select")
@RequestMapping("/getJVMInfo")
@ApiOperation(value = "当前JVM信息", notes = "当前JVM信息")
public ResultVo<?> getJVMInfo(HttpServletRequest request) throws Exception {
return ResultVo.success(iMonitorService.getJVMInfo());
public ResultVo<?> getJVMInfo() {
return ResultVo.success(
iMonitorService.getJVMInfo());
}
}

Loading…
Cancel
Save