Переглянути джерело

상품관련 interceptor 추가

eskim 5 роки тому
батько
коміт
f0451118d0

+ 37 - 19
src/main/java/com/style24/front/support/interceptor/TsfAflinkInterceptor.java

@@ -3,15 +3,25 @@ package com.style24.front.support.interceptor;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.web.servlet.ModelAndView;
 import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
 
+import com.style24.front.biz.service.TsfCommonService;
+import com.style24.front.support.security.session.TsfSession;
+import com.style24.persistence.domain.InflowHst;
+
 import lombok.extern.slf4j.Slf4j;
 
+import com.gagaframework.web.parameter.GagaMap;
+import com.gagaframework.web.parameter.GagaParameterUtil;
+import com.gagaframework.web.util.GagaStringUtil;
+
 /**
  * 제휴링크 Interceptor
- * 
+ *
  * @author gagamel
  * @since 2020. 9. 11
  */
@@ -19,27 +29,35 @@ import lombok.extern.slf4j.Slf4j;
 @Slf4j
 public class TsfAflinkInterceptor extends HandlerInterceptorAdapter {
 
-//	@Autowired
-//	private WfoCommonService commonService;
+	@Autowired
+	private TsfCommonService commonService;
 
 	@Override
 	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
-//		// Parameter
-//		GagaMap params = GagaParameterUtil.getParameterMap(request);
-//
-//		// 제휴링크코드
-//		String afLinkCd = params.getString("afLinkCd");
-//
-//		if (StringUtils.isNotBlank(afLinkCd)) {
-//			if (!afLinkCd.equals(FoSession.getAttribute("afLinkCd"))) {
-//				FoSession.setAttribute("afLinkCd", afLinkCd);
-//			}
-//		} else {
-//			afLinkCd = "AF001"; // STYLE24
-//			FoSession.setAttribute("afLinkCd", afLinkCd);
-//		}
-//
-//		commonService.createInflowHistory(afLinkCd);
+		// Parameter
+		GagaMap params = GagaParameterUtil.getParameterMap(request);
+
+		// 제휴링크코드
+		String afLinkCd = params.getString("afLinkCd");
+
+		if (StringUtils.isNotBlank(afLinkCd)) {
+			if (!afLinkCd.equals(TsfSession.getAttribute("afLinkCd"))) {
+				TsfSession.setAttribute("afLinkCd", afLinkCd);
+			}
+		} else {
+			afLinkCd = "AF001"; // STYLE24
+			TsfSession.setAttribute("afLinkCd", afLinkCd);
+		}
+
+		String queryString = GagaStringUtil.convertParameterToQueryString(request.getParameterMap());
+		if (StringUtils.isNotBlank(queryString)) {
+			queryString = "?" + queryString;
+		}
+
+		InflowHst inflow = new InflowHst();
+		inflow.setAfLinkCd(afLinkCd);
+		inflow.setReturnUrl(request.getRequestURL() + queryString);
+		commonService.createInflowHst(inflow);
 
 		return super.preHandle(request, response, handler);
 	}

+ 37 - 28
src/main/java/com/style24/front/support/interceptor/TsfGoodsViewInterceptor.java

@@ -3,15 +3,24 @@ package com.style24.front.support.interceptor;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 import org.springframework.web.servlet.ModelAndView;
 import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
 
+import com.style24.front.biz.service.TsfGoodsService;
+import com.style24.front.support.env.TsfConstants;
+
 import lombok.extern.slf4j.Slf4j;
 
+import com.gagaframework.web.parameter.GagaMap;
+import com.gagaframework.web.parameter.GagaParameterUtil;
+import com.gagaframework.web.util.GagaCookieUtil;
+
 /**
  * 상품뷰 Interceptor
- * 
+ *
  * @author gagamel
  * @since 2020. 9. 11
  */
@@ -19,37 +28,37 @@ import lombok.extern.slf4j.Slf4j;
 @Slf4j
 public class TsfGoodsViewInterceptor extends HandlerInterceptorAdapter {
 
-//	@Value("${has-ssl}")
-//	private String hasSsl;
+	@Value("${has-ssl}")
+	private String hasSsl;
 
-//	@Autowired
-//	private WfoGoodsService goodsService;
+	@Autowired
+	private TsfGoodsService 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);
-//		}
+		// Parameter
+		GagaMap params = GagaParameterUtil.getParameterMap(request);
+
+		// 상품뷰이력 생성
+		goodsService.createGoodsViewHst(params.getString("goodsCd"), params.getString("ithrCd"));
+
+		// SSL Server
+		boolean isSslServer = Boolean.parseBoolean(hasSsl);
+		log.debug("isSslServer: [{}]", isSslServer);
+
+		if (isSslServer) {
+			// 상품유입경로 쿠키 설정
+			GagaCookieUtil.setSecureCookie(response, TsfConstants.CK_PREFIX + "_ithrCd", params.getString("ithrCd"), -1);
+
+			// 컨텐츠위치코드 쿠키 설정
+			GagaCookieUtil.setSecureCookie(response, TsfConstants.CK_PREFIX + "_contentsLoc", params.getString("contentsLoc"), -1);
+		} else {
+			// 상품유입경로 쿠키 설정
+			GagaCookieUtil.setCookie(response, TsfConstants.CK_PREFIX + "_ithrCd", params.getString("ithrCd"), -1);
+
+			// 컨텐츠위치코드 쿠키 설정
+			GagaCookieUtil.setCookie(response, TsfConstants.CK_PREFIX + "_contentsLoc", params.getString("contentsLoc"), -1);
+		}
 
 		return super.preHandle(request, response, handler);
 	}

+ 28 - 0
src/main/java/com/style24/persistence/domain/InflowHst.java

@@ -0,0 +1,28 @@
+package com.style24.persistence.domain;
+
+import com.style24.persistence.TscBaseDomain;
+
+import lombok.Data;
+
+/**
+ *  제휴링크 이력 Domain
+ *
+ * @author eskim
+ * @since 2020. 03. 02
+ */
+@SuppressWarnings("serial")
+@Data
+public class InflowHst extends TscBaseDomain {
+
+	private String inflowDt;		// 유입일시
+	private String siteCd;			// 사이트코드
+	private String inflowRefer;		// 유입REFER
+	private String ipAddr;			// IP주소
+	private String afLinkCd;		// 제휴링크코드
+	private String jsessionId;		// J세션 ID
+	private String frontGb;			// PC,MO구분
+	private String appYn;			// APP구분
+	private String osType;			// Mobile OS 구분
+	private String returnUrl;		// return URL
+
+}