From 68e97384e60d0042cb189f8be8daa0768431580c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E5=86=B7?= <2270033969@qq.com> Date: Thu, 13 Jun 2024 17:20:11 +0800 Subject: [PATCH] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20screw=200.0.4=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E8=BF=9E=E6=8E=A5=E6=B1=A0=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/GenDsConfController.java | 171 +++++++++--------- 1 file changed, 89 insertions(+), 82 deletions(-) diff --git a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/controller/GenDsConfController.java b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/controller/GenDsConfController.java index ab2392db1..bc7c2a7f6 100755 --- a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/controller/GenDsConfController.java +++ b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/controller/GenDsConfController.java @@ -50,97 +50,104 @@ import javax.sql.DataSource; @RequestMapping("/dsconf") public class GenDsConfController { - private final GenDatasourceConfService datasourceConfService; + private final GenDatasourceConfService datasourceConfService; - private final Screw screw; + private final Screw screw; - /** - * 分页查询 - * @param page 分页对象 - * @param datasourceConf 数据源表 - * @return - */ - @GetMapping("/page") - public R getSysDatasourceConfPage(Page page, GenDatasourceConf datasourceConf) { - return R.ok(datasourceConfService.page(page, - Wrappers.lambdaQuery() - .like(StrUtil.isNotBlank(datasourceConf.getDsName()), GenDatasourceConf::getDsName, - datasourceConf.getDsName()))); - } + /** + * 分页查询 + * + * @param page 分页对象 + * @param datasourceConf 数据源表 + * @return + */ + @GetMapping("/page") + public R getSysDatasourceConfPage(Page page, GenDatasourceConf datasourceConf) { + return R.ok(datasourceConfService.page(page, + Wrappers.lambdaQuery() + .like(StrUtil.isNotBlank(datasourceConf.getDsName()), GenDatasourceConf::getDsName, + datasourceConf.getDsName()))); + } - /** - * 查询全部数据源 - * @return - */ - @GetMapping("/list") - @Inner(value = false) - public R list() { - return R.ok(datasourceConfService.list()); - } + /** + * 查询全部数据源 + * + * @return + */ + @GetMapping("/list") + @Inner(value = false) + public R list() { + return R.ok(datasourceConfService.list()); + } - /** - * 通过id查询数据源表 - * @param id id - * @return R - */ - @GetMapping("/{id}") - public R getById(@PathVariable("id") Long id) { - return R.ok(datasourceConfService.getById(id)); - } + /** + * 通过id查询数据源表 + * + * @param id id + * @return R + */ + @GetMapping("/{id}") + public R getById(@PathVariable("id") Long id) { + return R.ok(datasourceConfService.getById(id)); + } - /** - * 新增数据源表 - * @param datasourceConf 数据源表 - * @return R - */ - @PostMapping - @XssCleanIgnore - public R save(@RequestBody GenDatasourceConf datasourceConf) { - return R.ok(datasourceConfService.saveDsByEnc(datasourceConf)); - } + /** + * 新增数据源表 + * + * @param datasourceConf 数据源表 + * @return R + */ + @PostMapping + @XssCleanIgnore + public R save(@RequestBody GenDatasourceConf datasourceConf) { + return R.ok(datasourceConfService.saveDsByEnc(datasourceConf)); + } - /** - * 修改数据源表 - * @param conf 数据源表 - * @return R - */ - @PutMapping - @XssCleanIgnore - public R updateById(@RequestBody GenDatasourceConf conf) { - return R.ok(datasourceConfService.updateDsByEnc(conf)); - } + /** + * 修改数据源表 + * + * @param conf 数据源表 + * @return R + */ + @PutMapping + @XssCleanIgnore + public R updateById(@RequestBody GenDatasourceConf conf) { + return R.ok(datasourceConfService.updateDsByEnc(conf)); + } - /** - * 通过id删除数据源表 - * @param ids id - * @return R - */ - @DeleteMapping - public R removeById(@RequestBody Long[] ids) { - return R.ok(datasourceConfService.removeByDsId(ids)); - } + /** + * 通过id删除数据源表 + * + * @param ids id + * @return R + */ + @DeleteMapping + public R removeById(@RequestBody Long[] ids) { + return R.ok(datasourceConfService.removeByDsId(ids)); + } - /** - * 查询数据源对应的文档 - * @param dsName 数据源名称 - */ - @SneakyThrows - @GetMapping("/doc") - public void generatorDoc(String dsName, HttpServletResponse response) { - // 设置指定的数据源 - DynamicRoutingDataSource dynamicRoutingDataSource = SpringContextHolder.getBean(DynamicRoutingDataSource.class); - DynamicDataSourceContextHolder.push(dsName); - DataSource dataSource = dynamicRoutingDataSource.determineDataSource(); + /** + * 查询数据源对应的文档 + * + * @param dsName 数据源名称 + */ + @SneakyThrows + @GetMapping("/doc") + public void generatorDoc(String dsName, HttpServletResponse response) { + // 设置指定的数据源 + DynamicRoutingDataSource dynamicRoutingDataSource = SpringContextHolder.getBean(DynamicRoutingDataSource.class); + DynamicDataSourceContextHolder.push(dsName); + DataSource dataSource = dynamicRoutingDataSource.determineDataSource(); - // 设置指定的目标表 - ScrewProperties screwProperties = SpringContextHolder.getBean(ScrewProperties.class); + // 设置指定的目标表 + ScrewProperties screwProperties = SpringContextHolder.getBean(ScrewProperties.class); - // 生成 - byte[] data = screw.documentGeneration(dataSource, screwProperties).toByteArray(); - response.reset(); - response.addHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(data.length)); - response.setContentType(ContentType.OCTET_STREAM.getValue()); - IoUtil.write(response.getOutputStream(), Boolean.TRUE, data); - } + // 生成 + byte[] data = screw.documentGeneration(dsName, dataSource, screwProperties).toByteArray(); + response.reset(); + response.addHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(data.length)); + response.setContentType(ContentType.OCTET_STREAM.getValue()); + IoUtil.write(response.getOutputStream(), Boolean.FALSE, data); + } }