MarketLogMapper.xml 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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.dayou.mapper.MarketLogMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.dayou.entity.MarketLog">
  6. <result column="id" property="id" />
  7. <result column="deleted" property="deleted" />
  8. <result column="created" property="created" />
  9. <result column="modified" property="modified" />
  10. <result column="user_id" property="userId" />
  11. <result column="task_situation" property="taskSituation" />
  12. <result column="log_date" property="logDate" />
  13. </resultMap>
  14. <!-- 通用查询结果列 -->
  15. <sql id="Base_Column_List">
  16. ml.id,
  17. ml.deleted,
  18. ml.created,
  19. ml.modified,
  20. ml.user_id, ml.task_situation, ml.log_date
  21. </sql>
  22. <select id="getList" resultType="com.dayou.vo.ItemUserLogVO">
  23. select <include refid="Base_Column_List"/>,u.name as userName
  24. from market_log ml left join user u on u.id = ml.user_id
  25. where u.deleted = 0 and ml.deleted = 0
  26. <choose>
  27. <when test="startDate!=null">
  28. and ml.log_date &gt;= #{startDate}
  29. </when>
  30. <otherwise>
  31. and ml.log_date &gt;= date_add(curDate(),INTERVAL -10 DAY)
  32. </otherwise>
  33. </choose>
  34. <choose>
  35. <when test="endDate!=null">
  36. and ml.log_date &lt;= #{endDate}
  37. </when>
  38. <otherwise>
  39. and ml.log_date &lt;= curDate()
  40. </otherwise>
  41. </choose>
  42. <if test="userIds!=null and userIds.size!=0">
  43. and ml.user_id in
  44. <foreach collection="userIds" open="(" close=")" separator="," item="userId">
  45. #{userId}
  46. </foreach>
  47. </if>
  48. <if test="keyword!=null and keyword!='' ">
  49. and (
  50. u.name like concat ('%',#{keyword},'%')
  51. or ml.task_situation like concat ('%',#{keyword},'%')
  52. )
  53. </if>
  54. </select>
  55. <select id="getPage" parameterType="com.dayou.entity.MarketLog" resultType="com.dayou.vo.MarketLogVO">
  56. SELECT
  57. <include refid="Base_Column_List"/>,(
  58. SELECT
  59. count( id )
  60. FROM
  61. business_reply
  62. WHERE
  63. biz_type = 'MARKET_LOG_REPLY'
  64. AND biz_table_id = ml.id
  65. AND deleted = 0
  66. AND receiver_id = #{marketLog.userId}
  67. and state = 0
  68. ) AS replyCount
  69. FROM
  70. market_log ml
  71. WHERE
  72. ml.user_id = #{marketLog.userId}
  73. AND ml.deleted = 0
  74. order by ml.id DESC
  75. </select>
  76. </mapper>