Просмотр исходного кода

优化生成表字段comment过长问题

RuoYi лет назад: 3
Родитель
Сommit
308d497d74

+ 10 - 10
ruoyi-modules/ruoyi-gen/src/main/resources/mapper/generator/GenTableColumnMapper.xml

@@ -3,7 +3,7 @@
3 3
 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
4 4
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
5 5
 <mapper namespace="com.ruoyi.gen.mapper.GenTableColumnMapper">
6
-    
6
+
7 7
     <resultMap type="GenTableColumn" id="GenTableColumnResult">
8 8
         <id     property="columnId"       column="column_id"      />
9 9
         <result property="tableId"        column="table_id"       />
@@ -28,23 +28,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
28 28
         <result property="updateBy"       column="update_by"      />
29 29
         <result property="updateTime"     column="update_time"    />
30 30
     </resultMap>
31
-	
31
+
32 32
 	<sql id="selectGenTableColumnVo">
33 33
         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
34 34
     </sql>
35
-	
35
+
36 36
     <select id="selectGenTableColumnListByTableId" parameterType="GenTableColumn" resultMap="GenTableColumnResult">
37 37
         <include refid="selectGenTableColumnVo"/>
38 38
         where table_id = #{tableId}
39 39
         order by sort
40 40
     </select>
41
-    
41
+
42 42
     <select id="selectDbTableColumnsByName" parameterType="String" resultMap="GenTableColumnResult">
43 43
 		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
44 44
 		from information_schema.columns where table_schema = (select database()) and table_name = (#{tableName})
45 45
 		order by ordinal_position
46 46
 	</select>
47
-    
47
+
48 48
     <insert id="insertGenTableColumn" parameterType="GenTableColumn" useGeneratedKeys="true" keyProperty="columnId">
49 49
         insert into gen_table_column (
50 50
 			<if test="tableId != null and tableId != ''">table_id,</if>
@@ -69,7 +69,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
69 69
          )values(
70 70
 			<if test="tableId != null and tableId != ''">#{tableId},</if>
71 71
 			<if test="columnName != null and columnName != ''">#{columnName},</if>
72
-			<if test="columnComment != null and columnComment != ''">#{columnComment},</if>
72
+			<if test="columnComment != null and columnComment != ''">(select SUBSTRING_INDEX(#{columnComment}, ' ', 1)),</if>
73 73
 			<if test="columnType != null and columnType != ''">#{columnType},</if>
74 74
 			<if test="javaType != null and javaType != ''">#{javaType},</if>
75 75
 			<if test="javaField != null and javaField != ''">#{javaField},</if>
@@ -88,11 +88,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
88 88
 			sysdate()
89 89
          )
90 90
     </insert>
91
-	 
91
+
92 92
     <update id="updateGenTableColumn" parameterType="GenTableColumn">
93 93
         update gen_table_column
94 94
         <set>
95
-            <if test="columnComment != null">column_comment = #{columnComment},</if>
95
+            <if test="columnComment != null">column_comment = (select SUBSTRING_INDEX(#{columnComment}, ' ', 1)),</if>
96 96
             <if test="javaType != null">java_type = #{javaType},</if>
97 97
             <if test="javaField != null">java_field = #{javaField},</if>
98 98
             <if test="isInsert != null">is_insert = #{isInsert},</if>
@@ -111,14 +111,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
111 111
     </update>
112 112
 
113 113
     <delete id="deleteGenTableColumnByIds" parameterType="Long">
114
-        delete from gen_table_column where table_id in 
114
+        delete from gen_table_column where table_id in
115 115
         <foreach collection="array" item="tableId" open="(" separator="," close=")">
116 116
             #{tableId}
117 117
         </foreach>
118 118
     </delete>
119 119
     
120 120
     <delete id="deleteGenTableColumns">
121
-        delete from gen_table_column where column_id in 
121
+        delete from gen_table_column where column_id in
122 122
         <foreach collection="list" item="item" open="(" separator="," close=")">
123 123
             #{item.columnId}
124 124
         </foreach>