package com.ozs.da.feign;

import com.ozs.da.entity.remotedb.MdmCreateTableDTO;
import com.ozs.da.entity.remotedb.MdmInfoColumn;
import com.ozs.da.entity.remotedb.MdmInfoDatabase;
import com.ozs.da.entity.remotedb.MdmInfoTable;
import com.ozs.da.utils.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Map;

/**
 * @author 许明 on 2019/3/11.
 * @version 2.0.0
 */
@FeignClient(name = "mdm")
public interface DaMdmFeign {

	@GetMapping(value = "/mdm/kpiManage/database/{id}")
    MdmInfoDatabase database(@PathVariable(name = "id") String dbId);

	@GetMapping(value = "/mdm/kpiManage/listTableByDatabaseId")
	List<MdmInfoTable> listTableByDatabaseId(@RequestParam(name = "databaseId") String databaseId);

	@GetMapping(value = "/mdm/kpiManage/listOriginal")
	List<MdmInfoDatabase> listOriginal(@RequestParam(name = "resourceName") String resourceName);

	@GetMapping(value = "/mdm/kpiManage/listDatabase")
	List<MdmInfoDatabase> listDatabase(@RequestParam(name = "resourceName") String resourceName);

	@GetMapping(value = "/mdm/kpiManage/listColumnByTableId")
	List<MdmInfoColumn> listColumnByTableId(@RequestParam(name = "tableId") String tableId);

	@GetMapping(value = "/mdm/storageManage/getTableInfoById/{tableId}")
    R<MdmCreateTableDTO> getTableInfoById(@PathVariable(name = "tableId") String tableId);

	/**
	 * 执行sql获取查询数据
	 * 
	 * @param databaseId
	 * @param sql
	 * @return
	 */
	@PostMapping("/mdm/listData")
	List<Map<String, Object>> listData(@RequestParam("databaseId") String databaseId,
			@RequestBody Map<String, String> sql);

	/**
	 * 执行sql修改语句
	 * 
	 * @param databaseId
	 * @param sql
	 * @return
	 */
	@PostMapping("/mdm/executeSql")
	Integer executeSql(@RequestParam("databaseId") String databaseId, @RequestBody Map<String, String> sql);
}
