liujie
2026-01-29 b74a483a59ab4925b4f79d2b2e76e17ab4b8177d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
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());
        }
    }
}