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

Merge branch 'master' of
ssh://anderx@git.jishutao.com:55555/jishutao/jitao-server.git

Conflicts:
src/main/java/com/goafanti/common/mapper/JtBusinessProjectMapper.xml

anderx 7 роки тому
батько
коміт
3f12c1d07e

+ 0 - 5
src/main/java/com/goafanti/common/controller/PublicController.java

@@ -690,9 +690,4 @@ public class PublicController extends BaseController {
 		return res;
 	}
 	
-	
-	
-	
-	
-	
 }

Різницю між файлами не показано, бо вона завелика
+ 608 - 546
src/main/java/com/goafanti/common/controller/WebpageController.java


+ 40 - 0
src/main/java/com/goafanti/core/shiro/filter/DeviceFilter.java

@@ -0,0 +1,40 @@
+package com.goafanti.core.shiro.filter;
+
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.shiro.web.filter.AccessControlFilter;
+import org.apache.shiro.web.util.WebUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+
+import com.goafanti.common.utils.LoggerUtils;
+
+
+public class DeviceFilter extends  AccessControlFilter{
+
+	@Autowired
+	private ShiroFilterUtils shiroFilterUtils;
+	
+	@Value(value = "${app.mobile.website}")
+	private String mobileWebsite;
+	
+	@Override
+	protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue)
+			throws Exception {
+		if (shiroFilterUtils.isMobileDevice((HttpServletRequest)request) || request.getServerName().startsWith("m.")){
+			return false;
+		}
+		return true;
+	}
+
+	@Override
+	protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception {
+		if (shiroFilterUtils.isMobileDevice((HttpServletRequest)request) || request.getServerName().startsWith("m.")){
+			LoggerUtils.debug(getClass(), "当前访问为移动设备");
+			WebUtils.issueRedirect(request, response, mobileWebsite,null,false);
+		}
+		return false;
+	}
+}

+ 1 - 0
src/main/java/com/goafanti/core/shiro/filter/PermissionFilter.java

@@ -10,6 +10,7 @@ import org.apache.shiro.util.StringUtils;
 import org.apache.shiro.web.filter.AccessControlFilter;
 import org.apache.shiro.web.util.WebUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 
 import com.goafanti.common.bo.Error;
 import com.goafanti.common.bo.Result;

+ 18 - 0
src/main/java/com/goafanti/core/shiro/filter/ShiroFilterUtils.java

@@ -33,6 +33,24 @@ public class ShiroFilterUtils {
 	}
 
 	/**
+	 * 判断是否来自移动设备
+	 * @param request
+	 * @return
+	 */
+	public boolean isMobileDevice(HttpServletRequest request) {
+		String[] deviceArray = new String[]{"android","blackBerry","windows phone","iphone","ipod","ipad"};
+        if(request.getHeader("User-Agent") != null){
+        	String agent = request.getHeader("User-Agent");
+        	for(int i = 0; i<deviceArray.length; i++){
+        		if(agent.toLowerCase().indexOf(deviceArray[i]) >0 ){
+        			return true;
+        		}
+        	} 	
+        }
+       return false;
+	}
+	
+	/**
 	 * 
 	 * @param request
 	 * @return true if App request

+ 3 - 1
src/main/resources/props/config_local.properties

@@ -52,6 +52,7 @@ session.timeout=12000000
 session.validate.timespan=18000000
 
 app.name=AFT
+app.mobile.website=http://m.kedexinxi.com
 template.cacheable=false
 
 static.host=//sclient.jishutao.com/client/1.0.0
@@ -75,4 +76,5 @@ easemob.client.secret=YXA61NHE0renI5N8gEgizoI5ivM9SYE
 
 jiguang.appKey=dbcea43366e038073452a04e
 jiguang.masterSecret=59792298288e4f635c737def
-jiguang.pushUrl=https://api.jpush.cn/v3/push
+jiguang.pushUrl=https://api.jpush.cn/v3/push
+

+ 1 - 0
src/main/resources/props/config_test.properties

@@ -53,6 +53,7 @@ session.timeout=12000000
 session.validate.timespan=18000000
 
 app.name=AFT
+app.mobile.website=http://m.kedexinxi.com
 template.cacheable=false
 
 static.host=//statics.jishutao.com/client/1.0.0

+ 2 - 2
src/main/resources/shiro_base_auth.ini

@@ -1,5 +1,5 @@
 [base_auth]
-/=anon
+/=device
 /index=anon
 /login=anon
 /user/login.html=anon
@@ -16,7 +16,7 @@
 /open/**=anon
 /favicon.ico=anon
 /static/**=anon
-/portal/**=anon
+/portal/**=device
 /api/portal/**=anon
 /api/admin/**=admin
 /api/user/**=login

+ 3 - 0
src/main/resources/spring/spring-shiro.xml

@@ -160,6 +160,9 @@
 						<property name="loginUrl" value="/admin/login" />
 					</bean>
 				</entry>
+				<entry key="device">
+					<bean id="device" class="com.goafanti.core.shiro.filter.DeviceFilter"></bean>
+				</entry>
 			</util:map>
 		</property>
 	</bean>

+ 1 - 1
src/main/webapp/WEB-INF/views/common.html

@@ -283,7 +283,7 @@
 					<div class="text_top">
 						<a th:href="@{/portal/aboutUs}">关于公司/</a>
 						<a th:href="@{/portal/contactUs}">联系我们</a>
-						<p> Copyright &copy 2016-2017 科德 版权所有 湘ICP备15019731号
+						<p> Copyright &copy 2016-2017 科德 版权所有 <a href="http://www.miitbeian.gov.cn/" target="_blank">湘ICP备15019731号</a>
 							-2 技术支持:湖南阿凡提科技有限公司</p>
 					</div>
 					<div class="text_center">

Різницю між файлами не показано, бо вона завелика
+ 1 - 1
src/main/webapp/WEB-INF/views/portal/aboutUs.html