package incheon.sgp.por.web;

import java.net.URLEncoder;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import incheon.ags.por.service.PorBoardService;
import incheon.ags.por.service.PorDstrctService;
import incheon.ags.por.service.PorExternalService;
import incheon.ags.por.service.PorRtmsService;
import incheon.ags.por.vo.PorDstrctHistResultVO;
import incheon.ags.por.vo.PorDstrctIdResultVO;
import incheon.ags.por.vo.PorDstrctPlanResultVO;
import incheon.ags.por.vo.PorEstateResultVO;
import incheon.ags.por.vo.PorEstateVO;
import incheon.ags.por.vo.PorHousePriceResultVO;
import incheon.ags.por.vo.PorMapParameterVO;
import incheon.cmm.g2f.basemap.vo.G2FBasemapVO;
import lombok.RequiredArgsConstructor;

/**
 * @ClassName : PorController.java
 * @Description : 공간정보포털 컨트롤러
 *
 * @author : 관리자
 * @since : 2025. 07. 17
 * @version : 1.0
 *
 *		  <pre>
 * << 개정이력(Modification Information) >>
 *
 *   수정일			  수정자			   수정내용
 *  -------------  ------------   ---------------------
 *   2023. 10. 10	관리자			   최초 생성
 *   2024. 12. 19	관리자			   패널 기반 플랫폼으로 전면 개편
 *   2025. 07. 17	관리자			   공간정보포털로 전환
 *		  </pre>
 *
 */
@Controller
@RequestMapping("/sgp/por")
@RequiredArgsConstructor
public class PorDstrctController {
	
	private final PorDstrctService porDstrctService;

	/**
	 * 인천지도포털 -> 지구단위계획
	 * @param model
	 * @return jsonData
	 * @exception Exception
	 */
	@GetMapping("/info/dstrct.do")
	@ResponseBody
	public Map<String, Object> dstrct(
			@ModelAttribute PorDstrctPlanResultVO vo, Model model
			) throws Exception {
		
		Map<String, Object> resultMap = new HashMap<String, Object>();
		
		PorDstrctPlanResultVO result = porDstrctService.selectDstrctPlanList(vo);
		
		resultMap.put("data", result);
		
		return resultMap;
	}
	
	
	
	/**
	 * 인천지도포털 -> 지구단위계획 -> 연혁보기
	 * @param model
	 * @return jsonData
	 * @exception Exception
	 */
	@GetMapping("/info/dstrctHist.do")
	@ResponseBody
	public Map<String, Object> dstrctHist(
			@ModelAttribute PorDstrctHistResultVO vo
			) throws Exception {
		
		Map<String, Object> resultMap = new HashMap<String, Object>();
		
		List<PorDstrctHistResultVO> result = porDstrctService.selectDstrctHistList(vo);
		
		resultMap.put("data", result);
		
		return resultMap;
	}
	
	
	
	/**
	 * 인천지도포털 -> 지구단위계획
	 * @param model
	 * @return jsonData
	 * @exception Exception
	 */
	@GetMapping("/info/dstrctId.do")
	@ResponseBody
	public Map<String, Object> selectDstrctId(
			@ModelAttribute PorDstrctIdResultVO vo
			) throws Exception {
		
		Map<String, Object> resultMap = new HashMap<String, Object>();
		
		PorDstrctIdResultVO result = porDstrctService.selectDstrctId(vo);
		
		resultMap.put("data", result);
		
		return resultMap;
	}
	
	
	/**
	 * 인천지도포털 -> 지구단위계획
	 * @param model
	 * @return jsonData
	 * @exception Exception
	 */
	@GetMapping("/info/DstrctByPoint.do")
	@ResponseBody
	public Map<String, Object> selectDstrctPlanListByPoint(
			@ModelAttribute PorDstrctPlanResultVO vo
			) throws Exception {
		
		Map<String, Object> resultMap = new HashMap<String, Object>();
		
		PorDstrctPlanResultVO result = porDstrctService.selectDstrctPlanListByPoint(vo);
		
		resultMap.put("data", result);
		
		return resultMap;
	}
}