Files
pigx/pigx-visual/pigx-codegen/src/main/resources/mapper/GeneratorPostgresqlMapper.xml
T
冷冷 d2735da63e ♻️ 重构 GeneratorPostgresqlMapper 命名优化支持 PG数据库
(cherry picked from commit 335549fc99d945c74d01205ea756cfd2cffc6225)
2024-08-21 21:51:22 +08:00

58 lines
1.4 KiB
XML
Executable File

<?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>