feat(制品库功能开发): 优化产品库逻辑
产品库从受控库选择制品时需填写产品库路径:后端在返回制品时,返回制品移入时默认移入的路径
This commit is contained in:
parent
33a37555e6
commit
204e39774a
|
|
@ -2,6 +2,7 @@ package com.microservices.pms.productLibrary.domain.vo;
|
|||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.microservices.pms.productLibrary.domain.ProductLibraryRepositoriesFormatEnum;
|
||||
import com.microservices.pms.utils.PmsUtils;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
|
@ -123,13 +124,7 @@ public class NexusAssetResultDataVo {
|
|||
}
|
||||
|
||||
public String parseDirectory() {
|
||||
// 找到最后一个"/"的位置
|
||||
int lastSlashIndex = this.name.lastIndexOf('/');
|
||||
if (lastSlashIndex > 0) {
|
||||
// 截取到"/"之前的所有字符作为文件夹路径
|
||||
return this.name.substring(0, lastSlashIndex);
|
||||
}
|
||||
return "";
|
||||
return PmsUtils.parseDirectory(this.name);
|
||||
}
|
||||
|
||||
public String parseNexusVersion() {
|
||||
|
|
|
|||
|
|
@ -53,4 +53,9 @@ public class NexusResultDataVo {
|
|||
*/
|
||||
@ApiModelProperty(value = "是否已选择")
|
||||
private Boolean isChoose = false;
|
||||
/**
|
||||
* 默认文件夹
|
||||
*/
|
||||
@ApiModelProperty(value = "默认文件夹")
|
||||
private String defaultDir;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -279,7 +279,7 @@ public class PmsProductLibraryAsyncServiceImpl implements IPmsProductLibraryAsyn
|
|||
componentRawInputVo.setVersion(version);
|
||||
componentRawInputVo.setAttributes(customAttribute);
|
||||
componentRawInputVo.setAssetList(assetRawInputVoList);
|
||||
componentRawInputVo.setDirectory(String.format("/%s/%s", repo.getAlias(), directory));
|
||||
componentRawInputVo.setDirectory(EscapeUtil.removeExtraSlashOfUrl(String.format("/%s/%s", repo.getAlias(), directory)));
|
||||
pmsProductLibraryComponentService.insertRawComponent(componentRawInputVo);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import com.microservices.common.core.exception.ServiceException;
|
|||
import com.microservices.common.core.utils.DateUtils;
|
||||
import com.microservices.common.core.utils.PageUtils;
|
||||
import com.microservices.common.core.utils.StringUtils;
|
||||
import com.microservices.common.core.utils.html.EscapeUtil;
|
||||
import com.microservices.common.core.web.page.GenericsTableDataInfo;
|
||||
import com.microservices.common.security.utils.SecurityUtils;
|
||||
import com.microservices.pms.enterprise.domain.PmsEnterprise;
|
||||
|
|
@ -21,6 +22,7 @@ import com.microservices.pms.productLibrary.service.IPmsProductLibraryProductRep
|
|||
import com.microservices.pms.productLibrary.service.IPmsProductLibraryRepositoriesService;
|
||||
import com.microservices.pms.utils.NexusRequestHelper;
|
||||
import com.microservices.pms.utils.NexusRequestUrl;
|
||||
import com.microservices.pms.utils.PmsUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
|
@ -180,6 +182,7 @@ public class PmsProductLibraryProductRepoServiceImpl implements IPmsProductLibra
|
|||
|
||||
}
|
||||
setNexusResultDataVoChoose(productComponentList, keyNexusResultDataVoList, true);
|
||||
setNexusResultDataVoPath(repo, keyNexusResultDataVoList);
|
||||
return buildDockerResultVo(keyNexusResultDataVoList);
|
||||
} else {
|
||||
NexusComponentSearchVo<ComponentSearchVo> nexusComponentSearchVo = NexusComponentSearchVo.toRead(componentSearchVo, nexusRequestHelper.getNexusTid());
|
||||
|
|
@ -189,6 +192,7 @@ public class PmsProductLibraryProductRepoServiceImpl implements IPmsProductLibra
|
|||
if (nexusComponentResultStateVo.getSuccess()) {
|
||||
List<NexusResultDataVo> nexusResultDataVoList = nexusComponentResultStateVo.getData();
|
||||
setNexusResultDataVoChoose(productComponentList, nexusResultDataVoList, false);
|
||||
setNexusResultDataVoPath(repo, nexusResultDataVoList);
|
||||
// 当制品库为Maven时,需排除自动生成的制品数据
|
||||
if (ProductLibraryRepositoriesFormatEnum.MAVEN.getKey().equals(repo.getFormat())) {
|
||||
List<NexusResultDataVo> keyNexusResultDataVoList = new ArrayList<>();
|
||||
|
|
@ -245,6 +249,16 @@ public class PmsProductLibraryProductRepoServiceImpl implements IPmsProductLibra
|
|||
}
|
||||
}
|
||||
|
||||
private void setNexusResultDataVoPath(PmsProductLibraryRepositories repo, List<NexusResultDataVo> nexusResultDataVoList) {
|
||||
nexusResultDataVoList.forEach(x -> {
|
||||
if (ProductLibraryRepositoriesFormatEnum.DOCKER.getKey().equals(repo.getFormat())) {
|
||||
x.setDefaultDir(EscapeUtil.removeExtraSlashOfUrl(String.format("/%s/", repo.getAlias())));
|
||||
} else {
|
||||
x.setDefaultDir(EscapeUtil.removeExtraSlashOfUrl(String.format("/%s/%s", repo.getAlias(), PmsUtils.parseDirectory(x.getId()))));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private NexusComponentResultVo<List<NexusResultDataVo>> buildDockerResultVo(List<NexusResultDataVo> data) {
|
||||
NexusComponentResultVo<List<NexusResultDataVo>> target = new NexusComponentResultVo<>();
|
||||
target.setAction("coreui_Browse");
|
||||
|
|
|
|||
|
|
@ -80,4 +80,19 @@ public class PmsUtils {
|
|||
matcher.appendTail(sb);
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件路径中文件所在的文件夹
|
||||
*
|
||||
* @return 文件夹
|
||||
*/
|
||||
public static String parseDirectory(String filePath) {
|
||||
// 找到最后一个"/"的位置
|
||||
int lastSlashIndex = filePath.lastIndexOf('/');
|
||||
if (lastSlashIndex > 0) {
|
||||
// 截取到"/"之前的所有字符作为文件夹路径
|
||||
return filePath.substring(0, lastSlashIndex);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue