|
|
@@ -5,11 +5,13 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
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.TsfCommonService;
|
|
|
+import com.style24.front.support.env.TsfConstants;
|
|
|
import com.style24.front.support.security.session.TsfSession;
|
|
|
import com.style24.persistence.domain.InflowHst;
|
|
|
|
|
|
@@ -17,11 +19,15 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
import com.gagaframework.web.parameter.GagaMap;
|
|
|
import com.gagaframework.web.parameter.GagaParameterUtil;
|
|
|
+import com.gagaframework.web.util.GagaCookieUtil;
|
|
|
import com.gagaframework.web.util.GagaStringUtil;
|
|
|
|
|
|
/**
|
|
|
* 제휴링크 Interceptor
|
|
|
- *
|
|
|
+ * if 제휴링크코드가 있고 세션 값이 다를 경우
|
|
|
+ * 그리고 쿠키가 존재하고 제휴쿠키가 있지만 세션 처리가 안 되었을 경우 세션을 생성한다.
|
|
|
+ * else
|
|
|
+ * 제휴링크코드가 없고 제휴링크 세션도 없으면
|
|
|
* @author gagamel
|
|
|
* @since 2020. 9. 11
|
|
|
*/
|
|
|
@@ -32,6 +38,9 @@ public class TsfAflinkInterceptor extends HandlerInterceptorAdapter {
|
|
|
@Autowired
|
|
|
private TsfCommonService commonService;
|
|
|
|
|
|
+ @Value("${has-ssl}")
|
|
|
+ private String hasSsl;
|
|
|
+
|
|
|
@Override
|
|
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
|
|
// Parameter
|
|
|
@@ -39,45 +48,98 @@ public class TsfAflinkInterceptor extends HandlerInterceptorAdapter {
|
|
|
|
|
|
// 제휴링크코드
|
|
|
String afLinkCd = params.getString("afLinkCd");
|
|
|
-
|
|
|
- if (StringUtils.isNotBlank(afLinkCd)) {
|
|
|
- // 유효한 웹제휴채널코드 여부 조회
|
|
|
- String isAvailAfLinkCdYn = commonService.getAvailableAfLinkYn(afLinkCd);
|
|
|
- log.info("isAvailAfLinkCdYn: {}", isAvailAfLinkCdYn);
|
|
|
-
|
|
|
- // 유효한 웹제휴채널코드이면
|
|
|
- if (isAvailAfLinkCdYn.equals("Y")) {
|
|
|
- if (!afLinkCd.equals(TsfSession.getAttribute("afLinkCd"))) {
|
|
|
- TsfSession.setAttribute("afLinkCd", afLinkCd);
|
|
|
- }
|
|
|
- } else {
|
|
|
- afLinkCd = "";
|
|
|
- }
|
|
|
+ boolean makeAfSession = false;
|
|
|
+ log.info("========================1:{}", TsfSession.getAttribute("afLinkCd"));
|
|
|
+
|
|
|
+ // 제휴링크코드가 있고 세션 값과 다를 경우
|
|
|
+ // 또는
|
|
|
+ // 제휴링크코드 쿠키가 존재하고 세션 값이 없을 경우
|
|
|
+ if ((StringUtils.isNotBlank(afLinkCd) && !afLinkCd.equals(TsfSession.getAttribute("afLinkCd"))) ||
|
|
|
+ (StringUtils.isNotBlank(GagaCookieUtil.getCookie(request, TsfConstants.CK_PREFIX + "_afLinkCd")) && StringUtils.isNotBlank(TsfSession.getAttribute("afLinkCd")))) {
|
|
|
+ makeAfSession = true;
|
|
|
+// log.info("========================2");
|
|
|
+// // 파라미터로 들어온 값이 있으면
|
|
|
+// // 1.유효한 웹제휴채널코드 여부 조회
|
|
|
+// String isAvailAfLinkCdYn = commonService.getAvailableAfLinkYn(afLinkCd);
|
|
|
+// log.info("isAvailAfLinkCdYn: {}", isAvailAfLinkCdYn);
|
|
|
+// log.info("========================3");
|
|
|
+// // 2.유효한 웹제휴채널코드이고 세션 값과 다르면 다시 설정
|
|
|
+// // 유효한 웹제휴채널코드가 아니면 공백으로
|
|
|
+// if (isAvailAfLinkCdYn.equals("Y")) {
|
|
|
+// log.info("========================4");
|
|
|
+// if (!afLinkCd.equals(TsfSession.getAttribute("afLinkCd"))) {
|
|
|
+// log.info("========================5");
|
|
|
+// TsfSession.setAttribute("afLinkCd", afLinkCd);
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// log.info("========================6");
|
|
|
+// if (StringUtils.isNotBlank(TsfSession.getAttribute("afLinkCd"))) {
|
|
|
+// afLinkCd = TsfSession.getAttribute("afLinkCd");
|
|
|
+// } else {
|
|
|
+// afLinkCd = "";
|
|
|
+// }
|
|
|
+// }
|
|
|
} else {
|
|
|
- if (TsfSession.getAttribute("isApp").equals("true")) { // 앱이면
|
|
|
- if (TsfSession.getAttribute("osType").equals("A")) {
|
|
|
- afLinkCd = "AF016"; // AOS앱
|
|
|
- } else if (TsfSession.getAttribute("osType").equals("I")) {
|
|
|
- afLinkCd = "AF017"; // IOS앱
|
|
|
- }
|
|
|
- } else { // 웹이면
|
|
|
- if (TsfSession.getFrontGb().equals("P")) {
|
|
|
- afLinkCd = "AF006"; // PC웹
|
|
|
- } else if (TsfSession.getFrontGb().equals("M")) {
|
|
|
- afLinkCd = "AF015"; // 모바일웹
|
|
|
+ log.info("========================7");
|
|
|
+ // 파라미터로 들어온 값이 없을 때
|
|
|
+ // 2.1.세션에 담긴 값이 없으면 앱과 웹에 따라 OS에 따라 설정
|
|
|
+// if (StringUtils.isBlank(TsfSession.getAttribute("afLinkCd")) &&
|
|
|
+// StringUtils.isBlank(GagaCookieUtil.getCookie(request, TsfConstants.CK_PREFIX + "_afLinkCd"))) {
|
|
|
+ if (StringUtils.isBlank(TsfSession.getAttribute("afLinkCd")) && StringUtils.isBlank(GagaCookieUtil.getCookie(request, TsfConstants.CK_PREFIX + "_afLinkCd"))) {
|
|
|
+ log.info("========================8");
|
|
|
+ if (TsfSession.getAttribute("isApp").equals("true")) { // 앱이면
|
|
|
+ log.info("========================9");
|
|
|
+ if (TsfSession.getAttribute("osType").equals("A")) {
|
|
|
+ log.info("========================10");
|
|
|
+ afLinkCd = "AF016"; // AOS앱
|
|
|
+ } else if (TsfSession.getAttribute("osType").equals("I")) {
|
|
|
+ log.info("========================11");
|
|
|
+ afLinkCd = "AF017"; // IOS앱
|
|
|
+ }
|
|
|
+ log.info("========================12");
|
|
|
+ } else { // 웹이면
|
|
|
+ log.info("========================13");
|
|
|
+ if (TsfSession.getFrontGb().equals("P")) {
|
|
|
+ log.info("========================14");
|
|
|
+ afLinkCd = "AF006"; // PC웹
|
|
|
+ } else if (TsfSession.getFrontGb().equals("M")) {
|
|
|
+ log.info("========================15");
|
|
|
+ afLinkCd = "AF015"; // 모바일웹
|
|
|
+ }
|
|
|
+ log.info("========================16");
|
|
|
}
|
|
|
+ log.info("========================17");
|
|
|
}
|
|
|
+ log.info("========================18");
|
|
|
|
|
|
TsfSession.setAttribute("afLinkCd", afLinkCd);
|
|
|
- }
|
|
|
|
|
|
- String queryString = GagaStringUtil.convertParameterToQueryString(request.getParameterMap());
|
|
|
- if (StringUtils.isNotBlank(queryString)) {
|
|
|
- queryString = "?" + queryString;
|
|
|
+ // SSL Server
|
|
|
+ boolean isSslServer = Boolean.parseBoolean(hasSsl);
|
|
|
+ log.debug("isSslServer: [{}]", isSslServer);
|
|
|
+
|
|
|
+ if (isSslServer) {
|
|
|
+ GagaCookieUtil.setSecureCookie(response, TsfConstants.CK_PREFIX + "_afLinkCd", afLinkCd, -1);
|
|
|
+ } else {
|
|
|
+ GagaCookieUtil.setCookie(response, TsfConstants.CK_PREFIX + "_afLinkCd", afLinkCd, -1);
|
|
|
+ }
|
|
|
}
|
|
|
+ log.info("========================19:{}", TsfSession.getAttribute("afLinkCd"));
|
|
|
|
|
|
try {
|
|
|
if (StringUtils.isNotBlank(afLinkCd)) {
|
|
|
+ String queryString = GagaStringUtil.convertParameterToQueryString(request.getParameterMap());
|
|
|
+ if (StringUtils.isNotBlank(queryString)) {
|
|
|
+ queryString = "?" + queryString;
|
|
|
+ if (StringUtils.isNotBlank(TsfSession.getAttribute("afLinkCd"))) {
|
|
|
+ queryString += "&afLinkCd=" + TsfSession.getAttribute("afLinkCd");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (StringUtils.isNotBlank(TsfSession.getAttribute("afLinkCd"))) {
|
|
|
+ queryString += "?afLinkCd=" + TsfSession.getAttribute("afLinkCd");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
InflowHst inflow = new InflowHst();
|
|
|
inflow.setAfLinkCd(afLinkCd);
|
|
|
inflow.setPageUrl(request.getRequestURL() + queryString);
|