use of io.github.tesla.filter.domain.FilterRouteDO in project tesla by linking12.
the class FilterRouteServiceImpl method queryList.
@Override
public PageDO<FilterRouteDto> queryList(Query query) {
int total = routeDao.count(query);
List<FilterRouteDO> routes = routeDao.list(query);
List<FilterRouteDto> dtos = Lists.newArrayListWithCapacity(routes.size());
for (FilterRouteDO routeDo : routes) {
FilterRpcDO rpcDO = rpcDao.get(routeDo.getId());
FilterRouteDto dto = FilterRouteDto.buildRouteDto(routeDo, rpcDO);
dtos.add(dto);
}
PageDO<FilterRouteDto> page = new PageDO<>();
page.setTotal(total);
page.setRows(dtos);
return page;
}
use of io.github.tesla.filter.domain.FilterRouteDO in project tesla by linking12.
the class FilterRouteServiceImpl method save.
@Override
public int save(FilterRouteDto routeDto) {
FilterRouteDO routeDo = routeDto.buildRoute();
FilterRpcDO rpcDo = routeDto.buildRpc();
int success2 = routeDao.save(routeDo);
Long routeId = routeDo.getId();
rpcDo.setRouteId(routeId);
if (routeDo.getRpc()) {
int success1 = rpcDao.save(rpcDo);
if (success1 > 0 && success2 > 0) {
return CommonResponse.SUCCESS;
} else {
return CommonResponse.ERROR;
}
}
return success2;
}
use of io.github.tesla.filter.domain.FilterRouteDO in project tesla by linking12.
the class DynamicsRouteCacheComponent method doCache.
@Override
protected void doCache() {
try {
readWriteLock.writeLock().lock();
// clear data
ROUTE_CACHE.clear();
RPC_CACHE.clear();
// cache all data
List<FilterRouteDO> routes = routeDao.list(Maps.newHashMap());
for (FilterRouteDO route : routes) {
FilterRouteDO routeCopy = route.copy();
String path = routeCopy.getFromPath();
ROUTE_CACHE.put(path, routeCopy);
}
List<FilterRpcDO> rpcs = rpcDao.list(Maps.newHashMap());
for (FilterRpcDO rpc : rpcs) {
FilterRpcDO rpcCopy = rpc.copy();
RPC_CACHE.put(rpcCopy.getRouteId(), rpcCopy);
}
} finally {
readWriteLock.writeLock().unlock();
}
}
Aggregations