Merge branch 'dev_pms_zpk_cmdb' of code.gitlink.org.cn:otto/microservices into dev_PMS_ZPK
# Conflicts: # microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/productLibrary/mapper/PmsProductLibraryComponentMapper.java # microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/productLibrary/service/IPmsProductLibraryProductRepoService.java # microservices-modules/microservices-modules-pms/src/main/java/com/microservices/pms/productLibrary/service/impl/PmsProductLibraryProductRepoServiceImpl.java # microservices-modules/microservices-modules-pms/src/main/resources/mapper/pms/PmsProductLibraryComponentMapper.xml # microservices-modules/microservices-modules-pms/src/main/resources/mapper/pms/PmsProductLibraryRepositoriesMapper.xml
This commit is contained in:
commit
4db43bdc6c
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
|
|
|
|||
|
|
@ -135,6 +135,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