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.

69 lines
2.6 KiB

9 months ago
9 months ago
5 months ago
5 months ago
9 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. <select id="getMarketNameById" resultType="java.lang.String">
  8. SELECT name
  9. FROM market
  10. WHERE id = #{marketId}
  11. </select>
  12. <!-- 根据名称列表查询对应的市场ID及其子市场ID -->
  13. <select id="getMarketIds" parameterType="java.util.List" resultType="java.lang.String">
  14. SELECT id
  15. FROM market
  16. WHERE
  17. -- 匹配名称的市场ID
  18. name IN
  19. <foreach collection="list" item="name" open="(" separator="," close=")">
  20. #{name}
  21. </foreach>
  22. OR
  23. -- 父ID是上述市场ID的子市场
  24. parent_id IN (
  25. SELECT id
  26. FROM market
  27. WHERE name IN
  28. <foreach collection="list" item="name" open="(" separator="," close=")">
  29. #{name}
  30. </foreach>
  31. )
  32. </select>
  33. <select id="getMarketId" resultType="java.lang.String">
  34. select id from market where name=#{market}
  35. </select>
  36. <select id="getMarketIdDao" resultType="com.example.demo.domain.entity.Market">
  37. select * from markets where name=#{country}
  38. </select>
  39. <select id="getMarketIdBytype" resultType="com.example.demo.domain.entity.Market">
  40. select * from market where parent_id=#{parentId}
  41. </select>
  42. <select id="getMarketById" resultType="java.lang.String">
  43. select name from market where id=#{market}
  44. </select>
  45. <!-- 根据ID列表查询市场名称 -->
  46. <select id="getMarketByIds" resultType="com.example.demo.domain.entity.Market">
  47. select id, name from market
  48. where 1 = 0
  49. <if test="marketIds != null and marketIds.size() > 0">
  50. OR id IN
  51. <foreach collection="marketIds" item="marketId" open="(" separator="," close=")">
  52. #{marketId}
  53. </foreach>
  54. </if>
  55. </select>
  56. <select id="selectAreaPayTypeList" resultType="com.example.demo.domain.DTO.AreaPayTypeDTO">
  57. SELECT
  58. m.id AS areaId,
  59. m.name AS areaName,
  60. pt.id AS payTypeId,
  61. pt.name AS payTypeName
  62. FROM payment_type_tree ptt
  63. LEFT JOIN market m ON ptt.area_id = m.id
  64. LEFT JOIN payment_type pt ON ptt.type_id = pt.id
  65. WHERE m.id IS NOT NULL AND pt.id IS NOT NULL
  66. ORDER BY areaId
  67. </select>
  68. </mapper>