Ver Fonte

Update IndexController.java

jtoms há 4 anos atrás
pai
commit
7c3a74f4d8

+ 19 - 1
src/main/java/com/zhiqiyun/open/mvc/controller/IndexController.java

@@ -3,6 +3,7 @@ package com.zhiqiyun.open.mvc.controller;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.dliyun.oap.framework.service.RouterService;
 import com.dliyun.oap.framework.service.ServiceMethodHandler;
+import com.zhiqiyun.open.core.enmus.BzDataType;
 import com.zhiqiyun.open.core.models.bz.BaseDataInfo;
 import com.zhiqiyun.open.core.service.AppKeyInfoService;
 import com.zhiqiyun.open.core.service.BaseDataInfoService;
@@ -61,7 +62,7 @@ public class IndexController {
 
     @ResponseBody
     @PostMapping("/bz/base/findByMapBounds")
-    public Result findByMapBounds(BigDecimal maxlng, BigDecimal maxlat, BigDecimal minlng, BigDecimal minlat) {
+    public Result findByMapBounds(BigDecimal maxlng, BigDecimal maxlat, BigDecimal minlng, BigDecimal minlat, BzDataType dataType) {
         QueryWrapper<BaseDataInfo> queryWrapper = new QueryWrapper<>();
         if (maxlng != null) {
             queryWrapper.le("lng", maxlng);
@@ -75,11 +76,28 @@ public class IndexController {
         if (minlat != null) {
             queryWrapper.ge("lat", minlat);
         }
+        if (dataType != null) {
+            queryWrapper.eq("data_type", dataType);
+        }
 
         List<BaseDataInfo> listData = this.baseDataInfoService.list(queryWrapper);
         return Result.instance(Result.Code.SUCCESS).setData(listData);
     }
 
+    @ResponseBody
+    @PostMapping("/bz/base/findByGroupByDataType")
+    public Result findByGroupByDataType() {
+        QueryWrapper<BaseDataInfo> queryWrapper = new QueryWrapper<>();
+        queryWrapper.select("data_type, count(1) num");
+        queryWrapper.groupBy("data_type");
+        List<Map<String, Object>> listData = this.baseDataInfoService.listMaps(queryWrapper);
+        for (Map<String, Object> dataMap : listData) {
+            BzDataType dataType = BzDataType.valueOf(Integer.parseInt(dataMap.get("data_type").toString()));
+            dataMap.put("dataType", dataType);
+        }
+        return Result.instance(Result.Code.SUCCESS).setData(listData);
+    }
+
     @GetMapping("/")
     public void index(HttpServletResponse response) throws IOException {
         response.sendRedirect("/index.html");