GenTableMapper.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="cn.gov.customs.wxjy.generator.dao.GenTableMapper">
  6. <resultMap type="GenTable" id="GenTableResult">
  7. <result property="tableId" column="TABLE_ID"/>
  8. <result property="tableName" column="TABLE_NAME"/>
  9. <result property="tableComment" column="TABLE_COMMENT"/>
  10. <result property="subTableName" column="SUB_TABLE_NAME"/>
  11. <result property="subTableFkName" column="SUB_TABLE_FK_NAME"/>
  12. <result property="className" column="CLASS_NAME"/>
  13. <result property="tplCategory" column="TPL_CATEGORY"/>
  14. <result property="packageName" column="PACKAGE_NAME"/>
  15. <result property="moduleName" column="MODULE_NAME"/>
  16. <result property="businessName" column="BUSINESS_NAME"/>
  17. <result property="functionName" column="FUNCTION_NAME"/>
  18. <result property="functionAuthor" column="FUNCTION_AUTHOR"/>
  19. <result property="genType" column="GEN_TYPE"/>
  20. <result property="genPath" column="GEN_PATH"/>
  21. <result property="options" column="OPTIONS"/>
  22. <result property="createUser" column="CREATE_USER"/>
  23. <result property="createTime" column="CREATE_TIME"/>
  24. <result property="updateUser" column="UPDATE_USER"/>
  25. <result property="updateTime" column="UPDATE_TIME"/>
  26. <result property="remark" column="REMARK"/>
  27. <result property="tplWebType" column="TPL_WEB_TYPE"/>
  28. <result property="isDeleted" column="IS_DELETED"/>
  29. <collection property="columns" javaType="java.util.List" resultMap="GenTableColumnResult" />
  30. </resultMap>
  31. <resultMap type="GenTableColumn" id="GenTableColumnResult">
  32. <id property="columnId" column="column_id" />
  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="createUser" column="CREATE_USER" />
  51. <result property="createTime" column="create_time" />
  52. <result property="updateUser" column="UPDATE_USER" />
  53. <result property="updateTime" column="update_time" />
  54. </resultMap>
  55. <sql id="baseVo">
  56. 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_USER, CREATE_TIME, UPDATE_USER, UPDATE_TIME, REMARK, TPL_WEB_TYPE, IS_DELETED
  57. from SYS_GEN_TABLE
  58. </sql>
  59. <select id="selectList" parameterType="GenTableQuery" resultMap="GenTableResult">
  60. <include refid="baseVo"/>
  61. <where>
  62. <if test="tableName != null and tableName != ''">
  63. and TABLE_NAME like concat('%', #{tableName}, '%')
  64. </if>
  65. <if test="tableComment != null and tableComment != ''">
  66. and TABLE_COMMENT = #{tableComment}
  67. </if>
  68. <if test="subTableName != null and subTableName != ''">
  69. and SUB_TABLE_NAME like concat('%', #{subTableName}, '%')
  70. </if>
  71. <if test="subTableFkName != null and subTableFkName != ''">
  72. and SUB_TABLE_FK_NAME like concat('%', #{subTableFkName}, '%')
  73. </if>
  74. <if test="className != null and className != ''">
  75. and CLASS_NAME like concat('%', #{className}, '%')
  76. </if>
  77. <if test="tplCategory != null and tplCategory != ''">
  78. and TPL_CATEGORY = #{tplCategory}
  79. </if>
  80. <if test="packageName != null and packageName != ''">
  81. and PACKAGE_NAME like concat('%', #{packageName}, '%')
  82. </if>
  83. <if test="moduleName != null and moduleName != ''">
  84. and MODULE_NAME like concat('%', #{moduleName}, '%')
  85. </if>
  86. <if test="businessName != null and businessName != ''">
  87. and BUSINESS_NAME like concat('%', #{businessName}, '%')
  88. </if>
  89. <if test="functionName != null and functionName != ''">
  90. and FUNCTION_NAME like concat('%', #{functionName}, '%')
  91. </if>
  92. <if test="functionAuthor != null and functionAuthor != ''">
  93. and FUNCTION_AUTHOR = #{functionAuthor}
  94. </if>
  95. <if test="genType != null and genType != ''">
  96. and GEN_TYPE = #{genType}
  97. </if>
  98. <if test="genPath != null and genPath != ''">
  99. and GEN_PATH = #{genPath}
  100. </if>
  101. <if test="options != null and options != ''">
  102. and OPTIONS = #{options}
  103. </if>
  104. <if test="beginDate != null and beginDate != ''">
  105. and UPDATE_TIME &gt;= #{beginDate}
  106. </if>
  107. <if test="endDate != null and endDate != ''">
  108. and UPDATE_TIME &lt;= #{endDate}
  109. </if>
  110. <if test="tplWebType != null and tplWebType != ''">
  111. and TPL_WEB_TYPE = #{tplWebType}
  112. </if>
  113. </where>
  114. </select>
  115. <select id="selectByTableId" parameterType="String"
  116. resultMap="GenTableResult">
  117. <include refid="baseVo"/>
  118. where TABLE_ID = #{tableId}
  119. </select>
  120. <select id="selectGenTableAll" parameterType="String" resultMap="GenTableResult">
  121. 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,
  122. 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, coalesce(c.dict_type,'') as dict_type, c.sort
  123. FROM sys_gen_table t
  124. LEFT JOIN sys_gen_table_column c ON t.table_id = c.table_id
  125. order by c.sort
  126. </select>
  127. <select id="selectDbTableList" parameterType="GenTableQuery" resultMap="GenTableResult">
  128. SELECT
  129. t.TABLE_NAME as TABLE_NAME,
  130. t.COMMENTS as TABLE_COMMENT,
  131. SYSDATE as CREATE_TIME,
  132. SYSDATE as UPDATE_TIME
  133. FROM ALL_TAB_COMMENTS t
  134. WHERE t.OWNER = (SELECT USER FROM DUAL)
  135. AND t.TABLE_NAME NOT LIKE 'QRTZ_%'
  136. AND t.TABLE_NAME NOT LIKE 'GEN_%'
  137. AND t.TABLE_NAME NOT LIKE 'SYS_GEN_%'
  138. AND t.TABLE_NAME NOT IN (SELECT table_name FROM sys_gen_table)
  139. <if test="tableName != null and tableName != ''">
  140. AND LOWER(t.TABLE_NAME) LIKE LOWER(CONCAT(CONCAT('%', #{tableName}), '%'))
  141. </if>
  142. <if test="tableComment != null and tableComment != ''">
  143. AND LOWER(t.COMMENTS) LIKE LOWER(CONCAT(CONCAT('%', #{tableComment}), '%'))
  144. </if>
  145. ORDER BY t.TABLE_NAME
  146. </select>
  147. <select id="selectDbTableListByNames" resultMap="GenTableResult">
  148. SELECT
  149. t.TABLE_NAME as TABLE_NAME,
  150. t.COMMENTS as TABLE_COMMENT,
  151. SYSDATE as CREATE_TIME,
  152. SYSDATE as UPDATE_TIME
  153. FROM ALL_TAB_COMMENTS t
  154. WHERE t.OWNER = (SELECT USER FROM DUAL)
  155. AND t.TABLE_NAME NOT LIKE 'QRTZ_%'
  156. AND t.TABLE_NAME NOT LIKE 'GEN_%'
  157. AND t.TABLE_NAME NOT LIKE 'SYS_GEN_%'
  158. AND t.TABLE_NAME IN
  159. <foreach collection="array" item="name" open="(" separator="," close=")">
  160. #{name}
  161. </foreach>
  162. </select>
  163. <select id="selectGenTableByName" resultMap="GenTableResult">
  164. 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,
  165. 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, coalesce(c.dict_type,'') as dict_type, c.sort
  166. FROM SYS_GEN_TABLE t
  167. LEFT JOIN sys_gen_table_column c ON t.table_id = c.table_id
  168. where t.table_name = #{tableName} order by c.sort
  169. </select>
  170. <insert id="insert" parameterType="GenTable" useGeneratedKeys="true" keyProperty="tableId">
  171. insert into SYS_GEN_TABLE
  172. <trim prefix="(" suffix=")" suffixOverrides=",">
  173. <if test="tableId != null and tableId != ''">TABLE_ID,
  174. </if>
  175. <if test="tableName != null">TABLE_NAME,
  176. </if>
  177. <if test="tableComment != null">TABLE_COMMENT,
  178. </if>
  179. <if test="subTableName != null">SUB_TABLE_NAME,
  180. </if>
  181. <if test="subTableFkName != null">SUB_TABLE_FK_NAME,
  182. </if>
  183. <if test="className != null">CLASS_NAME,
  184. </if>
  185. <if test="tplCategory != null">TPL_CATEGORY,
  186. </if>
  187. <if test="packageName != null">PACKAGE_NAME,
  188. </if>
  189. <if test="moduleName != null">MODULE_NAME,
  190. </if>
  191. <if test="businessName != null">BUSINESS_NAME,
  192. </if>
  193. <if test="functionName != null">FUNCTION_NAME,
  194. </if>
  195. <if test="functionAuthor != null">FUNCTION_AUTHOR,
  196. </if>
  197. <if test="genType != null">GEN_TYPE,
  198. </if>
  199. <if test="genPath != null">GEN_PATH,
  200. </if>
  201. <if test="options != null">OPTIONS,
  202. </if>
  203. <if test="createUser != null">CREATE_USER,
  204. </if>
  205. <if test="createTime != null">CREATE_TIME,
  206. </if>
  207. <if test="updateUser != null">UPDATE_USER,
  208. </if>
  209. <if test="updateTime != null">UPDATE_TIME,
  210. </if>
  211. <if test="remark != null">REMARK,
  212. </if>
  213. <if test="tplWebType != null">TPL_WEB_TYPE,
  214. </if>
  215. <if test="isDeleted != null">IS_DELETED,
  216. </if>
  217. </trim>
  218. <trim prefix="values (" suffix=")" suffixOverrides=",">
  219. <if test="tableId != null and tableId != ''">#{tableId},
  220. </if>
  221. <if test="tableName != null">#{tableName},
  222. </if>
  223. <if test="tableComment != null">#{tableComment},
  224. </if>
  225. <if test="subTableName != null">#{subTableName},
  226. </if>
  227. <if test="subTableFkName != null">#{subTableFkName},
  228. </if>
  229. <if test="className != null">#{className},
  230. </if>
  231. <if test="tplCategory != null">#{tplCategory},
  232. </if>
  233. <if test="packageName != null">#{packageName},
  234. </if>
  235. <if test="moduleName != null">#{moduleName},
  236. </if>
  237. <if test="businessName != null">#{businessName},
  238. </if>
  239. <if test="functionName != null">#{functionName},
  240. </if>
  241. <if test="functionAuthor != null">#{functionAuthor},
  242. </if>
  243. <if test="genType != null">#{genType},
  244. </if>
  245. <if test="genPath != null">#{genPath},
  246. </if>
  247. <if test="options != null">#{options},
  248. </if>
  249. <if test="createUser != null">#{createUser},
  250. </if>
  251. <if test="createTime != null">#{createTime},
  252. </if>
  253. <if test="updateUser != null">#{updateUser},
  254. </if>
  255. <if test="updateTime != null">#{updateTime},
  256. </if>
  257. <if test="remark != null">#{remark},
  258. </if>
  259. <if test="tplWebType != null">#{tplWebType},
  260. </if>
  261. <if test="isDeleted != null">#{isDeleted},
  262. </if>
  263. </trim>
  264. </insert>
  265. <update id="update" parameterType="GenTable">
  266. update SYS_GEN_TABLE
  267. <trim prefix="SET" suffixOverrides=",">
  268. <if test="tableName != null">TABLE_NAME =
  269. #{tableName},
  270. </if>
  271. <if test="tableComment != null">TABLE_COMMENT =
  272. #{tableComment},
  273. </if>
  274. <if test="subTableName != null">SUB_TABLE_NAME =
  275. #{subTableName},
  276. </if>
  277. <if test="subTableFkName != null">SUB_TABLE_FK_NAME =
  278. #{subTableFkName},
  279. </if>
  280. <if test="className != null">CLASS_NAME =
  281. #{className},
  282. </if>
  283. <if test="tplCategory != null">TPL_CATEGORY =
  284. #{tplCategory},
  285. </if>
  286. <if test="packageName != null">PACKAGE_NAME =
  287. #{packageName},
  288. </if>
  289. <if test="moduleName != null">MODULE_NAME =
  290. #{moduleName},
  291. </if>
  292. <if test="businessName != null">BUSINESS_NAME =
  293. #{businessName},
  294. </if>
  295. <if test="functionName != null">FUNCTION_NAME =
  296. #{functionName},
  297. </if>
  298. <if test="functionAuthor != null">FUNCTION_AUTHOR =
  299. #{functionAuthor},
  300. </if>
  301. <if test="genType != null">GEN_TYPE =
  302. #{genType},
  303. </if>
  304. <if test="genPath != null">GEN_PATH =
  305. #{genPath},
  306. </if>
  307. <if test="options != null">OPTIONS =
  308. #{options},
  309. </if>
  310. <if test="createUser != null">CREATE_USER =
  311. #{createUser},
  312. </if>
  313. <if test="createTime != null">CREATE_TIME =
  314. #{createTime},
  315. </if>
  316. <if test="updateUser != null">UPDATE_USER =
  317. #{updateUser},
  318. </if>
  319. <if test="updateTime != null">UPDATE_TIME =
  320. #{updateTime},
  321. </if>
  322. <if test="remark != null">REMARK =
  323. #{remark},
  324. </if>
  325. <if test="tplWebType != null">TPL_WEB_TYPE =
  326. #{tplWebType},
  327. </if>
  328. <if test="isDeleted != null">IS_DELETED =
  329. #{isDeleted},
  330. </if>
  331. </trim>
  332. where TABLE_ID = #{tableId}
  333. </update>
  334. <delete id="deleteByTableId" parameterType="String">
  335. delete
  336. from SYS_GEN_TABLE where TABLE_ID = #{tableId}
  337. </delete>
  338. <delete id="deleteByTableIds" parameterType="String">
  339. delete from SYS_GEN_TABLE where TABLE_ID in
  340. <foreach item="tableId" collection="array" open="(" separator="," close=")">
  341. #{tableId}
  342. </foreach>
  343. </delete>
  344. <delete id="logicDelete" parameterType="String">
  345. update SYS_GEN_TABLE set is_del = 1 where TABLE_ID = #{tableId}
  346. </delete>
  347. </mapper>