Skip to content

Commit

Permalink
server: list as numbers and ipv4 subnets by keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
weizhouapache committed Aug 29, 2024
1 parent d754202 commit 2212f22
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
public interface ASNumberDao extends GenericDao<ASNumberVO, Long> {

Pair<List<ASNumberVO>, Integer> searchAndCountByZoneOrRangeOrAllocated(Long zoneId, Long asnRangeId, Integer asNumber, Long networkId, Long vpcId,
Boolean allocated, Long accountId, Long domainId, Long startIndex, Long pageSizeVal);
Boolean allocated, Long accountId, Long domainId, String keyword,
Long startIndex, Long pageSizeVal);
ASNumberVO findByAsNumber(Long asNumber);

ASNumberVO findOneByAllocationStateAndZone(long zoneId, boolean allocated);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public Pair<List<ASNumberVO>, Integer> searchAndCountByZoneOrRangeOrAllocated(Lo
Integer asNumber, Long networkId, Long vpcId,
Boolean allocated,
Long accountId, Long domainId,
String keyword,
Long startIndex, Long pageSizeVal) {
SearchCriteria<ASNumberVO> sc = asNumberSearch.create();
if (zoneId != null) {
Expand All @@ -73,6 +74,9 @@ public Pair<List<ASNumberVO>, Integer> searchAndCountByZoneOrRangeOrAllocated(Lo
if (domainId != null) {
sc.setParameters("domainId", domainId);
}
if (keyword != null) {
sc.addAnd("asNumber", SearchCriteria.Op.LIKE, "%" + keyword + "%");
}
Filter searchFilter = new Filter(ASNumberVO.class, "id", true, startIndex, pageSizeVal);
return searchAndCount(sc, searchFilter);
}
Expand Down
3 changes: 2 additions & 1 deletion server/src/main/java/com/cloud/bgp/BGPServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ public Pair<List<ASNumber>, Integer> listASNumbers(ListASNumbersCmd cmd) {
Long domainId = cmd.getDomainId();
Long startIndex = cmd.getStartIndex();
Long pageSizeVal = cmd.getPageSizeVal();
String keyword = cmd.getKeyword();

Account userAccount = null;
Domain domain = null;
Expand Down Expand Up @@ -209,7 +210,7 @@ public Pair<List<ASNumber>, Integer> listASNumbers(ListASNumbersCmd cmd) {
}
Pair<List<ASNumberVO>, Integer> pair = asNumberDao.searchAndCountByZoneOrRangeOrAllocated(zoneId, asNumberRangeId,
asNumber, networkSearchId, vpcSerchId, allocated, Objects.nonNull(userAccount) ? userAccount.getId() : null,
Objects.nonNull(domain) ? domain.getId() : null, startIndex, pageSizeVal);
Objects.nonNull(domain) ? domain.getId() : null, keyword, startIndex, pageSizeVal);
return new Pair<>(new ArrayList<>(pair.first()), pair.second());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -518,8 +518,9 @@ public List<Ipv4GuestSubnetNetworkMap> listIpv4GuestSubnetsForGuestNetwork(ListI
sc.addAnd("vpcId", SearchCriteria.Op.EQ, vpcId);
}
if (keyword != null) {
sc.addAnd("subnet", SearchCriteria.Op.LIKE, keyword);
sc.addAnd("subnet", SearchCriteria.Op.LIKE, "%" + keyword + "%");
}

return ipv4GuestSubnetNetworkMapDao.search(sc, null);
}

Expand Down

0 comments on commit 2212f22

Please sign in to comment.