Skip to content

Commit

Permalink
Merge pull request WeBankFinTech#279 from one-beauty/dev-1.0.0
Browse files Browse the repository at this point in the history
LGTM
  • Loading branch information
FinalTarget authored Apr 24, 2022
2 parents 7c3215e + 526be94 commit e424013
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ public ProjectResponseRef deleteProject(ProjectRequestRef projectRequestRef) thr
(requestRef) ->{
ExchangisEntityPostAction exchangisEntityPostAction = new ExchangisEntityPostAction();
exchangisEntityPostAction.setUser(requestRef.getCreateBy());
HashMap<String, String> labels = new HashMap<>();
labels.put("route", "dev");
exchangisEntityPostAction.addRequestPayload("labels", labels);
return exchangisEntityPostAction;
}, Map.class);
if (Objects.isNull(entity)){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,26 +44,30 @@ protected Logger getLogger() {

@Override
public DSSProject getProject(ProjectRequestRef projectRequestRef) throws ExternalOperationFailedException {
LOG.info("delete project request => dss_projectId:{}, name:{}, createName:{}", projectRequestRef.getId(),
LOG.info("get project request => dss_projectId:{}, name:{}, createName:{}", projectRequestRef.getId(),
projectRequestRef.getName(), projectRequestRef.getCreateBy());
String url = requestURL("appProject/check");
ExchangisEntityRespResult.BasicMessageEntity<Map<String, Object>> entity = requestToGetEntity(url,projectRequestRef.getWorkspace(), projectRequestRef,
(requestRef) ->{
ExchangisGetAction exchangisGetAction = new ExchangisGetAction();
exchangisGetAction.setUser(requestRef.getCreateBy());
exchangisGetAction.setParameter("keywords", projectRequestRef.getName());
return (HttpExtAction) exchangisGetAction;
String url = requestURL("appProject/check/" + projectRequestRef.getName() + "/");
ExchangisEntityRespResult.BasicMessageEntity<Map<String, Object>> entity = requestToGetEntity(url, projectRequestRef.getWorkspace(), projectRequestRef,
(requestRef) -> {
ExchangisEntityPostAction exchangisEntityPostAction = new ExchangisEntityPostAction();
exchangisEntityPostAction.setUser(requestRef.getCreateBy());
return exchangisEntityPostAction;
}, Map.class);
if (Objects.isNull(entity)){
if (Objects.isNull(entity)) {
throw new ExternalOperationFailedException(31020, "The response entity cannot be empty", null);
}
try {
ExchangisEntityRespResult httpResult = entity.getResult();
httpResult.getResponseBody();
Map resMap = AppConnUtils.getResponseMap(httpResult);
ExchangisProjectResponseRef responseRef = new ExchangisProjectResponseRef(httpResult, null);
DSSProject dssProject = new DSSProject();
Map<String, Object> payloadMap = (Map<String, Object>) resMap.get("payload");
dssProject.setId(Long.parseLong(payloadMap.get("id").toString()));
Map<String, Object> dataMap = (Map<String, Object>) resMap.get("data");
Map<String, Object> projectInfo = (Map<String, Object>) dataMap.get("projectInfo");
//如果查询不到project,则无重复项目可以直接返回
if (projectInfo == null) {
return null;
}
dssProject.setId(Long.parseLong(projectInfo.get("id").toString()));
return dssProject;
} catch (AppStandardErrorException e) {
throw new ExternalOperationFailedException(90176, "search Exchangis Project failed when get HttpResult", e);
Expand All @@ -82,4 +86,4 @@ public void setStructureService(StructureService structureService) {
this.structureService = structureService;
setSSORequestService(this.structureService);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ public ExchangisProjectResponseRef(ExchangisEntityRespResult result,
this.projectRefId = projectId;
}

public ExchangisProjectResponseRef(String responseBody,
int status){
super(responseBody, status);
}

@Override
public Long getProjectRefId() {
return projectRefId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,26 @@ public Message createProject(@Validated @RequestBody ExchangisProjectInfo projec
return Message.error("Fail to create project (创建工程失败)");
}
}
/**
* check project name
* @param request http request
* @param name project name
* @return
*/
@RequestMapping( value = "/check/{name}", method = RequestMethod.POST)
public Message getProjectByName(HttpServletRequest request, @PathVariable("name") String name) {
String username = SecurityFilter.getLoginUsername(request);
try {
ExchangisProjectInfo projectInfo = projectService.selectByName(name);
return ExchangisProjectRestfulUtils.dealOk("根据名字获取工程成功",
new Pair<>("projectInfo",projectInfo));
} catch (Exception t) {
LOG.error("Failed to delete project for user {}", username, t);
return Message.error("Failed to delete project (根据名字获取工程失败)");
}


}


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,28 @@ public Message deleteProject(HttpServletRequest request, @PathVariable("name") S
}


/**
* check project name
* @param request http request
* @param name project name
* @return
*/
@RequestMapping( value = "/check/{name}", method = RequestMethod.POST)
public Message getProjectByName(HttpServletRequest request, @PathVariable("name") String name) {
String username = SecurityFilter.getLoginUsername(request);
try {
ExchangisProjectInfo projectInfo = projectService.selectByName(name);
return ExchangisProjectRestfulUtils.dealOk("根据名字获取工程成功",
new Pair<>("projectInfo",projectInfo));
} catch (Exception t) {
LOG.error("Failed to delete project for user {}", username, t);
return Message.error("Failed to delete project (根据名字获取工程失败)");
}


}


/**
* @param username username
* @param project project
Expand Down

0 comments on commit e424013

Please sign in to comment.