package nlib.info.web;

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

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import nlib.cmm.NlibCommonController;
import nlib.cmm.service.NlibProperty;
import nlib.info.service.InformService;
import nlib.info.service.impl.InformServiceImpl;
import nlib.restful.service.DataApiReqVO;
import nlib.restful.service.DataApiResVO;
import nlib.util.StringUtil;

/**
 * <pre>
 * @Class Name : InformController.java
 * 
 * @Description : 이용안내 및 약관관련 정보 제공 클래스 
 * 
 * 
 * @프로젝트명: 지방문화원 통합자료관리시스템 구축사업 (2021)
 *
 * </pre>
 *
 * @ ------------    --------    ---------------------------
 * @ 수정일                           수정자                 수정내용
 * @ ------------    --------    ---------------------------
 * @ 2021. 7. 27.    KNKIM       최초 생성
 *
 * 
 * @author 이씨플라자 * DIGITALSHIP KNKIM
 * @since 2021. 7. 27.
 * @version 1.0
 *
 */
@Controller
public class InformController extends NlibCommonController {
	
	private static final Logger log = LoggerFactory.getLogger(InformController.class);
	
	@Resource(name="informService")
	private InformService informService;


	/**
	 * 이용약관을 조회한다. 
	 * 
	 * @param req
	 * @param authentication
	 * @param model
	 * @return
	 */
	@RequestMapping("/inform/selectTermsInfo.do")
	public String selectTermsInfo(HttpServletRequest request, ModelMap model) throws Exception {

    	HashMap<String, String> ret = informService.selectTermsInfo(NlibProperty.getString("nlib.council.cd"));

    	model.addAttribute("informTitle", ret.get("TITLE"));
    	model.addAttribute("informContent", ret.get("CONTENT"));

		return "nlib/inform/selectTermsInfo";
	}

	/**
	 * 개인정보처리방침을 조회한다. 
	 * 
	 * @param req
	 * @param authentication
	 * @param model
	 * @return
	 */
	@RequestMapping("/inform/selectPrivacyInfo.do")
	public String selectPrivacyInfo(HttpServletRequest request, Authentication authentication, ModelMap model) throws Exception {

    	HashMap<String, String> ret = informService.selectPrivacyInfo(NlibProperty.getString("nlib.council.cd"));

    	model.addAttribute("informTitle", ret.get("TITLE"));
    	model.addAttribute("informContent", ret.get("CONTENT"));

		return "nlib/inform/selectPrivacyInfo";
	}

	/**
	 * 인사말을 조회한다. 
	 * 
	 * @param req
	 * @param authentication
	 * @param model
	 * @return
	 */
	@RequestMapping("/inform/selectGreeting.do")
	public String selectGreeting(HttpServletRequest request, Authentication authentication, ModelMap model) throws Exception {

		
    	HashMap<String, String> ret = informService.selectGreeting(getCurCouncilCd(request));

    	model.addAttribute("informTitle", ret.get("TITLE"));
    	model.addAttribute("informContent", ret.get("CONTENT"));
    	model.addAttribute("councilNm", getCurCouncilNm(request));

		return "nlib/inform/selectGreeting";
	}

	/**
	 * 이용안내를 조회한다. 
	 * 
	 * @param req
	 * @param authentication
	 * @param model
	 * @return
	 */
	@RequestMapping("/inform/selectNCultureOperationInfo.do")
	public String selectNCultureOperationInfo(HttpServletRequest request, Authentication authentication, ModelMap model) throws Exception {

    	// 이용안내 내용 
    	HashMap<String, String> ret = informService.selectNCultureOperationInfo(getCurCouncilCd(request));
    	model.addAttribute("informTitle",   ret.get("informTitle"));
    	model.addAttribute("informContent", ret.get("informContent"));
    	model.addAttribute("openTime",      ret.get("openTime"));
    	model.addAttribute("closeTime",     ret.get("closeTime"));
    	model.addAttribute("closingInfo",   ret.get("closingInfo"));

		return "nlib/inform/selectNCultureOperationInfo";
	}
	

	/**
	 * 찾아오는길 조회한다. 
	 * 
	 * @param req
	 * @param authentication
	 * @param model
	 * @return
	 */
	@RequestMapping("/inform/selectNCultureLocationInfo.do")
	public String selectNCultureLocationInfo(HttpServletRequest request, Authentication authentication, ModelMap model) throws Exception {

    	HashMap<String, String> ret = informService.selectNCultureLocationInfo(getCurCouncilCd(request));

    	model.addAttribute("mngOrgNm"     , getCurCouncilNm(request));
    	
    	model.addAttribute("informTitle"  , ret.get("TITLE"));
    	model.addAttribute("informContent", ret.get("CONTENT"));

    	model.addAttribute("openTime",      ret.get("OPEN_TIME"));
    	model.addAttribute("closeTime",     ret.get("CLOSED_TIME"));
    	model.addAttribute("closingInfo",   ret.get("CLOSING_INFO"));

    	model.addAttribute("zipCode"      , ret.get("ZIP_CODE"));
    	model.addAttribute("address"      , ret.get("ADDRESS"));
    	model.addAttribute("addressDetail", ret.get("ADDRESS_DETAIL"));
    	model.addAttribute("phoneNo"      , ret.get("PHONE_NO"));
    	model.addAttribute("faxNo"        , ret.get("FAX_NO"));
    	model.addAttribute("latitude"     , ret.get("LATITUDE"));
    	model.addAttribute("longitude"    , ret.get("LONGITUDE"));

		return "nlib/inform/selectNCultureLocationInfo";
	}

	/**
	 * 찾아오는길 조회한다. 
	 * 
	 * @param req
	 * @param authentication
	 * @param model
	 * @return
	 */
	@RequestMapping("/inform/selectNCultureLocationInfoPopup.do")
	public String selectNCultureLocationInfoPopup(HttpServletRequest request, Authentication authentication, ModelMap model) throws Exception {

    	HashMap<String, String> ret = informService.selectNCultureLocationInfo(getCurCouncilCd(request));

    	model.addAttribute("informTitle", ret.get("TITLE"));
    	model.addAttribute("informContent", ret.get("CONTENT"));
    	
		return "nlib/inform/selectNCultureLocationInfoPopup";
	}

}