use of io.github.tesla.ops.common.CommonResponse 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.common.CommonResponse 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();
}
Aggregations