GenMapper.xml 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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.juxiao.xchat.module.tool.mapper.GenMapper">
  6. <resultMap type="com.juxiao.xchat.module.tool.domain.TableInfo" id="TableInfoResult">
  7. <id property="tableName" column="table_name" />
  8. <result property="tableComment" column="table_comment" />
  9. <result property="createTime" column="create_time" />
  10. <result property="updateTime" column="update_time" />
  11. </resultMap>
  12. <resultMap type="com.juxiao.xchat.module.tool.domain.ColumnInfo" id="ColumnInfoResult">
  13. <id property="columnName" column="column_name" />
  14. <result property="dataType" column="data_type" />
  15. <result property="columnComment" column="column_comment" />
  16. <result column="extra" property="extra"/>
  17. </resultMap>
  18. <sql id="selectGenVo">
  19. select table_name, table_comment, create_time, update_time from information_schema.tables
  20. </sql>
  21. <select id="selectTableList" parameterType="com.juxiao.xchat.module.tool.domain.TableInfo" resultMap="TableInfoResult">
  22. <include refid="selectGenVo"/>
  23. where table_comment <![CDATA[ <> ]]> '' and table_schema = (select database())
  24. <if test="tableName != null and tableName != ''">
  25. AND table_name like concat('%', #{tableName}, '%')
  26. </if>
  27. <if test="tableComment != null and tableComment != ''">
  28. AND table_comment like concat('%', #{tableComment}, '%')
  29. </if>
  30. <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
  31. and date_format(create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
  32. </if>
  33. <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
  34. and date_format(create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
  35. </if>
  36. </select>
  37. <select id="selectTableByName" parameterType="java.lang.String" resultMap="TableInfoResult">
  38. <include refid="selectGenVo"/>
  39. where table_comment <![CDATA[ <> ]]> '' and table_schema = (select database())
  40. and table_name = #{tableName}
  41. </select>
  42. <select id="selectTableColumnsByName" parameterType="java.lang.String" resultMap="ColumnInfoResult">
  43. select column_name, data_type, column_comment, extra from information_schema.columns
  44. where table_name = #{tableName} and table_schema = (select database()) order by ordinal_position
  45. </select>
  46. </mapper>