package com.tofly.analyse.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tofly.analyse.entity.DataSet;
import com.tofly.analyse.entity.MetaData;
import com.tofly.analyse.service.MetaDataService;
import com.tofly.common.core.entity.ResultRespone;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/metaData")
@Api(tags = "元数据信息管理")
public class MetaDataController {
	
	
	@Autowired	
    private MetaDataService metaDataService;
			 
	@ApiOperation(value = "获取元数据数据集")
	@GetMapping("/getDataSetPage")
	public ResultRespone getDataSetPage(Page page, @ModelAttribute DataSet dataSet) {
				
		if(dataSet.getSmdatasettype()!=null&&!dataSet.getSmdatasettype().trim().equals("")) {
			dataSet.setSmdatasettypeArray(dataSet.getSmdatasettype().split(","));
		}
		
  	  	return ResultRespone.success(metaDataService.getDataSetPage(page,dataSet));
	}
	

	@ApiOperation(value = "获取元数据数据集具体信息 ，参数：datasetId 元数据集ID")
	@GetMapping("/getMetaDataPage")
	public ResultRespone getMetaDataPage(Page page, @ModelAttribute MetaData metaData) {	   
  	  	return ResultRespone.success(metaDataService.getMetaDataPage(page,metaData));
	} 
	
	@PutMapping("/dataSetUpadte" )
    @ApiOperation(value = "修改数据集信息")
    public ResultRespone dataSetUpadte(@RequestBody DataSet dataSet) {
		metaDataService.updateDataSet(dataSet);   	     	 
   	 	return ResultRespone.success("修改数据集成功");
    }
	
	@PutMapping("/metaDataUpadte" )
    @ApiOperation(value = "修改元数据信息")
    public ResultRespone dataSetUpadte(@RequestBody MetaData MetaData) {
		metaDataService.updateMetaData(MetaData);   	     	 
   	 	return ResultRespone.success("修改元数据成功");
    }

	

}