| | |
| | | package com.zy.system.controller; |
| | | |
| | | import com.core.annotations.ManagerAuth; |
| | | import com.core.common.AesUtils; |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | import com.core.common.R; |
| | | import com.zy.common.properties.OSinfo; |
| | | import com.zy.common.properties.SystemProperties; |
| | | import com.zy.system.entity.license.*; |
| | | import de.schlichtherle.license.LicenseContent; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | */ |
| | | @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); |
| | | // 获取激活码 |
| | | String activationCode = SystemProperties.getActivationCode(OSinfo.getOSname().getActivationCodePath()); |
| | | if (!Cools.isEmpty(activationCode)) { |
| | | // 获取有效期 |
| | | String timeStr = AesUtils.decrypt(activationCode, SystemProperties.SALT); |
| | | if (null == timeStr) { |
| | | return R.error(); |
| | | } |
| | | Date exprTime = DateUtils.convert(timeStr, DateUtils.yyyyMMddHHmmss); |
| | | if (new Date().getTime() < exprTime.getTime()) { |
| | | Date start = new Date(); |
| | | Long starTime = start.getTime(); |
| | | Long endTime = exprTime.getTime(); |
| | | Long num = endTime - starTime;//时间戳相差的毫秒数 |
| | | int day = (int) (num / 24 / 60 / 60 / 1000); |
| | | return R.ok().add(day); |
| | | } |
| | | } |
| | | return R.error(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/updateLicense") |