-
admin
7 天以前 a95ad9fef48fd7ebaae3e5c9ba67d51dd21444ff
提交 | 用户 | 时间
a6316e 1 <?xml version="1.0" encoding="UTF-8" ?>
A 2 <!DOCTYPE mapper
110d30 3         PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
A 4         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
a6316e 5 <mapper namespace="com.billion.generator.mapper.GenTableMapper">
A 6
7     <resultMap type="GenTable" id="GenTableResult">
110d30 8         <id     property="tableId"        column="table_id"          />
a6316e 9         <result property="tableName"      column="table_name"        />
A 10         <result property="tableComment"   column="table_comment"     />
11         <result property="subTableName"   column="sub_table_name"    />
12         <result property="subTableFkName" column="sub_table_fk_name" />
13         <result property="className"      column="class_name"        />
14         <result property="tplCategory"    column="tpl_category"      />
15         <result property="packageName"    column="package_name"      />
16         <result property="moduleName"     column="module_name"       />
17         <result property="businessName"   column="business_name"     />
18         <result property="functionName"   column="function_name"     />
19         <result property="functionAuthor" column="function_author"   />
20         <result property="genType"        column="gen_type"          />
21         <result property="genPath"        column="gen_path"          />
22         <result property="options"        column="options"           />
23         <result property="createBy"       column="create_by"         />
24         <result property="createTime"     column="create_time"       />
25         <result property="updateBy"       column="update_by"         />
26         <result property="updateTime"     column="update_time"       />
27         <result property="remark"         column="remark"            />
110d30 28         <collection  property="columns"  javaType="java.util.List"  resultMap="GenTableColumnResult" />
a6316e 29     </resultMap>
110d30 30
a6316e 31     <resultMap type="GenTableColumn" id="GenTableColumnResult">
110d30 32         <id     property="columnId"       column="column_id"      />
A 33         <result property="tableId"        column="table_id"       />
34         <result property="columnName"     column="column_name"    />
35         <result property="columnComment"  column="column_comment" />
36         <result property="columnType"     column="column_type"    />
37         <result property="javaType"       column="java_type"      />
38         <result property="javaField"      column="java_field"     />
39         <result property="isPk"           column="is_pk"          />
40         <result property="isIncrement"    column="is_increment"   />
41         <result property="isRequired"     column="is_required"    />
42         <result property="isInsert"       column="is_insert"      />
43         <result property="isEdit"         column="is_edit"        />
44         <result property="isList"         column="is_list"        />
45         <result property="isQuery"        column="is_query"       />
46         <result property="queryType"      column="query_type"     />
47         <result property="htmlType"       column="html_type"      />
48         <result property="dictType"       column="dict_type"      />
49         <result property="sort"           column="sort"           />
50         <result property="createBy"       column="create_by"      />
51         <result property="createTime"     column="create_time"    />
52         <result property="updateBy"       column="update_by"      />
53         <result property="updateTime"     column="update_time"    />
54     </resultMap>
55
a6316e 56     <sql id="selectGenTableVo">
110d30 57         select table_id, table_name, table_comment, sub_table_name, sub_table_fk_name, class_name, tpl_category, package_name, module_name, business_name, function_name, function_author, gen_type, gen_path, options, create_by, create_time, update_by, update_time, remark from gen_table
A 58     </sql>
59
60     <select id="selectGenTableList" parameterType="GenTable" resultMap="GenTableResult">
a6316e 61         <include refid="selectGenTableVo"/>
A 62         <where>
63             <if test="tableName != null and tableName != ''">
64                 AND lower(table_name) like lower(concat('%', #{tableName}, '%'))
65             </if>
66             <if test="tableComment != null and tableComment != ''">
67                 AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
68             </if>
69             <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
110d30 70                 <!--                and <![CDATA[ create_time >= convert(datetime, #{params.beginTime}, 20)]]>-->
A 71                 and datediff(d, create_time, #{params.beginTime}) <![CDATA[<=]]> 0
a6316e 72             </if>
A 73             <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
110d30 74                 <!--                and <![CDATA[ create_time <= convert(datetime, #{params.endTime}, 20)]]>-->
A 75                 and datediff(d, create_time, #{params.endTime}) <![CDATA[>=]]> 0
a6316e 76             </if>
A 77         </where>
78     </select>
79
80     <select id="selectDbTableList" parameterType="GenTable" resultMap="GenTableResult">
110d30 81         SELECT
A 82         so.name as table_name,
83         sep.value as table_comment,
84         so.create_date as create_time,
85         so.modify_date as update_time
86         FROM
87         sys.objects as so
88         LEFT JOIN sys.extended_properties as sep on so.object_id = sep.major_id
89         WHERE
90         so.type = 'U'
91         AND sep.minor_id = 0
92         AND so.name NOT LIKE 'qrtz_%' AND so.name NOT LIKE 'gen_%'
93         AND so.name NOT LIKE 'act_%'  AND so.name NOT LIKE 'flw_%'
94         AND so.name NOT IN (select table_name from gen_table)
a6316e 95         <if test="tableName != null and tableName != ''">
110d30 96             AND lower(so.name) like lower(concat('%', #{tableName}, '%'))
a6316e 97         </if>
A 98         <if test="tableComment != null and tableComment != ''">
110d30 99             AND lower(cast(sep.value as nvarchar)) like lower(concat('%', #{tableComment}, '%'))
a6316e 100         </if>
A 101         <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
110d30 102             <!--            and <![CDATA[ create_time >= convert(datetime, #{params.beginTime}, 20)]]>-->
A 103             and datediff(d, so.create_date, #{params.beginTime}) <![CDATA[<=]]> 0
a6316e 104         </if>
A 105         <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
110d30 106             <!--            and <![CDATA[ create_time <= convert(datetime, #{params.endTime}, 20)]]>-->
A 107             and datediff(d, so.create_date, #{params.endTime}) <![CDATA[>=]]> 0
a6316e 108         </if>
110d30 109         order by so.create_date desc
a6316e 110     </select>
110d30 111
a6316e 112     <select id="selectDbTableListByNames" resultMap="GenTableResult">
110d30 113         SELECT
A 114         SO.name table_name,
115         SEP.VALUE table_comment,
116         SO.create_date create_time,
117         SO.modify_date update_time
118         FROM
119         sys.objects AS SO
120         LEFT JOIN sys.extended_properties AS SEP ON SO.object_id = SEP.major_id
121         WHERE
122         SO.type = 'U'
123         AND SEP.minor_id = 0
124         and SO.name NOT LIKE 'qrtz_%' and SO.name NOT LIKE 'gen_%'
125         AND so.name NOT LIKE 'act_%'  AND so.name NOT LIKE 'flw_%'
126         and SO.name in
127         <foreach collection="array" item="name" open="(" separator="," close=")">
128             #{name}
129         </foreach>
a6316e 130     </select>
110d30 131
a6316e 132     <select id="selectTableByName" parameterType="String" resultMap="GenTableResult">
A 133         select table_name, table_comment, create_time, update_time from information_schema.tables
134         where table_comment <![CDATA[ <> ]]> '' and table_schema = (select database())
110d30 135           and table_name = #{tableName}
a6316e 136     </select>
110d30 137
a6316e 138     <select id="selectGenTableById" parameterType="Long" resultMap="GenTableResult">
110d30 139         SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
a6316e 140                c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
A 141         FROM gen_table t
110d30 142                  LEFT JOIN gen_table_column c ON t.table_id = c.table_id
a6316e 143         where t.table_id = #{tableId} order by c.sort
A 144     </select>
110d30 145
a6316e 146     <select id="selectGenTableByName" parameterType="String" resultMap="GenTableResult">
110d30 147         SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
a6316e 148                c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
A 149         FROM gen_table t
110d30 150                  LEFT JOIN gen_table_column c ON t.table_id = c.table_id
a6316e 151         where t.table_name = #{tableName} order by c.sort
A 152     </select>
110d30 153
a6316e 154     <select id="selectGenTableAll" parameterType="String" resultMap="GenTableResult">
110d30 155         SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.options, t.remark,
a6316e 156                c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
A 157         FROM gen_table t
110d30 158                  LEFT JOIN gen_table_column c ON t.table_id = c.table_id
a6316e 159         order by c.sort
A 160     </select>
110d30 161
a6316e 162     <insert id="insertGenTable" parameterType="GenTable" useGeneratedKeys="true" keyProperty="tableId">
110d30 163         insert into gen_table (
A 164         <if test="tableName != null">table_name,</if>
165         <if test="tableComment != null and tableComment != ''">table_comment,</if>
166         <if test="className != null and className != ''">class_name,</if>
167         <if test="tplCategory != null and tplCategory != ''">tpl_category,</if>
168         <if test="packageName != null and packageName != ''">package_name,</if>
169         <if test="moduleName != null and moduleName != ''">module_name,</if>
170         <if test="businessName != null and businessName != ''">business_name,</if>
171         <if test="functionName != null and functionName != ''">function_name,</if>
172         <if test="functionAuthor != null and functionAuthor != ''">function_author,</if>
173         <if test="genType != null and genType != ''">gen_type,</if>
174         <if test="genPath != null and genPath != ''">gen_path,</if>
175         <if test="remark != null and remark != ''">remark,</if>
176         <if test="createBy != null and createBy != ''">create_by,</if>
177         create_time
178         )values(
179         <if test="tableName != null">#{tableName},</if>
180         <if test="tableComment != null and tableComment != ''">#{tableComment},</if>
181         <if test="className != null and className != ''">#{className},</if>
182         <if test="tplCategory != null and tplCategory != ''">#{tplCategory},</if>
183         <if test="packageName != null and packageName != ''">#{packageName},</if>
184         <if test="moduleName != null and moduleName != ''">#{moduleName},</if>
185         <if test="businessName != null and businessName != ''">#{businessName},</if>
186         <if test="functionName != null and functionName != ''">#{functionName},</if>
187         <if test="functionAuthor != null and functionAuthor != ''">#{functionAuthor},</if>
188         <if test="genType != null and genType != ''">#{genType},</if>
189         <if test="genPath != null and genPath != ''">#{genPath},</if>
190         <if test="remark != null and remark != ''">#{remark},</if>
191         <if test="createBy != null and createBy != ''">#{createBy},</if>
192         getdate()
193         )
194     </insert>
195
196     <update id="updateGenTable" parameterType="GenTable">
197         update gen_table
198         <set>
199             <if test="tableName != null">table_name = #{tableName},</if>
200             <if test="tableComment != null and tableComment != ''">table_comment = #{tableComment},</if>
201             <if test="subTableName != null">sub_table_name = #{subTableName},</if>
202             <if test="subTableFkName != null">sub_table_fk_name = #{subTableFkName},</if>
203             <if test="className != null and className != ''">class_name = #{className},</if>
204             <if test="functionAuthor != null and functionAuthor != ''">function_author = #{functionAuthor},</if>
205             <if test="genType != null and genType != ''">gen_type = #{genType},</if>
206             <if test="genPath != null and genPath != ''">gen_path = #{genPath},</if>
207             <if test="tplCategory != null and tplCategory != ''">tpl_category = #{tplCategory},</if>
208             <if test="packageName != null and packageName != ''">package_name = #{packageName},</if>
209             <if test="moduleName != null and moduleName != ''">module_name = #{moduleName},</if>
210             <if test="businessName != null and businessName != ''">business_name = #{businessName},</if>
211             <if test="functionName != null and functionName != ''">function_name = #{functionName},</if>
212             <if test="options != null and options != ''">options = #{options},</if>
213             <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
214             <if test="remark != null">remark = #{remark},</if>
215             update_time = getdate()
216         </set>
217         where table_id = #{tableId}
218     </update>
219
220     <delete id="deleteGenTableByIds" parameterType="Long">
221         delete from gen_table where table_id in
222         <foreach collection="array" item="tableId" open="(" separator="," close=")">
223             #{tableId}
224         </foreach>
225     </delete>
a6316e 226
A 227 </mapper>