MarketingReportMapper.xml 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. ~
  4. ~ Copyright (c) 2018-2025, lengleng All rights reserved.
  5. ~
  6. ~ Redistribution and use in source and binary forms, with or without
  7. ~ modification, are permitted provided that the following conditions are met:
  8. ~
  9. ~ Redistributions of source code must retain the above copyright notice,
  10. ~ this list of conditions and the following disclaimer.
  11. ~ Redistributions in binary form must reproduce the above copyright
  12. ~ notice, this list of conditions and the following disclaimer in the
  13. ~ documentation and/or other materials provided with the distribution.
  14. ~ Neither the name of the pig4cloud.com developer nor the names of its
  15. ~ contributors may be used to endorse or promote products derived from
  16. ~ this software without specific prior written permission.
  17. ~ Author: lengleng ([email protected])
  18. ~
  19. -->
  20. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  21. <mapper namespace="com.pig4cloud.pig.admin.mapper.MarketingReportMapper">
  22. <select id="selectMarketingReportGroupBy" resultType="com.pig4cloud.pig.admin.api.vo.marketing.PageMarketingReportRspVO">
  23. SELECT
  24. domain,ip,referrer,
  25. COUNT(*) AS total,
  26. SUM(CASE WHEN create_time >= #{lastHourTime} THEN 1 ELSE 0 END) AS hourly,
  27. SUM(CASE WHEN create_time >= #{todayStartTime} THEN 1 ELSE 0 END) AS daily
  28. FROM
  29. marketing_report
  30. <where>
  31. <if test="domain != null and domain != ''">
  32. AND domain LIKE CONCAT('%', #{domain}, '%')
  33. </if>
  34. <if test="ip != null and ip != ''">
  35. AND ip LIKE CONCAT('%', #{ip}, '%')
  36. </if>
  37. <if test="referrer != null and referrer != ''">
  38. AND referrer LIKE CONCAT('%', #{referrer}, '%')
  39. </if>
  40. </where>
  41. GROUP BY
  42. domain, ip, referrer
  43. LIMIT #{offset}, #{pageSize}
  44. </select>
  45. <select id="selectMarketingReportGroupByCount" resultType="java.lang.Long">
  46. SELECT
  47. COUNT(DISTINCT domain, ip, referrer)
  48. FROM
  49. marketing_report
  50. <where>
  51. <if test="domain != null and domain != ''">
  52. AND domain LIKE CONCAT('%', #{domain}, '%')
  53. </if>
  54. <if test="ip != null and ip != ''">
  55. AND ip LIKE CONCAT('%', #{ip}, '%')
  56. </if>
  57. <if test="referrer != null and referrer != ''">
  58. AND referrer LIKE CONCAT('%', #{referrer}, '%')
  59. </if>
  60. </where>
  61. </select>
  62. </mapper>