GenTableColumnMapper.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  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.GenTableColumnMapper">
  6. <resultMap type="GenTableColumn" id="GenTableColumnResult">
  7. <result property="columnId" column="COLUMN_ID"/>
  8. <result property="tableId" column="TABLE_ID"/>
  9. <result property="columnName" column="COLUMN_NAME"/>
  10. <result property="columnComment" column="COLUMN_COMMENT"/>
  11. <result property="columnType" column="COLUMN_TYPE"/>
  12. <result property="javaType" column="JAVA_TYPE"/>
  13. <result property="javaField" column="JAVA_FIELD"/>
  14. <result property="isPk" column="IS_PK"/>
  15. <result property="isIncrement" column="IS_INCREMENT"/>
  16. <result property="isRequired" column="IS_REQUIRED"/>
  17. <result property="isInsert" column="IS_INSERT"/>
  18. <result property="isEdit" column="IS_EDIT"/>
  19. <result property="isList" column="IS_LIST"/>
  20. <result property="isQuery" column="IS_QUERY"/>
  21. <result property="queryType" column="QUERY_TYPE"/>
  22. <result property="htmlType" column="HTML_TYPE"/>
  23. <result property="dictType" column="DICT_TYPE"/>
  24. <result property="sort" column="SORT"/>
  25. <result property="createUser" column="CREATE_USER"/>
  26. <result property="createTime" column="CREATE_TIME"/>
  27. <result property="updateUser" column="UPDATE_USER"/>
  28. <result property="updateTime" column="UPDATE_TIME"/>
  29. <result property="isDeleted" column="IS_DELETED"/>
  30. </resultMap>
  31. <sql id="baseVo">
  32. 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_USER, CREATE_TIME, UPDATE_USER, UPDATE_TIME, IS_DELETED
  33. from SYS_GEN_TABLE_COLUMN
  34. </sql>
  35. <select id="selectList" parameterType="GenTableColumnQuery" resultMap="GenTableColumnResult">
  36. <include refid="baseVo"/>
  37. <where>
  38. <if test="tableId != null and tableId != ''">
  39. and TABLE_ID = #{tableId}
  40. </if>
  41. <if test="columnName != null and columnName != ''">
  42. and COLUMN_NAME like concat('%', #{columnName}, '%')
  43. </if>
  44. <if test="columnComment != null and columnComment != ''">
  45. and COLUMN_COMMENT = #{columnComment}
  46. </if>
  47. <if test="columnType != null and columnType != ''">
  48. and COLUMN_TYPE = #{columnType}
  49. </if>
  50. <if test="javaType != null and javaType != ''">
  51. and JAVA_TYPE = #{javaType}
  52. </if>
  53. <if test="javaField != null and javaField != ''">
  54. and JAVA_FIELD = #{javaField}
  55. </if>
  56. <if test="isPk != null and isPk != ''">
  57. and IS_PK = #{isPk}
  58. </if>
  59. <if test="isIncrement != null and isIncrement != ''">
  60. and IS_INCREMENT = #{isIncrement}
  61. </if>
  62. <if test="isRequired != null and isRequired != ''">
  63. and IS_REQUIRED = #{isRequired}
  64. </if>
  65. <if test="isInsert != null and isInsert != ''">
  66. and IS_INSERT = #{isInsert}
  67. </if>
  68. <if test="isEdit != null and isEdit != ''">
  69. and IS_EDIT = #{isEdit}
  70. </if>
  71. <if test="isList != null and isList != ''">
  72. and IS_LIST = #{isList}
  73. </if>
  74. <if test="isQuery != null and isQuery != ''">
  75. and IS_QUERY = #{isQuery}
  76. </if>
  77. <if test="queryType != null and queryType != ''">
  78. and QUERY_TYPE = #{queryType}
  79. </if>
  80. <if test="htmlType != null and htmlType != ''">
  81. and HTML_TYPE = #{htmlType}
  82. </if>
  83. <if test="dictType != null and dictType != ''">
  84. and DICT_TYPE = #{dictType}
  85. </if>
  86. <if test="sort != null and sort != ''">
  87. and SORT = #{sort}
  88. </if>
  89. <if test="createUser != null and createUser != ''">
  90. and CREATE_USER = #{createUser}
  91. </if>
  92. <if test="createTime != null and createTime != ''">
  93. and CREATE_TIME = #{createTime}
  94. </if>
  95. <if test="updateUser != null and updateUser != ''">
  96. and UPDATE_USER = #{updateUser}
  97. </if>
  98. <if test="updateTime != null and updateTime != ''">
  99. and UPDATE_TIME = #{updateTime}
  100. </if>
  101. <if test="isDeleted != null and isDeleted != ''">
  102. and IS_DELETED = #{isDeleted}
  103. </if>
  104. </where>
  105. </select>
  106. <select id="selectByColumnId" parameterType="String"
  107. resultMap="GenTableColumnResult">
  108. <include refid="baseVo"/>
  109. where COLUMN_ID = #{columnId}
  110. </select>
  111. <select id="selectGenTableColumnListByTableId" parameterType="String" resultType="GenTableColumn">
  112. <include refid="baseVo"/>
  113. where table_id = #{tableId}
  114. order by sort
  115. </select>
  116. <select id="selectDbTableColumnsByName" resultType="GenTableColumn">
  117. SELECT
  118. c.COLUMN_NAME as column_name,
  119. CASE WHEN c.NULLABLE = 'N' THEN '1' ELSE '0' END as is_required,
  120. CASE WHEN pk.COLUMN_NAME IS NOT NULL THEN '1' ELSE '0' END as is_pk,
  121. c.COLUMN_ID as sort,
  122. cc.COMMENTS as column_comment,
  123. '0' as is_increment, <!-- 暂时设为0,不判断自增列 -->
  124. c.DATA_TYPE as column_type
  125. FROM USER_TAB_COLUMNS c
  126. LEFT JOIN USER_COL_COMMENTS cc ON c.TABLE_NAME = cc.TABLE_NAME AND c.COLUMN_NAME = cc.COLUMN_NAME
  127. LEFT JOIN (
  128. SELECT cu.COLUMN_NAME
  129. FROM USER_CONS_COLUMNS cu, USER_CONSTRAINTS au
  130. WHERE cu.CONSTRAINT_NAME = au.CONSTRAINT_NAME
  131. AND au.CONSTRAINT_TYPE = 'P'
  132. AND au.TABLE_NAME = #{tableName}
  133. ) pk ON c.COLUMN_NAME = pk.COLUMN_NAME
  134. WHERE c.TABLE_NAME = #{tableName}
  135. ORDER BY c.COLUMN_ID
  136. </select>
  137. <insert id="insert" parameterType="GenTableColumn">
  138. insert into SYS_GEN_TABLE_COLUMN
  139. <trim prefix="(" suffix=")" suffixOverrides=",">
  140. <if test="columnId != null and columnId != ''">COLUMN_ID,
  141. </if>
  142. <if test="tableId != null">TABLE_ID,
  143. </if>
  144. <if test="columnName != null">COLUMN_NAME,
  145. </if>
  146. <if test="columnComment != null">COLUMN_COMMENT,
  147. </if>
  148. <if test="columnType != null">COLUMN_TYPE,
  149. </if>
  150. <if test="javaType != null">JAVA_TYPE,
  151. </if>
  152. <if test="javaField != null">JAVA_FIELD,
  153. </if>
  154. <if test="isPk != null">IS_PK,
  155. </if>
  156. <if test="isIncrement != null">IS_INCREMENT,
  157. </if>
  158. <if test="isRequired != null">IS_REQUIRED,
  159. </if>
  160. <if test="isInsert != null">IS_INSERT,
  161. </if>
  162. <if test="isEdit != null">IS_EDIT,
  163. </if>
  164. <if test="isList != null">IS_LIST,
  165. </if>
  166. <if test="isQuery != null">IS_QUERY,
  167. </if>
  168. <if test="queryType != null">QUERY_TYPE,
  169. </if>
  170. <if test="htmlType != null">HTML_TYPE,
  171. </if>
  172. <if test="dictType != null">DICT_TYPE,
  173. </if>
  174. <if test="sort != null">SORT,
  175. </if>
  176. <if test="createUser != null">CREATE_USER,
  177. </if>
  178. <if test="createTime != null">CREATE_TIME,
  179. </if>
  180. <if test="updateUser != null">UPDATE_USER,
  181. </if>
  182. <if test="updateTime != null">UPDATE_TIME,
  183. </if>
  184. <if test="isDeleted != null">IS_DELETED,
  185. </if>
  186. </trim>
  187. <trim prefix="values (" suffix=")" suffixOverrides=",">
  188. <if test="columnId != null and columnId != ''">#{columnId},
  189. </if>
  190. <if test="tableId != null">#{tableId},
  191. </if>
  192. <if test="columnName != null">#{columnName},
  193. </if>
  194. <if test="columnComment != null">#{columnComment},
  195. </if>
  196. <if test="columnType != null">#{columnType},
  197. </if>
  198. <if test="javaType != null">#{javaType},
  199. </if>
  200. <if test="javaField != null">#{javaField},
  201. </if>
  202. <if test="isPk != null">#{isPk},
  203. </if>
  204. <if test="isIncrement != null">#{isIncrement},
  205. </if>
  206. <if test="isRequired != null">#{isRequired},
  207. </if>
  208. <if test="isInsert != null">#{isInsert},
  209. </if>
  210. <if test="isEdit != null">#{isEdit},
  211. </if>
  212. <if test="isList != null">#{isList},
  213. </if>
  214. <if test="isQuery != null">#{isQuery},
  215. </if>
  216. <if test="queryType != null">#{queryType},
  217. </if>
  218. <if test="htmlType != null">#{htmlType},
  219. </if>
  220. <if test="dictType != null">#{dictType},
  221. </if>
  222. <if test="sort != null">#{sort},
  223. </if>
  224. <if test="createUser != null">#{createUser},
  225. </if>
  226. <if test="createTime != null">#{createTime},
  227. </if>
  228. <if test="updateUser != null">#{updateUser},
  229. </if>
  230. <if test="updateTime != null">#{updateTime},
  231. </if>
  232. <if test="isDeleted != null">#{isDeleted},
  233. </if>
  234. </trim>
  235. </insert>
  236. <update id="update" parameterType="GenTableColumn">
  237. update SYS_GEN_TABLE_COLUMN
  238. <trim prefix="SET" suffixOverrides=",">
  239. <if test="tableId != null">TABLE_ID =
  240. #{tableId},
  241. </if>
  242. <if test="columnName != null">COLUMN_NAME =
  243. #{columnName},
  244. </if>
  245. <if test="columnComment != null">COLUMN_COMMENT =
  246. #{columnComment},
  247. </if>
  248. <if test="columnType != null">COLUMN_TYPE =
  249. #{columnType},
  250. </if>
  251. <if test="javaType != null">JAVA_TYPE =
  252. #{javaType},
  253. </if>
  254. <if test="javaField != null">JAVA_FIELD =
  255. #{javaField},
  256. </if>
  257. <if test="isPk != null">IS_PK =
  258. #{isPk},
  259. </if>
  260. <if test="isIncrement != null">IS_INCREMENT =
  261. #{isIncrement},
  262. </if>
  263. <if test="isRequired != null">IS_REQUIRED =
  264. #{isRequired},
  265. </if>
  266. <if test="isInsert != null">IS_INSERT =
  267. #{isInsert},
  268. </if>
  269. <if test="isEdit != null">IS_EDIT =
  270. #{isEdit},
  271. </if>
  272. <if test="isList != null">IS_LIST =
  273. #{isList},
  274. </if>
  275. <if test="isQuery != null">IS_QUERY =
  276. #{isQuery},
  277. </if>
  278. <if test="queryType != null">QUERY_TYPE =
  279. #{queryType},
  280. </if>
  281. <if test="htmlType != null">HTML_TYPE =
  282. #{htmlType},
  283. </if>
  284. <if test="dictType != null">DICT_TYPE =
  285. #{dictType},
  286. </if>
  287. <if test="sort != null">SORT =
  288. #{sort},
  289. </if>
  290. <if test="createUser != null">CREATE_USER =
  291. #{createUser},
  292. </if>
  293. <if test="createTime != null">CREATE_TIME =
  294. #{createTime},
  295. </if>
  296. <if test="updateUser != null">UPDATE_USER =
  297. #{updateUser},
  298. </if>
  299. <if test="updateTime != null">UPDATE_TIME =
  300. #{updateTime},
  301. </if>
  302. <if test="isDeleted != null">IS_DELETED =
  303. #{isDeleted},
  304. </if>
  305. </trim>
  306. where COLUMN_ID = #{columnId}
  307. </update>
  308. <delete id="deleteByColumnId" parameterType="String">
  309. delete
  310. from SYS_GEN_TABLE_COLUMN where COLUMN_ID = #{columnId}
  311. </delete>
  312. <delete id="deleteByColumnIds" parameterType="String">
  313. delete from SYS_GEN_TABLE_COLUMN where COLUMN_ID in
  314. <foreach item="columnId" collection="array" open="(" separator="," close=")">
  315. #{columnId}
  316. </foreach>
  317. </delete>
  318. <delete id="logicDelete" parameterType="String">
  319. update SYS_GEN_TABLE_COLUMN set is_del = 1 where COLUMN_ID = #{columnId}
  320. </delete>
  321. <delete id="deleteGenTableColumnByIds">
  322. delete from SYS_GEN_TABLE_COLUMN where table_id in
  323. <foreach collection="array" item="tableId" open="(" separator="," close=")">
  324. #{tableId}
  325. </foreach>
  326. </delete>
  327. <delete id="deleteGenTableColumns">
  328. delete from SYS_GEN_TABLE_COLUMN where column_id in
  329. <foreach collection="list" item="item" open="(" separator="," close=")">
  330. #{item.columnId}
  331. </foreach>
  332. </delete>
  333. </mapper>