package egovframework.com.mtdata.comtrls.web;

import egovframework.com.mtdata.comtrls.service.ComtrlsdataService;
import egovframework.com.mtdata.comtrls.vo.ComtrlsMetaDataVO;
import egovframework.com.mtdata.comtrls.vo.ComtrlsSrcdataVO;
import egovframework.com.mtdata.comtsrcdata.service.ComtsrcdataService;
import egovframework.com.mtdata.comtsrcdata.vo.ComtTableVO;
import egovframework.com.mtdata.database.vo.DatabaseInfoVO;
import org.json.simple.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.sql.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api")
public class ComtrlsdataController {

	/** Service */
	@Resource(name = "ComtsrcdataService")
	private ComtsrcdataService comtsrcdataService;
	@Resource(name = "ComtrlsdataService")
	private ComtrlsdataService comtrlsdataService;

	private static final Logger log = LoggerFactory.getLogger(ComtrlsdataController.class);

	@RequestMapping("/comtrls.do")
	@Transactional(rollbackFor = Exception.class)
	public String comtrls() throws Exception {

		try {
			ComtTableVO vo = new ComtTableVO();
			vo.setSrcDataMetaId(3);
			ComtTableVO tableVo =  comtsrcdataService.selectSrcMetaData(vo);
			ComtrlsMetaDataVO metaVo = new ComtrlsMetaDataVO();
			metaVo.setRlsDataNm("공유데이터 가져오기 테스트 DATA NAME");
//			metaVo.setRlsDataMngDeptId(tableVo.get);
			metaVo.setRlsDataAplcntId(1);
			metaVo.setRlsDataRvwId(3);
			metaVo.setRlsDataSrcInstId(4);
			metaVo.setDwnldType("JSON");
			metaVo.setRlsDataSttsChg("PROGRESS");
			metaVo.setRlsDataSttsChg("Y");



			return "공유데이터 컨트롤러 ::";
		} catch (Exception e) {
			log.error("Exception {}", e);
			throw new RuntimeException(e.getMessage());
		}


	}

}
