Sfoglia il codice sorgente

批量查询日统计

lyhzzz 2 anni fa
parent
commit
28dc2cf3c2

+ 11 - 0
src/main/java/com/cdf/controller/api/PageDataApiController.java

@@ -4,9 +4,11 @@ package com.cdf.controller.api;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.cdf.common.ResultCode;
 import com.cdf.common.ResultData;
 import com.cdf.entity.PageData;
 import com.cdf.entity.TotalData;
+import com.cdf.exception.BusinessException;
 import com.cdf.httpClient.client.CdfClient;
 import com.cdf.httpClient.request.CdfChannelclick;
 import com.cdf.service.IPageDataService;
@@ -120,6 +122,15 @@ public class PageDataApiController {
         return ResultData.ok(totalDataService.getByType(type,day,startDay,endDay));
     }
 
+    @GetMapping("/pageDataTime")
+    public ResultData pageDataTime(@RequestParam(required = false) String startDay,
+                                  @RequestParam(required = false) String endDay) {
+        if(StringUtils.isEmpty(startDay) || StringUtils.isEmpty(endDay)){
+            throw new BusinessException(ResultCode.PARAM_MISS);
+        }
+        return ResultData.ok(totalDataService.pageDataTime(startDay,endDay));
+    }
+
     @PostMapping("/pageDataList")
     public ResultData pageDataList(@RequestBody JSONObject jsonObject) throws Exception {
         JSONArray jsonArray = jsonObject.getJSONArray("days");

+ 2 - 0
src/main/java/com/cdf/service/ITotalDataService.java

@@ -18,4 +18,6 @@ public interface ITotalDataService extends IService<TotalData> {
     TotalData getByType(Integer type, String day,String startDay,String endDay) throws Exception;
 
     List<TotalData> getListByType( List<String> days) throws Exception;
+
+    List<TotalData> pageDataTime(String startDay, String endDay);
 }

+ 8 - 0
src/main/java/com/cdf/service/impl/TotalDataServiceImpl.java

@@ -80,6 +80,14 @@ public class TotalDataServiceImpl extends ServiceImpl<ITotalDataMapper, TotalDat
     }
 
     @Override
+    public List<TotalData> pageDataTime(String startDay, String endDay) {
+        LambdaQueryWrapper<TotalData> wrapper = new LambdaQueryWrapper<>();
+        wrapper.between(TotalData::getId,startDay,endDay);
+        wrapper.orderByAsc(TotalData::getId);
+        return this.list(wrapper);
+    }
+
+    @Override
     public List<TotalData> getListByType(List<String> days) throws Exception {
         LambdaQueryWrapper<TotalData> wrapper = new LambdaQueryWrapper<>();
         wrapper.in(TotalData::getId,days);

+ 43 - 1
vr场景统计结果接口文档.md

@@ -48,8 +48,50 @@
 }
  ```
 
+## 2、根据开始结束时间批量获取统计
+ 
+ **接口地址** `/api/pageDataTime`
+ 
+ **请求方式** `GET`
+ 
+ 
+ **请求参数**
+ 
+ | 参数名称      | 参数说明      | 是否必须 | 数据类型     | 示例     |
+ | ------------ | -----------   | -------- | -------     | -----    |
+ | startDay          | 开始天数,不为空   |  true   |   string      |2022-06-18   |
+ | endDay          | 结束天数 ,不为空    |  true   |   string      |2022-09-18 |
+
+ 
+ 
+ 
+ **响应示例**
+ 
+ 
+ ```json
+{
+  "code": 0,             
+  "message": "操作成功",
+  "data": [
+       {
+          "id": "2022-06-18",   //日期 ,type为1时日期所在周的第一天,type为2时返回月份
+          "avgStopTime": 2,     //平均停留时间 /秒
+          "avgJump": 0,         //跳出率  保留4位小数
+          "avgClickGame": 0,    //寻宝游戏点击率  保留4位小数
+          "avgClickShop": 0,    //商品详情点击率  保留4位小数
+          "avgStepNum": 4,      //平均步数
+          "videoNum": 1,        //视频点击次数
+          "createTime": "2022-06-19 00:00:00",
+          "updateTime": "2022-06-19 00:00:00"
+        }
+  ],
+  "success": true,
+  "timestamp": 1655707020322
+}
+ ```
+
 
- ## 2、批量获取统计结果
+ ## 3、根据具体日期批量获取统计结果
  
  **接口地址** `/api/pageDataList`