|
@@ -3,7 +3,6 @@ package com.style24.front.support.controller;
|
|
|
import java.util.Collection;
|
|
import java.util.Collection;
|
|
|
import java.util.Set;
|
|
import java.util.Set;
|
|
|
|
|
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
import javax.validation.ConstraintViolation;
|
|
import javax.validation.ConstraintViolation;
|
|
|
import javax.validation.Validation;
|
|
import javax.validation.Validation;
|
|
|
import javax.validation.Validator;
|
|
import javax.validation.Validator;
|
|
@@ -12,25 +11,17 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.propertyeditors.StringTrimmerEditor;
|
|
import org.springframework.beans.propertyeditors.StringTrimmerEditor;
|
|
|
import org.springframework.core.env.Environment;
|
|
import org.springframework.core.env.Environment;
|
|
|
-import org.springframework.mobile.device.Device;
|
|
|
|
|
-import org.springframework.mobile.device.DeviceUtils;
|
|
|
|
|
-import org.springframework.mobile.device.site.SitePreference;
|
|
|
|
|
-import org.springframework.mobile.device.site.SitePreferenceUtils;
|
|
|
|
|
-import org.springframework.mobile.device.util.ResolverUtils;
|
|
|
|
|
-import org.springframework.util.Assert;
|
|
|
|
|
import org.springframework.web.bind.WebDataBinder;
|
|
import org.springframework.web.bind.WebDataBinder;
|
|
|
import org.springframework.web.bind.annotation.ControllerAdvice;
|
|
import org.springframework.web.bind.annotation.ControllerAdvice;
|
|
|
import org.springframework.web.bind.annotation.InitBinder;
|
|
import org.springframework.web.bind.annotation.InitBinder;
|
|
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
-import org.springframework.web.context.request.RequestAttributes;
|
|
|
|
|
-import org.springframework.web.context.request.RequestContextHolder;
|
|
|
|
|
-import org.springframework.web.context.request.ServletRequestAttributes;
|
|
|
|
|
|
|
|
|
|
import com.style24.core.support.message.TscMessageByLocale;
|
|
import com.style24.core.support.message.TscMessageByLocale;
|
|
|
import com.style24.front.support.env.TsfConstants;
|
|
import com.style24.front.support.env.TsfConstants;
|
|
|
import com.style24.front.support.security.session.TsfSession;
|
|
import com.style24.front.support.security.session.TsfSession;
|
|
|
import com.style24.front.support.startup.TsfEnvsetInfo;
|
|
import com.style24.front.support.startup.TsfEnvsetInfo;
|
|
|
|
|
+import com.style24.front.support.util.ViewUtils;
|
|
|
import com.style24.persistence.domain.Cate1;
|
|
import com.style24.persistence.domain.Cate1;
|
|
|
import com.style24.persistence.domain.Login;
|
|
import com.style24.persistence.domain.Login;
|
|
|
import com.style24.persistence.domain.Meta;
|
|
import com.style24.persistence.domain.Meta;
|
|
@@ -40,7 +31,6 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import com.gagaframework.web.rest.exception.GagaRestException;
|
|
import com.gagaframework.web.rest.exception.GagaRestException;
|
|
|
import com.gagaframework.web.rest.server.GagaResponse;
|
|
import com.gagaframework.web.rest.server.GagaResponse;
|
|
|
import com.gagaframework.web.rest.server.GagaResponseStatus;
|
|
import com.gagaframework.web.rest.server.GagaResponseStatus;
|
|
|
-import com.gagaframework.web.util.GagaCookieUtil;
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Controller Advice
|
|
* Controller Advice
|
|
@@ -277,41 +267,7 @@ public class TsfBaseController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public String getDeviceViewName(String viewName) {
|
|
public String getDeviceViewName(String viewName) {
|
|
|
- RequestAttributes attrs = RequestContextHolder.getRequestAttributes();
|
|
|
|
|
- Assert.isInstanceOf(ServletRequestAttributes.class, attrs);
|
|
|
|
|
- HttpServletRequest request = ((ServletRequestAttributes)attrs).getRequest();
|
|
|
|
|
-
|
|
|
|
|
- Device device = DeviceUtils.getCurrentDevice(request);
|
|
|
|
|
- SitePreference sitePreference = SitePreferenceUtils.getCurrentSitePreference(request);
|
|
|
|
|
- String resolvedViewName = viewName;
|
|
|
|
|
-
|
|
|
|
|
- if (ResolverUtils.isNormal(device, sitePreference)) {
|
|
|
|
|
- resolvedViewName = "web/" + viewName + "Web";
|
|
|
|
|
- } else if (ResolverUtils.isMobile(device, sitePreference)) {
|
|
|
|
|
- if (GagaCookieUtil.getCookie(request, TsfConstants.CK_PREFIX + "_site_preference").equals("normal")) {
|
|
|
|
|
- resolvedViewName = "web/" + viewName + "Web";
|
|
|
|
|
- } else {
|
|
|
|
|
- resolvedViewName = "mob/" + viewName + "Mob";
|
|
|
|
|
- }
|
|
|
|
|
- } else if (ResolverUtils.isTablet(device, sitePreference)) {
|
|
|
|
|
- if (GagaCookieUtil.getCookie(request, TsfConstants.CK_PREFIX + "_site_preference").equals("normal")) {
|
|
|
|
|
- resolvedViewName = "web/" + viewName + "Web";
|
|
|
|
|
- } else {
|
|
|
|
|
- resolvedViewName = "mob/" + viewName + "Mob";
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- log.info("resolvedViewName: {}", resolvedViewName);
|
|
|
|
|
-
|
|
|
|
|
- return stripTrailingSlash(resolvedViewName);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private String stripTrailingSlash(String viewName) {
|
|
|
|
|
- if (viewName.endsWith("//")) {
|
|
|
|
|
- return viewName.substring(0, viewName.length() - 1);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return viewName;
|
|
|
|
|
|
|
+ return ViewUtils.getDeviceViewName(viewName);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|