From d7d99af35f7a304bba700ca7cb8a3330237cc8ea Mon Sep 17 00:00:00 2001 From: Junjie <540245094@qq.com> Date: 星期一, 04 八月 2025 15:44:26 +0800 Subject: [PATCH] # --- src/main/java/com/zy/system/controller/LicenseCreatorController.java | 42 +++++++++++++++--------------------------- 1 files changed, 15 insertions(+), 27 deletions(-) diff --git a/src/main/java/com/zy/system/controller/LicenseCreatorController.java b/src/main/java/com/zy/system/controller/LicenseCreatorController.java index d7bb9cb..13e2b1c 100644 --- a/src/main/java/com/zy/system/controller/LicenseCreatorController.java +++ b/src/main/java/com/zy/system/controller/LicenseCreatorController.java @@ -1,15 +1,12 @@ package com.zy.system.controller; -import com.core.annotations.ManagerAuth; import com.core.common.Cools; import com.core.common.R; import com.zy.system.entity.license.*; -import de.schlichtherle.license.LicenseContent; +import com.zy.system.timer.LicenseTimer; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.MediaType; -import org.springframework.util.ClassUtils; -import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @@ -17,12 +14,6 @@ import java.io.File; import java.io.IOException; -import java.text.SimpleDateFormat; -import java.time.temporal.ChronoUnit; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; -import java.util.prefs.Preferences; /** * @@ -34,10 +25,10 @@ @Value("${license.licensePath}") private String licensePath; - @Autowired private LicenseCheckListener licenseCheckListener; - + @Autowired + private LicenseTimer licenseTimer; /** * 鑾峰彇鏈嶅姟鍣ㄧ‖浠朵俊鎭� * @param osName 鎿嶄綔绯荤粺绫诲瀷锛屽鏋滀负绌哄垯鑷姩鍒ゆ柇 @@ -56,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(); } @@ -69,26 +60,17 @@ */ @RequestMapping(value = "/getLicenseDays") public R getLicenseDays() { - LicenseVerify licenseVerify = new LicenseVerify(); - LicenseContent verifyInfo = licenseVerify.getVerifyInfo(); - if (verifyInfo == null) { - return R.error(); - } - - Date start = new Date(); - Date end = verifyInfo.getNotAfter(); - Long starTime = start.getTime(); - Long endTime = end.getTime(); - Long num = endTime - starTime;//鏃堕棿鎴崇浉宸殑姣鏁� - int day = (int) (num / 24 / 60 / 60 / 1000); - return R.ok().add(day); + return R.ok(licenseTimer.getLicenseDays()); } @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(licensePath); + File serverFile = new File(licensePathFile.getPath()); if (serverFile.exists()) { try { serverFile.delete();//瀛樺湪鏂囦欢锛屽垹闄� @@ -114,4 +96,10 @@ return R.error("璁稿彲璇佹洿鏂板け璐�"); } + @RequestMapping(value = "/activate") + public R activate() { + licenseTimer.timer(); + return R.ok(); + } + } \ No newline at end of file -- Gitblit v1.9.1