Search in sources :

Example 6 with FilterRouteDO

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;
}
Also used : PageDO(io.github.tesla.ops.system.domain.PageDO) FilterRouteDO(io.github.tesla.filter.domain.FilterRouteDO) FilterRouteDto(io.github.tesla.ops.filter.dto.FilterRouteDto) FilterRpcDO(io.github.tesla.filter.domain.FilterRpcDO)

Example 7 with FilterRouteDO

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;
}
Also used : FilterRouteDO(io.github.tesla.filter.domain.FilterRouteDO) FilterRpcDO(io.github.tesla.filter.domain.FilterRpcDO)

Example 8 with FilterRouteDO

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();
    }
}
Also used : FilterRouteDO(io.github.tesla.filter.domain.FilterRouteDO) FilterRpcDO(io.github.tesla.filter.domain.FilterRpcDO)

Aggregations

FilterRouteDO (io.github.tesla.filter.domain.FilterRouteDO)8 FilterRpcDO (io.github.tesla.filter.domain.FilterRpcDO)6 FilterRouteDto (io.github.tesla.ops.filter.dto.FilterRouteDto)3 PageDO (io.github.tesla.ops.system.domain.PageDO)1