Ludc
2025-11-18 4470052c3b6bdeb18e45987f8aa293d1e93d0552
Source/UBCS/ubcs-service/ubcs-deploy/src/main/java/com/vci/ubcs/deploy/controller/DeployAppsController.java
@@ -1,17 +1,19 @@
package com.vci.ubcs.deploy.controller;
import com.alibaba.nacos.shaded.com.google.protobuf.ServiceException;
import com.vci.ubcs.common.validator.ComprehensiveFileValidator;
import com.vci.ubcs.deploy.entity.DeployApps;
import com.vci.ubcs.deploy.service.IDeployAppsService;
import com.vci.ubcs.deploy.vo.DeployAppsVO;
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import org.apache.http.auth.AuthenticationException;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tenant.annotation.NonDS;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springblade.core.tool.utils.Func;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import springfox.documentation.annotations.ApiIgnore;
import javax.servlet.ServletRequest;
@@ -24,17 +26,93 @@
 */
@NonDS
@RestController
@AllArgsConstructor
@RequiredArgsConstructor
@RequestMapping("/deploy")
@ApiIgnore
@Api(value = "应用管理", tags = "接口")
@Slf4j
public class DeployAppsController {
   private final IDeployAppsService deployAppsService;
   /**
    * 文件安全检查
    */
   @Autowired
   private ComprehensiveFileValidator fileValidator;
   /**
    * 获取服务运行列表
    * @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 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 {
      // 使用文件安全验证器
      ComprehensiveFileValidator.MultiUploadValidationResult quickResult = fileValidator.validateFiles(files, true);
      if (!quickResult.isValid()) {
         return R.fail(quickResult.getMessage());
      }
      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);
   }
}