From 7f1356a447d290c186fe047af557e050497e39e4 Mon Sep 17 00:00:00 2001 From: 疯狂的狮子li <15040126243@163.com> Date: 星期一, 14 三月 2022 14:05:37 +0800 Subject: [PATCH] update 重构代码生成 多数据库sql加载 使用xml特性动态切换sql --- ruoyi-generator/src/main/resources/mapper/generator/GenTableColumnMapper.xml | 38 +++++++++++++++++++++++++++++++++++--- 1 files changed, 35 insertions(+), 3 deletions(-) diff --git a/ruoyi-generator/src/main/resources/mapper/generator/GenTableColumnMapper.xml b/ruoyi-generator/src/main/resources/mapper/generator/GenTableColumnMapper.xml index 7ef9744..4614dd4 100644 --- a/ruoyi-generator/src/main/resources/mapper/generator/GenTableColumnMapper.xml +++ b/ruoyi-generator/src/main/resources/mapper/generator/GenTableColumnMapper.xml @@ -30,9 +30,41 @@ </resultMap> <select id="selectDbTableColumnsByName" parameterType="String" resultMap="GenTableColumnResult"> - select column_name, (case when (is_nullable = 'no' <![CDATA[ && ]]> column_key != 'PRI') then '1' else null end) as is_required, (case when column_key = 'PRI' then '1' else '0' end) as is_pk, ordinal_position as sort, column_comment, (case when extra = 'auto_increment' then '1' else '0' end) as is_increment, column_type - from information_schema.columns where table_schema = (select database()) and table_name = (#{tableName}) - order by ordinal_position + <if test="@com.ruoyi.common.helper.DataBaseHelper@isMySql()"> + select column_name, + (case when (is_nullable = 'no' <![CDATA[ && ]]> column_key != 'PRI') then '1' else null end) as is_required, + (case when column_key = 'PRI' then '1' else '0' end) as is_pk, + ordinal_position as sort, + column_comment, + (case when extra = 'auto_increment' then '1' else '0' end) as is_increment, + column_type + from information_schema.columns where table_schema = (select database()) and table_name = (#{tableName}) + order by ordinal_position + </if> + <if test="@com.ruoyi.common.helper.DataBaseHelper@isOracle()"> + select lower(temp.column_name) as column_name, + (case when (temp.nullable = 'N' and temp.constraint_type != 'P') then '1' else null end) as is_required, + (case when temp.constraint_type = 'P' then '1' else '0' end) as is_pk, + temp.column_id as sort, + temp.comments as column_comment, + (case when temp.constraint_type = 'P' then '1' else '0' end) as is_increment, + lower(temp.data_type) as column_type + from ( + select col.column_id, col.column_name,col.nullable, 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 = upper(#{tableName}) + ) temp + WHERE temp.row_flg = 1 + ORDER BY temp.column_id + </if> + <if test="@com.ruoyi.common.helper.DataBaseHelper@isPostgerSql()"> + </if> + <if test="@com.ruoyi.common.helper.DataBaseHelper@isSqlServer()"> + </if> </select> </mapper> -- Gitblit v1.9.3