Browse Source

获取列数据增加批量接口

chenw 7 years ago
parent
commit
3b663bc101

+ 9 - 0
bi-server/src/main/java/com/usoftchina/bi/server/controller/chart/ShowChartsController.java

@@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.bind.annotation.RestController;
 
 
 import java.sql.SQLException;
 import java.sql.SQLException;
+import java.util.List;
 
 
 @RestController
 @RestController
 @Api(description = "图表展现相关接口")
 @Api(description = "图表展现相关接口")
@@ -115,6 +116,14 @@ public class ShowChartsController {
     }
     }
 
 
     /*
     /*
+  展示列数据(数据源)
+   */
+    @ApiOperation(value = "展示数据源列数据(多个)", notes = "展示数据源列数据(多个)", response = RepEntity.class)
+    @PostMapping("/getScreenByBaseIds")
+    public RepEntity getScreenByBaseIds(@RequestBody List<ColumnScreenInfo> body){
+        return columnScreenService.getScreenByBaseIds(body);
+    }
+    /*
     展示图表数据信息
     展示图表数据信息
      */
      */
     @ApiOperation(value = "展示图表数据信息", notes = "展示图表数据信息", response = RepEntity.class)
     @ApiOperation(value = "展示图表数据信息", notes = "展示图表数据信息", response = RepEntity.class)

+ 19 - 1
bi-server/src/main/java/com/usoftchina/bi/server/service/dataSource/ColumnScreenService.java

@@ -64,7 +64,7 @@ public class ColumnScreenService {
     /*
     /*
     通过数据源ID获取列的值
     通过数据源ID获取列的值
      */
      */
-    public RepEntity getScreenByBaseId(ColumnScreenInfo columnScreenInfo){
+    public RepEntity<List<Object>> getScreenByBaseId(ColumnScreenInfo columnScreenInfo){
         //取表名
         //取表名
         int connectId = columnScreenInfo.getId();
         int connectId = columnScreenInfo.getId();
         String tableName = chartsConfigMapper.getTableNameByBase(connectId);
         String tableName = chartsConfigMapper.getTableNameByBase(connectId);
@@ -97,4 +97,22 @@ public class ColumnScreenService {
         }
         }
         return new RepEntity(RepCode.success, data);
         return new RepEntity(RepCode.success, data);
     }
     }
+
+    /**
+     * 通过多个数据源ID获取列的值
+     * @param columnScreenInfo
+     * @return
+     */
+    public RepEntity getScreenByBaseIds(List<ColumnScreenInfo> columnScreenInfo){
+        List<Object> result = new ArrayList<>();
+        for (ColumnScreenInfo info : columnScreenInfo) {
+            result.addAll(getScreenByBaseId(info).getData());
+        }
+        if (result.size() > 20) {
+            return new RepEntity(RepCode.success, result.subList(0, 20));
+        }else {
+            return new RepEntity(RepCode.success, result);
+        }
+    }
+
 }
 }