TableMapper.xml 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.liangjiang.price_collection.mapper.TableMapper">
  4. <!-- 创建数据表 -->
  5. <update id="createTable" parameterType="java.lang.String">
  6. CREATE TABLE IF NOT EXISTS ${tableName} (
  7. `id` INT UNSIGNED NOT NULL,
  8. `bid` VARCHAR(128) NOT NULL,
  9. `ask` VARCHAR(128) NOT NULL,
  10. PRIMARY KEY (`id`)
  11. )
  12. </update>
  13. <!-- 获取所有数据表格 -->
  14. <select id="getTableName" resultType="java.lang.String">
  15. SELECT
  16. table_name
  17. FROM
  18. information_schema.TABLES
  19. WHERE
  20. table_type = 'BASE TABLE'
  21. AND table_schema = 'one_price_warehouse'
  22. and table_name != 'info_backups'
  23. ORDER BY
  24. table_name
  25. </select>
  26. <insert id="savePrice">
  27. INSERT ${tableName} ( id, bid, ask ) VALUE (${id}, ${bid}, ${ask})on duplicate key update bid = ${bid}, ask = ${ask}
  28. </insert>
  29. <select id="getPriceInfo" resultType="com.liangjiang.price_collection.dto.PriceDto">
  30. select id as `time`, bid, ask from ${tableName} where id between ${startTime} and ${endTime}
  31. </select>
  32. </mapper>