✨ Introducing new features. close #3729 代码生成支持达梦数据库

This commit is contained in:
qraddx committed 2022-03-24 12:45:52 +08:00
1 parent 0210ed9b70
commit 2b970b0df2
7 files changed
+117 -5

No files matched your search

@@ -42,7 +42,12 @@ public enum DsJdbcUrlEnum {
/**
* db2
*/
DB2("db2", "jdbc:db2://%s:%s/%s", "select 1 from sysibm.sysdummy1", "DB2 TYPE4 连接");
DB2("db2", "jdbc:db2://%s:%s/%s", "select 1 from sysibm.sysdummy1", "DB2 TYPE4 连接"),
/**
* 达梦
*/
DM("dm", "jdbc:dm://%s:%s/%s", "select 1 from dual", "达梦连接");
private final String dbName;
+6 -1
View File
@@ -15,7 +15,7 @@
<description>代码生成模块</description>
<properties>
<screw.version>0.0.1</screw.version>
<screw.version>0.0.2</screw.version>
<db2.version>11.5.0.0</db2.version>
<configuration.version>1.10</configuration.version>
</properties>
@@ -71,6 +71,11 @@
<artifactId>jcc</artifactId>
<version>${db2.version}</version>
</dependency>
<!--DM-->
<dependency>
<groupId>com.dameng</groupId>
<artifactId>DmJdbcDriver18</artifactId>
</dependency>
<!-- druid 连接池 -->
<dependency>
<groupId>com.alibaba</groupId>
@@ -0,0 +1,31 @@
/*
* 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 {
}
@@ -70,7 +70,7 @@ public class GenFormConfServiceImpl extends ServiceImpl<GenFormConfMapper, GenFo
List<ColumnEntity> columns = mapper.selectTableColumn(tableName, dsName);
// 设置velocity资源加载器
Properties prop = new Properties();
prop.put("file.resource.loader.class", ClasspathResourceLoader.class.getName());
prop.put("resource.loader.file.class", ClasspathResourceLoader.class.getName());
Velocity.init(prop);
Template template = Velocity.getTemplate("template/avue/crud.js.vm", CharsetUtil.UTF_8);
VelocityContext context = new VelocityContext();
@@ -265,7 +265,7 @@ public class GenUtils {
TableEntity tableEntity, Map<String, Object> map) throws IOException {
// 设置velocity资源加载器
Properties prop = new Properties();
prop.put("file.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
prop.put("resource.loader.file.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
Velocity.init(prop);
VelocityContext context = new VelocityContext(map);
// 函数库
@@ -0,0 +1,70 @@
<?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
'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>
@@ -37,7 +37,7 @@ public class XxlJobAdminConfig implements InitializingBean, DisposableBean {
adminConfig = this;
xxlJobScheduler = new XxlJobScheduler();
// xxlJobScheduler.init();
// xxlJobScheduler.init();
}
@Override
@@ -163,4 +163,5 @@ public class XxlJobAdminConfig implements InitializingBean, DisposableBean {
public XxlJobScheduler getXxlJobScheduler() {
return xxlJobScheduler;
}
}