mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-08 20:49:00 +08:00
♻️ 重构 GeneratorPostgresqlMapper 命名优化支持 PG数据库
(cherry picked from commit 335549fc99d945c74d01205ea756cfd2cffc6225)
This commit is contained in:
1 parent
7d9acfd7fb
commit
d2735da63e
2 files changed
+3
-3
No files matched your search
+57
@@ -0,0 +1,57 @@
|
||||
<?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>
|
||||
Reference in new issue
Block a user