package com.tofly.analyse.controller;

import com.tofly.analyse.service.DataSetService;
import com.tofly.common.core.entity.ResultRespone;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/dataSet")
@Api(tags = "数据集管理")
public class DataSetController {
	
    @Autowired	
    private DataSetService dataSetService;
	
	@ApiOperation(value = "根据数据集名称以及字段名获取对应去重值")
    @GetMapping("/getFieldData")
    public ResultRespone getFieldData(
    		@ApiParam(value = "字段名",name = "fieldName",required = true) String fieldName,
    		@ApiParam(value = "数据集名称",name = "dataSetName",required = true) String dataSetName) {	  
	   Map<String,String>  queryParams = new HashMap<String,String>(); 
	   queryParams.put("fieldName", fieldName);
	   queryParams.put("dataSetName", dataSetName);	   
	   return ResultRespone.success(dataSetService.getColData(queryParams));
    }
	
	
	@ApiOperation(value = "根据数据集名称获取字段信息")
    @GetMapping("/getDataSetData")
    public ResultRespone getDataSetData(
    		@ApiParam(value = "数据集名称",name = "dataSetName",required = true) String dataSetName) {	  
	   Map<String,String>  queryParams = new HashMap<String,String>(); 
	   queryParams.put("dataSetName", dataSetName);	   
	   return ResultRespone.success(dataSetService.getDataSetData(queryParams));
    }
		
		
} 