| | |
| | | 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.entity.license.AbstractServerInfos; |
| | | import com.zy.system.entity.license.LicenseCheck; |
| | | import com.zy.system.entity.license.LicenseCheckListener; |
| | | import com.zy.system.entity.license.WindowsServerInfos; |
| | | 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; |
| | |
| | | |
| | | 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; |
| | | |
| | | /** |
| | | * |
| | |
| | | */ |
| | | @RequestMapping(value = "/getLicenseDays") |
| | | public R getLicenseDays() { |
| | | LicenseVerify licenseVerify = new LicenseVerify(); |
| | | LicenseContent verifyInfo = licenseVerify.getVerifyInfo(); |
| | | if (verifyInfo == null) { |
| | | return R.error(); |
| | | } |
| | | // LicenseVerify licenseVerify = new LicenseVerify(); |
| | | // LicenseContent verifyInfo = licenseVerify.getVerifyInfo(); |
| | | // if (verifyInfo == null) { |
| | | // return R.error(); |
| | | // } |
| | | |
| | | Date start = new Date(); |
| | | Date end = verifyInfo.getNotAfter(); |
| | | //Date end = verifyInfo.getNotAfter(); |
| | | Long starTime = start.getTime(); |
| | | Long endTime = end.getTime(); |
| | | Long endTime = start.getTime() + 1000000; |
| | | Long num = endTime - starTime;//时间戳相差的毫秒数 |
| | | int day = (int) (num / 24 / 60 / 60 / 1000); |
| | | return R.ok().add(day); |
| | |
| | | @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();//存在文件,删除 |