package org.jeecg.modules.base.controller;
|
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import lombok.extern.slf4j.Slf4j;
|
import org.apache.commons.lang3.StringUtils;
|
import org.jeecg.common.aspect.annotation.AutoLog;
|
import org.jeecg.config.license.*;
|
import org.jeecg.config.license.entity.LicenseCheckModel;
|
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.util.HashMap;
|
import java.util.Map;
|
|
/**
|
* @Author: lius
|
* @ClassName LicenseController
|
* @date 2024/11/2 17:35
|
*/
|
@Slf4j
|
@Api(tags = "license证书")
|
@RestController
|
@RequestMapping("/base/license")
|
public class LicenseController {
|
|
/**
|
* 证书生成路径
|
*/
|
@Value("${license.licensePath}")
|
private String licensePath;
|
|
/**
|
* @Author: lius
|
* @Description: 获取服务器硬件信息
|
* @DateTime: 17:35 2024/11/2
|
* @Params: osName 系统类型 windows或linux
|
* @Return
|
*/
|
@AutoLog(value = "获取服务器硬件信息")
|
@ApiOperation("获取服务器硬件信息")
|
@GetMapping("/getServerInfos/{osName}")
|
public LicenseCheckModel getServerInfos(@PathVariable String osName) {
|
//操作系统类型
|
if (StringUtils.isBlank(osName)) {
|
osName = System.getProperty("os.name");
|
}
|
osName = osName.toLowerCase();
|
|
AbstractServerInfos abstractServerInfos = null;
|
|
//根据不同操作系统类型选择不同的数据获取方法
|
if (osName.startsWith("windows")) {
|
abstractServerInfos = new WindowsServerInfos();
|
} else if (osName.startsWith("linux")) {
|
abstractServerInfos = new LinuxServerInfos();
|
} else {//其他服务器类型
|
abstractServerInfos = new LinuxServerInfos();
|
}
|
|
return abstractServerInfos.getServerInfos();
|
}
|
|
/**
|
* @Author: lius
|
* @Description: 生成证书
|
* @DateTime: 17:35 2024/11/2
|
*/
|
@AutoLog(value = "生成证书")
|
@ApiOperation("生成证书")
|
@PostMapping("/generateLicense")
|
public Map<String, Object> generateLicense(@RequestBody LicenseCreatorParam param) {
|
Map<String, Object> resultMap = new HashMap<>(2);
|
|
if (StringUtils.isBlank(param.getLicensePath())) {
|
param.setLicensePath(licensePath);
|
}
|
|
LicenseCreator licenseCreator = new LicenseCreator(param);
|
boolean result = licenseCreator.generateLicense();
|
|
if (result) {
|
resultMap.put("result", "ok");
|
resultMap.put("msg", param);
|
} else {
|
resultMap.put("result", "error");
|
resultMap.put("msg", "证书文件生成失败!");
|
}
|
|
return resultMap;
|
}
|
|
|
|
|
}
|