forked from github/dataease
refactor: 完善API接口文档
This commit is contained in:
parent
7faa88f2d3
commit
1a34172602
@ -1,26 +1,29 @@
|
||||
package io.dataease.base.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class Datasource implements Serializable {
|
||||
@ApiModelProperty("ID")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty("名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("描述")
|
||||
private String desc;
|
||||
|
||||
@ApiModelProperty("类型")
|
||||
private String type;
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
private Long createTime;
|
||||
|
||||
@ApiModelProperty("更新时间")
|
||||
private Long updateTime;
|
||||
|
||||
@ApiModelProperty("创建者")
|
||||
private String createBy;
|
||||
|
||||
@ApiModelProperty("状态")
|
||||
private String status;
|
||||
|
||||
@ApiModelProperty("配置详情")
|
||||
private String configuration;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
@ -5,6 +5,7 @@ import io.dataease.base.domain.ChartViewWithBLOBs;
|
||||
import io.dataease.commons.utils.AuthUtils;
|
||||
import io.dataease.controller.request.chart.ChartExtRequest;
|
||||
import io.dataease.controller.request.chart.ChartViewRequest;
|
||||
import io.dataease.controller.response.ChartDetail;
|
||||
import io.dataease.dto.chart.ChartViewDTO;
|
||||
import io.dataease.service.chart.ChartViewService;
|
||||
import io.swagger.annotations.Api;
|
||||
@ -66,7 +67,7 @@ public class ChartViewController {
|
||||
|
||||
@ApiOperation("视图详情")
|
||||
@PostMapping("chartDetail/{id}")
|
||||
public Map<String, Object> chartDetail(@PathVariable String id) {
|
||||
public ChartDetail chartDetail(@PathVariable String id) {
|
||||
return chartViewService.getChartDetail(id);
|
||||
}
|
||||
|
||||
|
@ -5,12 +5,14 @@ import io.dataease.base.domain.DatasetTable;
|
||||
import io.dataease.base.domain.DatasetTableField;
|
||||
import io.dataease.base.domain.DatasetTableIncrementalConfig;
|
||||
import io.dataease.controller.request.dataset.DataSetTableRequest;
|
||||
import io.dataease.controller.response.DataSetDetail;
|
||||
import io.dataease.datasource.dto.TableFiled;
|
||||
import io.dataease.dto.dataset.DataSetTableDTO;
|
||||
import io.dataease.dto.dataset.ExcelFileData;
|
||||
import io.dataease.service.dataset.DataSetTableService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@ -54,7 +56,7 @@ public class DataSetTableController {
|
||||
|
||||
@ApiOperation("删除")
|
||||
@PostMapping("delete/{id}")
|
||||
public void delete(@PathVariable String id) throws Exception {
|
||||
public void delete( @ApiParam(name = "id", value = "数据集ID", required = true) @PathVariable String id) throws Exception {
|
||||
dataSetTableService.delete(id);
|
||||
}
|
||||
|
||||
@ -72,7 +74,7 @@ public class DataSetTableController {
|
||||
|
||||
@ApiOperation("详息")
|
||||
@PostMapping("get/{id}")
|
||||
public DatasetTable get(@PathVariable String id) {
|
||||
public DatasetTable get(@ApiParam(name = "id", value = "数据集ID", required = true) @PathVariable String id) {
|
||||
return dataSetTableService.get(id);
|
||||
}
|
||||
|
||||
@ -84,8 +86,8 @@ public class DataSetTableController {
|
||||
|
||||
@ApiOperation("查询原始字段")
|
||||
@PostMapping("getFields")
|
||||
public List<TableFiled> getFields(@RequestBody DataSetTableRequest dataSetTableRequest) throws Exception {
|
||||
return dataSetTableService.getFields(dataSetTableRequest);
|
||||
public List<TableFiled> getFields(@RequestBody DatasetTable datasetTable) throws Exception {
|
||||
return dataSetTableService.getFields(datasetTable);
|
||||
}
|
||||
|
||||
@ApiOperation("查询生成字段")
|
||||
@ -126,11 +128,11 @@ public class DataSetTableController {
|
||||
|
||||
@ApiOperation("数据集详息")
|
||||
@PostMapping("datasetDetail/{id}")
|
||||
public Map<String, Object> datasetDetail(@PathVariable String id) {
|
||||
public DataSetDetail datasetDetail(@PathVariable String id) {
|
||||
return dataSetTableService.getDatasetDetail(id);
|
||||
}
|
||||
|
||||
@ApiOperation("excel上传")
|
||||
// @ApiOperation("excel上传")
|
||||
@PostMapping("excel/upload")
|
||||
public ExcelFileData excelUpload(@RequestParam("file") MultipartFile file, @RequestParam("tableId") String tableId, @RequestParam("editType") Integer editType ) throws Exception {
|
||||
return dataSetTableService.excelSaveAndParse(file, tableId, editType);
|
||||
|
@ -2,6 +2,7 @@ package io.dataease.controller.dataset;
|
||||
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
|
||||
import io.dataease.base.domain.DatasetTableField;
|
||||
import io.dataease.controller.response.DatasetTableField4Type;
|
||||
import io.dataease.service.dataset.DataSetFieldService;
|
||||
import io.dataease.service.dataset.DataSetTableFieldsService;
|
||||
import io.swagger.annotations.Api;
|
||||
@ -39,7 +40,7 @@ public class DataSetTableFieldController {
|
||||
|
||||
@ApiOperation("分组查询表下属字段")
|
||||
@PostMapping("listByDQ/{tableId}")
|
||||
public Map<String, List<DatasetTableField>> listByDQ(@PathVariable String tableId) {
|
||||
public DatasetTableField4Type listByDQ(@PathVariable String tableId) {
|
||||
DatasetTableField datasetTableField = DatasetTableField.builder().build();
|
||||
datasetTableField.setTableId(tableId);
|
||||
datasetTableField.setGroupType("d");
|
||||
@ -47,10 +48,10 @@ public class DataSetTableFieldController {
|
||||
datasetTableField.setGroupType("q");
|
||||
List<DatasetTableField> quotaList = dataSetTableFieldsService.list(datasetTableField);
|
||||
|
||||
Map<String, List<DatasetTableField>> map = new HashMap<>();
|
||||
map.put("dimensionList", dimensionList);
|
||||
map.put("quotaList", quotaList);
|
||||
return map;
|
||||
DatasetTableField4Type datasetTableField4Type = new DatasetTableField4Type();
|
||||
datasetTableField4Type.setDimensionList(dimensionList);
|
||||
datasetTableField4Type.setQuotaList(quotaList);
|
||||
return datasetTableField4Type;
|
||||
}
|
||||
|
||||
@ApiOperation("批量更新")
|
||||
|
@ -0,0 +1,13 @@
|
||||
package io.dataease.controller.response;
|
||||
|
||||
import io.dataease.base.domain.ChartViewWithBLOBs;
|
||||
import io.dataease.base.domain.DatasetTable;
|
||||
import io.dataease.base.domain.Datasource;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ChartDetail extends DataSetDetail{
|
||||
@ApiModelProperty("视图")
|
||||
private ChartViewWithBLOBs chart;
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package io.dataease.controller.response;
|
||||
|
||||
import io.dataease.base.domain.DatasetTable;
|
||||
import io.dataease.base.domain.Datasource;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class DataSetDetail {
|
||||
@ApiModelProperty("数据集")
|
||||
private DatasetTable table;
|
||||
@ApiModelProperty("数据源")
|
||||
private Datasource datasource;
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package io.dataease.controller.response;
|
||||
|
||||
import io.dataease.base.domain.DatasetTableField;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class DatasetTableField4Type {
|
||||
@ApiModelProperty("维度")
|
||||
List<DatasetTableField> dimensionList;
|
||||
@ApiModelProperty("指标")
|
||||
List<DatasetTableField> quotaList;
|
||||
}
|
@ -12,6 +12,8 @@ import io.dataease.commons.utils.BeanUtils;
|
||||
import io.dataease.commons.utils.CommonBeanFactory;
|
||||
import io.dataease.commons.utils.LogUtil;
|
||||
import io.dataease.controller.request.chart.*;
|
||||
import io.dataease.controller.response.ChartDetail;
|
||||
import io.dataease.controller.response.DataSetDetail;
|
||||
import io.dataease.datasource.provider.DatasourceProvider;
|
||||
import io.dataease.datasource.provider.ProviderFactory;
|
||||
import io.dataease.datasource.request.DatasourceRequest;
|
||||
@ -1055,15 +1057,16 @@ public class ChartViewService {
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, Object> getChartDetail(String id) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
public ChartDetail getChartDetail(String id) {
|
||||
ChartDetail chartDetail = new ChartDetail();
|
||||
ChartViewWithBLOBs chartViewWithBLOBs = chartViewMapper.selectByPrimaryKey(id);
|
||||
map.put("chart", chartViewWithBLOBs);
|
||||
chartDetail.setChart(chartViewWithBLOBs);
|
||||
if (ObjectUtils.isNotEmpty(chartViewWithBLOBs)) {
|
||||
Map<String, Object> datasetDetail = dataSetTableService.getDatasetDetail(chartViewWithBLOBs.getTableId());
|
||||
map.putAll(datasetDetail);
|
||||
DataSetDetail datasetDetail = dataSetTableService.getDatasetDetail(chartViewWithBLOBs.getTableId());
|
||||
chartDetail.setTable(datasetDetail.getTable());
|
||||
chartDetail.setDatasource(datasetDetail.getDatasource());
|
||||
}
|
||||
return map;
|
||||
return chartDetail;
|
||||
}
|
||||
|
||||
public List<ChartView> viewsByIds(List<String> viewIds) {
|
||||
|
@ -15,6 +15,7 @@ import io.dataease.commons.utils.*;
|
||||
import io.dataease.controller.request.dataset.DataSetGroupRequest;
|
||||
import io.dataease.controller.request.dataset.DataSetTableRequest;
|
||||
import io.dataease.controller.request.dataset.DataSetTaskRequest;
|
||||
import io.dataease.controller.response.DataSetDetail;
|
||||
import io.dataease.datasource.constants.DatasourceTypes;
|
||||
import io.dataease.datasource.dto.TableFiled;
|
||||
import io.dataease.datasource.provider.DatasourceProvider;
|
||||
@ -382,13 +383,13 @@ public class DataSetTableService {
|
||||
return extDataSetTableMapper.searchOne(dataSetTableRequest);
|
||||
}
|
||||
|
||||
public List<TableFiled> getFields(DataSetTableRequest dataSetTableRequest) throws Exception {
|
||||
Datasource ds = datasourceMapper.selectByPrimaryKey(dataSetTableRequest.getDataSourceId());
|
||||
public List<TableFiled> getFields(DatasetTable datasetTable) throws Exception {
|
||||
Datasource ds = datasourceMapper.selectByPrimaryKey(datasetTable.getDataSourceId());
|
||||
DatasourceProvider datasourceProvider = ProviderFactory.getProvider(ds.getType());
|
||||
DatasourceRequest datasourceRequest = new DatasourceRequest();
|
||||
datasourceRequest.setDatasource(ds);
|
||||
QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType());
|
||||
datasourceRequest.setQuery(qp.convertTableToSql(new Gson().fromJson(dataSetTableRequest.getInfo(), DataTableInfoDTO.class).getTable(), ds));
|
||||
datasourceRequest.setQuery(qp.convertTableToSql(new Gson().fromJson(datasetTable.getInfo(), DataTableInfoDTO.class).getTable(), ds));
|
||||
return datasourceProvider.fetchResultField(datasourceRequest);
|
||||
}
|
||||
|
||||
@ -966,7 +967,7 @@ public class DataSetTableService {
|
||||
List<TableFiled> fields = new ArrayList<>();
|
||||
long syncTime = System.currentTimeMillis();
|
||||
if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "db")) {
|
||||
fields = getFields(dataSetTableRequest);
|
||||
fields = getFields(datasetTable);
|
||||
} else if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "sql")) {
|
||||
DatasourceProvider datasourceProvider = ProviderFactory.getProvider(ds.getType());
|
||||
DatasourceRequest datasourceRequest = new DatasourceRequest();
|
||||
@ -1198,15 +1199,15 @@ public class DataSetTableService {
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, Object> getDatasetDetail(String id) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
public DataSetDetail getDatasetDetail(String id) {
|
||||
DataSetDetail dataSetDetail = new DataSetDetail();
|
||||
DatasetTable table = datasetTableMapper.selectByPrimaryKey(id);
|
||||
map.put("table", table);
|
||||
dataSetDetail.setTable(table);
|
||||
if (ObjectUtils.isNotEmpty(table)) {
|
||||
Datasource datasource = datasourceMapper.selectByPrimaryKey(table.getDataSourceId());
|
||||
map.put("datasource", datasource);
|
||||
dataSetDetail.setDatasource(datasource);
|
||||
}
|
||||
return map;
|
||||
return dataSetDetail;
|
||||
}
|
||||
|
||||
public ExcelFileData excelSaveAndParse(MultipartFile file, String tableId, Integer editType) throws Exception {
|
||||
|
Loading…
Reference in New Issue
Block a user