package com.style24.front.support.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import lombok.extern.slf4j.Slf4j;

/**
 * 상품뷰 Interceptor
 * 
 * @author gagamel
 * @since 2020. 9. 11
 */
@Component
@Slf4j
public class TsfGoodsViewInterceptor extends HandlerInterceptorAdapter {

//	@Value("${has-ssl}")
//	private String hasSsl;

//	@Autowired
//	private WfoGoodsService goodsService;

	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//		// Parameter
//		GagaMap params = GagaParameterUtil.getParameterMap(request);
//
//		// 상품뷰이력 생성
//		goodsService.createGoodsViewHistory(params.getString("goodsCd"), params.getString("ithrCd"));
//
//		// SSL Server
//		boolean isSslServer = Boolean.parseBoolean(hasSsl);
//		log.debug("isSslServer: [{}]", isSslServer);
//
//		if (isSslServer) {
//			// 상품유입경로 쿠키 설정
//			GagaCookieUtil.setSecureCookie(response, FoConstants.CK_PREFIX + "_ithrCd", params.getString("ithrCd"), -1);
//
//			// 컨텐츠위치코드 쿠키 설정
//			GagaCookieUtil.setSecureCookie(response, FoConstants.CK_PREFIX + "_contentsLoc", params.getString("contentsLoc"), -1);
//		} else {
//			// 상품유입경로 쿠키 설정
//			GagaCookieUtil.setCookie(response, FoConstants.CK_PREFIX + "_ithrCd", params.getString("ithrCd"), -1);
//
//			// 컨텐츠위치코드 쿠키 설정
//			GagaCookieUtil.setCookie(response, FoConstants.CK_PREFIX + "_contentsLoc", params.getString("contentsLoc"), -1);
//		}

		return super.preHandle(request, response, handler);
	}

	@Override
	public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
		ModelAndView modelAndView) throws Exception {
		// Do nothing
	}

}
