Search in sources :

Example 1 with FilterRouteDto

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();
}
Also used : InputStream(java.io.InputStream) FilterRouteDto(io.github.tesla.ops.filter.dto.FilterRouteDto) IOException(java.io.IOException) CommonResponse(io.github.tesla.ops.common.CommonResponse) TeslaException(io.github.tesla.ops.common.TeslaException) RequiresPermissions(org.apache.shiro.authz.annotation.RequiresPermissions) PostMapping(org.springframework.web.bind.annotation.PostMapping) Log(io.github.tesla.ops.common.Log) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 2 with FilterRouteDto

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();
}
Also used : InputStream(java.io.InputStream) FilterRouteDto(io.github.tesla.ops.filter.dto.FilterRouteDto) IOException(java.io.IOException) CommonResponse(io.github.tesla.ops.common.CommonResponse) TeslaException(io.github.tesla.ops.common.TeslaException) RequiresPermissions(org.apache.shiro.authz.annotation.RequiresPermissions) PostMapping(org.springframework.web.bind.annotation.PostMapping) Log(io.github.tesla.ops.common.Log) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 3 with FilterRouteDto

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

Example 4 with FilterRouteDto

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

Example 5 with FilterRouteDto

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;
}
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)

Aggregations

FilterRouteDto (io.github.tesla.ops.filter.dto.FilterRouteDto)8 RequiresPermissions (org.apache.shiro.authz.annotation.RequiresPermissions)4 FilterRouteDO (io.github.tesla.filter.domain.FilterRouteDO)3 FilterRpcDO (io.github.tesla.filter.domain.FilterRpcDO)3 Log (io.github.tesla.ops.common.Log)3 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)3 CommonResponse (io.github.tesla.ops.common.CommonResponse)2 TeslaException (io.github.tesla.ops.common.TeslaException)2 RouteVo (io.github.tesla.ops.filter.vo.RouteVo)2 PageDO (io.github.tesla.ops.system.domain.PageDO)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 GetMapping (org.springframework.web.bind.annotation.GetMapping)2 PostMapping (org.springframework.web.bind.annotation.PostMapping)2 Query (io.github.tesla.ops.utils.Query)1