1
13693261870
2025-01-14 2421ab222448e9db9bba26315c2bd4b7419e7a42
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
package com.se.system.controller;
 
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
import com.se.system.domain.vo.LicenseExtraParamVo;
import com.se.system.domain.vo.NacosConfigVo;
import com.se.system.service.NacosService;
import com.se.system.service.inte.IAServerInfoService;
import com.se.system.utils.CommonUtils;
import org.springframework.web.bind.annotation.*;
import com.se.common.log.annotation.Log;
import com.se.common.log.enums.BusinessType;
import com.se.common.security.annotation.RequiresPermissions;
import com.se.system.domain.*;
import com.se.system.service.inte.ISysSoftService;
import com.se.common.core.web.controller.BaseController;
import com.se.common.core.web.domain.AjaxResult;
import com.se.common.core.utils.poi.ExcelUtil;
import com.se.common.core.web.page.TableDataInfo;
 
/**
 * 软件Controller
 * 
 * @author se
 * @date 2024-11-22
 */
@RestController
@SuppressWarnings("ALL")
@RequestMapping("/soft")
public class SysSoftController extends BaseController {
    @Resource
    NacosService nacosService;
 
    @Resource
    private ISysSoftService sysSoftService;
 
    /**
     * 查询软件列表
     */
    @RequiresPermissions("system:soft:list")
    @GetMapping("/list")
    public TableDataInfo list(SysSoft sysSoft) {
        startPage();
        List<SysSoft> list = sysSoftService.selectSysSoftList(sysSoft);
        return getDataTable(list);
    }
 
    /**
     * 导出软件列表
     */
    @RequiresPermissions("system:soft:export")
    @Log(title = "软件", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysSoft sysSoft) {
        List<SysSoft> list = sysSoftService.selectSysSoftList(sysSoft);
        ExcelUtil<SysSoft> util = new ExcelUtil<SysSoft>(SysSoft.class);
        util.exportExcel(response, list, "软件数据");
    }
 
    /**
     * 获取软件详细信息
     */
    @RequiresPermissions("system:soft:query")
    @GetMapping(value = "/{softId}")
    public AjaxResult getInfo(@PathVariable("softId") Long softId) {
        return success(sysSoftService.selectSysSoftBySoftId(softId));
    }
 
    /**
     * 新增软件
     */
    @RequiresPermissions("system:soft:add")
    @Log(title = "软件", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysSoft sysSoft) {
        return toAjax(sysSoftService.insertSysSoft(sysSoft));
    }
 
    /**
     * 修改软件
     */
    @RequiresPermissions("system:soft:edit")
    @Log(title = "软件", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysSoft sysSoft) {
        return toAjax(sysSoftService.updateSysSoft(sysSoft));
    }
 
    /**
     * 删除软件
     */
    @RequiresPermissions("system:soft:remove")
    @Log(title = "软件", businessType = BusinessType.DELETE)
    @DeleteMapping("/{softIds}")
    public AjaxResult remove(@PathVariable Long[] softIds) {
        return toAjax(sysSoftService.deleteSysSoftBySoftIds(softIds));
    }
 
    @Log(title = "软件-获取配置", businessType = BusinessType.OTHER)
    @RequiresPermissions("system:soft:query")
    @GetMapping(value = "getNacosConfig")
    public void getNacosConfig(String dataId, HttpServletRequest req, HttpServletResponse res) {
        try {
            nacosService.getNacosConfig(dataId, req, res);
        } catch (Exception e) {
            try {
                res.getWriter().print(e.getMessage());
            } catch (Exception ex) {
                logger.error(ex.getMessage(), ex);
            }
        }
    }
 
    @Log(title = "软件-更新配置", businessType = BusinessType.UPDATE)
    @RequiresPermissions("system:soft:edit")
    @PostMapping(value = "updateNacosConfig")
    public void updateNacosConfig(@RequestBody NacosConfigVo vo, HttpServletRequest req, HttpServletResponse res) {
        try {
            nacosService.updateNacosConfig(vo, req, res);
        } catch (Exception e) {
            try {
                res.getWriter().print(e.getMessage());
            } catch (Exception ex) {
                logger.error(ex.getMessage(), ex);
            }
        }
    }
 
    @GetMapping(value = "/getServerInfo")
    public AjaxResult getServerInfo() {
        LicenseExtraParamVo serverInfos = IAServerInfoService.getServer("").getServerInfos();
        System.out.println("serverInfos = " + serverInfos);
 
        return success(serverInfos);
    }
 
    @GetMapping(value = "/getLicenseKey")
    public AjaxResult getLicenseKey() throws Exception {
        LicenseExtraParamVo serverInfos = IAServerInfoService.getServer("").getServerInfos();
        String jsonString = serverInfos.toJsonString();
 
        System.out.println("原始数据 = " + jsonString);
        String encryptedJson = CommonUtils.encrypt(jsonString);
        System.out.println("加密数据 = " + serverInfos);
 
        return success(encryptedJson);
    }
}