1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!--
- ~
- ~ Copyright (c) 2018-2025, lengleng All rights reserved.
- ~
- ~ Redistribution and use in source and binary forms, with or without
- ~ modification, are permitted provided that the following conditions are met:
- ~
- ~ Redistributions of source code must retain the above copyright notice,
- ~ this list of conditions and the following disclaimer.
- ~ Redistributions in binary form must reproduce the above copyright
- ~ notice, this list of conditions and the following disclaimer in the
- ~ documentation and/or other materials provided with the distribution.
- ~ Neither the name of the pig4cloud.com developer nor the names of its
- ~ contributors may be used to endorse or promote products derived from
- ~ this software without specific prior written permission.
- ~ Author: lengleng ([email protected])
- ~
- -->
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.pig4cloud.pig.admin.mapper.MarketingReportMapper">
- <select id="selectMarketingReportGroupBy" resultType="com.pig4cloud.pig.admin.api.vo.marketing.PageMarketingReportRspVO">
- SELECT
- domain,ip,referrer,
- COUNT(*) AS total,
- SUM(CASE WHEN create_time >= #{lastHourTime} THEN 1 ELSE 0 END) AS hourly,
- SUM(CASE WHEN create_time >= #{todayStartTime} THEN 1 ELSE 0 END) AS daily
- FROM
- marketing_report
- <where>
- <if test="domain != null and domain != ''">
- AND domain LIKE CONCAT('%', #{domain}, '%')
- </if>
- <if test="ip != null and ip != ''">
- AND ip LIKE CONCAT('%', #{ip}, '%')
- </if>
- <if test="referrer != null and referrer != ''">
- AND referrer LIKE CONCAT('%', #{referrer}, '%')
- </if>
- </where>
- GROUP BY
- domain, ip, referrer
- LIMIT #{offset}, #{pageSize}
- </select>
- <select id="selectMarketingReportGroupByCount" resultType="java.lang.Long">
- SELECT
- COUNT(DISTINCT domain, ip, referrer)
- FROM
- marketing_report
- <where>
- <if test="domain != null and domain != ''">
- AND domain LIKE CONCAT('%', #{domain}, '%')
- </if>
- <if test="ip != null and ip != ''">
- AND ip LIKE CONCAT('%', #{ip}, '%')
- </if>
- <if test="referrer != null and referrer != ''">
- AND referrer LIKE CONCAT('%', #{referrer}, '%')
- </if>
- </where>
- </select>
- </mapper>
|