GenTableColumnMapper.xml 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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.ruoyi.gen.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, 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
  32. </sql>
  33. <select id="selectGenTableColumnListByTableId" parameterType="GenTableColumn" resultMap="GenTableColumnResult">
  34. <include refid="selectGenTableColumnVo"/>
  35. where table_id = #{tableId}
  36. order by sort
  37. </select>
  38. <select id="selectDbTableColumnsByName" parameterType="String" resultMap="GenTableColumnResult">
  39. select column_name, (case when (is_nullable = 'no' <![CDATA[ && ]]> column_key != 'PRI') then '1' else null 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
  40. from information_schema.columns where table_schema = (select database()) and table_name = (#{tableName})
  41. order by ordinal_position
  42. </select>
  43. <insert id="insertGenTableColumn" parameterType="GenTableColumn" useGeneratedKeys="true" keyProperty="columnId">
  44. insert into gen_table_column (
  45. <if test="tableId != null and tableId != ''">table_id,</if>
  46. <if test="columnName != null and columnName != ''">column_name,</if>
  47. <if test="columnComment != null and columnComment != ''">column_comment,</if>
  48. <if test="columnType != null and columnType != ''">column_type,</if>
  49. <if test="javaType != null and javaType != ''">java_type,</if>
  50. <if test="javaField != null and javaField != ''">java_field,</if>
  51. <if test="isPk != null and isPk != ''">is_pk,</if>
  52. <if test="isIncrement != null and isIncrement != ''">is_increment,</if>
  53. <if test="isRequired != null and isRequired != ''">is_required,</if>
  54. <if test="isInsert != null and isInsert != ''">is_insert,</if>
  55. <if test="isEdit != null and isEdit != ''">is_edit,</if>
  56. <if test="isList != null and isList != ''">is_list,</if>
  57. <if test="isQuery != null and isQuery != ''">is_query,</if>
  58. <if test="queryType != null and queryType != ''">query_type,</if>
  59. <if test="htmlType != null and htmlType != ''">html_type,</if>
  60. <if test="dictType != null and dictType != ''">dict_type,</if>
  61. <if test="sort != null">sort,</if>
  62. <if test="createBy != null and createBy != ''">create_by,</if>
  63. create_time
  64. )values(
  65. <if test="tableId != null and tableId != ''">#{tableId},</if>
  66. <if test="columnName != null and columnName != ''">#{columnName},</if>
  67. <if test="columnComment != null and columnComment != ''">#{columnComment},</if>
  68. <if test="columnType != null and columnType != ''">#{columnType},</if>
  69. <if test="javaType != null and javaType != ''">#{javaType},</if>
  70. <if test="javaField != null and javaField != ''">#{javaField},</if>
  71. <if test="isPk != null and isPk != ''">#{isPk},</if>
  72. <if test="isIncrement != null and isIncrement != ''">#{isIncrement},</if>
  73. <if test="isRequired != null and isRequired != ''">#{isRequired},</if>
  74. <if test="isInsert != null and isInsert != ''">#{isInsert},</if>
  75. <if test="isEdit != null and isEdit != ''">#{isEdit},</if>
  76. <if test="isList != null and isList != ''">#{isList},</if>
  77. <if test="isQuery != null and isQuery != ''">#{isQuery},</if>
  78. <if test="queryType != null and queryType != ''">#{queryType},</if>
  79. <if test="htmlType != null and htmlType != ''">#{htmlType},</if>
  80. <if test="dictType != null and dictType != ''">#{dictType},</if>
  81. <if test="sort != null">#{sort},</if>
  82. <if test="createBy != null and createBy != ''">#{createBy},</if>
  83. sysdate()
  84. )
  85. </insert>
  86. <update id="updateGenTableColumn" parameterType="GenTableColumn">
  87. update gen_table_column
  88. <set>
  89. column_comment = #{columnComment},
  90. java_type = #{javaType},
  91. java_field = #{javaField},
  92. is_insert = #{isInsert},
  93. is_edit = #{isEdit},
  94. is_list = #{isList},
  95. is_query = #{isQuery},
  96. is_required = #{isRequired},
  97. query_type = #{queryType},
  98. html_type = #{htmlType},
  99. dict_type = #{dictType},
  100. sort = #{sort},
  101. update_by = #{updateBy},
  102. update_time = sysdate()
  103. </set>
  104. where column_id = #{columnId}
  105. </update>
  106. <delete id="deleteGenTableColumnByIds" parameterType="Long">
  107. delete from gen_table_column where table_id in
  108. <foreach collection="array" item="tableId" open="(" separator="," close=")">
  109. #{tableId}
  110. </foreach>
  111. </delete>
  112. <delete id="deleteGenTableColumns">
  113. delete from gen_table_column where column_id in
  114. <foreach collection="list" item="item" open="(" separator="," close=")">
  115. #{item.columnId}
  116. </foreach>
  117. </delete>
  118. </mapper>