Commit 7c35a79c authored by ZhengJie's avatar ZhengJie
Browse files

[新增功能](el-admin v2.5): v2.5 beta

详情 https://www.ydyno.com/archives/1225.html
parent d35ffc9d
package me.zhengjie.res;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import oshi.SystemInfo;
import oshi.hardware.CentralProcessor;
import oshi.hardware.GlobalMemory;
import oshi.hardware.HardwareAbstractionLayer;
import oshi.hardware.VirtualMemory;
import oshi.software.os.OSFileStore;
import oshi.software.os.OperatingSystem;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
* @author Zhang houying
* @date 2019-11-03
*/
@RestController
@RequestMapping("/api/serverMonitor")
public class ServerMonitorController {
private static final double GB = 1024 * 1024 * 1024.00;
@GetMapping
public ResponseEntity<Object> getServerInfo() {
Map<String, Object> resultMap = new HashMap<>(8);
try {
SystemInfo si = new SystemInfo();
HardwareAbstractionLayer hal = si.getHardware();
CentralProcessor processor = hal.getProcessor();
long[] prevTicks = processor.getSystemCpuLoadTicks();
TimeUnit.SECONDS.sleep(1);
resultMap.put("cpuRate", processor.getSystemCpuLoadBetweenTicks(prevTicks));
resultMap.put("cpuCore", processor.getLogicalProcessorCount());
GlobalMemory memory = hal.getMemory();
resultMap.put("memTotal", memory.getTotal() / GB);
resultMap.put("memUsed", (memory.getTotal() - memory.getAvailable()) / GB);
double diskTotal = 0;
double diskUsable = 0;
OperatingSystem os = si.getOperatingSystem();
OSFileStore[] fsArray = os.getFileSystem().getFileStores();
for (OSFileStore fs : fsArray) {
long usable = fs.getUsableSpace();
long total = fs.getTotalSpace();
diskTotal += total / GB;
diskUsable += usable / GB;
}
resultMap.put("diskTotal", diskTotal);
resultMap.put("diskUsed", diskTotal - diskUsable);
VirtualMemory vm = memory.getVirtualMemory();
resultMap.put("swapTotal", vm.getSwapTotal() / GB);
resultMap.put("swapUsed", vm.getSwapUsed() / GB);
} catch (Exception e) {
e.printStackTrace();
}
return new ResponseEntity<>(resultMap, HttpStatus.OK);
}
}
_ _ _
| | | | (_)
___| |______ __ _ __| |_ __ ___ _ _ __
/ _ | |______/ _` |/ _` | '_ ` _ \| | '_ \
| __| | | (_| | (_| | | | | | | | | | |
\___|_| \__,_|\__,_|_| |_| |_|_|_| |_|
:: Spring Boot :: (v2.1.0.RELEASE)
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<contextName>elAdmin Monitor</contextName>
<!--输出到控制台-->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%black(%contextName-) %red(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta(%logger{36}) - %gray(%msg%n)</pattern>
<charset>utf-8</charset>
</encoder>
</appender>
<!--普通日志输出到控制台-->
<root level="info">
<appender-ref ref="console" />
</root>
</configuration>
/**
* MIT License
* <p>
* Copyright (c) 2010 - 2020 The OSHI Project Contributors: https://github.com/oshi/oshi/graphs/contributors
* <p>
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* <p>
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* <p>
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package me.zhengjie;
import static org.junit.Assert.assertFalse;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import oshi.PlatformEnum;
import oshi.SystemInfo;
import oshi.hardware.CentralProcessor;
import oshi.hardware.CentralProcessor.TickType;
import oshi.hardware.ComputerSystem;
import oshi.hardware.Display;
import oshi.hardware.GlobalMemory;
import oshi.hardware.HWDiskStore;
import oshi.hardware.HWPartition;
import oshi.hardware.HardwareAbstractionLayer;
import oshi.hardware.NetworkIF;
import oshi.hardware.PhysicalMemory;
import oshi.hardware.PowerSource;
import oshi.hardware.Sensors;
import oshi.hardware.SoundCard;
import oshi.hardware.UsbDevice;
import oshi.hardware.VirtualMemory;
import oshi.software.os.FileSystem;
import oshi.software.os.NetworkParams;
import oshi.software.os.OSFileStore;
import oshi.software.os.OSProcess;
import oshi.software.os.OSService;
import oshi.software.os.OperatingSystem;
import oshi.software.os.OperatingSystem.ProcessSort;
import oshi.util.FormatUtil;
import oshi.util.Util;
/**
* A demonstration of access to many of OSHI's capabilities
*/
public class SystemInfoTest {
private static final Logger logger = LoggerFactory.getLogger(SystemInfoTest.class);
static List<String> oshi = new ArrayList<>();
/**
* Test that this platform is implemented..
*/
@Test
public void testPlatformEnum() {
assertFalse(PlatformEnum.UNKNOWN.equals(SystemInfo.getCurrentPlatformEnum()));
// Exercise the main method
main(null);
}
/**
* The main method, demonstrating use of classes.
*
* @param args the arguments (unused)
*/
public static void main(String[] args) {
logger.info("Initializing System...");
SystemInfo si = new SystemInfo();
HardwareAbstractionLayer hal = si.getHardware();
OperatingSystem os = si.getOperatingSystem();
printOperatingSystem(os);
logger.info("Checking computer system...");
printComputerSystem(hal.getComputerSystem());
logger.info("Checking Processor...");
printProcessor(hal.getProcessor());
logger.info("Checking Memory...");
printMemory(hal.getMemory());
logger.info("Checking CPU...");
printCpu(hal.getProcessor());
logger.info("Checking Processes...");
printProcesses(os, hal.getMemory());
logger.info("Checking Services...");
printServices(os);
logger.info("Checking Sensors...");
printSensors(hal.getSensors());
logger.info("Checking Power sources...");
printPowerSources(hal.getPowerSources());
logger.info("Checking Disks...");
printDisks(hal.getDiskStores());
logger.info("Checking File System...");
printFileSystem(os.getFileSystem());
logger.info("Checking Network interfaces...");
printNetworkInterfaces(hal.getNetworkIFs());
logger.info("Checking Network parameters...");
printNetworkParameters(os.getNetworkParams());
// hardware: displays
logger.info("Checking Displays...");
printDisplays(hal.getDisplays());
// hardware: USB devices
logger.info("Checking USB Devices...");
printUsbDevices(hal.getUsbDevices(true));
logger.info("Checking Sound Cards...");
printSoundCards(hal.getSoundCards());
StringBuilder output = new StringBuilder();
for (int i = 0; i < oshi.size(); i++) {
output.append(oshi.get(i));
if (oshi.get(i) != null && !oshi.get(i).endsWith("\n")) {
output.append('\n');
}
}
logger.info("Printing Operating System and Hardware Info:{}{}", '\n', output);
}
private static void printOperatingSystem(final OperatingSystem os) {
oshi.add(String.valueOf(os));
oshi.add("Booted: " + Instant.ofEpochSecond(os.getSystemBootTime()));
oshi.add("Uptime: " + FormatUtil.formatElapsedSecs(os.getSystemUptime()));
oshi.add("Running with" + (os.isElevated() ? "" : "out") + " elevated permissions.");
}
private static void printComputerSystem(final ComputerSystem computerSystem) {
oshi.add("system: " + computerSystem.toString());
oshi.add(" firmware: " + computerSystem.getFirmware().toString());
oshi.add(" baseboard: " + computerSystem.getBaseboard().toString());
}
private static void printProcessor(CentralProcessor processor) {
oshi.add(processor.toString());
}
private static void printMemory(GlobalMemory memory) {
oshi.add("Memory: \n " + memory.toString());
VirtualMemory vm = memory.getVirtualMemory();
oshi.add("Swap: \n " + vm.toString());
PhysicalMemory[] pmArray = memory.getPhysicalMemory();
if (pmArray.length > 0) {
oshi.add("Physical Memory: ");
for (PhysicalMemory pm : pmArray) {
oshi.add(" " + pm.toString());
}
}
}
private static void printCpu(CentralProcessor processor) {
oshi.add("Context Switches/Interrupts: " + processor.getContextSwitches() + " / " + processor.getInterrupts());
long[] prevTicks = processor.getSystemCpuLoadTicks();
long[][] prevProcTicks = processor.getProcessorCpuLoadTicks();
oshi.add("CPU, IOWait, and IRQ ticks @ 0 sec:" + Arrays.toString(prevTicks));
// Wait a second...
Util.sleep(1000);
long[] ticks = processor.getSystemCpuLoadTicks();
oshi.add("CPU, IOWait, and IRQ ticks @ 1 sec:" + Arrays.toString(ticks));
long user = ticks[TickType.USER.getIndex()] - prevTicks[TickType.USER.getIndex()];
long nice = ticks[TickType.NICE.getIndex()] - prevTicks[TickType.NICE.getIndex()];
long sys = ticks[TickType.SYSTEM.getIndex()] - prevTicks[TickType.SYSTEM.getIndex()];
long idle = ticks[TickType.IDLE.getIndex()] - prevTicks[TickType.IDLE.getIndex()];
long iowait = ticks[TickType.IOWAIT.getIndex()] - prevTicks[TickType.IOWAIT.getIndex()];
long irq = ticks[TickType.IRQ.getIndex()] - prevTicks[TickType.IRQ.getIndex()];
long softirq = ticks[TickType.SOFTIRQ.getIndex()] - prevTicks[TickType.SOFTIRQ.getIndex()];
long steal = ticks[TickType.STEAL.getIndex()] - prevTicks[TickType.STEAL.getIndex()];
long totalCpu = user + nice + sys + idle + iowait + irq + softirq + steal;
oshi.add(String.format(
"User: %.1f%% Nice: %.1f%% System: %.1f%% Idle: %.1f%% IOwait: %.1f%% IRQ: %.1f%% SoftIRQ: %.1f%% Steal: %.1f%%",
100d * user / totalCpu, 100d * nice / totalCpu, 100d * sys / totalCpu, 100d * idle / totalCpu,
100d * iowait / totalCpu, 100d * irq / totalCpu, 100d * softirq / totalCpu, 100d * steal / totalCpu));
oshi.add(String.format("CPU load: %.1f%%", processor.getSystemCpuLoadBetweenTicks(prevTicks) * 100));
double[] loadAverage = processor.getSystemLoadAverage(3);
oshi.add("CPU load averages:" + (loadAverage[0] < 0 ? " N/A" : String.format(" %.2f", loadAverage[0]))
+ (loadAverage[1] < 0 ? " N/A" : String.format(" %.2f", loadAverage[1]))
+ (loadAverage[2] < 0 ? " N/A" : String.format(" %.2f", loadAverage[2])));
// per core CPU
StringBuilder procCpu = new StringBuilder("CPU load per processor:");
double[] load = processor.getProcessorCpuLoadBetweenTicks(prevProcTicks);
for (double avg : load) {
procCpu.append(String.format(" %.1f%%", avg * 100));
}
oshi.add(procCpu.toString());
long freq = processor.getProcessorIdentifier().getVendorFreq();
if (freq > 0) {
oshi.add("Vendor Frequency: " + FormatUtil.formatHertz(freq));
}
freq = processor.getMaxFreq();
if (freq > 0) {
oshi.add("Max Frequency: " + FormatUtil.formatHertz(freq));
}
long[] freqs = processor.getCurrentFreq();
if (freqs[0] > 0) {
StringBuilder sb = new StringBuilder("Current Frequencies: ");
for (int i = 0; i < freqs.length; i++) {
if (i > 0) {
sb.append(", ");
}
sb.append(FormatUtil.formatHertz(freqs[i]));
}
oshi.add(sb.toString());
}
}
private static void printProcesses(OperatingSystem os, GlobalMemory memory) {
oshi.add("My PID: " + os.getProcessId() + " with affinity "
+ Long.toBinaryString(os.getProcessAffinityMask(os.getProcessId())));
oshi.add("Processes: " + os.getProcessCount() + ", Threads: " + os.getThreadCount());
// Sort by highest CPU
List<OSProcess> procs = Arrays.asList(os.getProcesses(5, ProcessSort.CPU));
oshi.add(" PID %CPU %MEM VSZ RSS Name");
for (int i = 0; i < procs.size() && i < 5; i++) {
OSProcess p = procs.get(i);
oshi.add(String.format(" %5d %5.1f %4.1f %9s %9s %s", p.getProcessID(),
100d * (p.getKernelTime() + p.getUserTime()) / p.getUpTime(),
100d * p.getResidentSetSize() / memory.getTotal(), FormatUtil.formatBytes(p.getVirtualSize()),
FormatUtil.formatBytes(p.getResidentSetSize()), p.getName()));
}
}
private static void printServices(OperatingSystem os) {
oshi.add("Services: ");
oshi.add(" PID State Name");
// DO 5 each of running and stopped
int i = 0;
for (OSService s : os.getServices()) {
if (s.getState().equals(OSService.State.RUNNING) && i++ < 5) {
oshi.add(String.format(" %5d %7s %s", s.getProcessID(), s.getState(), s.getName()));
}
}
i = 0;
for (OSService s : os.getServices()) {
if (s.getState().equals(OSService.State.STOPPED) && i++ < 5) {
oshi.add(String.format(" %5d %7s %s", s.getProcessID(), s.getState(), s.getName()));
}
}
}
private static void printSensors(Sensors sensors) {
oshi.add("Sensors: " + sensors.toString());
}
private static void printPowerSources(PowerSource[] powerSources) {
StringBuilder sb = new StringBuilder("Power Sources: ");
if (powerSources.length == 0) {
sb.append("Unknown");
}
for (PowerSource powerSource : powerSources) {
sb.append("\n ").append(powerSource.toString());
}
oshi.add(sb.toString());
}
private static void printDisks(HWDiskStore[] diskStores) {
oshi.add("Disks:");
for (HWDiskStore disk : diskStores) {
oshi.add(" " + disk.toString());
HWPartition[] partitions = disk.getPartitions();
for (HWPartition part : partitions) {
oshi.add(" |-- " + part.toString());
}
}
}
private static void printFileSystem(FileSystem fileSystem) {
oshi.add("File System:");
oshi.add(String.format(" File Descriptors: %d/%d", fileSystem.getOpenFileDescriptors(),
fileSystem.getMaxFileDescriptors()));
OSFileStore[] fsArray = fileSystem.getFileStores();
for (OSFileStore fs : fsArray) {
long usable = fs.getUsableSpace();
long total = fs.getTotalSpace();
oshi.add(String.format(
" %s (%s) [%s] %s of %s free (%.1f%%), %s of %s files free (%.1f%%) is %s "
+ (fs.getLogicalVolume() != null && fs.getLogicalVolume().length() > 0 ? "[%s]" : "%s")
+ " and is mounted at %s",
fs.getName(), fs.getDescription().isEmpty() ? "file system" : fs.getDescription(), fs.getType(),
FormatUtil.formatBytes(usable), FormatUtil.formatBytes(fs.getTotalSpace()), 100d * usable / total,
FormatUtil.formatValue(fs.getFreeInodes(), ""), FormatUtil.formatValue(fs.getTotalInodes(), ""),
100d * fs.getFreeInodes() / fs.getTotalInodes(), fs.getVolume(), fs.getLogicalVolume(),
fs.getMount()));
}
}
private static void printNetworkInterfaces(NetworkIF[] networkIFs) {
StringBuilder sb = new StringBuilder("Network Interfaces:");
if (networkIFs.length == 0) {
sb.append(" Unknown");
}
for (NetworkIF net : networkIFs) {
sb.append("\n ").append(net.toString());
}
oshi.add(sb.toString());
}
private static void printNetworkParameters(NetworkParams networkParams) {
oshi.add("Network parameters:\n " + networkParams.toString());
}
private static void printDisplays(Display[] displays) {
oshi.add("Displays:");
int i = 0;
for (Display display : displays) {
oshi.add(" Display " + i + ":");
oshi.add(String.valueOf(display));
i++;
}
}
private static void printUsbDevices(UsbDevice[] usbDevices) {
oshi.add("USB Devices:");
for (UsbDevice usbDevice : usbDevices) {
oshi.add(String.valueOf(usbDevice));
}
}
private static void printSoundCards(SoundCard[] cards) {
oshi.add("Sound Cards:");
for (SoundCard card : cards) {
oshi.add(" " + String.valueOf(card));
}
}
}
\ No newline at end of file
......@@ -14,6 +14,8 @@
<properties>
<jjwt.version>0.10.6</jjwt.version>
<!-- oshi监控需要指定jna版本, 问题详见 https://github.com/oshi/oshi/issues/1040 -->
<jna.version>5.5.0</jna.version>
</properties>
<dependencies>
......@@ -77,6 +79,12 @@
<version>0.1.55</version>
</dependency>
<dependency>
<groupId>com.github.oshi</groupId>
<artifactId>oshi-core</artifactId>
<version>4.7.1</version>
</dependency>
</dependencies>
<build>
......
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie;
import io.swagger.annotations.Api;
import me.zhengjie.annotation.AnonymousAccess;
import me.zhengjie.utils.SpringContextHolder;
import org.springframework.boot.SpringApplication;
......@@ -20,9 +36,10 @@ import org.springframework.web.bind.annotation.RestController;
*/
@EnableAsync
@RestController
@EnableJpaAuditing(auditorAwareRef = "auditorAware")
@Api(hidden = true)
@SpringBootApplication
@EnableTransactionManagement
@EnableJpaAuditing(auditorAwareRef = "auditorAware")
public class AppRun {
public static void main(String[] args) {
......
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.config;
import org.springframework.context.annotation.Bean;
......
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.config;
import me.zhengjie.modules.system.domain.Dept;
......
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.config;
import org.springframework.context.annotation.Bean;
......
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.config.thread;
import lombok.extern.slf4j.Slf4j;
......
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.config.thread;
import lombok.Data;
......
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.config.thread;
import org.springframework.stereotype.Component;
......
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.config.thread;
import me.zhengjie.utils.SpringContextHolder;
......
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.mnt.domain;
import lombok.Data;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import org.hibernate.annotations.CreationTimestamp;
import lombok.Getter;
import lombok.Setter;
import me.zhengjie.base.BaseEntity;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* @author zhanghouying
* @date 2019-08-24
*/
@Entity
@Data
@Getter
@Setter
@Table(name="mnt_app")
public class App implements Serializable {
public class App extends BaseEntity implements Serializable {
/**
* 应用编号
*/
@Id
@Column(name = "app_id")
@ApiModelProperty(value = "ID", hidden = true)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
/**
* 应用名称
*/
@Column(name = "name")
@ApiModelProperty(value = "名称")
private String name;
/**
* 端口
*/
@Column(name = "port")
@ApiModelProperty(value = "端口")
private int port;
/**
* 上传目录
*/
@Column(name = "upload_path")
@ApiModelProperty(value = "上传路径")
private String uploadPath;
/**
* 部署目录
*/
@Column(name = "deploy_path")
@ApiModelProperty(value = "部署路径")
private String deployPath;
/**
* 备份目录
*/
@Column(name = "backup_path")
@ApiModelProperty(value = "备份路径")
private String backupPath;
/**
* 启动脚本
*/
@Column(name = "start_script")
@ApiModelProperty(value = "启动脚本")
private String startScript;
/**
* 部署脚本
*/
@Column(name = "deploy_script")
@ApiModelProperty(value = "部署脚本")
private String deployScript;
@CreationTimestamp
private Timestamp createTime;
public void copy(App source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
......
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.mnt.domain;
import lombok.Data;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import org.hibernate.annotations.CreationTimestamp;
import lombok.Getter;
import lombok.Setter;
import me.zhengjie.base.BaseEntity;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* @author zhanghouying
* @date 2019-08-24
*/
@Entity
@Data
@Getter
@Setter
@Table(name="mnt_database")
public class Database implements Serializable {
public class Database extends BaseEntity implements Serializable {
/**
* id
*/
@Id
@Column(name = "id")
@Column(name = "db_id")
@ApiModelProperty(value = "ID", hidden = true)
private String id;
/**
* 数据库名称
*/
@Column(name = "name",nullable = false)
@ApiModelProperty(value = "数据库名称")
private String name;
/**
* 数据库连接地址
*/
@Column(name = "jdbc_url",nullable = false)
@ApiModelProperty(value = "数据库连接地址")
private String jdbcUrl;
/**
* 数据库密码
*/
@Column(name = "pwd",nullable = false)
@ApiModelProperty(value = "数据库密码")
private String pwd;
/**
* 用户名
*/
@Column(name = "user_name",nullable = false)
@ApiModelProperty(value = "用户名")
private String userName;
@CreationTimestamp
private Timestamp createTime;
public void copy(Database source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
......
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.mnt.domain;
import lombok.Data;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import org.hibernate.annotations.CreationTimestamp;
import lombok.Getter;
import lombok.Setter;
import me.zhengjie.base.BaseEntity;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Set;
/**
......@@ -15,34 +30,29 @@ import java.util.Set;
* @date 2019-08-24
*/
@Entity
@Data
@Getter
@Setter
@Table(name="mnt_deploy")
public class Deploy implements Serializable {
public class Deploy extends BaseEntity implements Serializable {
/**
* 部署编号
*/
@Id
@Column(name = "deploy_id")
@ApiModelProperty(value = "ID", hidden = true)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
/**
* 应用编号
*/
@ManyToMany
@ApiModelProperty(name = "服务器", hidden = true)
@JoinTable(name = "mnt_deploy_server",
joinColumns = {@JoinColumn(name = "deploy_id",referencedColumnName = "deploy_id")},
inverseJoinColumns = {@JoinColumn(name = "server_id",referencedColumnName = "server_id")})
private Set<ServerDeploy> deploys;
@ManyToOne
@JoinColumn(name = "app_id")
@ApiModelProperty(value = "应用编号")
private App app;
/**
* 服务器
*/
@ManyToMany
@JoinTable(name = "mnt_deploy_server", joinColumns = {@JoinColumn(name = "deploy_id",referencedColumnName = "id")}, inverseJoinColumns = {@JoinColumn(name = "server_id",referencedColumnName = "id")})
private Set<ServerDeploy> deploys;
@CreationTimestamp
private Timestamp createTime;
public void copy(Deploy source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
......
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.mnt.domain;
import lombok.Data;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.CreationTimestamp;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
......@@ -14,46 +30,30 @@ import java.sql.Timestamp;
* @date 2019-08-24
*/
@Entity
@Data
@Getter
@Setter
@Table(name="mnt_deploy_history")
public class DeployHistory implements Serializable {
/**
* 编号
*/
@Id
@Column(name = "id")
@Column(name = "history_id")
@ApiModelProperty(value = "ID", hidden = true)
private String id;
/**
* 应用名称
*/
@Column(name = "app_name",nullable = false)
@ApiModelProperty(value = "应用名称")
private String appName;
/**
* 部署IP
*/
@Column(name = "ip",nullable = false)
@ApiModelProperty(value = "IP")
private String ip;
/**
* 部署时间
*/
@Column(name = "deploy_date")
@CreationTimestamp
@ApiModelProperty(value = "部署时间")
private Timestamp deployDate;
/**
* 部署人员
*/
@Column(name = "deploy_user",nullable = false)
@ApiModelProperty(value = "部署者")
private String deployUser;
/**
* 部署编号
*/
@Column(name = "deploy_id",nullable = false)
@ApiModelProperty(value = "部署ID")
private Long deployId;
public void copy(DeployHistory source){
......
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.mnt.domain;
import lombok.Data;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import org.hibernate.annotations.CreationTimestamp;
import lombok.Getter;
import lombok.Setter;
import me.zhengjie.base.BaseEntity;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* @author zhanghouying
* @date 2019-08-24
*/
@Entity
@Data
@Getter
@Setter
@Table(name="mnt_server")
public class ServerDeploy implements Serializable {
public class ServerDeploy extends BaseEntity implements Serializable {
@Id
@Column(name = "server_id")
@ApiModelProperty(value = "ID", hidden = true)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ApiModelProperty(value = "服务器名称")
private String name;
@ApiModelProperty(value = "IP")
private String ip;
@ApiModelProperty(value = "端口")
private Integer port;
@ApiModelProperty(value = "账号")
private String account;
@ApiModelProperty(value = "密码")
private String password;
@CreationTimestamp
private Timestamp createTime;
public void copy(ServerDeploy source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
......
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.mnt.repository;
import me.zhengjie.modules.mnt.domain.App;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment