wangyifei
2024-10-30 3cf717d9c9cb1426f25bd5cd886ec20873058e39
src/main/java/com/se/simu/controller/WaterController.java
@@ -102,6 +102,23 @@
        }
    }
    @ApiOperation(value = "获取降水曲线文件曲线图")
    @GetMapping("/{serviceName}/rainfall.json")
    public void getRainfall(@PathVariable String serviceName, HttpServletResponse res) {
        try {
            if (!validate(serviceName, res)) {
                return;
            }
            byte[] bytes = waterService.getRainfall(serviceName);
            WebHelper.writeBytes(bytes, res);
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
            WebHelper.writeStr2Page(res, HttpStatus.INTERNAL_SERVER_ERROR, ex.getMessage());
        }
    }
    private boolean validate(String serviceName, HttpServletResponse res) {
        if (WebHelper.isEmpty(serviceName)) {
            return WebHelper.writeJson2Page(res, HttpStatus.BAD_REQUEST, "服务名不能为空");