use of com.xhuicloud.generator.handle.JdbcHandle in project XHuiCloud by sindaZeng.
the class GenCodeController method generator.
/**
* 代码生成
* 数据库名 需要生成的表名。必须严格传入此库拥有的表
*/
@SneakyThrows
@PostMapping
@PreAuthorize("@authorize.hasPermission('sys_download_code')")
public void generator(@RequestParam Integer dataSourceId, @Valid @RequestBody GenCodeDto genCodeDto, HttpServletResponse response) {
GenDsInfo genDsInfo = genDsInfoService.getById(dataSourceId);
JdbcHandle jdbcHandle = handle.get(genDsInfo.getType());
if (ObjectUtil.isNotNull(jdbcHandle) && jdbcHandle.test(genDsInfo)) {
DynamicDataSourceContextHolder.push(genDsInfo.getName());
byte[] data = jdbcHandle.genCode(genCodeDto);
response.reset();
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, String.format("attachment; filename=%s.zip", genCodeDto.getModuleName()));
response.addHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(data.length));
response.setContentType("application/octet-stream; charset=UTF-8");
IoUtil.write(response.getOutputStream(), Boolean.TRUE, data);
DynamicDataSourceContextHolder.clear();
}
}
use of com.xhuicloud.generator.handle.JdbcHandle in project XHuiCloud by sindaZeng.
the class GenDatasourceInfoController method save.
/**
* 保存
* <p>
* TODO 后面入参需要加密
*/
@PostMapping
public // @PreAuthorize("@authorize.hasPermission('sys_add_dataSource')")
Response save(@RequestBody GenDsInfo genDsInfo) throws Exception {
// 构建前端对应解密AES 因子
genDsInfo.setPassword(AesUtil.decrypt(genDsInfo.getPassword()));
genDsInfo.setUsername(AesUtil.decrypt(genDsInfo.getUsername()));
JdbcHandle jdbcHandle = handle.get(genDsInfo.getType());
if (jdbcHandle.test(genDsInfo)) {
genDsInfoService.save(genDsInfo);
genDsInfoService.addDynamicDataSource(genDsInfo);
return Response.success();
}
return Response.failed();
}
use of com.xhuicloud.generator.handle.JdbcHandle in project XHuiCloud by sindaZeng.
the class GenDatasourceInfoController method getTableInfoById.
/**
* 分页查询数据源的表信息
*
* @param id 数据源
* @return
*/
@GetMapping("/{id}")
public Response getTableInfoById(Page page, @PathVariable Integer id) {
GenDsInfo genDsInfo = genDsInfoService.getById(id);
JdbcHandle jdbcHandle = handle.get(genDsInfo.getType());
jdbcHandle.test(genDsInfo);
return Response.success(jdbcHandle.getPageTableInfo(page));
}
Aggregations