mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-12 21:49:01 +08:00
refactor(codegen): 重构codegen 使用anyline 实现数据库创表抽象
This commit is contained in:
1 parent
9540050f63
commit
4e8fff59ab
61 files changed
+1696
-1689
No files matched your search
@@ -1,25 +0,0 @@
|
||||
# 数据源
|
||||
spring:
|
||||
redis:
|
||||
host: pigx-redis
|
||||
database: 9 #避免和微服务 PIGX 冲突
|
||||
datasource:
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
druid:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
username: root
|
||||
password: root
|
||||
url: jdbc:mysql://pigx-mysql:3306/pigxx_boot_codegen?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true&allowPublicKeyRetrieval=true
|
||||
web:
|
||||
resources:
|
||||
static-locations: classpath:/static/,classpath:/views/
|
||||
|
||||
# 租户表维护
|
||||
pigx:
|
||||
tenant:
|
||||
column: tenant_id
|
||||
tables:
|
||||
- gen_datasource_conf
|
||||
- gen_form_conf
|
||||
- gen_template
|
||||
- gen_group
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
<mapper namespace="com.pig4cloud.pigx.codegen.mapper.GenGroupMapper">
|
||||
|
||||
<resultMap id="genGroupMap" type="com.pig4cloud.pigx.codegen.util.vo.GroupVo">
|
||||
<resultMap id="genGroupMap" type="com.pig4cloud.pigx.codegen.util.vo.GroupVO">
|
||||
<id property="id" column="group_id"/>
|
||||
<result property="groupName" column="group_name"/>
|
||||
<result property="groupDesc" column="group_desc"/>
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.pig4cloud.pigx.codegen.mapper.GeneratorDB2Mapper">
|
||||
|
||||
<select id="queryTable" resultType="map">
|
||||
SELECT
|
||||
'db2' AS "dbType",
|
||||
TABNAME AS "tableName",
|
||||
REMARKS AS "tableComment",
|
||||
CREATE_TIME AS "createTime"
|
||||
FROM syscat.TABLES
|
||||
WHERE TABSCHEMA = (SELECT CURRENT_SCHEMA
|
||||
FROM SYSIBM.SYSDUMMY1
|
||||
)
|
||||
<if test="tableName != null and tableName.trim() != ''">
|
||||
and TABNAME = #{tableName}
|
||||
</if>
|
||||
ORDER BY CREATE_TIME DESC
|
||||
</select>
|
||||
|
||||
|
||||
<sql id="queryColumn">
|
||||
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}
|
||||
</sql>
|
||||
|
||||
<select id="selectTableColumn" resultType="com.pig4cloud.pigx.codegen.entity.ColumnEntity">
|
||||
<include refid="queryColumn"/>
|
||||
</select>
|
||||
|
||||
<select id="selectMapTableColumn" resultType="map">
|
||||
<include refid="queryColumn"/>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -1,70 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.pig4cloud.pigx.codegen.mapper.GeneratorDmMapper">
|
||||
|
||||
<select id="queryTable" resultType="map">
|
||||
SELECT
|
||||
DISTINCT utc.TABLE_NAME AS "tableName",
|
||||
utc.comments AS "tableComment"
|
||||
FROM user_tab_comments utc
|
||||
<where>
|
||||
<if test="tableName != null and tableName.trim() != ''">
|
||||
and utc.TABLE_NAME = #{tableName}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY utc.TABLE_NAME
|
||||
</select>
|
||||
|
||||
<sql id="queryColumn">
|
||||
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
|
||||
</sql>
|
||||
|
||||
<select id="selectTableColumn" resultType="com.pig4cloud.pigx.codegen.entity.ColumnEntity">
|
||||
<include refid="queryColumn"/>
|
||||
</select>
|
||||
|
||||
<select id="selectMapTableColumn" resultType="map">
|
||||
<include refid="queryColumn"/>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -1,65 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.pig4cloud.pigx.codegen.mapper.GeneratorHighGoMapper">
|
||||
|
||||
<select id="queryTable" resultType="map">
|
||||
SELECT
|
||||
relname AS "tableName",
|
||||
obj_description ( oid ) AS "tableComment"
|
||||
FROM
|
||||
pg_class
|
||||
WHERE
|
||||
relkind = 'r'
|
||||
<if test="tableName != null and tableName.trim() != ''">
|
||||
and relname = #{tableName}
|
||||
</if>
|
||||
AND relname NOT LIKE'pg_%'
|
||||
AND relname NOT LIKE'sql_%'
|
||||
AND relchecks = 0
|
||||
AND relnamespace = (
|
||||
SELECT
|
||||
oid
|
||||
FROM
|
||||
pg_namespace
|
||||
WHERE
|
||||
nspname = ( SELECT CURRENT_SCHEMA ( ) )
|
||||
)
|
||||
ORDER BY relname
|
||||
</select>
|
||||
|
||||
|
||||
<sql id="queryColumn">
|
||||
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
|
||||
</sql>
|
||||
|
||||
<select id="selectTableColumn" resultType="com.pig4cloud.pigx.codegen.entity.ColumnEntity">
|
||||
<include refid="queryColumn"/>
|
||||
</select>
|
||||
|
||||
<select id="selectMapTableColumn" resultType="map">
|
||||
<include refid="queryColumn"/>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -1,86 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.pig4cloud.pigx.codegen.mapper.GeneratorMssqlMapper">
|
||||
|
||||
<select id="queryTable" resultType="map">
|
||||
SELECT *
|
||||
FROM (
|
||||
SELECT CAST
|
||||
(so.NAME AS nvarchar(500)) AS tableName,
|
||||
CAST(sep.VALUE AS nvarchar(500)) AS tableComment
|
||||
FROM sysobjects so
|
||||
LEFT JOIN sys.extended_properties sep ON sep.major_id = so.ID
|
||||
AND sep.minor_id = 0
|
||||
WHERE (xtype = 'U' OR xtype = 'v')
|
||||
) T
|
||||
<where>
|
||||
<if test="tableName != null and tableName.trim() != ''">
|
||||
and T.tableName = #{tableName}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<sql id="queryColumn">
|
||||
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'
|
||||
</sql>
|
||||
|
||||
<select id="selectTableColumn" resultType="com.pig4cloud.pigx.codegen.entity.ColumnEntity">
|
||||
<include refid="queryColumn"/>
|
||||
</select>
|
||||
|
||||
<select id="selectMapTableColumn" resultType="map">
|
||||
<include refid="queryColumn"/>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -1,48 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.pig4cloud.pigx.codegen.mapper.GeneratorMysqlMapper">
|
||||
|
||||
<select id="queryTable" resultType="map">
|
||||
SELECT
|
||||
'mysql' AS dbType,
|
||||
table_name AS tableName,
|
||||
ENGINE,
|
||||
table_comment AS tableComment,
|
||||
create_time AS createTime
|
||||
FROM
|
||||
information_schema.TABLES
|
||||
WHERE
|
||||
table_schema = (
|
||||
SELECT DATABASE
|
||||
())
|
||||
<if test="tableName != null and tableName.trim() != ''">
|
||||
and table_name = #{tableName}
|
||||
</if>
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
<sql id="queryColumn">
|
||||
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
|
||||
</sql>
|
||||
|
||||
<select id="selectTableColumn" resultType="com.pig4cloud.pigx.codegen.entity.ColumnEntity">
|
||||
<include refid="queryColumn"/>
|
||||
</select>
|
||||
|
||||
<select id="selectMapTableColumn" resultType="map">
|
||||
<include refid="queryColumn"/>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -1,72 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.pig4cloud.pigx.codegen.mapper.GeneratorOracleMapper">
|
||||
|
||||
<select id="queryTable" resultType="map">
|
||||
SELECT
|
||||
ut.TABLE_NAME AS "tableName",
|
||||
utc.comments AS "tableComment"
|
||||
FROM
|
||||
user_tables ut,
|
||||
user_tab_comments utc
|
||||
WHERE
|
||||
ut.TABLE_NAME = utc.TABLE_NAME
|
||||
<if test="tableName != null and tableName.trim() != ''">
|
||||
and ut.TABLE_NAME = #{tableName}
|
||||
</if>
|
||||
ORDER BY ut.TABLE_NAME
|
||||
</select>
|
||||
|
||||
<sql id="queryColumn">
|
||||
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
|
||||
</sql>
|
||||
|
||||
<select id="selectTableColumn" resultType="com.pig4cloud.pigx.codegen.entity.ColumnEntity">
|
||||
<include refid="queryColumn"/>
|
||||
</select>
|
||||
|
||||
<select id="selectMapTableColumn" resultType="map">
|
||||
<include refid="queryColumn"/>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -1,57 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.pig4cloud.pigx.codegen.mapper.GeneratorPostgresqlMapper">
|
||||
|
||||
<select id="queryTable" resultType="map">
|
||||
SELECT
|
||||
relname AS "tableName",
|
||||
obj_description ( oid ) AS "tableComment"
|
||||
FROM
|
||||
pg_class pc
|
||||
WHERE
|
||||
relkind = 'r'
|
||||
AND relname NOT LIKE'pg_%'
|
||||
AND relname NOT LIKE'sql_%'
|
||||
AND relchecks = 0
|
||||
<if test="tableName != null and tableName.trim() != ''">
|
||||
and pc.relname = #{tableName}
|
||||
</if>
|
||||
ORDER BY relname
|
||||
</select>
|
||||
|
||||
|
||||
<sql id="queryColumn">
|
||||
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
|
||||
</sql>
|
||||
|
||||
<select id="selectTableColumn" resultType="com.pig4cloud.pigx.codegen.entity.ColumnEntity">
|
||||
<include refid="queryColumn"/>
|
||||
</select>
|
||||
|
||||
<select id="selectMapTableColumn" resultType="map">
|
||||
<include refid="queryColumn"/>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"project": {
|
||||
"packageName": "com.pig4cloud.pigx",
|
||||
"version": "1.0.0",
|
||||
"backendPath": "pigx",
|
||||
"frontendPath": "pigx-ui"
|
||||
},
|
||||
"developer": {
|
||||
"author": "pig",
|
||||
"email": "sw@mail.pigx.vip"
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user