commit
345d7afb07
16 changed files with 300 additions and 26 deletions
@ -0,0 +1,29 @@ |
|||||||
|
package com.yipin.liuwanr.config; |
||||||
|
|
||||||
|
/** |
||||||
|
* @description |
||||||
|
* @author: Mr.JK |
||||||
|
* @create: 2021-06-03 16:24 |
||||||
|
**/ |
||||||
|
|
||||||
|
import com.yipin.liuwanr.filter.AuthInterceptor; |
||||||
|
import org.springframework.context.annotation.Bean; |
||||||
|
import org.springframework.context.annotation.Configuration; |
||||||
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry; |
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
||||||
|
|
||||||
|
@Configuration |
||||||
|
public class AuthConfig implements WebMvcConfigurer { |
||||||
|
|
||||||
|
@Bean |
||||||
|
public AuthInterceptor initAuthInterceptor(){ |
||||||
|
return new AuthInterceptor(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void addInterceptors(InterceptorRegistry registry) { |
||||||
|
registry.addInterceptor(initAuthInterceptor()).addPathPatterns("/**") |
||||||
|
.excludePathPatterns("/userInfo/adminLogins/**","/userInfo/loginSchoolClient/**","/userInfo/logins/**","/userInfo/updateLogInNumber/**"); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,58 @@ |
|||||||
|
package com.yipin.liuwanr.filter; |
||||||
|
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
|
import org.springframework.data.redis.core.StringRedisTemplate; |
||||||
|
import org.springframework.data.redis.core.ValueOperations; |
||||||
|
import org.springframework.util.StringUtils; |
||||||
|
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.util.Objects; |
||||||
|
import java.util.concurrent.TimeUnit; |
||||||
|
|
||||||
|
/** |
||||||
|
* @description |
||||||
|
* @author: Mr.JK |
||||||
|
* @create: 2021-06-03 16:19 |
||||||
|
**/ |
||||||
|
public class AuthInterceptor implements HandlerInterceptor { |
||||||
|
|
||||||
|
@Resource |
||||||
|
StringRedisTemplate stringRedisTemplate; |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { |
||||||
|
response.setCharacterEncoding("UTF-8"); |
||||||
|
response.setContentType("text/html;charset=utf-8"); |
||||||
|
String token = request.getHeader("token"); |
||||||
|
if (StringUtils.isEmpty(token)) { |
||||||
|
response.getWriter().print("0");//用户未登录,请登录后操作!
|
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
ValueOperations<String, String> ops = stringRedisTemplate.opsForValue(); |
||||||
|
Object loginStatus = ops.get(token); |
||||||
|
|
||||||
|
|
||||||
|
if( Objects.isNull(loginStatus)){ |
||||||
|
response.getWriter().print("1");//token错误
|
||||||
|
return false; |
||||||
|
} |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -1,2 +1,2 @@ |
|||||||
#\u9009\u62E9\u6307\u5B9A\u73AF\u5883,\u76EE\u524D\u53EA\u6709\u6D4B\u8BD5\u548C\u6B63\u5F0F\u73AF\u5883 |
#\u9009\u62E9\u6307\u5B9A\u73AF\u5883,\u76EE\u524D\u53EA\u6709\u6D4B\u8BD5\u548C\u6B63\u5F0F\u73AF\u5883 |
||||||
spring.profiles.active=prod |
spring.profiles.active=test_keda |
@ -0,0 +1,49 @@ |
|||||||
|
server.port=8090 |
||||||
|
server.servlet.context-path=/liuwanr |
||||||
|
|
||||||
|
#\u79D1\u5927\u6B63\u5F0F\u6570\u636E\u5E93\u8FDE\u63A5 |
||||||
|
spring.datasource.url=jdbc:mysql://192.168.0.99:3306/keda?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai |
||||||
|
spring.datasource.username=root |
||||||
|
spring.datasource.password=mssdk@028 |
||||||
|
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver |
||||||
|
|
||||||
|
#redis\u914D\u7F6E |
||||||
|
spring.redis.database=0 |
||||||
|
spring.redis.host=127.0.0.1 |
||||||
|
spring.redis.password=msdw@2021 |
||||||
|
spring.redis.port=6379 |
||||||
|
spring.redis.timeout=3000 |
||||||
|
spring.redis.jedis.pool.max-idle=500 |
||||||
|
spring.redis.jedis.pool.min-idle=50 |
||||||
|
spring.redis.jedis.pool.max-active=2000 |
||||||
|
spring.redis.jedis.pool.max-wait=1000 |
||||||
|
|
||||||
|
#redis-cluster |
||||||
|
redis.cluster.maxTotal=200 |
||||||
|
redis.cluster.maxIdle=8 |
||||||
|
redis.cluster.minIdle=3 |
||||||
|
redis.cluster.nodes=192.168.136.191:8000,192.168.136.191:8001,192.168.136.191:8002 |
||||||
|
|
||||||
|
spring.mina.port=9123 |
||||||
|
spring.mina.buffersize=2048 |
||||||
|
spring.mina.idletime=15 |
||||||
|
spring.main.show-banner=false |
||||||
|
|
||||||
|
#\u65E5\u5FD7\u7EA7\u522B |
||||||
|
logging.level.jdbc=OFF |
||||||
|
logging.level.jdbc.sqltiming=DEBUG |
||||||
|
logging.level.jdbc.resultsettable=DEBUG |
||||||
|
logging.level.com.yipin.liuwar.mapper=DEBUG |
||||||
|
logging.level.com.yipin.liuwanr.mapper=DEBUG |
||||||
|
|
||||||
|
spring.elasticsearch.rest.uris=http://es-cn-v641e944a0006xtwy.elasticsearch.aliyuncs.com:9200 |
||||||
|
spring.elasticsearch.rest.username=elastic |
||||||
|
spring.elasticsearch.rest.password=1qaz@WSX |
||||||
|
|
||||||
|
# maxFileSize \u5355\u4E2A\u6570\u636E\u5927\u5C0F |
||||||
|
spring.servlet.multipart.maxFileSize = 1024MB |
||||||
|
# maxRequestSize \u662F\u603B\u6570\u636E\u5927\u5C0F |
||||||
|
spring.servlet.multipart.maxRequestSize=10240MB |
||||||
|
|
||||||
|
pagehelper.reasonable=false |
||||||
|
|
@ -0,0 +1,49 @@ |
|||||||
|
server.port=8090 |
||||||
|
server.servlet.context-path=/liuwanr |
||||||
|
|
||||||
|
#\u6D4B\u8BD5\u6570\u636E\u5E93\u8FDE\u63A5 |
||||||
|
spring.datasource.url=jdbc:mysql://rm-wz9y13wf7u8q8610fwo.mysql.rds.aliyuncs.com:3306/keda?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai |
||||||
|
spring.datasource.username=super |
||||||
|
spring.datasource.password=huoran888 |
||||||
|
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver |
||||||
|
|
||||||
|
#redis\u914D\u7F6E |
||||||
|
spring.redis.database=0 |
||||||
|
spring.redis.host=127.0.0.1 |
||||||
|
spring.redis.password=msdw@2021 |
||||||
|
spring.redis.port=6379 |
||||||
|
spring.redis.timeout=3000 |
||||||
|
spring.redis.jedis.pool.max-idle=500 |
||||||
|
spring.redis.jedis.pool.min-idle=50 |
||||||
|
spring.redis.jedis.pool.max-active=2000 |
||||||
|
spring.redis.jedis.pool.max-wait=1000 |
||||||
|
|
||||||
|
#redis-cluster |
||||||
|
redis.cluster.maxTotal=200 |
||||||
|
redis.cluster.maxIdle=8 |
||||||
|
redis.cluster.minIdle=3 |
||||||
|
redis.cluster.nodes=192.168.136.191:8000,192.168.136.191:8001,192.168.136.191:8002 |
||||||
|
|
||||||
|
spring.mina.port=9123 |
||||||
|
spring.mina.buffersize=2048 |
||||||
|
spring.mina.idletime=15 |
||||||
|
spring.main.show-banner=false |
||||||
|
|
||||||
|
#\u65E5\u5FD7\u7EA7\u522B |
||||||
|
logging.level.jdbc=OFF |
||||||
|
logging.level.jdbc.sqltiming=DEBUG |
||||||
|
logging.level.jdbc.resultsettable=DEBUG |
||||||
|
logging.level.com.yipin.liuwar.mapper=DEBUG |
||||||
|
logging.level.com.yipin.liuwanr.mapper=DEBUG |
||||||
|
|
||||||
|
spring.elasticsearch.rest.uris=http://es-cn-v641e944a0006xtwy.elasticsearch.aliyuncs.com:9200 |
||||||
|
spring.elasticsearch.rest.username=elastic |
||||||
|
spring.elasticsearch.rest.password=1qaz@WSX |
||||||
|
|
||||||
|
# maxFileSize \u5355\u4E2A\u6570\u636E\u5927\u5C0F |
||||||
|
spring.servlet.multipart.maxFileSize = 1024MB |
||||||
|
# maxRequestSize \u662F\u603B\u6570\u636E\u5927\u5C0F |
||||||
|
spring.servlet.multipart.maxRequestSize=10240MB |
||||||
|
|
||||||
|
pagehelper.reasonable=false |
||||||
|
|
Loading…
Reference in new issue