ludc
2024-03-04 702657b9e1d73c8c26cafbc64b3284f121ad2b58
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
package com.vci.ubcs.deploy.controller;
 
import com.alibaba.nacos.shaded.com.google.protobuf.ServiceException;
import com.vci.ubcs.deploy.entity.DeployApps;
import com.vci.ubcs.deploy.service.IDeployAppsService;
import com.vci.ubcs.deploy.vo.DeployAppsVO;
import com.vci.ubcs.starter.util.LocalFileUtil;
import com.vci.ubcs.starter.web.util.ControllerUtil;
import com.vci.ubcs.starter.web.util.LangBaseUtil;
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.auth.AuthenticationException;
import org.springblade.core.tenant.annotation.NonDS;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import springfox.documentation.annotations.ApiIgnore;
 
import javax.servlet.ServletRequest;
import java.io.File;
import java.util.List;
 
/**
 * 服务远程更新部署
 * @author ludc
 * @date 2024/1/7 0:24
 */
@NonDS
@RestController
@RequiredArgsConstructor
@RequestMapping("/deploy")
@ApiIgnore
@Api(value = "应用管理", tags = "接口")
@Slf4j
public class DeployAppsController {
 
    private final IDeployAppsService deployAppsService;
 
    /**
     * 获取服务运行列表
     * @param servletRequest
     * @return
     * @throws ServiceException
     */
    @GetMapping("/applications")
    public R<List<DeployAppsVO>> getApplications(ServletRequest servletRequest) throws ServiceException {
        return R.data(deployAppsService.getApplications(servletRequest));
    }
 
    /**
     * 获取服务配置信息
     * @param deployAppsVO
     * @return
     * @throws ServiceException
     */
    @PostMapping("/saveOrGetServiceConfInfo")
    public R<DeployApps> saveOrGetServiceConfInfo(@RequestBody DeployAppsVO deployAppsVO) throws ServiceException {
        return R.data(deployAppsService.saveOrGetServiceConfInfo(deployAppsVO));
    }
 
    /**
     * 新增或获取服务默认配置信息
     * @param deployAppsVO
     * @return
     * @throws ServiceException
     */
    @PostMapping("/saveOrUpdateServiceInfo")
    public R saveOrUpdateDefault(@RequestBody DeployAppsVO deployAppsVO) throws ServiceException {
        return R.status(deployAppsService.saveOrUpdateServiceInfo(deployAppsVO));
    }
 
    /**
     * 添加服务信息
     * @param deployApps
     * @return
     * @throws ServiceException
     */
    @PostMapping("/addSave")
    public R addSave(@RequestBody DeployApps deployApps) throws ServiceException {
        return R.status(deployAppsService.addSave(deployApps));
    }
 
    /**
     * 服务更新包
     * @param files 更新的jar或文件夹
     * @param serverName 服务名称
     * @return
     * @throws ServiceException
     */
    @PostMapping("/importUpdateServiceJar")
    public R importClassify(@RequestParam("files") MultipartFile[] files,@RequestParam String serverName) throws ServiceException {
        if(Func.isBlank(serverName)){
            return R.fail("Mandatory parameter service name not found!");
        }
        return deployAppsService.importJarUpdate(files,serverName);
    }
 
    /**
     * 执行命令
     * @param deployAppsVO
     * @return
     */
    @PostMapping("/cmdExecute")
    public R cmdExecute(@RequestBody DeployAppsVO deployAppsVO) throws ServiceException {
        return deployAppsService.cmdExecute(deployAppsVO);
    }
 
}