GenTableMapper.xml 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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.generator.mapper.GenTableMapper">
  6. <select id="selectDbTableList" parameterType="GenTable" resultMap="GenTableResult">
  7. select table_name, table_comment, create_time, update_time from information_schema.tables
  8. where table_schema = (select database())
  9. AND table_name NOT LIKE 'qrtz_%' AND table_name NOT LIKE 'gen_%'
  10. AND table_name NOT IN (select table_name from gen_table)
  11. <if test="tableName != null and tableName != ''">
  12. AND lower(table_name) like lower(concat('%', #{tableName}, '%'))
  13. </if>
  14. <if test="tableComment != null and tableComment != ''">
  15. AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
  16. </if>
  17. <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
  18. AND date_format(create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
  19. </if>
  20. <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
  21. AND date_format(create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
  22. </if>
  23. </select>
  24. <select id="selectDbTableListByNames" resultMap="GenTableResult">
  25. select table_name, table_comment, create_time, update_time from information_schema.tables
  26. where table_name NOT LIKE 'qrtz_%' and table_name NOT LIKE 'gen_%' and table_schema = (select database())
  27. and table_name in
  28. <foreach collection="array" item="name" open="(" separator="," close=")">
  29. #{name}
  30. </foreach>
  31. </select>
  32. <select id="selectTableByName" parameterType="String" resultMap="GenTableResult">
  33. select table_name, table_comment, create_time, update_time from information_schema.tables
  34. where table_comment <![CDATA[ <> ]]> '' and table_schema = (select database())
  35. and table_name = #{tableName}
  36. </select>
  37. <select id="selectGenTableById" parameterType="Long" resultMap="GenTableResult">
  38. SELECT t.table_id, t.table_name, t.table_comment, 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,
  39. 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
  40. FROM gen_table t
  41. LEFT JOIN gen_table_column c ON t.table_id = c.table_id
  42. where t.table_id = #{tableId} order by c.sort
  43. </select>
  44. <select id="selectGenTableByName" parameterType="String" resultMap="GenTableResult">
  45. SELECT t.table_id, t.table_name, t.table_comment, 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,
  46. 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
  47. FROM gen_table t
  48. LEFT JOIN gen_table_column c ON t.table_id = c.table_id
  49. where t.table_name = #{tableName} order by c.sort
  50. </select>
  51. <insert id="insertGenTable" parameterType="GenTable" useGeneratedKeys="true" keyProperty="tableId">
  52. insert into gen_table (
  53. <if test="tableName != null">table_name,</if>
  54. <if test="tableComment != null and tableComment != ''">table_comment,</if>
  55. <if test="className != null and className != ''">class_name,</if>
  56. <if test="tplCategory != null and tplCategory != ''">tpl_category,</if>
  57. <if test="packageName != null and packageName != ''">package_name,</if>
  58. <if test="moduleName != null and moduleName != ''">module_name,</if>
  59. <if test="businessName != null and businessName != ''">business_name,</if>
  60. <if test="functionName != null and functionName != ''">function_name,</if>
  61. <if test="functionAuthor != null and functionAuthor != ''">function_author,</if>
  62. <if test="genType != null and genType != ''">gen_type,</if>
  63. <if test="genPath != null and genPath != ''">gen_path,</if>
  64. <if test="remark != null and remark != ''">remark,</if>
  65. <if test="createBy != null and createBy != ''">create_by,</if>
  66. create_time
  67. )values(
  68. <if test="tableName != null">#{tableName},</if>
  69. <if test="tableComment != null and tableComment != ''">#{tableComment},</if>
  70. <if test="className != null and className != ''">#{className},</if>
  71. <if test="tplCategory != null and tplCategory != ''">#{tplCategory},</if>
  72. <if test="packageName != null and packageName != ''">#{packageName},</if>
  73. <if test="moduleName != null and moduleName != ''">#{moduleName},</if>
  74. <if test="businessName != null and businessName != ''">#{businessName},</if>
  75. <if test="functionName != null and functionName != ''">#{functionName},</if>
  76. <if test="functionAuthor != null and functionAuthor != ''">#{functionAuthor},</if>
  77. <if test="genType != null and genType != ''">#{genType},</if>
  78. <if test="genPath != null and genPath != ''">#{genPath},</if>
  79. <if test="remark != null and remark != ''">#{remark},</if>
  80. <if test="createBy != null and createBy != ''">#{createBy},</if>
  81. sysdate()
  82. )
  83. </insert>
  84. <update id="updateGenTable" parameterType="GenTable">
  85. update gen_table
  86. <set>
  87. <if test="tableName != null">table_name = #{tableName},</if>
  88. <if test="tableComment != null and tableComment != ''">table_comment = #{tableComment},</if>
  89. <if test="className != null and className != ''">class_name = #{className},</if>
  90. <if test="functionAuthor != null and functionAuthor != ''">function_author = #{functionAuthor},</if>
  91. <if test="genType != null and genType != ''">gen_type = #{genType},</if>
  92. <if test="genPath != null and genPath != ''">gen_path = #{genPath},</if>
  93. <if test="tplCategory != null and tplCategory != ''">tpl_category = #{tplCategory},</if>
  94. <if test="packageName != null and packageName != ''">package_name = #{packageName},</if>
  95. <if test="moduleName != null and moduleName != ''">module_name = #{moduleName},</if>
  96. <if test="businessName != null and businessName != ''">business_name = #{businessName},</if>
  97. <if test="functionName != null and functionName != ''">function_name = #{functionName},</if>
  98. <if test="options != null and options != ''">options = #{options},</if>
  99. <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
  100. <if test="remark != null">remark = #{remark},</if>
  101. update_time = sysdate()
  102. </set>
  103. where table_id = #{tableId}
  104. </update>
  105. <delete id="deleteGenTableByIds" parameterType="Long">
  106. delete from gen_table where table_id in
  107. <foreach collection="array" item="tableId" open="(" separator="," close=")">
  108. #{tableId}
  109. </foreach>
  110. </delete>
  111. </mapper>