package com.estate.expert.admin.controller;
|
|
import com.estate.expert.admin.utils.License;
|
import com.estate.expert.common.auth.IgnoreAuth;
|
import com.estate.expert.common.rpc.Result;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import java.util.Map;
|
|
/**
|
* License管理控制器
|
* 提供License信息查询接口
|
*/
|
@RestController
|
@RequestMapping("/api/license")
|
@Slf4j
|
public class LicenseController {
|
|
/**
|
* 获取License状态信息
|
* @return License状态
|
*/
|
@GetMapping("/status")
|
@IgnoreAuth
|
public Result<Map<String, Object>> getLicenseStatus() {
|
try {
|
boolean isValid = License.isLicenseValid();
|
long remainingDays = License.getRemainingDays();
|
boolean isExpired = License.isLicenseExpired();
|
|
Map<String, Object> data = Map.of(
|
"isValid", isValid,
|
"isExpired", isExpired,
|
"remainingDays", remainingDays,
|
"message", isValid ? "License有效" : "License已过期"
|
);
|
|
return Result.success(data);
|
|
} catch (Exception e) {
|
log.error("获取License状态失败", e);
|
return Result.error("获取License状态失败: " + e.getMessage());
|
}
|
}
|
|
/**
|
* 获取详细License信息
|
* @return 详细License信息
|
*/
|
@GetMapping("/info")
|
@IgnoreAuth
|
public Result<Map<String, Object>> getLicenseInfo() {
|
try {
|
String licenseInfo = License.getLicenseInfo();
|
|
Map<String, Object> data = Map.of(
|
"licenseInfo", licenseInfo,
|
"isValid", License.isLicenseValid(),
|
"remainingDays", License.getRemainingDays()
|
);
|
|
return Result.success(data);
|
|
} catch (Exception e) {
|
log.error("获取License信息失败", e);
|
return Result.error("获取License信息失败: " + e.getMessage());
|
}
|
}
|
}
|