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.

47 lines
1.7 KiB

  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.cash.MessageMapper">
  4. <update id="update">
  5. update message
  6. set flag=1
  7. where id=#{id}
  8. </update>
  9. <select id="getMessage" resultType="com.example.demo.domain.vo.coin.Messages">
  10. SELECT
  11. m.id,
  12. m.jwcode,
  13. m.name, <!-- ✅ message.name -->
  14. m.title,
  15. m.`desc`,
  16. m.status,
  17. m.market,
  18. m.type,
  19. m.type_id,
  20. m.flag,
  21. m.cz_time,
  22. m.query_id, <!-- 🔍 添加 queryId 字段 -->
  23. m.executor, <!-- 👤 添加 executor 字段 -->
  24. mk.name AS market_name <!-- ✅ market.name -->
  25. FROM message m
  26. LEFT JOIN market mk ON m.market = mk.id
  27. <where>
  28. m.flag = 0
  29. <if test="status != null and status.size() > 0">
  30. AND m.status IN
  31. <foreach item="item" collection="status" open="(" separator="," close=")">
  32. #{item}
  33. </foreach>
  34. </if>
  35. <if test="markets != null and markets.size() > 0">
  36. AND m.market IN
  37. <foreach item="item" collection="markets" open="(" separator="," close=")">
  38. #{item}
  39. </foreach>
  40. </if>
  41. <!-- 只有当 executor 不为 null 时才添加过滤条件 -->
  42. <if test="executor != null">
  43. AND (m.executor = #{executor} OR m.executor IS NULL)
  44. </if>
  45. </where>
  46. ORDER BY m.cz_time DESC
  47. </select>
  48. </mapper>