use of io.github.tesla.ops.filter.dto.FilterRouteDto in project tesla by linking12.
the class FilterRouteController method save.
@Log("保存路由")
@RequiresPermissions("filter:route:add")
@PostMapping("/save")
@ResponseBody()
public CommonResponse save(RouteVo zuulVo, @RequestParam(name = "zipFile", required = false) MultipartFile zipFile) {
try {
// grpc路由
if (zipFile != null) {
InputStream directoryZipStream = zipFile.getInputStream();
CommonResponse response = judgeFileType(directoryZipStream, "zip");
if (response != null) {
return response;
} else {
String serviceFileName = zuulVo.getServiceFileName();
byte[] protoContext = protobufService.compileDirectoryProto(zipFile, serviceFileName);
FilterRouteDto zuulDto = zuulVo.buildRouteDto();
zuulDto.setProtoContext(protoContext);
routeService.save(zuulDto);
}
} else {
FilterRouteDto zuulDto = zuulVo.buildRouteDto();
routeService.save(zuulDto);
}
} catch (IOException e) {
throw new TeslaException("保存路由失败", e);
}
return CommonResponse.ok();
}
use of io.github.tesla.ops.filter.dto.FilterRouteDto in project tesla by linking12.
the class FilterRouteController method update.
@Log("更新路由")
@RequiresPermissions("filter:route:edit")
@PostMapping("/update")
@ResponseBody()
public CommonResponse update(RouteVo zuulVo, @RequestParam(name = "zipFile", required = false) MultipartFile zipFile) {
try {
// grpc路由
if (zipFile != null) {
InputStream directoryZipStream = zipFile.getInputStream();
CommonResponse response = judgeFileType(directoryZipStream, "zip");
if (response != null) {
return response;
} else {
String serviceFileName = zuulVo.getServiceFileName();
byte[] protoContext = protobufService.compileDirectoryProto(zipFile, serviceFileName);
FilterRouteDto zuulDto = zuulVo.buildRouteDto();
zuulDto.setProtoContext(protoContext);
routeService.update(zuulDto);
}
} else {
FilterRouteDto zuulDto = zuulVo.buildRouteDto();
routeService.update(zuulDto);
}
} catch (IOException e) {
throw new TeslaException("保存路由失败", e);
}
return CommonResponse.ok();
}
use of io.github.tesla.ops.filter.dto.FilterRouteDto in project tesla by linking12.
the class FilterRouteServiceImpl method list.
@Override
public List<FilterRouteDto> list(Map<String, Object> map) {
List<FilterRouteDO> routes = routeDao.list(map);
List<FilterRouteDto> routeDtos = Lists.newArrayList();
for (FilterRouteDO route : routes) {
FilterRpcDO rpc = rpcDao.get(route.getId());
FilterRouteDto routeDto = FilterRouteDto.buildRouteDto(route, rpc);
routeDtos.add(routeDto);
}
return routeDtos;
}
use of io.github.tesla.ops.filter.dto.FilterRouteDto in project tesla by linking12.
the class FilterRouteServiceImpl method get.
@Override
public FilterRouteDto get(Long routeId) {
FilterRouteDO route = routeDao.get(routeId);
FilterRpcDO rpc = rpcDao.get(routeId);
FilterRouteDto routeDto = FilterRouteDto.buildRouteDto(route, rpc);
return routeDto;
}
use of io.github.tesla.ops.filter.dto.FilterRouteDto 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;
}
Aggregations