Merge remote-tracking branch 'origin/master'

master
chen 4 years ago
commit 43ddb4d2fb
  1. 6
      pom.xml
  2. 51
      src/main/java/com/yipin/liuwanr/config/AuthConfig.java
  3. 3
      src/main/java/com/yipin/liuwanr/entity/UserInfo.java
  4. 63
      src/main/java/com/yipin/liuwanr/filter/AuthInterceptor.java
  5. 17
      src/main/java/com/yipin/liuwanr/service/UserInfoService.java
  6. 0
      src/main/resources/application-dev.properties
  7. 7
      src/main/resources/application-keda.properties
  8. 62
      src/main/resources/application-prod.properties
  9. 7
      src/main/resources/application-test.properties
  10. 7
      src/main/resources/application-test_keda.properties
  11. 3
      src/main/resources/application.yml

@ -271,6 +271,12 @@
<version>2.3.28</version> <version>2.3.28</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
</dependencies> </dependencies>
<build> <build>
<finalName>root</finalName> <finalName>root</finalName>

@ -0,0 +1,51 @@
package com.yipin.liuwanr.config;
import com.yipin.liuwanr.filter.AuthInterceptor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
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;
import java.util.List;
/**
* @description
* @author: Mr.JK
* @create: 2021-06-03 16:24
**/
@Configuration
@ConfigurationProperties(prefix = "auth")
public class AuthConfig implements WebMvcConfigurer {
//开启拦截字符串
public static String openInterceptStr;
//放行url
public static List<String> permitUrl;
@Value("${auth.openInterceptStr}")
public void setOpenInterceptStr(String openInterceptStr) {
AuthConfig.openInterceptStr = openInterceptStr;
}
@Value("${auth.permitUrl}")
public void setPermitUrl(List<String> permitUrl) {
AuthConfig.permitUrl = permitUrl;
}
@Bean
public AuthInterceptor initAuthInterceptor(){
return new AuthInterceptor();
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(initAuthInterceptor()).addPathPatterns(openInterceptStr)
.excludePathPatterns(permitUrl);
}
}

@ -101,4 +101,7 @@ public class UserInfo {
private Integer organizationRelationshipId; private Integer organizationRelationshipId;
//登陆时间 //登陆时间
private String dataTime; private String dataTime;
//鉴权token
private String loginToken;
} }

@ -0,0 +1,63 @@
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);
//userid
String userId = request.getParameter("userId");
if( Objects.isNull(loginStatus)){
response.getWriter().print("1");//token错误
return false;
}else {
if (!StringUtils.isEmpty(userId)){
return userId.equals(loginStatus);
}else {
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 {
}
}

@ -129,13 +129,13 @@ public class UserInfoService {
userInfoMapper.userAddStudent(student); userInfoMapper.userAddStudent(student);
} }
int size = userProfilesList.size(); int size = userProfilesList.size();
if (size<=0){ // if (size<=0){
for (int i = 0;i<size; i++){ for (int i = 0;i<size; i++){
UserProfiles userProfiles = userProfilesList.get(i); UserProfiles userProfiles = userProfilesList.get(i);
userProfiles.setUserId(userId); userProfiles.setUserId(userId);
userInfoMapper.addPersonalFile(userProfiles); userInfoMapper.addPersonalFile(userProfiles);
} }
} // }
int staffListSize = staffList.size(); int staffListSize = staffList.size();
for (int i = 0;i<staffListSize;i++){ for (int i = 0;i<staffListSize;i++){
Staff staff = staffList.get(i); Staff staff = staffList.get(i);
@ -440,6 +440,13 @@ public class UserInfoService {
// List<UserInfo> studentList = userInfoMapper.loginsGetStudentSchoolInfo(userId,schoolId); // List<UserInfo> studentList = userInfoMapper.loginsGetStudentSchoolInfo(userId,schoolId);
List<UserInfoReceiveVo> studentList = userInfoMapper.loginsGetStudentSchoolInfo(userId,schoolId); List<UserInfoReceiveVo> studentList = userInfoMapper.loginsGetStudentSchoolInfo(userId,schoolId);
obj.put("studentList",studentList); obj.put("studentList",studentList);
//鉴权,登录后将信息存入redis
ValueOperations<String, String> redis = stringRedisTemplate.opsForValue();
String loginToken = UUID.randomUUID().toString();
redis.set(loginToken,user.getUserId().toString(),2, TimeUnit.HOURS);
obj.put("loginToken",loginToken);
resp.put("retcode", 200); resp.put("retcode", 200);
resp.put("retvalue", obj); resp.put("retvalue", obj);
}else { }else {
@ -546,6 +553,12 @@ public class UserInfoService {
ValueOperations<String, String> redis = stringRedisTemplate.opsForValue(); ValueOperations<String, String> redis = stringRedisTemplate.opsForValue();
redis.set(token,lastLoginTime, 24, TimeUnit.HOURS); redis.set(token,lastLoginTime, 24, TimeUnit.HOURS);
user.setDataTime(lastLoginTime); user.setDataTime(lastLoginTime);
//鉴权,登录后将信息存入redis
String loginToken = UUID.randomUUID().toString();
redis.set(loginToken,user.getUserId().toString(),2, TimeUnit.HOURS);
user.setLoginToken(loginToken);
resp.put("retvalue",user); resp.put("retvalue",user);
resp.put("retcode", 200); resp.put("retcode", 200);
} }

@ -47,3 +47,10 @@ spring.servlet.multipart.maxRequestSize=10240MB
pagehelper.reasonable=false pagehelper.reasonable=false
#开启全局拦截,为空不开启拦截
#auth.openInterceptStr=
auth.openInterceptStr=/**
#放行Url
auth.permitUrl=/userInfo/adminLogins/**,/userInfo/loginSchoolClient/**,/province/queryProvince/**,/city/queryCity/**,/customer/querySchool/**,/userInfo/queryPhone/**

@ -1,49 +1,59 @@
server.port=8090 # See http://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html
server.servlet.context-path=/liuwanr spring.thymeleaf.cache=false
spring.main.show-banner=false
#\u6B63\u5F0F\u6570\u636E\u5E93\u8FDE\u63A5 logging.level.jdbc=OFF
spring.datasource.url=jdbc:mysql://rm-wz90d92p0pf083nxzno.mysql.rds.aliyuncs.com:3306/huoran?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai logging.level.jdbc.sqltiming=DEBUG
logging.level.jdbc.resultsettable=DEBUG
logging.level.com.yipin.liuwar.mapper=DEBUG
#¿Æ´óÊý¾Ý¿â 116.63.168.79
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.username=root
spring.datasource.password=HuoRan@2021 spring.datasource.password=mssdk@028
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
#´¨´óÊý¾Ý¿â
#spring.datasource.url=jdbc:mysql://139.9.247.137:3306/keda?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
#spring.datasource.username=root
#spring.datasource.password=123456
#spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.mina.port=9123
spring.mina.buffersize=2048
spring.mina.idletime=15
#redis\u914D\u7F6E
spring.redis.database=0 spring.redis.database=0
spring.redis.host=127.0.0.1 spring.redis.host=127.0.0.1
spring.redis.password= spring.redis.password=msdw@2021
#spring.redis.password=
spring.redis.port=6379 spring.redis.port=6379
spring.redis.timeout=3000 spring.redis.timeout=3000
spring.redis.jedis.pool.max-idle=500 spring.redis.jedis.pool.max-idle=500
spring.redis.jedis.pool.min-idle=50 spring.redis.jedis.pool.min-idle=50
spring.redis.jedis.pool.max-active=2000 spring.redis.jedis.pool.max-active=2000
spring.redis.jedis.pool.max-wait=1000 spring.redis.jedis.pool.max-wait=1000
#spring.redis.pool.max-idle=500
#redis-cluster #spring.redis.pool.min-idle=50
redis.cluster.maxTotal=200 #spring.redis.pool.max-active=2000
redis.cluster.maxIdle=8 #spring.redis.pool.max-wait=1000
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.uris=http://es-cn-v641e944a0006xtwy.elasticsearch.aliyuncs.com:9200
spring.elasticsearch.rest.username=elastic spring.elasticsearch.rest.username=elastic
spring.elasticsearch.rest.password=1qaz@WSX spring.elasticsearch.rest.password=1qaz@WSX
pagehelper.reasonable=false
# maxFileSize \u5355\u4E2A\u6570\u636E\u5927\u5C0F # maxFileSize \u5355\u4E2A\u6570\u636E\u5927\u5C0F
spring.servlet.multipart.maxFileSize = 1024MB spring.servlet.multipart.maxFileSize = 1024MB
# maxRequestSize \u662F\u603B\u6570\u636E\u5927\u5C0F # maxRequestSize \u662F\u603B\u6570\u636E\u5927\u5C0F
spring.servlet.multipart.maxRequestSize=10240MB spring.servlet.multipart.maxRequestSize=10240MB
pagehelper.reasonable=false logging.level.com.yipin.liuwanr.mapper=debug
#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
server.port=8090
server.servlet.context-path= /liuwanr

@ -47,3 +47,10 @@ spring.servlet.multipart.maxRequestSize=10240MB
pagehelper.reasonable=false pagehelper.reasonable=false
#开启全局拦截,为空不开启拦截
#auth.openInterceptStr=
auth.openInterceptStr=/**
#放行Url
auth.permitUrl=/userInfo/adminLogins/**,/userInfo/loginSchoolClient/**,/province/queryProvince/**,/city/queryCity/**,/customer/querySchool/**,/userInfo/queryPhone/**

@ -47,3 +47,10 @@ spring.servlet.multipart.maxRequestSize=10240MB
pagehelper.reasonable=false pagehelper.reasonable=false
#开启全局拦截,为空不开启拦截
#auth.openInterceptStr=
auth.openInterceptStr=/**
#放行Url
auth.permitUrl=/userInfo/adminLogins/**,/userInfo/loginSchoolClient/**,/province/queryProvince/**,/city/queryCity/**,/customer/querySchool/**,/userInfo/queryPhone/**

@ -0,0 +1,3 @@
spring:
profiles:
active: prod
Loading…
Cancel
Save