---
date: 2025-03-28 03:46:49
title: License使用
permalink: /pages/6817ab
tags:
  - Spring Boot
author:
  name: 华总
  link: https://xiaoying.org.cn
categories:
  - 后端
  - 功能扩展
  - 通用模块

---






## 引用

```java
@RestController
@Slf4j
@RequestMapping("/license")
public class LicenseController {
  
    @Resource
    private LicenseService licenseService;

    @Resource
    private LicenseVerify licenseVerify;
}
```



## 获取服务器硬件信息

```java
@Operation(summary = "获取服务器硬件信息")
@GetMapping("/getServerInfos")
public BaseResponse<LicenseCheckModel> getServerInfos(@RequestParam String osName) {
    return licenseService.getServerInfos(osName);
}
```



## 生成证书

```java
@Operation(summary = "生成证书")
@PostMapping("/generateLicense")
public Map<String, Object> generateLicense(@RequestBody @Valid LicenseCreatorParam param) {
    return licenseService.generateLicense(param);
}
```



## 上传授权文件

```java
@Operation(summary = "上传授权文件")
@PostMapping("/uploadLicense")
public BaseResponse<String> uploadLicense(@RequestParam("file") MultipartFile file) throws Exception {
    return licenseService.uploadFileByParam(file);
}
```



## 校验证书

```java
@Operation(summary = "校验证书")
@GetMapping("/verifyLicense")
public BaseResponse<Long> verifyLicense() throws Exception {
    return licenseVerify.verifyLicense();
}
```