diff --git a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/controller/GenTableController.java b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/controller/GenTableController.java index 311832018..808fb5aaf 100644 --- a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/controller/GenTableController.java +++ b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/controller/GenTableController.java @@ -25,7 +25,6 @@ import com.pig4cloud.pigx.codegen.service.GenTableColumnService; import com.pig4cloud.pigx.codegen.service.GenTableService; import com.pig4cloud.pigx.common.core.util.R; import com.pig4cloud.pigx.common.excel.annotation.ResponseExcel; -import com.pig4cloud.pigx.common.log.annotation.SysLog; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tag; @@ -48,129 +47,101 @@ import java.util.List; @SecurityRequirement(name = HttpHeaders.AUTHORIZATION) public class GenTableController { - private final GenTableColumnService tableColumnService; + private final GenTableColumnService tableColumnService; - private final GenTableService tableService; + private final GenTableService tableService; - /** - * 分页查询 - * @param page 分页对象 - * @param table 列属性 - * @return - */ - @Operation(summary = "分页查询", description = "分页查询") - @GetMapping("/page") - public R getTablePage(Page page, GenTable table) { + /** + * 分页查询 + * + * @param page 分页对象 + * @param table 列属性 + * @return + */ + @Operation(summary = "分页查询", description = "分页查询") + @GetMapping("/page") + public R getTablePage(Page page, GenTable table) { + return R.ok(tableService.queryTablePage(page, table)); + } - return R.ok(tableService.list(page, table)); - } + /** + * 通过id查询表信息(代码生成设置 + 表 + 字段设置) + * + * @param id id + * @return R + */ + @Operation(summary = "通过id查询", description = "通过id查询") + @GetMapping("/{id}") + public R getTable(@PathVariable("id") Long id) { + return R.ok(tableService.getById(id)); + } - /** - * 通过id查询列属性 - * @param id id - * @return R - */ - @Operation(summary = "通过id查询", description = "通过id查询") - @GetMapping("/{id}") - public R getById(@PathVariable("id") Long id) { - return R.ok(tableService.getById(id)); - } + /** + * 获取表信息 + * + * @param dsName 数据源 + * @param tableName 表名称 + */ + @GetMapping("/{dsName}/{tableName}") + public R getTable(@PathVariable("dsName") String dsName, @PathVariable String tableName) { + return R.ok(tableService.queryOrBuildTable(dsName, tableName)); + } - /** - * 新增列属性 - * @param table 列属性 - * @return R - */ - @Operation(summary = "新增列属性", description = "新增列属性") - @SysLog("新增列属性") - @PostMapping - public R save(@RequestBody GenTable table) { - return R.ok(tableService.save(table)); - } + /** + * 查询表DDL语句 + * + * @param dsName 数据源 + * @param tableName 表名称 + */ + @GetMapping("/column/{dsName}/{tableName}") + public R getDdl(@PathVariable("dsName") String dsName, @PathVariable String tableName) throws Exception { + return R.ok(tableService.queryTableDdl(dsName, tableName)); + } - /** - * 修改列属性 - * @param table 列属性 - * @return R - */ - @Operation(summary = "修改列属性", description = "修改列属性") - @SysLog("修改列属性") - @PutMapping - public R updateById(@RequestBody GenTable table) { - return R.ok(tableService.updateById(table)); - } - /** - * 通过id删除列属性 - * @param id id - * @return R - */ - @Operation(summary = "通过id删除列属性", description = "通过id删除列属性") - @SysLog("通过id删除列属性") - @DeleteMapping("/{id}") - public R removeById(@PathVariable Long id) { - return R.ok(tableService.removeById(id)); - } + /** + * 同步表信息 + * + * @param dsName 数据源 + * @param tableName 表名称 + */ + @GetMapping("/sync/{dsName}/{tableName}") + public R syncTable(@PathVariable("dsName") String dsName, @PathVariable String tableName) { + // 表配置删除 + tableService.remove( + Wrappers.lambdaQuery().eq(GenTable::getDsName, dsName).eq(GenTable::getTableName, tableName)); + // 字段配置删除 + tableColumnService.remove(Wrappers.lambdaQuery() + .eq(GenTableColumnEntity::getDsName, dsName) + .eq(GenTableColumnEntity::getTableName, tableName)); + return R.ok(tableService.queryOrBuildTable(dsName, tableName)); + } - /** - * 导出excel 表格 - * @param table 查询条件 - * @return excel 文件流 - */ - @ResponseExcel - @GetMapping("/export") - public List export(GenTable table) { - return tableService.list(Wrappers.query(table)); - } + /** + * 修改表字段数据 + * + * @param dsName 数据源 + * @param tableName 表名称 + * @param tableFieldList 字段列表 + */ + @PutMapping("/field/{dsName}/{tableName}") + public R updateTableField(@PathVariable("dsName") String dsName, @PathVariable String tableName, + @RequestBody List tableFieldList) { + tableColumnService.updateTableField(dsName, tableName, tableFieldList); + return R.ok(); + } - @GetMapping("/list/{dsName}") - public R listTable(@PathVariable("dsName") String dsName) { - return R.ok(tableService.queryDsAllTable(dsName)); - } + /** + * 导出excel 表格 + * + * @param table 查询条件 + * @return excel 文件流 + */ + @ResponseExcel + @GetMapping("/export") + public List export(GenTable table) { + return tableService.list(Wrappers.query(table)); + } - @GetMapping("/column/{dsName}/{tableName}") - public R column(@PathVariable("dsName") String dsName, @PathVariable String tableName) { - return R.ok(tableService.queryColumn(dsName, tableName)); - } - - /** - * 获取表信息 - * @param dsName 数据源 - * @param tableName 表名称 - */ - @GetMapping("/{dsName}/{tableName}") - public R info(@PathVariable("dsName") String dsName, @PathVariable String tableName) { - return R.ok(tableService.queryOrBuildTable(dsName, tableName)); - } - - /** - * 同步表信息 - * @param dsName 数据源 - * @param tableName 表名称 - */ - @GetMapping("/sync/{dsName}/{tableName}") - public R sync(@PathVariable("dsName") String dsName, @PathVariable String tableName) { - // 表配置删除 - tableService.remove( - Wrappers.lambdaQuery().eq(GenTable::getDsName, dsName).eq(GenTable::getTableName, tableName)); - // 字段配置删除 - tableColumnService.remove(Wrappers.lambdaQuery() - .eq(GenTableColumnEntity::getDsName, dsName) - .eq(GenTableColumnEntity::getTableName, tableName)); - return R.ok(tableService.queryOrBuildTable(dsName, tableName)); - } - - /** - * 修改表字段数据 - * @param dsName 数据源 - * @param tableName 表名称 - * @param tableFieldList 字段列表 - */ - @PutMapping("/field/{dsName}/{tableName}") - public R updateTableField(@PathVariable("dsName") String dsName, @PathVariable String tableName, - @RequestBody List tableFieldList) { - tableColumnService.updateTableField(dsName, tableName, tableFieldList); - return R.ok(); - } } diff --git a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/mapper/GeneratorDB2Mapper.java b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/mapper/GeneratorDB2Mapper.java deleted file mode 100755 index 3fb3473a7..000000000 --- a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/mapper/GeneratorDB2Mapper.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - */ - -package com.pig4cloud.pigx.codegen.mapper; - -import org.apache.ibatis.annotations.Mapper; - -/** - * 支持 db2 代码生成器 - * - * @author lengleng - * @date 2020-12-11 - */ -@Mapper -public interface GeneratorDB2Mapper extends GeneratorMapper { - -} diff --git a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/mapper/GeneratorDmMapper.java b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/mapper/GeneratorDmMapper.java deleted file mode 100755 index 518d9fb32..000000000 --- a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/mapper/GeneratorDmMapper.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - */ - -package com.pig4cloud.pigx.codegen.mapper; - -import org.apache.ibatis.annotations.Mapper; - -/** - * 支持 达梦 代码生成器 - * - * @author lengleng - * @date 2022-03-24 - */ -@Mapper -public interface GeneratorDmMapper extends GeneratorMapper { - -} diff --git a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/mapper/GeneratorHighGoMapper.java b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/mapper/GeneratorHighGoMapper.java deleted file mode 100755 index a94b154d0..000000000 --- a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/mapper/GeneratorHighGoMapper.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - */ - -package com.pig4cloud.pigx.codegen.mapper; - -import org.apache.ibatis.annotations.Mapper; - -/** - * 支持 瀚高数据库 代码生成器 - * - * @author lengleng - * @date 2023-04-26 - */ -@Mapper -public interface GeneratorHighGoMapper extends GeneratorMapper { - -} diff --git a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/mapper/GeneratorMapper.java b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/mapper/GeneratorMapper.java deleted file mode 100755 index 0c687d83c..000000000 --- a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/mapper/GeneratorMapper.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - */ - -package com.pig4cloud.pigx.codegen.mapper; - -import com.baomidou.dynamic.datasource.annotation.DS; -import com.baomidou.mybatisplus.annotation.InterceptorIgnore; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.pig4cloud.pigx.codegen.entity.ColumnEntity; -import com.pig4cloud.pigx.common.data.datascope.PigxBaseMapper; -import org.apache.ibatis.annotations.Param; - -import java.util.List; -import java.util.Map; - -/** - * 代码生成器 - * - * @author lengleng - * @date 2018-07-30 - */ -public interface GeneratorMapper extends PigxBaseMapper { - - /** - * 查询全部的表 - * @return - */ - @InterceptorIgnore(tenantLine = "true") - List> queryTable(); - - /** - * 分页查询表格 - * @param page 分页信息 - * @param tableName 表名称 - * @return - */ - @InterceptorIgnore(tenantLine = "true") - IPage> queryTable(Page page, @Param("tableName") String tableName); - - /** - * 查询表信息 - * @param tableName 表名称 - * @param dsName 数据源名称 - * @return - */ - @DS("#last") - @InterceptorIgnore(tenantLine = "true") - Map queryTable(@Param("tableName") String tableName, String dsName); - - /** - * 分页查询表分页信息 - * @param page - * @param tableName - * @param dsName - * @return - */ - @DS("#last") - @InterceptorIgnore(tenantLine = "true") - IPage selectTableColumn(Page page, @Param("tableName") String tableName, - @Param("dsName") String dsName); - - /** - * 查询表全部列信息 - * @param tableName - * @param dsName - * @return - */ - @DS("#last") - @InterceptorIgnore(tenantLine = "true") - List selectTableColumn(@Param("tableName") String tableName, @Param("dsName") String dsName); - - /** - * 查询表全部列信息 - * @param tableName 表名称 - * @param dsName 数据源名称 - * @return - */ - @DS("#last") - @InterceptorIgnore(tenantLine = "true") - List> selectMapTableColumn(@Param("tableName") String tableName, String dsName); - -} diff --git a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/mapper/GeneratorMssqlMapper.java b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/mapper/GeneratorMssqlMapper.java deleted file mode 100755 index 6849530bf..000000000 --- a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/mapper/GeneratorMssqlMapper.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - */ - -package com.pig4cloud.pigx.codegen.mapper; - -import org.apache.ibatis.annotations.Mapper; - -/** - * 支持 SQL SERVER 代码生成器 - * - * @author lengleng - * @date 2020-12-11 - */ -@Mapper -public interface GeneratorMssqlMapper extends GeneratorMapper { - -} diff --git a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/mapper/GeneratorMysqlMapper.java b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/mapper/GeneratorMysqlMapper.java deleted file mode 100755 index 512c5b612..000000000 --- a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/mapper/GeneratorMysqlMapper.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - */ - -package com.pig4cloud.pigx.codegen.mapper; - -import org.apache.ibatis.annotations.Mapper; - -/** - * 支持 mysql 代码生成器 - * - * @author lengleng - * @date 2020-12-11 - */ -@Mapper -public interface GeneratorMysqlMapper extends GeneratorMapper { - -} diff --git a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/mapper/GeneratorOracleMapper.java b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/mapper/GeneratorOracleMapper.java deleted file mode 100755 index 4ad521c2b..000000000 --- a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/mapper/GeneratorOracleMapper.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - */ - -package com.pig4cloud.pigx.codegen.mapper; - -import org.apache.ibatis.annotations.Mapper; - -/** - * 支持 Oracle 代码生成器 - * - * @author lengleng - * @date 2020-12-11 - */ -@Mapper -public interface GeneratorOracleMapper extends GeneratorMapper { - -} diff --git a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/mapper/GeneratorPgMapper.java b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/mapper/GeneratorPgMapper.java deleted file mode 100755 index b140f3e00..000000000 --- a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/mapper/GeneratorPgMapper.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - */ - -package com.pig4cloud.pigx.codegen.mapper; - -import org.apache.ibatis.annotations.Mapper; - -/** - * 支持 PostgreSQL 代码生成器 - * - * @author lengleng - * @date 2020-12-11 - */ -@Mapper -public interface GeneratorPgMapper extends GeneratorMapper { - -} diff --git a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/service/GenTableService.java b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/service/GenTableService.java index ac8b3b4ef..604b2cb24 100644 --- a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/service/GenTableService.java +++ b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/service/GenTableService.java @@ -21,8 +21,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; import com.pig4cloud.pigx.codegen.entity.GenTable; +import org.anyline.metadata.Table; -import java.util.List; import java.util.Map; /** @@ -33,19 +33,37 @@ import java.util.Map; */ public interface GenTableService extends IService { - /** - * 获取默认配置信息 - * @param path 配置文件路径 - * @return - */ - Map getGeneratorConfig(); + /** + * 获取默认配置信息 + * + * @return map + */ + Map getGeneratorConfig(); - IPage list(Page page, GenTable table); + /** + * 查询对应数据源的表 + * @param page 分页信息 + * @param table 查询条件 + * @return 表 + */ + IPage queryTablePage(Page page, GenTable table); - GenTable queryOrBuildTable(String dsName, String tableName); + /** + * 查询表信息(列),然后插入到中间表中 + * @param dsName 数据源 + * @param tableName 表名 + * @return GenTable + */ + GenTable queryOrBuildTable(String dsName, String tableName); - List> queryDsAllTable(String dsName); - - List> queryColumn(String dsName, String tableName); + /** + * 查询表ddl 语句 + * + * @param dsName 数据源名称 + * @param tableName 表名称 + * @return ddl 语句 + * @throws Exception + */ + String queryTableDdl(String dsName, String tableName) throws Exception; } diff --git a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/service/impl/GenTableServiceImpl.java b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/service/impl/GenTableServiceImpl.java index 7873771df..75c0f4e57 100644 --- a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/service/impl/GenTableServiceImpl.java +++ b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/service/impl/GenTableServiceImpl.java @@ -16,16 +16,16 @@ */ package com.pig4cloud.pigx.codegen.service.impl; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.io.IoUtil; import cn.hutool.core.io.resource.ClassPathResource; -import cn.hutool.core.map.MapUtil; import cn.hutool.core.text.NamingCase; import cn.hutool.core.util.EnumUtil; +import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder; import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -33,20 +33,22 @@ import com.pig4cloud.pigx.codegen.entity.GenGroupEntity; import com.pig4cloud.pigx.codegen.entity.GenTable; import com.pig4cloud.pigx.codegen.entity.GenTableColumnEntity; import com.pig4cloud.pigx.codegen.mapper.GenTableMapper; -import com.pig4cloud.pigx.codegen.mapper.GeneratorMapper; import com.pig4cloud.pigx.codegen.service.GenGroupService; import com.pig4cloud.pigx.codegen.service.GenTableColumnService; import com.pig4cloud.pigx.codegen.service.GenTableService; import com.pig4cloud.pigx.codegen.util.*; import lombok.RequiredArgsConstructor; +import org.anyline.metadata.Column; +import org.anyline.metadata.Database; +import org.anyline.metadata.Table; +import org.anyline.proxy.ServiceProxy; +import org.anyline.service.AnylineService; +import org.jetbrains.annotations.NotNull; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Objects; +import java.util.*; /** * 列属性 @@ -58,148 +60,179 @@ import java.util.Objects; @RequiredArgsConstructor public class GenTableServiceImpl extends ServiceImpl implements GenTableService { - /** - * 默认配置信息 - */ - private static final String CONFIG_PATH = "template/config.json"; + /** + * 默认配置信息 + */ + private static final String CONFIG_PATH = "template/config.json"; - private final GenTableColumnService columnService; + private final GenTableColumnService columnService; - private final GenGroupService genGroupService; + private final GenGroupService genGroupService; - /** - * 获取配置信息 - * @param path 配置文件路径 - * @return - */ - @Override - public Map getGeneratorConfig() { - ClassPathResource classPathResource = new ClassPathResource(CONFIG_PATH); - JSONObject jsonObject = JSONUtil.parseObj(IoUtil.readUtf8(classPathResource.getStream())); - return jsonObject.getRaw(); - } + /** + * 获取配置信息 + * + * @return map + */ + @Override + public Map getGeneratorConfig() { + ClassPathResource classPathResource = new ClassPathResource(CONFIG_PATH); + JSONObject jsonObject = JSONUtil.parseObj(IoUtil.readUtf8(classPathResource.getStream())); + return jsonObject.getRaw(); + } - @Override - public List> queryDsAllTable(String dsName) { - GeneratorMapper mapper = GenKit.getMapper(dsName); - // 手动切换数据源 - DynamicDataSourceContextHolder.push(dsName); - return mapper.queryTable(); - } + /** + * 查询表ddl 语句 + * + * @param dsName 数据源名称 + * @param tableName 表名称 + * @return ddl 语句 + * @throws Exception + */ + @Override + public String queryTableDdl(String dsName, String tableName) throws Exception { + // 手动切换数据源 + DynamicDataSourceContextHolder.push(dsName); + Table table = ServiceProxy.metadata().table(tableName); // 获取表结构 + table.execute(false);// 不执行SQL + ServiceProxy.ddl().create(table); + return table.getDdl();// 返回创建表的DDL + } - @Override - public List> queryColumn(String dsName, String tableName) { - GeneratorMapper mapper = GenKit.getMapper(dsName); - return mapper.selectMapTableColumn(tableName, dsName); - } + /** + * 查询对应数据源的表 + * + * @param page 分页信息 + * @param table 查询条件 + * @return 表 + */ + @Override + public IPage queryTablePage(Page
page, GenTable table) { + // 手动切换数据源 + DynamicDataSourceContextHolder.push(table.getDsName()); + List
tableList = ServiceProxy.metadata().tables().values().stream() + .filter(t -> StrUtil.containsIgnoreCase(t.getTableName(), table.getTableName())).toList(); - @Override - public IPage list(Page page, GenTable table) { - GeneratorMapper mapper = GenKit.getMapper(table.getDsName()); - // 手动切换数据源 - DynamicDataSourceContextHolder.push(table.getDsName()); - return mapper.queryTable(page, table.getTableName()); - } + // 根据 page 进行分页 + List
records = CollUtil.page((int) page.getCurrent() - 1, (int) page.getSize(), tableList); + page.setTotal(tableList.size()); + page.setRecords(records); + return page; + } - /** - * 获取表信息 - * @param dsName - * @param tableName - * @return - */ - @Override - public GenTable queryOrBuildTable(String dsName, String tableName) { - GenTable genTable = baseMapper.selectOne( - Wrappers.lambdaQuery().eq(GenTable::getTableName, tableName).eq(GenTable::getDsName, dsName)); - // 如果 genTable 为空, 执行导入 - if (Objects.isNull(genTable)) { - genTable = this.tableImport(dsName, tableName); - } + /** + * 查询表信息(列),然后插入到中间表中 + * + * @param dsName 数据源 + * @param tableName 表名 + * @return GenTable + */ + @Override + public GenTable queryOrBuildTable(String dsName, String tableName) { + GenTable genTable = baseMapper.selectOne( + Wrappers.lambdaQuery().eq(GenTable::getTableName, tableName).eq(GenTable::getDsName, dsName)); + // 如果 genTable 为空, 执行导入 + if (Objects.isNull(genTable)) { + genTable = this.tableImport(dsName, tableName); + } - List fieldList = columnService.list(Wrappers.lambdaQuery() - .eq(GenTableColumnEntity::getDsName, dsName) - .eq(GenTableColumnEntity::getTableName, tableName) - .orderByAsc(GenTableColumnEntity::getSort)); - genTable.setFieldList(fieldList); + List fieldList = columnService.list(Wrappers.lambdaQuery() + .eq(GenTableColumnEntity::getDsName, dsName) + .eq(GenTableColumnEntity::getTableName, tableName) + .orderByAsc(GenTableColumnEntity::getSort)); + genTable.setFieldList(fieldList); - // 查询模板分组信息 - List groupEntities = genGroupService.list(); - genTable.setGroupList(groupEntities); - return genTable; - } + // 查询模板分组信息 + List groupEntities = genGroupService.list(); + genTable.setGroupList(groupEntities); + return genTable; + } - @Transactional(rollbackFor = Exception.class) - public GenTable tableImport(String dsName, String tableName) { - GeneratorMapper mapper = GenKit.getMapper(dsName); - // 手动切换数据源 - DynamicDataSourceContextHolder.push(dsName); + @Transactional(rollbackFor = Exception.class) + protected GenTable tableImport(String dsName, String tableName) { + // 手动切换数据源 + DynamicDataSourceContextHolder.push(dsName); - // 查询表是否存在 - GenTable table = new GenTable(); + // 查询表是否存在 + GenTable table = new GenTable(); + // 从数据库获取表信息 + AnylineService service = ServiceProxy.service(); + Table tableMetadata = service.metadata().table(tableName); + Database database = service.metadata().database(); + // 获取默认表配置信息 () + Map generatorConfig = getGeneratorConfig(); - // 从数据库获取表信息 - Map queryTable = mapper.queryTable(tableName, dsName); + JSONObject project = (JSONObject) generatorConfig.get("project"); + JSONObject developer = (JSONObject) generatorConfig.get("developer"); - // 获取默认表配置信息 () - Map generatorConfig = getGeneratorConfig(); + table.setPackageName(project.getStr("packageName")); + table.setVersion(project.getStr("version")); + table.setBackendPath(project.getStr("backendPath")); + table.setFrontendPath(project.getStr("frontendPath")); + table.setAuthor(developer.getStr("author")); + table.setEmail(developer.getStr("email")); + table.setTableName(tableName); + table.setDsName(dsName); + table.setTableComment(tableMetadata.getComment()); - JSONObject project = (JSONObject) generatorConfig.get("project"); - JSONObject developer = (JSONObject) generatorConfig.get("developer"); + table.setDbType(database.getDatabase().title()); + table.setFormLayout(FormLayoutEnum.TWO.getValue()); + table.setGeneratorType(GeneratorTypeEnum.ZIP_DOWNLOAD.getValue()); + table.setClassName(NamingCase.toPascalCase(tableName)); + table.setModuleName(GenKit.getModuleName(table.getPackageName())); + table.setFunctionName(GenKit.getFunctionName(tableName)); + table.setCreateTime(LocalDateTime.now()); - table.setPackageName(project.getStr("packageName")); - table.setVersion(project.getStr("version")); - table.setBackendPath(project.getStr("backendPath")); - table.setFrontendPath(project.getStr("frontendPath")); - table.setAuthor(developer.getStr("author")); - table.setEmail(developer.getStr("email")); - table.setTableName(tableName); - table.setDsName(dsName); - table.setTableComment(MapUtil.getStr(queryTable, "tableComment")); - table.setDbType(MapUtil.getStr(queryTable, "dbType")); - table.setFormLayout(FormLayoutEnum.TWO.getValue()); - table.setGeneratorType(GeneratorTypeEnum.ZIP_DOWNLOAD.getValue()); - table.setClassName(NamingCase.toPascalCase(tableName)); - table.setModuleName(GenKit.getModuleName(table.getPackageName())); - table.setFunctionName(GenKit.getFunctionName(tableName)); - table.setCreateTime(LocalDateTime.now()); - this.save(table); + // 使用默认数据源 + DynamicDataSourceContextHolder.clear(); + this.save(table); - // 获取原生字段数据 - List> queryColumnList = mapper.selectMapTableColumn(tableName, dsName); - List tableFieldList = new ArrayList<>(); + // 获取原生字段数据 + List tableFieldList = getGenTableColumnEntities(dsName, tableName, tableMetadata); - for (Map columnMap : queryColumnList) { - String columnName = MapUtil.getStr(columnMap, "columnName"); - GenTableColumnEntity genTableColumnEntity = new GenTableColumnEntity(); - genTableColumnEntity.setTableName(tableName); - genTableColumnEntity.setDsName(dsName); - genTableColumnEntity.setFieldName(MapUtil.getStr(columnMap, "columnName")); - genTableColumnEntity.setFieldComment(MapUtil.getStr(columnMap, "comments")); - genTableColumnEntity.setFieldType(MapUtil.getStr(columnMap, "dataType")); - String columnKey = MapUtil.getStr(columnMap, "columnKey"); - genTableColumnEntity.setPrimaryPk((StringUtils.isNotBlank(columnKey) && "PRI".equalsIgnoreCase(columnKey)) - ? BoolFillEnum.TRUE.getValue() : BoolFillEnum.FALSE.getValue()); - genTableColumnEntity.setAutoFill(AutoFillEnum.DEFAULT.name()); - genTableColumnEntity.setFormItem(BoolFillEnum.TRUE.getValue()); - genTableColumnEntity.setGridItem(BoolFillEnum.TRUE.getValue()); + // 初始化字段数据 + columnService.initFieldList(tableFieldList); + // 保存列数据 + columnService.saveOrUpdateBatch(tableFieldList); - // 审计字段处理 - if (EnumUtil.contains(CommonColumnFiledEnum.class, columnName)) { - CommonColumnFiledEnum commonColumnFiledEnum = CommonColumnFiledEnum.valueOf(columnName); - genTableColumnEntity.setFormItem(commonColumnFiledEnum.getFormItem()); - genTableColumnEntity.setGridItem(commonColumnFiledEnum.getGridItem()); - genTableColumnEntity.setAutoFill(commonColumnFiledEnum.getAutoFill()); - genTableColumnEntity.setSort(commonColumnFiledEnum.getSort()); - } - tableFieldList.add(genTableColumnEntity); - } - // 初始化字段数据 - columnService.initFieldList(tableFieldList); - // 保存列数据 - columnService.saveOrUpdateBatch(tableFieldList); + table.setFieldList(tableFieldList); + return table; + } - table.setFieldList(tableFieldList); - return table; - } + /** + * 获取表字段信息 + * + * @param dsName 数据源信息 + * @param tableName 表名称 + * @param tableMetadata 表的元数据 + * @return list + */ + private static @NotNull List getGenTableColumnEntities(String dsName, String tableName, Table tableMetadata) { + List tableFieldList = new ArrayList<>(); + LinkedHashMap columns = tableMetadata.getColumns(); + columns.forEach((columnName, column) -> { + GenTableColumnEntity genTableColumnEntity = new GenTableColumnEntity(); + genTableColumnEntity.setTableName(tableName); + genTableColumnEntity.setDsName(dsName); + genTableColumnEntity.setFieldName(column.getName()); + genTableColumnEntity.setFieldComment(column.getComment()); + genTableColumnEntity.setFieldType(column.getTypeName()); + genTableColumnEntity.setPrimaryPk(column.isPrimaryKey() == 1 ? BoolFillEnum.TRUE.getValue() : BoolFillEnum.FALSE.getValue()); + genTableColumnEntity.setAutoFill(AutoFillEnum.DEFAULT.name()); + genTableColumnEntity.setFormItem(BoolFillEnum.TRUE.getValue()); + genTableColumnEntity.setGridItem(BoolFillEnum.TRUE.getValue()); + + // 审计字段处理 + if (EnumUtil.contains(CommonColumnFiledEnum.class, column.getName())) { + CommonColumnFiledEnum commonColumnFiledEnum = CommonColumnFiledEnum.valueOf(column.getName()); + genTableColumnEntity.setFormItem(commonColumnFiledEnum.getFormItem()); + genTableColumnEntity.setGridItem(commonColumnFiledEnum.getGridItem()); + genTableColumnEntity.setAutoFill(commonColumnFiledEnum.getAutoFill()); + genTableColumnEntity.setSort(commonColumnFiledEnum.getSort()); + } + tableFieldList.add(genTableColumnEntity); + }); + return tableFieldList; + } } diff --git a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/util/GenKit.java b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/util/GenKit.java index a2de9b3bd..69d1876bd 100644 --- a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/util/GenKit.java +++ b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/util/GenKit.java @@ -1,18 +1,7 @@ package com.pig4cloud.pigx.codegen.util; import cn.hutool.core.util.StrUtil; -import com.baomidou.mybatisplus.annotation.DbType; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.baomidou.mybatisplus.extension.toolkit.JdbcUtils; -import com.pig4cloud.pigx.codegen.entity.GenDatasourceConf; -import com.pig4cloud.pigx.codegen.mapper.GenDatasourceConfMapper; -import com.pig4cloud.pigx.codegen.mapper.GeneratorMapper; -import com.pig4cloud.pigx.common.core.util.SpringContextHolder; -import com.pig4cloud.pigx.common.datasource.config.DruidDataSourceProperties; import lombok.experimental.UtilityClass; -import org.springframework.context.ApplicationContext; - -import java.util.Map; /** * 代码生成工具类 @@ -23,59 +12,25 @@ import java.util.Map; @UtilityClass public class GenKit { - /** - * 获取功能名 sys_a_b sysAb - * @param tableName 表名 - * @return 功能名 - */ - public String getFunctionName(String tableName) { - return StrUtil.toCamelCase(tableName); - } + /** + * 获取功能名 sys_a_b sysAb + * + * @param tableName 表名 + * @return 功能名 + */ + public String getFunctionName(String tableName) { + return StrUtil.toCamelCase(tableName); + } - /** - * 获取模块名称 - * @param packageName 包名 - * @return 功能名 - */ - public String getModuleName(String packageName) { - return StrUtil.subAfter(packageName, ".", true); - } + /** + * 获取模块名称 + * + * @param packageName 包名 + * @return 功能名 + */ + public String getModuleName(String packageName) { + return StrUtil.subAfter(packageName, ".", true); + } - /** - * 获取数据源对应方言的mapper - * @param dsName 数据源名称 - * @return GeneratorMapper - */ - public GeneratorMapper getMapper(String dsName) { - // 获取目标数据源数据库类型 - GenDatasourceConfMapper datasourceConfMapper = SpringContextHolder.getBean(GenDatasourceConfMapper.class); - GenDatasourceConf datasourceConf = datasourceConfMapper - .selectOne(Wrappers.lambdaQuery().eq(GenDatasourceConf::getName, dsName)); - - String dbConfType; - // 为空 根据jdbc-url推断数据库类型 - if (datasourceConf == null) { - DruidDataSourceProperties dataSourceProperties = SpringContextHolder - .getBean(DruidDataSourceProperties.class); - DbType dbType = JdbcUtils.getDbType(dataSourceProperties.getUrl()); - dbConfType = dbType.getDb(); - } - else { - dbConfType = datasourceConf.getDsType(); - } - - // 获取全部数据实现 - ApplicationContext context = SpringContextHolder.getApplicationContext(); - Map beansOfType = context.getBeansOfType(GeneratorMapper.class); - - // 根据数据类型选择mapper - for (String key : beansOfType.keySet()) { - if (StrUtil.containsIgnoreCase(key, dbConfType)) { - return beansOfType.get(key); - } - } - - throw new IllegalArgumentException("dsName 不合法: " + dsName); - } } diff --git a/pigx-visual/pigx-codegen/src/main/resources/mapper/GeneratorDB2Mapper.xml b/pigx-visual/pigx-codegen/src/main/resources/mapper/GeneratorDB2Mapper.xml deleted file mode 100755 index 51d54cab8..000000000 --- a/pigx-visual/pigx-codegen/src/main/resources/mapper/GeneratorDB2Mapper.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - SELECT 'db2' AS "dbType", - COLNAME AS "columnName", - TYPENAME AS "dataType", - REMARKS AS "comments", - TYPENAME AS "columnType" - FROM SYSCAT.COLUMNS - WHERE TABSCHEMA = (SELECT CURRENT_SCHEMA - FROM SYSIBM.SYSDUMMY1 - ) - and TABNAME = #{tableName} - - - - - - - diff --git a/pigx-visual/pigx-codegen/src/main/resources/mapper/GeneratorDmMapper.xml b/pigx-visual/pigx-codegen/src/main/resources/mapper/GeneratorDmMapper.xml deleted file mode 100755 index 0b06e793e..000000000 --- a/pigx-visual/pigx-codegen/src/main/resources/mapper/GeneratorDmMapper.xml +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - - SELECT - 'dm' AS "dbType", - TEMP.COLUMN_NAME AS "columnName", - TEMP.data_type AS "columnType", - TEMP.data_type AS "dataType", - TEMP.comments AS "comments", - CASE - TEMP.constraint_type - WHEN 'P' THEN - 'PRI' - WHEN 'C' THEN - 'UNI' ELSE'' - END "columnKey" - FROM - ( - SELECT - col.column_id, - col.COLUMN_NAME, - col.data_type, - colc.comments, - uc.constraint_type, - ROW_NUMBER ( ) OVER ( - PARTITION BY col.COLUMN_NAME - ORDER BY - uc.constraint_type DESC - ) AS row_flg - FROM - user_tab_columns col - LEFT JOIN user_col_comments colc ON colc.TABLE_NAME = col.TABLE_NAME - AND colc.COLUMN_NAME = col. - COLUMN_NAME LEFT JOIN user_cons_columns ucc ON ucc.TABLE_NAME = col.TABLE_NAME - AND ucc.COLUMN_NAME = col. - COLUMN_NAME LEFT JOIN user_constraints uc ON uc.CONSTRAINT_NAME = ucc.CONSTRAINT_NAME - WHERE - col.TABLE_NAME = #{tableName} - ) TEMP - WHERE - TEMP.row_flg = 1 - ORDER BY - TEMP.column_id - - - - - - - diff --git a/pigx-visual/pigx-codegen/src/main/resources/mapper/GeneratorHighGoMapper.xml b/pigx-visual/pigx-codegen/src/main/resources/mapper/GeneratorHighGoMapper.xml deleted file mode 100755 index 95f9321db..000000000 --- a/pigx-visual/pigx-codegen/src/main/resources/mapper/GeneratorHighGoMapper.xml +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - - - SELECT - 'highgo' AS "dbType", - pa.attname AS "columnName", - pg_type.typname AS "columnType", - pg_type.typname AS "dataType", - col_description ( pa.attrelid, pa.attnum ) AS "comments", - ( - CASE - pcon.contype - WHEN 'p' THEN - 'PRI' ELSE'' - END - ) AS "columnKey" - FROM - pg_class AS pc, - pg_attribute AS pa - INNER JOIN pg_type ON pg_type.oid = pa.atttypid - LEFT JOIN pg_constraint pcon ON pa.attnum = pcon.conkey[1] - AND pa.attrelid = pcon.conrelid - WHERE - pc.relname = #{ tableName } - AND pa.attrelid = pc.oid - AND pa.attnum > 0 - - - - - - diff --git a/pigx-visual/pigx-codegen/src/main/resources/mapper/GeneratorMssqlMapper.xml b/pigx-visual/pigx-codegen/src/main/resources/mapper/GeneratorMssqlMapper.xml deleted file mode 100755 index 3e3b6ed10..000000000 --- a/pigx-visual/pigx-codegen/src/main/resources/mapper/GeneratorMssqlMapper.xml +++ /dev/null @@ -1,86 +0,0 @@ - - - - - - - - - SELECT - 'mssql' AS dbType, - CAST ( b.NAME AS NVARCHAR ( 500 ) ) AS columnName, - CAST ( sys.types.NAME AS NVARCHAR ( 500 ) ) AS dataType, - CAST ( sys.types.NAME AS NVARCHAR ( 500 ) ) AS columnType, - CAST ( c.VALUE AS NVARCHAR ( 500 ) ) AS comments, - ( - SELECT - CASE - COUNT - ( 1 ) - WHEN 1 THEN - 'PRI' ELSE '' - END - FROM - syscolumns, - sysobjects, - sysindexes, - sysindexkeys, - systypes - WHERE - syscolumns.xusertype = systypes.xusertype - AND syscolumns.id = object_id( A.NAME ) - AND sysobjects.xtype = 'PK' - AND sysobjects.parent_obj = syscolumns.id - AND sysindexes.id = syscolumns.id - AND sysobjects.NAME = sysindexes.NAME - AND sysindexkeys.id = syscolumns.id - AND sysindexkeys.indid = sysindexes.indid - AND syscolumns.colid = sysindexkeys.colid - AND syscolumns.NAME = B.NAME - ) AS columnKey, - '' AS extra - FROM - ( - SELECT - name, - object_id - FROM - sys.tables UNION ALL - SELECT - name, - object_id - FROM - sys.views - ) a - INNER JOIN sys.COLUMNS b ON b.object_id = a.object_id - LEFT JOIN sys.types ON b.user_type_id = sys.types.user_type_id - LEFT JOIN sys.extended_properties c ON c.major_id = b.object_id - AND c.minor_id = b.column_id - WHERE a.NAME = #{tableName} and sys.types.NAME != 'sysname' - - - - - - - diff --git a/pigx-visual/pigx-codegen/src/main/resources/mapper/GeneratorMySqlMapper.xml b/pigx-visual/pigx-codegen/src/main/resources/mapper/GeneratorMySqlMapper.xml deleted file mode 100755 index 832acb45c..000000000 --- a/pigx-visual/pigx-codegen/src/main/resources/mapper/GeneratorMySqlMapper.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - SELECT - column_name columnName, - data_type dataType, - column_comment comments, - column_key columnKey, - extra, - is_nullable AS isNullable, - column_type AS columnType - FROM - information_schema.COLUMNS - WHERE - table_name = #{tableName} and table_schema = (select database()) order by ordinal_position - - - - - - - diff --git a/pigx-visual/pigx-codegen/src/main/resources/mapper/GeneratorOracleMapper.xml b/pigx-visual/pigx-codegen/src/main/resources/mapper/GeneratorOracleMapper.xml deleted file mode 100755 index 8489707e4..000000000 --- a/pigx-visual/pigx-codegen/src/main/resources/mapper/GeneratorOracleMapper.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - - - SELECT - 'oracle' AS "dbType", - TEMP.COLUMN_NAME AS "columnName", - TEMP.data_type AS "columnType", - TEMP.data_type AS "dataType", - TEMP.comments AS "comments", - CASE - TEMP.constraint_type - WHEN 'P' THEN - 'PRI' - WHEN 'C' THEN - 'UNI' ELSE'' - END "columnKey" - FROM - ( - SELECT - col.column_id, - col.COLUMN_NAME, - col.data_type, - colc.comments, - uc.constraint_type, - ROW_NUMBER ( ) OVER ( - PARTITION BY col.COLUMN_NAME - ORDER BY - uc.constraint_type DESC - ) AS row_flg - FROM - user_tab_columns col - LEFT JOIN user_col_comments colc ON colc.TABLE_NAME = col.TABLE_NAME - AND colc.COLUMN_NAME = col. - COLUMN_NAME LEFT JOIN user_cons_columns ucc ON ucc.TABLE_NAME = col.TABLE_NAME - AND ucc.COLUMN_NAME = col. - COLUMN_NAME LEFT JOIN user_constraints uc ON uc.CONSTRAINT_NAME = ucc.CONSTRAINT_NAME - WHERE - col.TABLE_NAME = #{tableName} - ) TEMP - WHERE - TEMP.row_flg = 1 - ORDER BY - TEMP.column_id - - - - - - - diff --git a/pigx-visual/pigx-codegen/src/main/resources/mapper/GeneratorPgMapper.xml b/pigx-visual/pigx-codegen/src/main/resources/mapper/GeneratorPgMapper.xml deleted file mode 100755 index 20c8c0b7b..000000000 --- a/pigx-visual/pigx-codegen/src/main/resources/mapper/GeneratorPgMapper.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - - SELECT - 'pg' AS "dbType", - pa.attname AS "columnName", - pg_type.typname AS "columnType", - pg_type.typname AS "dataType", - col_description ( pa.attrelid, pa.attnum ) AS "comments", - ( - CASE - pcon.contype - WHEN 'p' THEN - 'PRI' ELSE'' - END - ) AS "columnKey" - FROM - pg_class AS pc, - pg_attribute AS pa - INNER JOIN pg_type ON pg_type.oid = pa.atttypid - LEFT JOIN pg_constraint pcon ON pa.attnum = pcon.conkey[1] - AND pa.attrelid = pcon.conrelid - WHERE - pc.relname = #{ tableName } - AND pa.attrelid = pc.oid - AND pa.attnum > 0 - - - - - -