TableMapper.xml 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  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. ORDER BY
  23. table_name
  24. </select>
  25. <insert id="savePrice">
  26. INSERT ${tableName} ( id, bid, ask ) VALUE (${id}, ${bid}, ${ask})on duplicate key update bid = ${bid}, ask = ${ask}
  27. </insert>
  28. <select id="getPriceInfo" resultType="com.liangjiang.price_collection.dto.PriceInfoDto">
  29. select id, bid, ask from ${tableName} where id > ${timeEnd}
  30. </select>
  31. </mapper>