GenTableColumnMapper.xml 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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="com.phm.generator.mapper.GenTableColumnMapper">
  6. <resultMap type="GenTableColumn" id="GenTableColumnResult">
  7. <id 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="createBy" column="create_by"/>
  26. <result property="createTime" column="create_time"/>
  27. <result property="updateBy" column="update_by"/>
  28. <result property="updateTime" column="update_time"/>
  29. </resultMap>
  30. <sql id="selectGenTableColumnVo">
  31. select column_id,
  32. table_id,
  33. column_name,
  34. column_comment,
  35. column_type,
  36. java_type,
  37. java_field,
  38. is_pk,
  39. is_increment,
  40. is_required,
  41. is_insert,
  42. is_edit,
  43. is_list,
  44. is_query,
  45. query_type,
  46. html_type,
  47. dict_type,
  48. sort,
  49. create_by,
  50. create_time,
  51. update_by,
  52. update_time
  53. from PHM.GEN_TABLE_COLUMN
  54. </sql>
  55. <select id="selectGenTableColumnListByTableId" parameterType="Long" resultMap="GenTableColumnResult">
  56. <include refid="selectGenTableColumnVo"/>
  57. where table_id = #{tableId}
  58. order by sort
  59. </select>
  60. <!-- RuoYi-vue 3.8.5版本,主要增加了(is_required是否必填属性) -->
  61. <select id="selectDbTableColumnsByName" parameterType="String" resultMap="GenTableColumnResult">
  62. select sc.NAME column_name,
  63. (case when sc.NULLABLE$ = 'N' then '1' else null end) as is_required,
  64. (case when sc.INFO2 = 1 then '1' else '0' end) is_pk,
  65. sc.COLID sort,
  66. scc.COMMENT$ column_comment,
  67. (case when sc.INFO2 = 1 then '1' else '0' end) as is_increment,
  68. LOWER(sc.TYPE$) column_type
  69. from SYS.SYSCOLUMNS sc
  70. left join SYS.SYSOBJECTS so on sc.ID = so.ID
  71. left join SYS.SYSCOLUMNCOMMENTS SCC on sc.NAME = scc.COLNAME and scc.TABLE_TYPE = 'TABLE' and
  72. scc.SCHNAME = (select CURR_SCH from V$SESSIONS LIMIT 1) and
  73. scc.TVNAME = so.NAME
  74. where so.TYPE$ = 'SCHOBJ'
  75. and so.SUBTYPE$ = 'UTAB'
  76. and so.PID = -1
  77. and so.SCHID =
  78. (select ID from SYS.SYSOBJECTS where TYPE$ = 'SCH' and NAME = (select CURR_SCH from V$SESSIONS LIMIT 1))
  79. and so.NAME = #{tableName}
  80. order by sc.COLID
  81. </select>
  82. <insert id="insertGenTableColumn" parameterType="GenTableColumn" useGeneratedKeys="true" keyProperty="columnId">
  83. insert into PHM.GEN_TABLE_COLUMN (
  84. <if test="tableId != null and tableId != ''">table_id,</if>
  85. <if test="columnName != null and columnName != ''">column_name,</if>
  86. <if test="columnComment != null and columnComment != ''">column_comment,</if>
  87. <if test="columnType != null and columnType != ''">column_type,</if>
  88. <if test="javaType != null and javaType != ''">java_type,</if>
  89. <if test="javaField != null and javaField != ''">java_field,</if>
  90. <if test="isPk != null and isPk != ''">is_pk,</if>
  91. <if test="isIncrement != null and isIncrement != ''">is_increment,</if>
  92. <if test="isRequired != null and isRequired != ''">is_required,</if>
  93. <if test="isInsert != null and isInsert != ''">is_insert,</if>
  94. <if test="isEdit != null and isEdit != ''">is_edit,</if>
  95. <if test="isList != null and isList != ''">is_list,</if>
  96. <if test="isQuery != null and isQuery != ''">is_query,</if>
  97. <if test="queryType != null and queryType != ''">query_type,</if>
  98. <if test="htmlType != null and htmlType != ''">html_type,</if>
  99. <if test="dictType != null and dictType != ''">dict_type,</if>
  100. <if test="sort != null">sort,</if>
  101. <if test="createBy != null and createBy != ''">create_by,</if>
  102. create_time
  103. )values(
  104. <if test="tableId != null and tableId != ''">#{tableId},</if>
  105. <if test="columnName != null and columnName != ''">#{columnName},</if>
  106. <if test="columnComment != null and columnComment != ''">#{columnComment},</if>
  107. <if test="columnType != null and columnType != ''">#{columnType},</if>
  108. <if test="javaType != null and javaType != ''">#{javaType},</if>
  109. <if test="javaField != null and javaField != ''">#{javaField},</if>
  110. <if test="isPk != null and isPk != ''">#{isPk},</if>
  111. <if test="isIncrement != null and isIncrement != ''">#{isIncrement},</if>
  112. <if test="isRequired != null and isRequired != ''">#{isRequired},</if>
  113. <if test="isInsert != null and isInsert != ''">#{isInsert},</if>
  114. <if test="isEdit != null and isEdit != ''">#{isEdit},</if>
  115. <if test="isList != null and isList != ''">#{isList},</if>
  116. <if test="isQuery != null and isQuery != ''">#{isQuery},</if>
  117. <if test="queryType != null and queryType != ''">#{queryType},</if>
  118. <if test="htmlType != null and htmlType != ''">#{htmlType},</if>
  119. <if test="dictType != null and dictType != ''">#{dictType},</if>
  120. <if test="sort != null">#{sort},</if>
  121. <if test="createBy != null and createBy != ''">#{createBy},</if>
  122. sysdate()
  123. )
  124. </insert>
  125. <update id="updateGenTableColumn" parameterType="GenTableColumn">
  126. update PHM.GEN_TABLE_COLUMN
  127. <set>
  128. <if test="columnComment != null">column_comment = #{columnComment},</if>
  129. <if test="javaType != null">java_type = #{javaType},</if>
  130. <if test="javaField != null">java_field = #{javaField},</if>
  131. <if test="isInsert != null">is_insert = #{isInsert},</if>
  132. <if test="isEdit != null">is_edit = #{isEdit},</if>
  133. <if test="isList != null">is_list = #{isList},</if>
  134. <if test="isQuery != null">is_query = #{isQuery},</if>
  135. <if test="isRequired != null">is_required = #{isRequired},</if>
  136. <if test="queryType != null">query_type = #{queryType},</if>
  137. <if test="htmlType != null">html_type = #{htmlType},</if>
  138. <if test="dictType != null">dict_type = #{dictType},</if>
  139. <if test="sort != null">sort = #{sort},</if>
  140. <if test="updateBy != null">update_by = #{updateBy},</if>
  141. update_time = sysdate()
  142. </set>
  143. where column_id = #{columnId}
  144. </update>
  145. <delete id="deleteGenTableColumnByIds" parameterType="Long">
  146. delete from PHM.GEN_TABLE_COLUMN where table_id in
  147. <foreach collection="array" item="tableId" open="(" separator="," close=")">
  148. #{tableId}
  149. </foreach>
  150. </delete>
  151. <delete id="deleteGenTableColumns">
  152. delete from PHM.GEN_TABLE_COLUMN where column_id in
  153. <foreach collection="list" item="item" open="(" separator="," close=")">
  154. #{item.columnId}
  155. </foreach>
  156. </delete>
  157. </mapper>