提交 | 用户 | 时间
|
a6316e
|
1 |
<?xml version="1.0" encoding="UTF-8" ?> |
A |
2 |
<!DOCTYPE mapper |
|
3 |
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
|
4 |
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|
5 |
<mapper namespace="com.billion.generator.mapper.GenTableColumnMapper"> |
|
6 |
|
|
7 |
<resultMap type="GenTableColumn" id="GenTableColumnResult"> |
|
8 |
<id property="columnId" column="column_id" /> |
|
9 |
<result property="tableId" column="table_id" /> |
|
10 |
<result property="columnName" column="column_name" /> |
|
11 |
<result property="columnComment" column="column_comment" /> |
|
12 |
<result property="columnType" column="column_type" /> |
|
13 |
<result property="javaType" column="java_type" /> |
|
14 |
<result property="javaField" column="java_field" /> |
|
15 |
<result property="isPk" column="is_pk" /> |
|
16 |
<result property="isIncrement" column="is_increment" /> |
|
17 |
<result property="isRequired" column="is_required" /> |
|
18 |
<result property="isInsert" column="is_insert" /> |
|
19 |
<result property="isEdit" column="is_edit" /> |
|
20 |
<result property="isList" column="is_list" /> |
|
21 |
<result property="isQuery" column="is_query" /> |
|
22 |
<result property="queryType" column="query_type" /> |
|
23 |
<result property="htmlType" column="html_type" /> |
|
24 |
<result property="dictType" column="dict_type" /> |
|
25 |
<result property="sort" column="sort" /> |
|
26 |
<result property="createBy" column="create_by" /> |
|
27 |
<result property="createTime" column="create_time" /> |
|
28 |
<result property="updateBy" column="update_by" /> |
|
29 |
<result property="updateTime" column="update_time" /> |
|
30 |
</resultMap> |
|
31 |
|
|
32 |
<sql id="selectGenTableColumnVo"> |
|
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 |
</sql> |
|
35 |
|
|
36 |
<select id="selectGenTableColumnListByTableId" parameterType="Long" resultMap="GenTableColumnResult"> |
|
37 |
<include refid="selectGenTableColumnVo"/> |
|
38 |
where table_id = #{tableId} |
|
39 |
order by sort |
|
40 |
</select> |
|
41 |
|
|
42 |
<select id="selectDbTableColumnsByName" parameterType="String" resultMap="GenTableColumnResult"> |
|
43 |
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 |
|
44 |
from information_schema.columns where table_schema = (select database()) and table_name = (#{tableName}) |
|
45 |
order by ordinal_position |
|
46 |
</select> |
|
47 |
|
|
48 |
<insert id="insertGenTableColumn" parameterType="GenTableColumn" useGeneratedKeys="true" keyProperty="columnId"> |
|
49 |
insert into gen_table_column ( |
|
50 |
<if test="tableId != null and tableId != ''">table_id,</if> |
|
51 |
<if test="columnName != null and columnName != ''">column_name,</if> |
|
52 |
<if test="columnComment != null and columnComment != ''">column_comment,</if> |
|
53 |
<if test="columnType != null and columnType != ''">column_type,</if> |
|
54 |
<if test="javaType != null and javaType != ''">java_type,</if> |
|
55 |
<if test="javaField != null and javaField != ''">java_field,</if> |
|
56 |
<if test="isPk != null and isPk != ''">is_pk,</if> |
|
57 |
<if test="isIncrement != null and isIncrement != ''">is_increment,</if> |
|
58 |
<if test="isRequired != null and isRequired != ''">is_required,</if> |
|
59 |
<if test="isInsert != null and isInsert != ''">is_insert,</if> |
|
60 |
<if test="isEdit != null and isEdit != ''">is_edit,</if> |
|
61 |
<if test="isList != null and isList != ''">is_list,</if> |
|
62 |
<if test="isQuery != null and isQuery != ''">is_query,</if> |
|
63 |
<if test="queryType != null and queryType != ''">query_type,</if> |
|
64 |
<if test="htmlType != null and htmlType != ''">html_type,</if> |
|
65 |
<if test="dictType != null and dictType != ''">dict_type,</if> |
|
66 |
<if test="sort != null">sort,</if> |
|
67 |
<if test="createBy != null and createBy != ''">create_by,</if> |
|
68 |
create_time |
|
69 |
)values( |
|
70 |
<if test="tableId != null and tableId != ''">#{tableId},</if> |
|
71 |
<if test="columnName != null and columnName != ''">#{columnName},</if> |
|
72 |
<if test="columnComment != null and columnComment != ''">#{columnComment},</if> |
|
73 |
<if test="columnType != null and columnType != ''">#{columnType},</if> |
|
74 |
<if test="javaType != null and javaType != ''">#{javaType},</if> |
|
75 |
<if test="javaField != null and javaField != ''">#{javaField},</if> |
|
76 |
<if test="isPk != null and isPk != ''">#{isPk},</if> |
|
77 |
<if test="isIncrement != null and isIncrement != ''">#{isIncrement},</if> |
|
78 |
<if test="isRequired != null and isRequired != ''">#{isRequired},</if> |
|
79 |
<if test="isInsert != null and isInsert != ''">#{isInsert},</if> |
|
80 |
<if test="isEdit != null and isEdit != ''">#{isEdit},</if> |
|
81 |
<if test="isList != null and isList != ''">#{isList},</if> |
|
82 |
<if test="isQuery != null and isQuery != ''">#{isQuery},</if> |
|
83 |
<if test="queryType != null and queryType != ''">#{queryType},</if> |
|
84 |
<if test="htmlType != null and htmlType != ''">#{htmlType},</if> |
|
85 |
<if test="dictType != null and dictType != ''">#{dictType},</if> |
|
86 |
<if test="sort != null">#{sort},</if> |
|
87 |
<if test="createBy != null and createBy != ''">#{createBy},</if> |
|
88 |
sysdate() |
|
89 |
) |
|
90 |
</insert> |
|
91 |
|
|
92 |
<update id="updateGenTableColumn" parameterType="GenTableColumn"> |
|
93 |
update gen_table_column |
|
94 |
<set> |
|
95 |
<if test="columnComment != null">column_comment = #{columnComment},</if> |
|
96 |
<if test="javaType != null">java_type = #{javaType},</if> |
|
97 |
<if test="javaField != null">java_field = #{javaField},</if> |
|
98 |
<if test="isInsert != null">is_insert = #{isInsert},</if> |
|
99 |
<if test="isEdit != null">is_edit = #{isEdit},</if> |
|
100 |
<if test="isList != null">is_list = #{isList},</if> |
|
101 |
<if test="isQuery != null">is_query = #{isQuery},</if> |
|
102 |
<if test="isRequired != null">is_required = #{isRequired},</if> |
|
103 |
<if test="queryType != null">query_type = #{queryType},</if> |
|
104 |
<if test="htmlType != null">html_type = #{htmlType},</if> |
|
105 |
<if test="dictType != null">dict_type = #{dictType},</if> |
|
106 |
<if test="sort != null">sort = #{sort},</if> |
|
107 |
<if test="updateBy != null">update_by = #{updateBy},</if> |
|
108 |
update_time = sysdate() |
|
109 |
</set> |
|
110 |
where column_id = #{columnId} |
|
111 |
</update> |
|
112 |
|
|
113 |
<delete id="deleteGenTableColumnByIds" parameterType="Long"> |
|
114 |
delete from gen_table_column where table_id in |
|
115 |
<foreach collection="array" item="tableId" open="(" separator="," close=")"> |
|
116 |
#{tableId} |
|
117 |
</foreach> |
|
118 |
</delete> |
|
119 |
|
|
120 |
<delete id="deleteGenTableColumns"> |
|
121 |
delete from gen_table_column where column_id in |
|
122 |
<foreach collection="list" item="item" open="(" separator="," close=")"> |
|
123 |
#{item.columnId} |
|
124 |
</foreach> |
|
125 |
</delete> |
|
126 |
|
|
127 |
</mapper> |