Merge branch 'dev_PMS_ZPK' of code.gitlink.org.cn:otto/microservices into dev_PMS_ZPK_packaged
This commit is contained in:
commit
10687428c4
|
|
@ -4,9 +4,9 @@ import com.microservices.common.core.constant.SecurityConstants;
|
|||
import com.microservices.common.core.constant.ServiceNameConstants;
|
||||
import com.microservices.common.core.domain.R;
|
||||
import com.microservices.system.api.domain.SysFile;
|
||||
import com.microservices.system.api.domain.SysFileBytes;
|
||||
import com.microservices.system.api.domain.SysFileInfo;
|
||||
import com.microservices.system.api.factory.RemoteFileFallbackFactory;
|
||||
import feign.Response;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
|
@ -71,9 +71,8 @@ public interface RemoteFileService {
|
|||
* 根据文件标识获取文件实体
|
||||
*
|
||||
* @param fileIdentifier 文件标识
|
||||
* @return 文件实体
|
||||
*/
|
||||
@GetMapping("/common/getFileEntityByIdentifier/{fileIdentifier}")
|
||||
R<SysFileBytes> getFileEntityByIdentifier(@PathVariable("fileIdentifier") String fileIdentifier,
|
||||
@RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
Response getFileEntityByIdentifier(@PathVariable("fileIdentifier") String fileIdentifier,
|
||||
@RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,12 +17,7 @@ public class SysFileBytes {
|
|||
private String fileName;
|
||||
|
||||
/**
|
||||
* 文件地址
|
||||
*/
|
||||
private byte[] fileBytes;
|
||||
|
||||
/**
|
||||
* 文件地址
|
||||
* 文件流
|
||||
*/
|
||||
private InputStream fileInputStream;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
package com.microservices.system.api.factory;
|
||||
|
||||
import com.microservices.common.core.domain.R;
|
||||
import com.microservices.common.core.exception.ServiceException;
|
||||
import com.microservices.system.api.RemoteFileService;
|
||||
import com.microservices.system.api.domain.SysFile;
|
||||
import com.microservices.system.api.domain.SysFileBytes;
|
||||
import com.microservices.system.api.domain.SysFileInfo;
|
||||
import feign.Response;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
|
|
@ -54,8 +55,8 @@ public class RemoteFileFallbackFactory implements FallbackFactory<RemoteFileServ
|
|||
}
|
||||
|
||||
@Override
|
||||
public R<SysFileBytes> getFileEntityByIdentifier(String fileIdentifier, String source) {
|
||||
return R.fail("根据文件标识获取文件实体失败:" + throwable.getMessage());
|
||||
public Response getFileEntityByIdentifier(String fileIdentifier, String source) {
|
||||
throw new ServiceException("文件获取失败:" + throwable.getMessage());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ import org.springframework.stereotype.Component;
|
|||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
|
@ -32,7 +31,6 @@ import java.net.URLEncoder;
|
|||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.microservices.common.core.web.domain.AjaxResult.DATA_TAG;
|
||||
|
||||
|
|
@ -371,23 +369,16 @@ public class HttpAPIService {
|
|||
HttpEntity httpEntity = response.getEntity();
|
||||
if (httpEntity != null) {
|
||||
InputStream input = httpEntity.getContent();
|
||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||
byte[] buffer = new byte[4096];
|
||||
int n = 0;
|
||||
while (-1 != (n = input.read(buffer))) {
|
||||
output.write(buffer, 0, n);
|
||||
}
|
||||
String fileName = url.substring(url.lastIndexOf('/') + 1);
|
||||
Header fileNameHeader = response.getFirstHeader("Content-Disposition");
|
||||
if (fileNameHeader != null) {
|
||||
fileName = fileNameHeader.getValue();
|
||||
}
|
||||
SysFileBytes sysFileBytes = new SysFileBytes();
|
||||
sysFileBytes.setFileBytes(output.toByteArray());
|
||||
sysFileBytes.setFileInputStream(input);
|
||||
sysFileBytes.setFileName(fileName);
|
||||
return sysFileBytes;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
throw new Exception("请求响应失败");
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import com.microservices.common.core.web.controller.BaseController;
|
|||
import com.microservices.common.core.web.domain.AjaxResult;
|
||||
import com.microservices.common.security.annotation.InnerAuth;
|
||||
import com.microservices.file.service.ISysFileInfoService;
|
||||
import com.microservices.system.api.domain.SysFileBytes;
|
||||
import com.microservices.system.api.domain.SysFileInfo;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
|
|
@ -66,8 +65,8 @@ public class CommonController extends BaseController {
|
|||
@GetMapping("/getFileEntityByIdentifier/{fileIdentifier}")
|
||||
@ApiOperation("根据文件标识获取文件实体")
|
||||
@InnerAuth
|
||||
public R<SysFileBytes> getFileEntityByIdentifier(@PathVariable("fileIdentifier") String fileIdentifier) {
|
||||
return sysFileInfoService.getFileEntityByIdentifier(fileIdentifier);
|
||||
public void getFileEntityByIdentifier(@PathVariable("fileIdentifier") String fileIdentifier, HttpServletResponse response) {
|
||||
sysFileInfoService.getFileEntityByIdentifier(response, fileIdentifier);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
package com.microservices.file.service;
|
||||
|
||||
|
||||
import com.microservices.common.core.domain.R;
|
||||
import com.microservices.common.core.web.domain.AjaxResult;
|
||||
import com.microservices.system.api.domain.SysFileBytes;
|
||||
import com.microservices.system.api.domain.SysFileInfo;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
|
|
@ -171,7 +169,6 @@ public interface ISysFileInfoService {
|
|||
* 根据文件标识获取文件实体
|
||||
*
|
||||
* @param fileIdentifier 文件标识
|
||||
* @return 文件实体
|
||||
*/
|
||||
R<SysFileBytes> getFileEntityByIdentifier(String fileIdentifier);
|
||||
void getFileEntityByIdentifier(HttpServletResponse response, String fileIdentifier);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import com.alibaba.fastjson2.JSONObject;
|
|||
import com.j256.simplemagic.ContentInfo;
|
||||
import com.j256.simplemagic.ContentInfoUtil;
|
||||
import com.microservices.common.core.constant.Constants;
|
||||
import com.microservices.common.core.domain.R;
|
||||
import com.microservices.common.core.exception.ServiceException;
|
||||
import com.microservices.common.core.utils.DateUtils;
|
||||
import com.microservices.common.core.utils.StringUtils;
|
||||
|
|
@ -20,7 +19,6 @@ import com.microservices.common.security.utils.SecurityUtils;
|
|||
import com.microservices.file.mapper.SysFileInfoMapper;
|
||||
import com.microservices.file.service.ISysFileInfoService;
|
||||
import com.microservices.file.utils.FileUploadUtils;
|
||||
import com.microservices.system.api.domain.SysFileBytes;
|
||||
import com.microservices.system.api.domain.SysFileInfo;
|
||||
import com.microservices.system.api.model.LoginUser;
|
||||
import org.slf4j.Logger;
|
||||
|
|
@ -34,8 +32,9 @@ import org.springframework.web.multipart.MultipartFile;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.file.Paths;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -511,23 +510,31 @@ public class SysFileInfoServiceImpl implements ISysFileInfoService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public R<SysFileBytes> getFileEntityByIdentifier(String fileIdentifier) {
|
||||
SysFileBytes fileEntity = new SysFileBytes();
|
||||
public void getFileEntityByIdentifier(HttpServletResponse response, String fileIdentifier) {
|
||||
SysFileInfo sysFileInfo = selectSysFileInfoByFileIdentifier(fileIdentifier);
|
||||
String filePath = localFilePath + sysFileInfo.getFilePath();
|
||||
File file = new File(filePath);
|
||||
if (!file.exists()) {
|
||||
throw new ServiceException("该文件不存在");
|
||||
}
|
||||
byte[] fileBytes;
|
||||
response.setHeader("FileName", sysFileInfo.getFileOriginName());
|
||||
try {
|
||||
fileBytes = Files.readAllBytes(file.toPath());
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" + file.getName());
|
||||
|
||||
try (FileInputStream fileInputStream = new FileInputStream(file);
|
||||
OutputStream outputStream = response.getOutputStream()) {
|
||||
// 根据实际情况调整缓冲区大小
|
||||
byte[] buffer = new byte[4096];
|
||||
int bytesRead;
|
||||
while ((bytesRead = fileInputStream.read(buffer)) != -1) {
|
||||
outputStream.write(buffer, 0, bytesRead);
|
||||
}
|
||||
outputStream.flush();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new ServiceException("文件流读取失败:", e.getMessage());
|
||||
throw new ServiceException("文件读取失败", e);
|
||||
}
|
||||
fileEntity.setFileBytes(fileBytes);
|
||||
fileEntity.setFileName(sysFileInfo.getFileOriginName());
|
||||
return R.ok(fileEntity);
|
||||
}
|
||||
|
||||
private void fileDownload(SysFileInfo sysFileInfo, HttpServletResponse response) {
|
||||
|
|
|
|||
|
|
@ -35,6 +35,20 @@ public class PmsProductLibraryController extends BaseController {
|
|||
@Autowired
|
||||
private IPmsProductLibraryComponentService pmsProductLibraryComponentService;
|
||||
|
||||
/**
|
||||
* 获取产品库制品列表
|
||||
*/
|
||||
// @RequiresPermissions("pms:pmsProductLibraryRepositories:list")
|
||||
@GetMapping("/componentList")
|
||||
@ApiOperation(value = "获取产品库制品列表")
|
||||
public GenericsTableDataInfo<PmsProductLibraryComponentDataVo> selectComponentList(
|
||||
@PathVariable String enterpriseIdentifier,
|
||||
@ApiParam(value = "产品库制品查询条件") PmsProductLibraryComponentSearchVo search) {
|
||||
search.setPmsEnterpriseIdentifier(enterpriseIdentifier);
|
||||
startPage();
|
||||
return pmsProductLibraryProductRepoService.selectComponentList(search);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询制品库-仓库列表
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.microservices.pms.productLibrary.domain;
|
|||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.microservices.common.core.utils.StringUtils;
|
||||
import com.microservices.common.core.utils.bean.BeanUtils;
|
||||
import com.microservices.common.core.utils.sign.Base64;
|
||||
import com.microservices.common.core.web.domain.BaseEntity;
|
||||
import com.microservices.pms.productLibrary.domain.vo.*;
|
||||
|
|
@ -173,4 +174,10 @@ public class PmsProductLibraryComponent extends BaseEntity {
|
|||
target.setDirectory(this.getGroup());
|
||||
return target;
|
||||
}
|
||||
|
||||
public PmsProductLibraryComponentDataVo toPmsProductLibraryComponentDataVo() {
|
||||
PmsProductLibraryComponentDataVo target = new PmsProductLibraryComponentDataVo();
|
||||
BeanUtils.copyProperties(this, target);
|
||||
return target;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,97 @@
|
|||
package com.microservices.pms.productLibrary.domain.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 制品库数据对象
|
||||
*
|
||||
* @author otto
|
||||
* @date 2024-07-11
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("产品库制品数据对象")
|
||||
public class PmsProductLibraryComponentDataVo {
|
||||
|
||||
/**
|
||||
* 制品ID
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 制品标识
|
||||
*/
|
||||
@ApiModelProperty(value = "制品标识")
|
||||
private String identifier;
|
||||
|
||||
/**
|
||||
* 制品路径
|
||||
*/
|
||||
@ApiModelProperty(value = "制品路径")
|
||||
private String path;
|
||||
|
||||
/**
|
||||
* 制品所在组
|
||||
*/
|
||||
@ApiModelProperty(value = "制品所在组")
|
||||
private String group;
|
||||
|
||||
/**
|
||||
* 制品名称
|
||||
*/
|
||||
@ApiModelProperty(value = "制品名称")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 制品库Id
|
||||
*/
|
||||
@ApiModelProperty(value = "制品库Id")
|
||||
private Long repoId;
|
||||
|
||||
/**
|
||||
* 制品版本
|
||||
*/
|
||||
@ApiModelProperty(value = "制品版本")
|
||||
private String version;
|
||||
|
||||
/**
|
||||
* 制品文件Id
|
||||
*/
|
||||
@ApiModelProperty(value = "制品文件Id")
|
||||
private String fileIdentifier;
|
||||
|
||||
/**
|
||||
* 制品下载地址
|
||||
*/
|
||||
@ApiModelProperty(value = "制品下载地址")
|
||||
private String downloadUrl;
|
||||
/**
|
||||
* 创建者
|
||||
*/
|
||||
@ApiModelProperty(value = "创建者", hidden = true)
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "创建时间", hidden = true)
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新者
|
||||
*/
|
||||
@ApiModelProperty(value = "更新者", hidden = true)
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "更新时间", hidden = true)
|
||||
private Date updateTime;
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package com.microservices.pms.productLibrary.domain.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 制品库数据对象
|
||||
*
|
||||
* @author otto
|
||||
* @date 2024-07-11
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("产品库制品查询对象")
|
||||
public class PmsProductLibraryComponentSearchVo {
|
||||
@ApiModelProperty(value = "需排除的制品Id列表(逗号分割的字符串)")
|
||||
private String excludeIds;
|
||||
@ApiModelProperty(value = "产品库标识")
|
||||
private String productRepoName;
|
||||
/**
|
||||
* 关联企业ID
|
||||
*/
|
||||
@ApiModelProperty(value = "关联企业标识", hidden = true)
|
||||
private String pmsEnterpriseIdentifier;
|
||||
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package com.microservices.pms.productLibrary.mapper;
|
||||
|
||||
import com.microservices.pms.productLibrary.domain.PmsProductLibraryComponent;
|
||||
import com.microservices.pms.productLibrary.domain.vo.PmsProductLibraryComponentSearchVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
|
|
@ -90,6 +91,14 @@ public interface PmsProductLibraryComponentMapper {
|
|||
*/
|
||||
List<PmsProductLibraryComponent> selectPmsProductLibraryComponentUnderThePath(@Param("path") String path, @Param("repoId") Long repoId, @Param("pmsEnterpriseId") Long pmsEnterpriseId);
|
||||
|
||||
/**
|
||||
* 查询产品库制品列表
|
||||
*
|
||||
* @param search 查询条件
|
||||
* @return 制品列表
|
||||
*/
|
||||
List<PmsProductLibraryComponent> selectProductRepoComponentList(PmsProductLibraryComponentSearchVo search);
|
||||
|
||||
/**
|
||||
* 通过制品标识查询制品
|
||||
*
|
||||
|
|
|
|||
|
|
@ -129,4 +129,5 @@ public interface PmsProductLibraryRepositoriesMapper {
|
|||
|
||||
List<PmsProductLibraryRepositories> selectPmsProductLibrarySnapshotPageList(@Param("pmsEnterpriseIdentifier") String pmsEnterpriseIdentifier, @Param("repoName") String repoName, @Param("snapshotName") String snapshotName);
|
||||
|
||||
PmsProductLibraryRepositories selectProductRepoById(Long repoId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,5 +75,7 @@ public interface IPmsProductLibraryProductRepoService {
|
|||
*/
|
||||
NexusComponentResultVo<List<NexusResultDataVo>> selectPmsProductLibraryKeyComponentList(String enterpriseIdentifier, ComponentSearchVo componentSearchVo);
|
||||
|
||||
GenericsTableDataInfo<PmsProductLibraryComponentDataVo> selectComponentList(PmsProductLibraryComponentSearchVo search);
|
||||
|
||||
boolean addDockerComponentToProductRepo(DockerComponentAddToProductRepoVo dockerComponentAddToProductRepoVo);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -129,4 +129,6 @@ public interface IPmsProductLibraryRepositoriesService {
|
|||
* @return 锁定中的制品库id列表
|
||||
*/
|
||||
List<Long> getLockStatusRepositoryList(String enterpriseIdentifier, String repoIds);
|
||||
|
||||
PmsProductLibraryRepositories selectPmsProductLibraryRepositoriesById(Long repoId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ import com.microservices.pms.utils.NexusRequestUrl;
|
|||
import com.microservices.pms.utils.PmsUtils;
|
||||
import com.microservices.system.api.RemoteFileService;
|
||||
import com.microservices.system.api.domain.SysFileBytes;
|
||||
import com.microservices.system.api.utils.FeignUtils;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.apache.http.entity.mime.MultipartEntityBuilder;
|
||||
import org.slf4j.Logger;
|
||||
|
|
@ -426,14 +425,12 @@ public class PmsProductLibraryComponentServiceImpl implements IPmsProductLibrary
|
|||
if (assetMavenInputVo.getFileBytes() != null) {
|
||||
fileBytes = assetMavenInputVo.getFileBytes();
|
||||
} else {
|
||||
fileBytes = FeignUtils.getReturnData(
|
||||
fileService.getFileEntityByIdentifier(assetMavenInputVo.getFileIdentifier(), SecurityConstants.INNER)
|
||||
);
|
||||
if (fileBytes == null) {
|
||||
throw new ServiceException("制品文件读取失败");
|
||||
}
|
||||
fileBytes = PmsUtils.getFeignFile(fileService.getFileEntityByIdentifier(assetMavenInputVo.getFileIdentifier(), SecurityConstants.INNER));
|
||||
}
|
||||
builder.addBinaryBody(String.format("maven2.asset%d", i + 1), fileBytes.getFileBytes(), ContentType.DEFAULT_BINARY, fileBytes.getFileName());
|
||||
if (fileBytes == null || fileBytes.getFileInputStream() == null) {
|
||||
throw new ServiceException("制品文件读取失败");
|
||||
}
|
||||
builder.addBinaryBody(String.format("maven2.asset%d", i + 1), fileBytes.getFileInputStream(), ContentType.DEFAULT_BINARY, fileBytes.getFileName());
|
||||
}
|
||||
JSONObject bodyLog = toBodyLog(componentMavenInputVo);
|
||||
nexusRequestHelper.doRequest(NexusRequestUrl.UPLOAD_COMPONENTS(componentMavenInputVo.getNexusRepoName()), builder.build(), bodyLog);
|
||||
|
|
@ -487,20 +484,13 @@ public class PmsProductLibraryComponentServiceImpl implements IPmsProductLibrary
|
|||
SysFileBytes fileBytes;
|
||||
if (assetRawInputVo.getFileBytes() != null) {
|
||||
fileBytes = assetRawInputVo.getFileBytes();
|
||||
if (fileBytes.getFileInputStream() != null) {
|
||||
builder.addBinaryBody(String.format("raw.asset%d", i + 1), fileBytes.getFileInputStream(), ContentType.DEFAULT_BINARY, fileBytes.getFileName());
|
||||
} else {
|
||||
builder.addBinaryBody(String.format("raw.asset%d", i + 1), fileBytes.getFileBytes(), ContentType.DEFAULT_BINARY, fileBytes.getFileName());
|
||||
}
|
||||
} else {
|
||||
fileBytes = FeignUtils.getReturnData(
|
||||
fileService.getFileEntityByIdentifier(assetRawInputVo.getFileIdentifier(), SecurityConstants.INNER)
|
||||
);
|
||||
if (fileBytes == null) {
|
||||
throw new ServiceException("制品文件读取失败");
|
||||
}
|
||||
builder.addBinaryBody(String.format("raw.asset%d", i + 1), fileBytes.getFileBytes(), ContentType.DEFAULT_BINARY, fileBytes.getFileName());
|
||||
fileBytes = PmsUtils.getFeignFile(fileService.getFileEntityByIdentifier(assetRawInputVo.getFileIdentifier(), SecurityConstants.INNER));
|
||||
}
|
||||
if (fileBytes == null || fileBytes.getFileInputStream() == null) {
|
||||
throw new ServiceException("制品文件读取失败");
|
||||
}
|
||||
builder.addBinaryBody(String.format("raw.asset%d", i + 1), fileBytes.getFileInputStream(), ContentType.DEFAULT_BINARY, fileBytes.getFileName());
|
||||
}
|
||||
JSONObject bodyLog = toBodyLog(componentRawInputVo);
|
||||
nexusRequestHelper.doRequest(NexusRequestUrl.UPLOAD_COMPONENTS(componentRawInputVo.getNexusRepoName()), builder.build(), bodyLog);
|
||||
|
|
@ -535,15 +525,13 @@ public class PmsProductLibraryComponentServiceImpl implements IPmsProductLibrary
|
|||
if (componentInputVo.getFileBytes() != null) {
|
||||
fileBytes = componentInputVo.getFileBytes();
|
||||
} else {
|
||||
fileBytes = FeignUtils.getReturnData(
|
||||
fileService.getFileEntityByIdentifier(componentInputVo.getFileIdentifier(), SecurityConstants.INNER)
|
||||
);
|
||||
if (fileBytes == null) {
|
||||
throw new ServiceException("制品文件读取失败");
|
||||
}
|
||||
fileBytes = PmsUtils.getFeignFile(fileService.getFileEntityByIdentifier(componentInputVo.getFileIdentifier(), SecurityConstants.INNER));
|
||||
}
|
||||
if (fileBytes == null || fileBytes.getFileInputStream() == null) {
|
||||
throw new ServiceException("制品文件读取失败");
|
||||
}
|
||||
|
||||
builder.addBinaryBody("npm.asset", fileBytes.getFileBytes(), ContentType.DEFAULT_BINARY, fileBytes.getFileName());
|
||||
builder.addBinaryBody("npm.asset", fileBytes.getFileInputStream(), ContentType.DEFAULT_BINARY, fileBytes.getFileName());
|
||||
JSONObject bodyLog = toBodyLog(componentInputVo);
|
||||
try {
|
||||
nexusRequestHelper.doRequest(NexusRequestUrl.UPLOAD_COMPONENTS(componentInputVo.getNexusRepoName()), builder.build(), bodyLog);
|
||||
|
|
@ -574,15 +562,12 @@ public class PmsProductLibraryComponentServiceImpl implements IPmsProductLibrary
|
|||
if (componentInputVo.getFileBytes() != null) {
|
||||
fileBytes = componentInputVo.getFileBytes();
|
||||
} else {
|
||||
fileBytes = FeignUtils.getReturnData(
|
||||
fileService.getFileEntityByIdentifier(componentInputVo.getFileIdentifier(), SecurityConstants.INNER)
|
||||
);
|
||||
fileBytes = PmsUtils.getFeignFile(fileService.getFileEntityByIdentifier(componentInputVo.getFileIdentifier(), SecurityConstants.INNER));
|
||||
}
|
||||
|
||||
if (fileBytes == null) {
|
||||
if (fileBytes == null || fileBytes.getFileInputStream() == null) {
|
||||
throw new ServiceException("制品文件读取失败");
|
||||
}
|
||||
builder.addBinaryBody("pypi.asset1", fileBytes.getFileBytes(), ContentType.DEFAULT_BINARY, fileBytes.getFileName());
|
||||
builder.addBinaryBody("pypi.asset1", fileBytes.getFileInputStream(), ContentType.DEFAULT_BINARY, fileBytes.getFileName());
|
||||
JSONObject bodyLog = toBodyLog(componentInputVo);
|
||||
JSONObject res;
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import org.springframework.stereotype.Service;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author OTTO
|
||||
|
|
@ -66,6 +67,15 @@ public class PmsProductLibraryProductRepoServiceImpl implements IPmsProductLibra
|
|||
return pmsProductLibraryRepositories;
|
||||
}
|
||||
|
||||
private PmsProductLibraryRepositories selectPmsProductLibraryRepositoriesById(Long repoId) {
|
||||
PmsProductLibraryRepositories pmsProductLibraryRepositories =
|
||||
pmsProductLibraryRepositoriesMapper.selectProductRepoById(repoId);
|
||||
if (pmsProductLibraryRepositories == null) {
|
||||
throw new ServiceException("组织下不存在该产品库(产品库id[%d])", repoId);
|
||||
}
|
||||
return pmsProductLibraryRepositories;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GenericsTableDataInfo<PmsProductLibrarySimpleVo> selectPmsProductLibraryPageList(String enterpriseIdentifier, String name) {
|
||||
return PageUtils.toPage(pmsProductLibraryRepositoriesMapper.selectPmsProductLibraryList(enterpriseIdentifier, name), PmsProductLibraryRepositories::toPmsProductLibrarySimpleVo);
|
||||
|
|
@ -261,7 +271,22 @@ public class PmsProductLibraryProductRepoServiceImpl implements IPmsProductLibra
|
|||
pmsProductLibraryAsyncService.asyncAddDockerComponentToProductRepo(productRepo, repo, nexusComponentResultDataVoList, dockerComponentAddToProductRepoVo.getDirectory());
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public GenericsTableDataInfo<PmsProductLibraryComponentDataVo> selectComponentList(PmsProductLibraryComponentSearchVo search) {
|
||||
List<PmsProductLibraryComponent> pmsProductLibraryComponentList =
|
||||
pmsProductLibraryComponentMapper.selectProductRepoComponentList(search);
|
||||
List<Long> repoIdList = pmsProductLibraryComponentList.stream().map(PmsProductLibraryComponent::getRepoId).distinct().collect(Collectors.toList());
|
||||
List<PmsProductLibraryRepositories> repoList = repoIdList.stream().map(this::selectPmsProductLibraryRepositoriesById).collect(Collectors.toList());
|
||||
return PageUtils.toPage(pmsProductLibraryComponentList, x -> toPmsProductLibraryComponentDataVo(x, repoList));
|
||||
}
|
||||
|
||||
private PmsProductLibraryComponentDataVo toPmsProductLibraryComponentDataVo(PmsProductLibraryComponent component, List<PmsProductLibraryRepositories> repoList) {
|
||||
PmsProductLibraryComponentDataVo pmsProductLibraryComponentDataVo = component.toPmsProductLibraryComponentDataVo();
|
||||
repoList.stream().filter(x -> x.getId().equals(component.getRepoId())).findFirst().ifPresent(repo -> pmsProductLibraryComponentDataVo.setDownloadUrl(
|
||||
EscapeUtil.removeExtraSlashOfUrl(
|
||||
String.format("%s/%s", repo.getUrl(), component.getPath()))));
|
||||
return pmsProductLibraryComponentDataVo;
|
||||
}
|
||||
private void setNexusResultDataVoChoose(PmsProductLibraryRepositories productRepo, List<PmsProductLibraryComponent> productComponentList, List<NexusResultDataVo> nexusResultDataVoList, boolean isDocker) {
|
||||
for (PmsProductLibraryComponent component : productComponentList) {
|
||||
nexusResultDataVoList.forEach(x -> {
|
||||
|
|
@ -277,7 +302,6 @@ public class PmsProductLibraryProductRepoServiceImpl implements IPmsProductLibra
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void setNexusResultDataVoPath(PmsProductLibraryRepositories repo, List<NexusResultDataVo> nexusResultDataVoList) {
|
||||
nexusResultDataVoList.forEach(x -> {
|
||||
if (ProductLibraryRepositoriesFormatEnum.DOCKER.getKey().equals(repo.getFormat())) {
|
||||
|
|
@ -287,7 +311,6 @@ public class PmsProductLibraryProductRepoServiceImpl implements IPmsProductLibra
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
private NexusComponentResultVo<List<NexusResultDataVo>> buildDockerResultVo(List<NexusResultDataVo> data) {
|
||||
NexusComponentResultVo<List<NexusResultDataVo>> target = new NexusComponentResultVo<>();
|
||||
target.setAction("coreui_Browse");
|
||||
|
|
|
|||
|
|
@ -50,6 +50,16 @@ public class PmsProductLibraryRepositoriesServiceImpl implements IPmsProductLibr
|
|||
return pmsProductLibraryRepositories;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PmsProductLibraryRepositories selectPmsProductLibraryRepositoriesById(Long repoId) {
|
||||
PmsProductLibraryRepositories pmsProductLibraryRepositories =
|
||||
pmsProductLibraryRepositoriesMapper.selectPmsProductLibraryRepositoriesById(repoId);
|
||||
if (pmsProductLibraryRepositories == null) {
|
||||
throw new ServiceException("组织下不存在该制品库(制品库id[%s])", repoId);
|
||||
}
|
||||
return pmsProductLibraryRepositories;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NexusHostedRepoInputVo getNexusRepo(String type, String format, String nexusRepoName) {
|
||||
NexusHostedRepoInputVo nexusRepo = nexusRequestHelper.doRequestToJavaObject(
|
||||
|
|
|
|||
|
|
@ -285,7 +285,6 @@ public class NexusRequestHelper {
|
|||
if (res == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return JSONObject.parseObject(res.toJSONString(), buildType(ownerClass, List.class, rawClass));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,11 @@ package com.microservices.pms.utils;
|
|||
|
||||
import com.microservices.common.core.exception.ServiceException;
|
||||
import com.microservices.common.core.utils.ServletUtils;
|
||||
import com.microservices.system.api.domain.SysFileBytes;
|
||||
import feign.Response;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
|
@ -95,4 +99,17 @@ public class PmsUtils {
|
|||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static SysFileBytes getFeignFile(Response response) {
|
||||
try {
|
||||
InputStream inputStream = response.body().asInputStream();
|
||||
String fileName = response.headers().get("FileName") + "";
|
||||
SysFileBytes sysFileBytes = new SysFileBytes();
|
||||
sysFileBytes.setFileInputStream(inputStream);
|
||||
sysFileBytes.setFileName(fileName);
|
||||
return sysFileBytes;
|
||||
} catch (IOException e) {
|
||||
throw new ServiceException("获取文件失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,6 +49,33 @@
|
|||
from pms_product_library_component
|
||||
</sql>
|
||||
|
||||
<sql id="selectPmsProductLibraryComponentAliasVo">
|
||||
select pplc.id,
|
||||
pplc.identifier,
|
||||
pplc.path,
|
||||
pplc.`group`,
|
||||
pplc.name,
|
||||
pplc.repo_id,
|
||||
pplc.version,
|
||||
pplc.file_identifier,
|
||||
pplc.dept_id,
|
||||
pplc.pms_enterprise_id,
|
||||
pplc.update_time,
|
||||
pplc.update_by,
|
||||
pplc.create_time,
|
||||
pplc.create_by,
|
||||
pplc.del_flag,
|
||||
pplc.attributes,
|
||||
pplc.reserved_field_1,
|
||||
pplc.reserved_field_2,
|
||||
pplc.reserved_field_3,
|
||||
pe.enterprise_identifier,
|
||||
pplr.format
|
||||
from pms_product_library_component as pplc
|
||||
left join pms_enterprise as pe on pplc.pms_enterprise_id = pe.id
|
||||
left join pms_product_library_repositories as pplr on pplr.id = pplc.repo_id
|
||||
</sql>
|
||||
|
||||
<select id="selectPmsProductLibraryComponentList" parameterType="PmsProductLibraryComponent"
|
||||
resultMap="PmsProductLibraryComponentResult">
|
||||
<include refid="selectPmsProductLibraryComponentVo"/>
|
||||
|
|
@ -92,6 +119,21 @@
|
|||
and repo_id = #{repoId}
|
||||
and pms_enterprise_id = #{pmsEnterpriseId}
|
||||
</select>
|
||||
<select id="selectProductRepoComponentList" resultMap="PmsProductLibraryComponentResult">
|
||||
<include refid="selectPmsProductLibraryComponentAliasVo"/>
|
||||
<where>
|
||||
<if test="excludeIds != null and excludeIds != ''">
|
||||
and pplc.id not in
|
||||
<foreach item="item" index="index" collection="excludeIds.split(',')" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="productRepoName != null and productRepoName != ''">and pplr.`name` = #{productRepoName}</if>
|
||||
<if test="pmsEnterpriseIdentifier != null ">and pe.enterprise_identifier = #{pmsEnterpriseIdentifier}</if>
|
||||
and pplr.format='product'
|
||||
</where>
|
||||
order by pplc.create_time desc,pplc.update_time desc
|
||||
</select>
|
||||
<select id="selectPmsProductLibraryComponentByIdentifier" resultMap="PmsProductLibraryComponentResult">
|
||||
<include refid="selectPmsProductLibraryComponentVo"/>
|
||||
where repo_id = #{repoId}
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@
|
|||
and pe.enterprise_identifier = #{pmsEnterpriseIdentifier}
|
||||
and pplr.name = #{repoName}
|
||||
and pplr.snapshot_name IS NOT NULL
|
||||
order by pplr.create_time desc
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
|
@ -135,6 +136,11 @@
|
|||
and pe.enterprise_identifier = #{pmsEnterpriseIdentifier}
|
||||
and pplr.snapshot_name IS NOT NULL
|
||||
</select>
|
||||
<select id="selectProductRepoById" resultMap="PmsProductLibraryRepositoriesResult">
|
||||
<include refid="selectPmsProductLibraryRepositoriesAliasVo"/>
|
||||
where pplr.id = #{repoId}
|
||||
and pplr.format = 'product'
|
||||
</select>
|
||||
<select id="selectPmsProductLibraryRepositoriesByAlias" resultMap="PmsProductLibraryRepositoriesResult">
|
||||
<include refid="selectPmsProductLibraryRepositoriesAliasVo"/>
|
||||
where pplr.alias = #{alias}
|
||||
|
|
|
|||
Loading…
Reference in New Issue