You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.8 KiB

4 months ago
4 months ago
4 months ago
  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.example.demo.mapper.coin.MarketMapper">
  4. <select id="getMarket" resultType="com.example.demo.domain.entity.Market">
  5. select * from market
  6. </select>
  7. <!-- 根据名称列表查询对应的市场ID及其子市场ID -->
  8. <select id="getMarketIds" parameterType="java.util.List" resultType="java.lang.String">
  9. SELECT id
  10. FROM market
  11. WHERE
  12. -- 匹配名称的市场ID
  13. name IN
  14. <foreach collection="list" item="name" open="(" separator="," close=")">
  15. #{name}
  16. </foreach>
  17. OR
  18. -- 父ID是上述市场ID的子市场
  19. parent_id IN (
  20. SELECT id
  21. FROM market
  22. WHERE name IN
  23. <foreach collection="list" item="name" open="(" separator="," close=")">
  24. #{name}
  25. </foreach>
  26. )
  27. </select>
  28. <select id="getMarketId" resultType="java.lang.String">
  29. select id from market where name=#{market}
  30. </select>
  31. <select id="getMarketIdDao" resultType="com.example.demo.domain.entity.Market">
  32. select * from markets where name=#{country}
  33. </select>
  34. <select id="getMarketIdBytype" resultType="com.example.demo.domain.entity.Market">
  35. select * from market where parent_id=#{parentId}
  36. </select>
  37. <select id="getMarketById" resultType="java.lang.String">
  38. select name from market where id=#{market}
  39. </select>
  40. <select id="getMarketByIds" resultType="com.example.demo.domain.entity.Market">
  41. select id,name from market where id in
  42. <foreach collection="marketIds" item="marketId" open="(" separator="," close=")">
  43. #{marketId}
  44. </foreach>
  45. </select>
  46. </mapper>