Skip to content

Commit

Permalink
Merge pull request #259 from CodingCattwo/dev142
Browse files Browse the repository at this point in the history
fix ignore path repeat
  • Loading branch information
CodingCattwo authored Dec 4, 2020
2 parents c99e230 + 0c92838 commit 465e4d9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ public BaseResponse addContractPath(@Valid @RequestBody ContractPathParam param)
if ("".equals(contractPath)) {
contractPath = "/";
}
int result = contractPathService.save(param.getGroupId(), contractPath);
int result = contractPathService.save(param.getGroupId(), contractPath, false);
response.setData(result);

log.info("end addContractPath. useTime:{} add result:{}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,15 @@ public List<TbContractPath> listContractPath(Integer groupId) {
* @param pathName
* @return
*/
public int save(Integer groupId, String pathName) {
public int save(Integer groupId, String pathName, boolean ignoreRepeat) {
TbContractPath check = contractPathMapper.findOne(new ContractPathParam(groupId, pathName));
if (check != null) {
log.error("save path, path exists check:{}", check);
throw new NodeMgrException(ConstantCode.CONTRACT_PATH_IS_EXISTS);
if (ignoreRepeat) {
return 0;
} else {
log.error("save path, path exists check:{}", check);
throw new NodeMgrException(ConstantCode.CONTRACT_PATH_IS_EXISTS);
}
}
TbContractPath contractPath = new TbContractPath();
contractPath.setContractPath(pathName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ private TbContract newContract(Contract contract) {
contractMapper.add(tbContract);
// save contract path
log.debug("newContract save contract path");
// if exist, auto not save
contractPathService.save(contract.getGroupId(), contract.getContractPath());
// if exist, auto not save (ignor)
contractPathService.save(contract.getGroupId(), contract.getContractPath(), true);
return tbContract;
}

Expand Down

0 comments on commit 465e4d9

Please sign in to comment.