From c97552b69c0af01aadc2580a59a46f58d5545985 Mon Sep 17 00:00:00 2001
From: kaiyu <404897439@qq.com>
Date: Tue, 15 Sep 2020 15:06:00 +0800
Subject: [PATCH] B/S登陆以及测试接口上传

---
 src/main/java/com/moral/common/webAnno/PassToken.java          |   18 +
 /dev/null                                                      |   39 --
 src/main/java/com/moral/common/interceptor/WebInterceptor.java |  106 +++++++
 src/main/java/com/moral/controller/WebController.java          |   16 
 src/main/java/com/moral/common/webAnno/UserLoginToken.java     |   20 +
 src/main/java/com/moral/ScreenApiApplication.java              |    8 
 src/main/java/com/moral/config/WebInterceptorConfig.java       |   12 
 pom.xml                                                        |  568 ++++++++++++++++++++--------------------
 src/main/resources/banner.txt                                  |   23 +
 src/main/resources/application.yml                             |    4 
 10 files changed, 477 insertions(+), 337 deletions(-)

diff --git a/pom.xml b/pom.xml
index e938a1f..b9a283b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,292 +1,298 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-	<modelVersion>4.0.0</modelVersion>
+		 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<modelVersion>4.0.0</modelVersion>
 
-	<groupId>com.moral</groupId>
-	<artifactId>screen_api</artifactId>
-	<version>2.0.0</version>
-	<packaging>war</packaging>
+<groupId>com.moral</groupId>
+<artifactId>screen_api</artifactId>
+<version>2.0.0</version>
+<packaging>war</packaging>
 
-	<name>screen_api</name>
-	<description>Screen API</description>
+<name>screen_api</name>
+<description>Screen API</description>
 
-	<parent>
+<parent>
+	<groupId>org.springframework.boot</groupId>
+	<artifactId>spring-boot-starter-parent</artifactId>
+	<version>1.5.8.RELEASE</version>
+	<relativePath/> <!-- lookup parent from repository -->
+</parent>
+
+<properties>
+	<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+	<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+	<java.version>1.8</java.version>
+</properties>
+
+<repositories>
+	<repository>
+		<id>aliyunRepository</id>
+		<name>myRepository</name>
+		<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
+		<snapshots>
+			<enabled>false</enabled>
+		</snapshots>
+	</repository>
+
+	<repository>
+		<id>spring-milestone</id>
+		<url>http://repo.spring.io/libs-release</url>
+	</repository>
+</repositories>
+
+<dependencies>
+	<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
+	<dependency>
+		<groupId>com.google.code.gson</groupId>
+		<artifactId>gson</artifactId>
+		<version>2.8.5</version>
+	</dependency>
+
+
+	<dependency>
 		<groupId>org.springframework.boot</groupId>
-		<artifactId>spring-boot-starter-parent</artifactId>
-		<version>1.5.8.RELEASE</version>
-		<relativePath/> <!-- lookup parent from repository -->
-	</parent>
+		<artifactId>spring-boot-starter</artifactId>
+	</dependency>
 
-	<properties>
-		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
-		<java.version>1.8</java.version>
-	</properties>
-
-	<repositories>
-		<repository>
-			<id>aliyunRepository</id>
-			<name>myRepository</name>
-			<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
-			<snapshots>
-				<enabled>false</enabled>
-			</snapshots>
-		</repository>
-
-		<repository>
-			<id>spring-milestone</id>
-			<url>http://repo.spring.io/libs-release</url>
-		</repository>
-	</repositories>
-
-	<dependencies>
-		<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
-		<dependency>
-			<groupId>com.google.code.gson</groupId>
-			<artifactId>gson</artifactId>
-			<version>2.8.5</version>
-		</dependency>
+	<!-- https://mvnrepository.com/artifact/org.json/json -->
+	<dependency>
+		<groupId>org.json</groupId>
+		<artifactId>json</artifactId>
+		<version>20160810</version>
+	</dependency>
 
 
-		<dependency>
+	<dependency>
+		<groupId>org.springframework.boot</groupId>
+		<artifactId>spring-boot-starter-web</artifactId>
+	</dependency>
+
+	<dependency>
+		<groupId>org.springframework.boot</groupId>
+		<artifactId>spring-boot-starter-security</artifactId>
+	</dependency>
+
+	<dependency>
+		<groupId>org.mybatis.spring.boot</groupId>
+		<artifactId>mybatis-spring-boot-starter</artifactId>
+		<version>1.3.1</version>
+	</dependency>
+
+	<dependency>
+		<groupId>org.springframework.boot</groupId>
+		<artifactId>spring-boot-starter-data-redis</artifactId>
+	</dependency>
+
+
+	<dependency>
+		<groupId>org.springframework.boot</groupId>
+		<artifactId>spring-boot-starter-tomcat</artifactId>
+		<scope>provided</scope>
+	</dependency>
+
+	<dependency>
+		<groupId>org.springframework.boot</groupId>
+		<artifactId>spring-boot-starter-test</artifactId>
+		<scope>test</scope>
+	</dependency>
+
+	<dependency>
+		<groupId>org.springframework.security.oauth</groupId>
+		<artifactId>spring-security-oauth2</artifactId>
+	</dependency>
+
+	<dependency>
+		<groupId>org.springframework.boot</groupId>
+		<artifactId>spring-boot-configuration-processor</artifactId>
+		<optional>true</optional>
+	</dependency>
+
+	<dependency>
+		<groupId>com.alibaba</groupId>
+		<artifactId>druid</artifactId>
+		<version>1.1.5</version>
+	</dependency>
+
+	<dependency>
+		<groupId>mysql</groupId>
+		<artifactId>mysql-connector-java</artifactId>
+		<version>5.1.44</version>
+	</dependency>
+
+	<dependency>
+		<groupId>org.springframework.boot</groupId>
+		<artifactId>spring-boot-starter-data-mongodb</artifactId>
+	</dependency>
+	<dependency>
+		<groupId>org.apache.commons</groupId>
+		<artifactId>commons-lang3</artifactId>
+		<version>3.5</version>
+	</dependency>
+	<dependency>
+		<groupId>com.alibaba</groupId>
+		<artifactId>fastjson</artifactId>
+		<version>1.2.39</version>
+	</dependency>
+	<dependency>
+		<groupId>net.sourceforge.jexcelapi</groupId>
+		<artifactId>jxl</artifactId>
+		<version>2.6.12</version>
+	</dependency>
+	<dependency>
+		<groupId>net.sf.json-lib</groupId>
+		<artifactId>json-lib</artifactId>
+		<version>2.4</version>
+		<classifier>jdk15</classifier>
+	</dependency>
+	<dependency>
+		<groupId>org.projectlombok</groupId>
+		<artifactId>lombok</artifactId>
+		<version>1.16.18</version>
+	</dependency>
+	<dependency>
+		<groupId>org.springframework.boot</groupId>
+		<artifactId>spring-boot-starter-aop</artifactId>
+	</dependency>
+	<dependency>
+		<groupId>com.github.pagehelper</groupId>
+		<artifactId>pagehelper</artifactId>
+		<version>4.2.1</version>
+	</dependency>
+	<dependency>
+		<groupId>tk.mybatis</groupId>
+		<artifactId>mapper</artifactId>
+		<version>3.4.6</version>
+	</dependency>
+	<dependency>
+		<groupId>jstl</groupId>
+		<artifactId>jstl</artifactId>
+		<version>1.2</version>
+	</dependency>
+	<dependency>
+		<groupId>taglibs</groupId>
+		<artifactId>standard</artifactId>
+		<version>1.1.2</version>
+	</dependency>
+	<dependency>
+		<groupId>org.apache.tomcat.embed</groupId>
+		<artifactId>tomcat-embed-jasper</artifactId>
+		<scope>provided</scope>
+	</dependency>
+	<dependency>
+		<groupId>dom4j</groupId>
+		<artifactId>dom4j</artifactId>
+		<version>1.6.1</version>
+	</dependency>
+	<dependency>
+		<groupId>commons-net</groupId>
+		<artifactId>commons-net</artifactId>
+		<version>3.6</version>
+	</dependency>
+	<dependency>
+		<groupId>io.jsonwebtoken</groupId>
+		<artifactId>jjwt</artifactId>
+		<version>0.9.0</version>
+	</dependency>
+	<dependency>
+		<groupId>com.auth0</groupId>
+		<artifactId>java-jwt</artifactId>
+		<version>3.4.0</version>
+	</dependency>
+
+
+	<!-- ������������ -->
+	<dependency>
+		<groupId>com.taobao.api</groupId>
+		<artifactId>taobao-sdk</artifactId>
+		<version>1.0.0</version>
+		<scope>system</scope>
+		<systemPath>${project.basedir}/lib/taobao-sdk-java-auto_1455552377940-20160607.jar</systemPath>
+	</dependency>
+
+	<dependency>
+		<groupId>io.springfox</groupId>
+		<artifactId>springfox-swagger2</artifactId>
+		<version>2.7.0</version>
+	</dependency>
+	<dependency>
+		<groupId>io.springfox</groupId>
+		<artifactId>springfox-swagger-ui</artifactId>
+		<version>2.7.0</version>
+	</dependency>
+	<!-- https://mvnrepository.com/artifact/com.googlecode.aviator/aviator -->
+	<dependency>
+		<groupId>com.googlecode.aviator</groupId>
+		<artifactId>aviator</artifactId>
+		<version>4.2.0</version>
+	</dependency>
+
+	<dependency>
+		<groupId>cn.hutool</groupId>
+		<artifactId>hutool-all</artifactId>
+		<version>5.3.1</version>
+	</dependency>
+
+	<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
+	<dependency>
+		<groupId>org.apache.poi</groupId>
+		<artifactId>poi-ooxml</artifactId>
+		<version>4.1.2</version>
+	</dependency>
+
+	<dependency>
+		<groupId>org.springframework.boot</groupId>
+		<artifactId>spring-boot-starter-amqp</artifactId>
+	</dependency>
+
+	<dependency>
+		<groupId>org.springframework.boot</groupId>
+		<artifactId>spring-boot-starter-websocket</artifactId>
+	</dependency>
+</dependencies>
+
+<build>
+	<finalName>screen_api_v2</finalName>
+	<plugins>
+		<plugin>
+			<groupId>org.mybatis.generator</groupId>
+			<artifactId>mybatis-generator-maven-plugin</artifactId>
+			<version>1.3.2</version>
+			<configuration>
+				<!--���������������������-->
+				<configurationFile>src/main/resources/generatorConfig.xml</configurationFile>
+				<verbose>true</verbose>
+				<overwrite>false</overwrite>
+			</configuration>
+			<dependencies>
+				<dependency>
+					<groupId>org.mybatis.generator</groupId>
+					<artifactId>mybatis-generator-core</artifactId>
+					<version>1.3.2</version>
+				</dependency>
+			</dependencies>
+		</plugin>
+		<plugin>
 			<groupId>org.springframework.boot</groupId>
-			<artifactId>spring-boot-starter</artifactId>
-		</dependency>
-
-		<!-- https://mvnrepository.com/artifact/org.json/json -->
-		<dependency>
-			<groupId>org.json</groupId>
-			<artifactId>json</artifactId>
-			<version>20160810</version>
-		</dependency>
-
-
-		<dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-web</artifactId>
-        </dependency>
-
-		<dependency>
-			<groupId>org.springframework.boot</groupId>
-			<artifactId>spring-boot-starter-security</artifactId>
-		</dependency>
-
-        <dependency>
-            <groupId>org.mybatis.spring.boot</groupId>
-            <artifactId>mybatis-spring-boot-starter</artifactId>
-            <version>1.3.1</version>
-        </dependency>
-
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-data-redis</artifactId>
-        </dependency>
-
-
-		<dependency>
-			<groupId>org.springframework.boot</groupId>
-			<artifactId>spring-boot-starter-tomcat</artifactId>
-			<scope>provided</scope>
-		</dependency>
-
-		<dependency>
-			<groupId>org.springframework.boot</groupId>
-			<artifactId>spring-boot-starter-test</artifactId>
-			<scope>test</scope>
-		</dependency>
-
-        <dependency>
-            <groupId>org.springframework.security.oauth</groupId>
-            <artifactId>spring-security-oauth2</artifactId>
-        </dependency>
-
-		<dependency>
-			<groupId>org.springframework.boot</groupId>
-			<artifactId>spring-boot-configuration-processor</artifactId>
-			<optional>true</optional>
-		</dependency>
-
-        <dependency>
-            <groupId>com.alibaba</groupId>
-            <artifactId>druid</artifactId>
-            <version>1.1.5</version>
-        </dependency>
-
-        <dependency>
-            <groupId>mysql</groupId>
-            <artifactId>mysql-connector-java</artifactId>
-            <version>5.1.44</version>
-        </dependency>
-
-		<dependency>
-			<groupId>org.springframework.boot</groupId>
-			<artifactId>spring-boot-starter-data-mongodb</artifactId>
-		</dependency>
-		<dependency>
-			<groupId>org.apache.commons</groupId>
-			<artifactId>commons-lang3</artifactId>
-			<version>3.5</version>
-		</dependency>
-		<dependency>
-			<groupId>com.alibaba</groupId>
-			<artifactId>fastjson</artifactId>
-			<version>1.2.39</version>
-		</dependency>
-		<dependency>
-		    <groupId>net.sourceforge.jexcelapi</groupId>
-		    <artifactId>jxl</artifactId>
-		    <version>2.6.12</version>
-		</dependency>
-		<dependency>
-			<groupId>net.sf.json-lib</groupId>
-			<artifactId>json-lib</artifactId>
-			<version>2.4</version>
-			<classifier>jdk15</classifier>
-		</dependency>
-		<dependency>
-		    <groupId>org.projectlombok</groupId>
-		    <artifactId>lombok</artifactId>
-		    <version>1.16.18</version>
-		</dependency>
-		<dependency>
-			<groupId>org.springframework.boot</groupId>
-			<artifactId>spring-boot-starter-aop</artifactId>
-		</dependency>
-		<dependency>
-		    <groupId>com.github.pagehelper</groupId>
-		    <artifactId>pagehelper</artifactId>
-		    <version>4.2.1</version>
-		</dependency>
-		<dependency>
-		    <groupId>tk.mybatis</groupId>
-		    <artifactId>mapper</artifactId>
-		    <version>3.4.6</version>
-		</dependency>
-		<dependency>
-			<groupId>jstl</groupId>
-			<artifactId>jstl</artifactId>
-			<version>1.2</version>
-		</dependency>
-		<dependency>
-			<groupId>taglibs</groupId>
-			<artifactId>standard</artifactId>
-			<version>1.1.2</version>
-		</dependency>
-		<dependency>
-			<groupId>org.apache.tomcat.embed</groupId>
-			<artifactId>tomcat-embed-jasper</artifactId>
-            <scope>provided</scope>
-		</dependency>
-		<dependency>
-			<groupId>dom4j</groupId>
-			<artifactId>dom4j</artifactId>
-			<version>1.6.1</version>
-		</dependency>
-		<dependency>
-			<groupId>commons-net</groupId>
-			<artifactId>commons-net</artifactId>
-			<version>3.6</version>
-		</dependency>
-		<dependency>
-			<groupId>io.jsonwebtoken</groupId>
-			<artifactId>jjwt</artifactId>
-			<version>0.9.0</version>
-		</dependency>
-
-		<!-- ������������ -->
-		<dependency>
-			<groupId>com.taobao.api</groupId>
-			<artifactId>taobao-sdk</artifactId>
-			<version>1.0.0</version>
-			<scope>system</scope>
-			<systemPath>${project.basedir}/lib/taobao-sdk-java-auto_1455552377940-20160607.jar</systemPath>
-		</dependency>
-
-		<dependency>
-			<groupId>io.springfox</groupId>
-			<artifactId>springfox-swagger2</artifactId>
-			<version>2.7.0</version>
-		</dependency>
-		<dependency>
-			<groupId>io.springfox</groupId>
-			<artifactId>springfox-swagger-ui</artifactId>
-			<version>2.7.0</version>
-		</dependency>
-		<!-- https://mvnrepository.com/artifact/com.googlecode.aviator/aviator -->
-		<dependency>
-		    <groupId>com.googlecode.aviator</groupId>
-		    <artifactId>aviator</artifactId>
-		    <version>4.2.0</version>
-		</dependency>
-
-        <dependency>
-            <groupId>cn.hutool</groupId>
-            <artifactId>hutool-all</artifactId>
-            <version>5.3.1</version>
-        </dependency>
-
-        <!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
-        <dependency>
-            <groupId>org.apache.poi</groupId>
-            <artifactId>poi-ooxml</artifactId>
-            <version>4.1.2</version>
-        </dependency>
-
-		<dependency>
-			<groupId>org.springframework.boot</groupId>
-			<artifactId>spring-boot-starter-amqp</artifactId>
-		</dependency>
-
-		<dependency>
-			<groupId>org.springframework.boot</groupId>
-			<artifactId>spring-boot-starter-websocket</artifactId>
-		</dependency>
-	</dependencies>
-
-	<build>
-		<finalName>screen_api_v2</finalName>
-		<plugins>
-			<plugin>
-				<groupId>org.mybatis.generator</groupId>
-				<artifactId>mybatis-generator-maven-plugin</artifactId>
-				<version>1.3.2</version>
-				<configuration>
-					<!--���������������������-->
-					<configurationFile>src/main/resources/generatorConfig.xml</configurationFile>
-					<verbose>true</verbose>
-					<overwrite>false</overwrite>
-                </configuration>
-				<dependencies>
-					<dependency>
-						<groupId>org.mybatis.generator</groupId>
-						<artifactId>mybatis-generator-core</artifactId>
-						<version>1.3.2</version>
-					</dependency>
-				</dependencies>
-			</plugin>
-			<plugin>
-				<groupId>org.springframework.boot</groupId>
-				<artifactId>spring-boot-maven-plugin</artifactId>
-			</plugin>
-			<plugin>
-				<groupId>org.apache.maven.plugins</groupId>
-				<artifactId>maven-dependency-plugin</artifactId>
-				<version>3.1.0</version>
-				<executions>
-					<execution>
-						<id>copy-dependencies</id>
-						<phase>compile</phase>
-						<goals>
-							<goal>copy-dependencies</goal>
-						</goals>
-						<configuration>
-							<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/lib</outputDirectory>
-							<includeScope>system</includeScope>
-						</configuration>
-					</execution>
-				</executions>
-			</plugin>
-		</plugins>
-	</build>
+			<artifactId>spring-boot-maven-plugin</artifactId>
+		</plugin>
+		<plugin>
+			<groupId>org.apache.maven.plugins</groupId>
+			<artifactId>maven-dependency-plugin</artifactId>
+			<version>3.1.0</version>
+			<executions>
+				<execution>
+					<id>copy-dependencies</id>
+					<phase>compile</phase>
+					<goals>
+						<goal>copy-dependencies</goal>
+					</goals>
+					<configuration>
+						<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/lib</outputDirectory>
+						<includeScope>system</includeScope>
+					</configuration>
+				</execution>
+			</executions>
+		</plugin>
+	</plugins>
+</build>
 </project>
\ No newline at end of file
diff --git a/src/main/java/com/moral/ScreenApiApplication.java b/src/main/java/com/moral/ScreenApiApplication.java
index 2a7e881..f2b2fb0 100644
--- a/src/main/java/com/moral/ScreenApiApplication.java
+++ b/src/main/java/com/moral/ScreenApiApplication.java
@@ -17,14 +17,6 @@
         return application.sources(ScreenApiApplication.class);
     }
 
-    //Session������������
-    @Bean
-    public EmbeddedServletContainerCustomizer containerCustomizer() {
-        return container -> {
-            container.setSessionTimeout(28800);/*���������S*/
-        };
-    }
-
     public static void main(String[] args) {
         SpringApplication.run(ScreenApiApplication.class, args);
     }
diff --git a/src/main/java/com/moral/Webinterceptor/WebInterceptor.java b/src/main/java/com/moral/Webinterceptor/WebInterceptor.java
deleted file mode 100644
index 931913a..0000000
--- a/src/main/java/com/moral/Webinterceptor/WebInterceptor.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package com.moral.Webinterceptor;
-
-import com.alibaba.fastjson.JSONObject;
-import org.springframework.web.servlet.HandlerInterceptor;
-import org.springframework.web.servlet.ModelAndView;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.PrintWriter;
-import java.util.HashMap;
-
-public class WebInterceptor implements HandlerInterceptor {
-    public static final String SESSION_KEY = "USER_LOGIN";
-
-    @Override
-    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object o) throws Exception {
-        if (request.getSession().getAttribute(SESSION_KEY) == null) {
-            HashMap resultMap = new HashMap<String, Object>();
-            resultMap.put("msg", "���������");
-            resultMap.put("accountId", -1);
-            JSONObject json = new JSONObject(resultMap);
-            response.setContentType("application/json; charset=utf-8");
-            PrintWriter writer = response.getWriter();
-            writer.write(json.toString());
-            return false;
-        }
-        return true;
-    }
-
-    @Override
-    public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) throws Exception {
-
-    }
-
-    @Override
-    public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception {
-
-    }
-}
diff --git a/src/main/java/com/moral/common/interceptor/WebInterceptor.java b/src/main/java/com/moral/common/interceptor/WebInterceptor.java
new file mode 100644
index 0000000..0255cd8
--- /dev/null
+++ b/src/main/java/com/moral/common/interceptor/WebInterceptor.java
@@ -0,0 +1,106 @@
+package com.moral.common.interceptor;
+
+import com.auth0.jwt.JWT;
+import com.auth0.jwt.JWTVerifier;
+import com.auth0.jwt.algorithms.Algorithm;
+import com.auth0.jwt.exceptions.JWTDecodeException;
+import com.auth0.jwt.exceptions.JWTVerificationException;
+import com.auth0.jwt.interfaces.Claim;
+import com.moral.common.exception.WebAuthException;
+import com.moral.common.webAnno.PassToken;
+import com.moral.common.webAnno.UserLoginToken;
+import com.moral.entity.Account;
+import com.moral.service.AccountService;
+import com.moral.service.impl.WebTokenServiceImpl;
+import org.springframework.util.ObjectUtils;
+import org.springframework.web.method.HandlerMethod;
+import org.springframework.web.servlet.HandlerInterceptor;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.lang.reflect.Method;
+import java.util.Enumeration;
+import java.util.Map;
+
+/**
+* @Description: 
+        * @Param: Web������������������������
+        * @return:
+        * @Author: ���������
+        * @Date: 2020/9/14
+        */ 
+public class WebInterceptor implements HandlerInterceptor {
+    @Resource
+    AccountService accountService;
+
+    @Override
+    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object o) throws Exception {
+        String token = request.getHeader("token");
+        Enumeration<String> headerNames = request.getHeaderNames();
+        //������������������������������������������
+        if(!(o instanceof HandlerMethod)){
+            return true;
+        }
+        HandlerMethod handlerMethod = (HandlerMethod)o;
+        Method method = handlerMethod.getMethod();
+        
+        //���������passtoken���������������
+        if(method.isAnnotationPresent(PassToken.class)){
+            PassToken passToken= method.getAnnotation(PassToken.class);
+            //������������������������
+            if(passToken.required())
+                return true;
+        }
+
+        //���������������������������������������
+        if(method.isAnnotationPresent(UserLoginToken.class)){
+            //������������������������
+            UserLoginToken loginToken = method.getAnnotation(UserLoginToken.class);
+            if(loginToken.required()){
+                if(ObjectUtils.isEmpty(token)){
+                    throw new WebAuthException("���token������������������");
+                }
+                //������ID
+                String id = "";
+                try {
+                    Map<String, Claim> claims = JWT.decode(token).getClaims();
+                    Claim accountId = claims.get("aid");
+                    id = accountId.asString();
+                }catch (JWTDecodeException e){
+                    throw new WebAuthException("401,token������");
+                }
+                Account account = accountService.getAccountById(Integer.parseInt(id));
+                if(ObjectUtils.isEmpty(account)){
+                    throw new WebAuthException("���������������������������������");
+                }
+
+                //������token
+                Algorithm algorithm = Algorithm.HMAC256(WebTokenServiceImpl.SECRET);
+                JWTVerifier jwtVerifier = JWT.require(algorithm)
+                        .withIssuer("qxpc")
+                        .build();
+                try{
+                    jwtVerifier.verify(token);
+                }catch (JWTVerificationException e){
+                    throw new WebAuthException("401,token������������������");
+                }
+
+                return true;
+            }
+        }
+        return true;
+        
+    }
+
+    @Override
+    public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) throws Exception {
+
+    }
+
+    @Override
+    public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception {
+
+    }
+}
diff --git a/src/main/java/com/moral/common/webAnno/PassToken.java b/src/main/java/com/moral/common/webAnno/PassToken.java
new file mode 100644
index 0000000..affa139
--- /dev/null
+++ b/src/main/java/com/moral/common/webAnno/PassToken.java
@@ -0,0 +1,18 @@
+package com.moral.common.webAnno;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+/**
+* @Description: ���������web������������������
+        * @Param:
+        * @return:
+        * @Author: ���������
+        * @Date: 2020/9/14
+        */
+@Target({ElementType.METHOD, ElementType.TYPE})
+@Retention(RetentionPolicy.RUNTIME)
+public @interface PassToken {
+    boolean required() default true;
+}
diff --git a/src/main/java/com/moral/common/webAnno/UserLoginToken.java b/src/main/java/com/moral/common/webAnno/UserLoginToken.java
new file mode 100644
index 0000000..09eecc9
--- /dev/null
+++ b/src/main/java/com/moral/common/webAnno/UserLoginToken.java
@@ -0,0 +1,20 @@
+package com.moral.common.webAnno;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+* @Description: ���������web������������������������������������������������������
+        * @Param:
+        * @return:
+        * @Author: ���������
+        * @Date: 2020/9/14
+        */
+@Target({ElementType.METHOD, ElementType.TYPE})
+@Retention(RetentionPolicy.RUNTIME)
+public @interface UserLoginToken {
+    boolean required() default true;
+}
+
diff --git a/src/main/java/com/moral/config/WebLoginConfig.java b/src/main/java/com/moral/config/WebInterceptorConfig.java
similarity index 87%
rename from src/main/java/com/moral/config/WebLoginConfig.java
rename to src/main/java/com/moral/config/WebInterceptorConfig.java
index 35960c8..5e90bab 100644
--- a/src/main/java/com/moral/config/WebLoginConfig.java
+++ b/src/main/java/com/moral/config/WebInterceptorConfig.java
@@ -1,6 +1,7 @@
 package com.moral.config;
 
-import com.moral.Webinterceptor.WebInterceptor;
+import com.moral.common.interceptor.WebInterceptor;
+import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.format.FormatterRegistry;
 import org.springframework.http.converter.HttpMessageConverter;
@@ -9,16 +10,21 @@
 import org.springframework.web.method.support.HandlerMethodArgumentResolver;
 import org.springframework.web.method.support.HandlerMethodReturnValueHandler;
 import org.springframework.web.servlet.HandlerExceptionResolver;
+import org.springframework.web.servlet.HandlerInterceptor;
 import org.springframework.web.servlet.config.annotation.*;
 
 import java.util.List;
 
 @Configuration
-public class WebLoginConfig implements WebMvcConfigurer {
+public class WebInterceptorConfig implements WebMvcConfigurer {
+    @Bean
+    public HandlerInterceptor getTokenInterceptor(){
+        return new WebInterceptor();
+    }
 
     @Override
     public void addInterceptors(InterceptorRegistry interceptorRegistry) {
-        InterceptorRegistration registration = interceptorRegistry.addInterceptor(new WebInterceptor());
+        InterceptorRegistration registration = interceptorRegistry.addInterceptor(getTokenInterceptor());
         registration.addPathPatterns("/web/**");
         registration.excludePathPatterns("/web/login");
     }
diff --git a/src/main/java/com/moral/controller/WebController.java b/src/main/java/com/moral/controller/WebController.java
index fcec4ca..de4f6df 100644
--- a/src/main/java/com/moral/controller/WebController.java
+++ b/src/main/java/com/moral/controller/WebController.java
@@ -1,13 +1,15 @@
 package com.moral.controller;
 
-import com.moral.Webinterceptor.WebInterceptor;
 import com.moral.common.util.BeanUtils;
+import com.moral.common.webAnno.UserLoginToken;
 import com.moral.entity.AreaNames;
 import com.moral.entity.Organization;
 import com.moral.service.AccountService;
 import com.moral.service.DictionaryDataService;
 import com.moral.service.OrganizationService;
+import com.moral.service.WebTokenService;
 import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
@@ -30,6 +32,8 @@
     @Resource
     DictionaryDataService dictionaryDataService;
     OrganizationService organizationService;
+    @Resource
+    WebTokenService webTokenService;
 
     @RequestMapping("login")
     public Map<String, Object> login(HttpServletRequest request){
@@ -44,7 +48,9 @@
             Object orgId = resultMap.get("orgId");
             if (resultMap.get("orgId") != null && resultMap.get("orgId") instanceof Integer) {
                 StringBuilder areaNamesBuilder = new StringBuilder("������");
+                //���������������������������������
                 if (!((Integer) orgId).equals(dictionaryDataService.querySupperOrgId())) {
+                    //���������������������������������������������������
                     Organization organization = organizationService.getOrganizationById((Integer) orgId);
                     if (organization.getAreaNames() != null) {
                         Map<String, String> areaNameMap = BeanUtils.beanToMap(organization.getAreaNames());
@@ -78,14 +84,16 @@
                     resultMap.put("mapAreaCode", mapAreaCode.toString());
                 }
                 resultMap.put("mapPath", areaNamesBuilder.toString());
+                String accountId= String.valueOf(resultMap.get("accountId"));
+                resultMap.put("token",webTokenService.getToken(accountId));
             }
         }
-        request.getSession().setAttribute(WebInterceptor.SESSION_KEY,resultMap);
         return resultMap;
     }
 
-    @RequestMapping("add")
+    @UserLoginToken
+    @GetMapping("test")
     public String add(){
-        return "123123";
+        return "test success!";
     }
 }
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index ccef0eb..d44149a 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -53,9 +53,9 @@
     password: guest
     channelCacheSize: 10
   redis:
-    host: 47.100.8.247
+    host: r-bp1672d21a422a14pd.redis.rds.aliyuncs.com
     port: 6379
-    password: moral_2018
+    password: KtElFcI1sYm9NP3
     database: 1
     timeout: 5000
     pool:
diff --git a/src/main/resources/banner.txt b/src/main/resources/banner.txt
new file mode 100644
index 0000000..8c33c24
--- /dev/null
+++ b/src/main/resources/banner.txt
@@ -0,0 +1,23 @@
+${AnsiColor.BRIGHT_BLACK}
+////////////////////////////////////////////////////////////////////
+//                          _ooOoo_                               //
+//                         o8888888o                              //
+//                         88" . "88                              //
+//                         (| ^_^ |)                              //
+//                         O\  =  /O                              //
+//                      ____/`---'\____                           //
+//                    .'  \\|     |//  `.                         //
+//                   /  \\|||  :  |||//  \                        //
+//                  /  _||||| -:- |||||-  \                       //
+//                  |   | \\\  -  /// |   |                       //
+//                  | \_|  ''\---/''  |   |                       //
+//                  \  .-\__  `-`  ___/-. /                       //
+//                ___`. .'  /--.--\  `. . ___                     //
+//              ."" '<  `.___\_<|>_/___.'  >'"".                  //
+//            | | :  `- \`.;`\ _ /`;.`/ - ` : | |                 //
+//            \  \ `-.   \_ __\ /__ _/   .-` /  /                 //
+//      ========`-.____`-.___\_____/___.-`____.-'========         //
+//                           `=---='                              //
+//      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^        //
+//            ������������       ������������      ������BUG                //
+////////////////////////////////////////////////////////////////////
\ No newline at end of file

--
Gitblit v1.8.0