From 5a8d3f9952ec4ff545ef0f5878d861692b0a39a3 Mon Sep 17 00:00:00 2001 From: zhang <zc857179121@qq.com> Date: 星期二, 30 九月 2025 15:35:31 +0800 Subject: [PATCH] 13 --- src/main/java/com/zy/system/controller/LicenseCreatorController.java | 75 +++++++++++++++++++------------------ 1 files changed, 39 insertions(+), 36 deletions(-) diff --git a/src/main/java/com/zy/system/controller/LicenseCreatorController.java b/src/main/java/com/zy/system/controller/LicenseCreatorController.java index 6d0c904..5650623 100644 --- a/src/main/java/com/zy/system/controller/LicenseCreatorController.java +++ b/src/main/java/com/zy/system/controller/LicenseCreatorController.java @@ -4,7 +4,6 @@ import com.core.common.R; import com.zy.system.entity.license.*; import com.zy.system.timer.LicenseTimer; -import de.schlichtherle.license.LicenseContent; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.MediaType; @@ -15,7 +14,6 @@ import java.io.File; import java.io.IOException; -import java.util.Date; /** * @@ -25,9 +23,8 @@ @RequestMapping("/license") public class LicenseCreatorController { - @Value("${license.licensePath}") - private String licensePath; - +// @Value("${license.licensePath}") +// private String licensePath; @Autowired private LicenseCheckListener licenseCheckListener; @Autowired @@ -50,7 +47,7 @@ if (osName.startsWith("windows")) { abstractServerInfos = new WindowsServerInfos(); } else if (osName.startsWith("linux")) { -// abstractServerInfos = new LinuxServerInfos(); + abstractServerInfos = new LinuxServerInfos(); }else{//鍏朵粬鏈嶅姟鍣ㄧ被鍨� abstractServerInfos = new WindowsServerInfos(); } @@ -66,37 +63,43 @@ return R.ok(licenseTimer.getLicenseDays()); } - @RequestMapping(value = "/updateLicense") - public R updateLicense(@RequestParam("file") MultipartFile[] files){ - MultipartFile file = files[0]; +// @RequestMapping(value = "/updateLicense") +// public R updateLicense(@RequestParam("file") MultipartFile[] files){ +// MultipartFile file = files[0]; +// +// String licensePathFileName = this.getClass().getClassLoader().getResource(licensePath).getPath(); +// File licensePathFile = new File(licensePathFileName); +// //鏈嶅姟鍣ㄧ淇濆瓨鐨勬枃浠跺璞� +// File serverFile = new File(licensePathFile.getPath()); +// if (serverFile.exists()) { +// try { +// serverFile.delete();//瀛樺湪鏂囦欢锛屽垹闄� +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } +// +// try { +// //鍒涘缓鏂囦欢 +// serverFile.createNewFile(); +// //灏嗕笂浼犵殑鏂囦欢鍐欏叆鍒版湇鍔″櫒绔枃浠跺唴 +// file.transferTo(serverFile); +// } catch (IOException e) { +// e.printStackTrace(); +// } +// +// //閲嶆柊鍔犺浇璁稿彲璇� +// boolean loadedLicense = licenseCheckListener.loadLicense(); +// if (loadedLicense) { +// return R.ok(); +// } +// return R.error("璁稿彲璇佹洿鏂板け璐�"); +// } - String licensePathFileName = this.getClass().getClassLoader().getResource(licensePath).getPath(); - File licensePathFile = new File(licensePathFileName); - //鏈嶅姟鍣ㄧ淇濆瓨鐨勬枃浠跺璞� - File serverFile = new File(licensePathFile.getPath()); - if (serverFile.exists()) { - try { - serverFile.delete();//瀛樺湪鏂囦欢锛屽垹闄� - } catch (Exception e) { - e.printStackTrace(); - } - } - - try { - //鍒涘缓鏂囦欢 - serverFile.createNewFile(); - //灏嗕笂浼犵殑鏂囦欢鍐欏叆鍒版湇鍔″櫒绔枃浠跺唴 - file.transferTo(serverFile); - } catch (IOException e) { - e.printStackTrace(); - } - - //閲嶆柊鍔犺浇璁稿彲璇� - boolean loadedLicense = licenseCheckListener.loadLicense(); - if (loadedLicense) { - return R.ok(); - } - return R.error("璁稿彲璇佹洿鏂板け璐�"); + @RequestMapping(value = "/activate") + public R activate() { + licenseTimer.timer(); + return R.ok(); } } \ No newline at end of file -- Gitblit v1.9.1