From a95ad9fef48fd7ebaae3e5c9ba67d51dd21444ff Mon Sep 17 00:00:00 2001
From: admin <15939171744@163.com>
Date: 星期四, 06 三月 2025 18:23:55 +0800
Subject: [PATCH] -

---
 billion-generator/src/main/resources/mapper/generator/GenTableColumnMapper.xml |  132 ++++++++++++++++++++++++++-----------------
 1 files changed, 79 insertions(+), 53 deletions(-)

diff --git a/billion-generator/src/main/resources/mapper/generator/GenTableColumnMapper.xml b/billion-generator/src/main/resources/mapper/generator/GenTableColumnMapper.xml
index f60cb7b..63a2902 100644
--- a/billion-generator/src/main/resources/mapper/generator/GenTableColumnMapper.xml
+++ b/billion-generator/src/main/resources/mapper/generator/GenTableColumnMapper.xml
@@ -1,7 +1,7 @@
 <?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">
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.billion.generator.mapper.GenTableColumnMapper">
 
     <resultMap type="GenTableColumn" id="GenTableColumnResult">
@@ -29,7 +29,7 @@
         <result property="updateTime"     column="update_time"    />
     </resultMap>
 
-	<sql id="selectGenTableColumnVo">
+    <sql id="selectGenTableColumnVo">
         select column_id, table_id, column_name, column_comment, column_type, java_type, java_field, is_pk, is_increment, is_required, is_insert, is_edit, is_list, is_query, query_type, html_type, dict_type, sort, create_by, create_time, update_by, update_time from gen_table_column
     </sql>
 
@@ -40,72 +40,98 @@
     </select>
 
     <select id="selectDbTableColumnsByName" parameterType="String" resultMap="GenTableColumnResult">
-		select column_name, (case when (is_nullable = 'no' <![CDATA[ && ]]> column_key != 'PRI') then '1' else '0' 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
-	</select>
+        SELECT a.name                                                                       AS column_name,
+               (CASE WHEN a.isnullable = 1 THEN 0 ELSE 1 END)                               AS is_required,
+               (CASE WHEN (
+                              SELECT COUNT(*) FROM sysobjects
+                              WHERE (name IN (
+                                  SELECT name FROM sysindexes
+                                  WHERE (id = a.id)
+                                    AND (indid IN (
+                                      SELECT indid FROM sysindexkeys
+                                      WHERE (id = a.id)
+                                        AND (colid IN (SELECT colid FROM syscolumns WHERE (id = a.id) AND (name = a.name)))
+                                  ))))
+                                AND (xtype = 'PK')
+                          ) > 0 THEN 1
+                     ELSE 0 END)                                                             AS is_pk,
+               a.colorder                                                                   AS sort,
+               isnull(g.[value], ' ')                                                       AS column_comment,
+               (CASE WHEN COLUMNPROPERTY(a.id, a.name, 'IsIdentity') = 1 THEN 1 ELSE 0 END) AS is_increment,
+               b.name                                                                       AS column_type
+        FROM syscolumns as a
+                 LEFT JOIN systypes b ON a.xtype = b.xusertype
+                 INNER JOIN sysobjects d ON a.id = d.id AND d.xtype = 'U' AND d.name <![CDATA[<>]]> 'dtproperties'
+                 LEFT JOIN syscomments e ON a.cdefault = e.id
+                 LEFT JOIN sys.extended_properties g ON a.id = g.major_id AND a.colid = g.minor_id
+                 LEFT JOIN sys.extended_properties f ON d.id = f.class AND f.minor_id = 0
+                 LEFT JOIN sys.objects h ON a.id = h.object_id
+                 LEFT JOIN sys.schemas i ON h.schema_id = i.schema_id
+        WHERE d.name = #{tableName}
+        ORDER BY a.colorder
+    </select>
 
     <insert id="insertGenTableColumn" parameterType="GenTableColumn" useGeneratedKeys="true" keyProperty="columnId">
         insert into gen_table_column (
-			<if test="tableId != null and tableId != ''">table_id,</if>
-			<if test="columnName != null and columnName != ''">column_name,</if>
-			<if test="columnComment != null and columnComment != ''">column_comment,</if>
-			<if test="columnType != null and columnType != ''">column_type,</if>
-			<if test="javaType != null and javaType != ''">java_type,</if>
-			<if test="javaField != null  and javaField != ''">java_field,</if>
-			<if test="isPk != null and isPk != ''">is_pk,</if>
-			<if test="isIncrement != null and isIncrement != ''">is_increment,</if>
-			<if test="isRequired != null and isRequired != ''">is_required,</if>
-			<if test="isInsert != null and isInsert != ''">is_insert,</if>
-			<if test="isEdit != null and isEdit != ''">is_edit,</if>
-			<if test="isList != null and isList != ''">is_list,</if>
-			<if test="isQuery != null and isQuery != ''">is_query,</if>
-			<if test="queryType != null and queryType != ''">query_type,</if>
-			<if test="htmlType != null and htmlType != ''">html_type,</if>
-			<if test="dictType != null and dictType != ''">dict_type,</if>
-			<if test="sort != null">sort,</if>
-			<if test="createBy != null and createBy != ''">create_by,</if>
-			create_time
-         )values(
-			<if test="tableId != null and tableId != ''">#{tableId},</if>
-			<if test="columnName != null and columnName != ''">#{columnName},</if>
-			<if test="columnComment != null and columnComment != ''">#{columnComment},</if>
-			<if test="columnType != null and columnType != ''">#{columnType},</if>
-			<if test="javaType != null and javaType != ''">#{javaType},</if>
-			<if test="javaField != null and javaField != ''">#{javaField},</if>
-			<if test="isPk != null and isPk != ''">#{isPk},</if>
-			<if test="isIncrement != null and isIncrement != ''">#{isIncrement},</if>
-			<if test="isRequired != null and isRequired != ''">#{isRequired},</if>
-			<if test="isInsert != null and isInsert != ''">#{isInsert},</if>
-			<if test="isEdit != null and isEdit != ''">#{isEdit},</if>
-			<if test="isList != null and isList != ''">#{isList},</if>
-			<if test="isQuery != null and isQuery != ''">#{isQuery},</if>
-			<if test="queryType != null and queryType != ''">#{queryType},</if>
-			<if test="htmlType != null and htmlType != ''">#{htmlType},</if>
-			<if test="dictType != null and dictType != ''">#{dictType},</if>
-			<if test="sort != null">#{sort},</if>
-			<if test="createBy != null and createBy != ''">#{createBy},</if>
-			sysdate()
-         )
+        <if test="tableId != null and tableId != ''">table_id,</if>
+        <if test="columnName != null and columnName != ''">column_name,</if>
+        <if test="columnComment != null and columnComment != ''">column_comment,</if>
+        <if test="columnType != null and columnType != ''">column_type,</if>
+        <if test="javaType != null and javaType != ''">java_type,</if>
+        <if test="javaField != null  and javaField != ''">java_field,</if>
+        <if test="isPk != null and isPk != ''">is_pk,</if>
+        <if test="isIncrement != null and isIncrement != ''">is_increment,</if>
+        <if test="isRequired != null and isRequired != ''">is_required,</if>
+        <if test="isInsert != null and isInsert != ''">is_insert,</if>
+        <if test="isEdit != null and isEdit != ''">is_edit,</if>
+        <if test="isList != null and isList != ''">is_list,</if>
+        <if test="isQuery != null and isQuery != ''">is_query,</if>
+        <if test="queryType != null and queryType != ''">query_type,</if>
+        <if test="htmlType != null and htmlType != ''">html_type,</if>
+        <if test="dictType != null and dictType != ''">dict_type,</if>
+        <if test="sort != null">sort,</if>
+        <if test="createBy != null and createBy != ''">create_by,</if>
+        create_time
+        )values(
+        <if test="tableId != null and tableId != ''">#{tableId},</if>
+        <if test="columnName != null and columnName != ''">#{columnName},</if>
+        <if test="columnComment != null and columnComment != ''">#{columnComment},</if>
+        <if test="columnType != null and columnType != ''">#{columnType},</if>
+        <if test="javaType != null and javaType != ''">#{javaType},</if>
+        <if test="javaField != null and javaField != ''">#{javaField},</if>
+        <if test="isPk != null and isPk != ''">#{isPk},</if>
+        <if test="isIncrement != null and isIncrement != ''">#{isIncrement},</if>
+        <if test="isRequired != null and isRequired != ''">#{isRequired},</if>
+        <if test="isInsert != null and isInsert != ''">#{isInsert},</if>
+        <if test="isEdit != null and isEdit != ''">#{isEdit},</if>
+        <if test="isList != null and isList != ''">#{isList},</if>
+        <if test="isQuery != null and isQuery != ''">#{isQuery},</if>
+        <if test="queryType != null and queryType != ''">#{queryType},</if>
+        <if test="htmlType != null and htmlType != ''">#{htmlType},</if>
+        <if test="dictType != null and dictType != ''">#{dictType},</if>
+        <if test="sort != null">#{sort},</if>
+        <if test="createBy != null and createBy != ''">#{createBy},</if>
+        getdate()
+        )
     </insert>
 
     <update id="updateGenTableColumn" parameterType="GenTableColumn">
         update gen_table_column
         <set>
+            is_insert = #{isInsert},
+            is_edit = #{isEdit},
+            is_list = #{isList},
+            is_query = #{isQuery},
+            is_required = #{isRequired},
             <if test="columnComment != null">column_comment = #{columnComment},</if>
             <if test="javaType != null">java_type = #{javaType},</if>
             <if test="javaField != null">java_field = #{javaField},</if>
-            <if test="isInsert != null">is_insert = #{isInsert},</if>
-            <if test="isEdit != null">is_edit = #{isEdit},</if>
-            <if test="isList != null">is_list = #{isList},</if>
-            <if test="isQuery != null">is_query = #{isQuery},</if>
-            <if test="isRequired != null">is_required = #{isRequired},</if>
             <if test="queryType != null">query_type = #{queryType},</if>
             <if test="htmlType != null">html_type = #{htmlType},</if>
             <if test="dictType != null">dict_type = #{dictType},</if>
             <if test="sort != null">sort = #{sort},</if>
             <if test="updateBy != null">update_by = #{updateBy},</if>
-            update_time = sysdate()
+            update_time = getdate()
         </set>
         where column_id = #{columnId}
     </update>

--
Gitblit v1.9.3