Commit 48c99f2ebce1611f7ad06e4fd4e554d2828065d3

Authored by 王富生
1 parent 14519673

提交session 为空判断

@@ -10,11 +10,10 @@ @@ -10,11 +10,10 @@
10 10
11 <name>zteits_daily_report</name> 11 <name>zteits_daily_report</name>
12 <description>Demo project for Spring Boot</description> 12 <description>Demo project for Spring Boot</description>
13 -  
14 <parent> 13 <parent>
15 <groupId>org.springframework.boot</groupId> 14 <groupId>org.springframework.boot</groupId>
16 <artifactId>spring-boot-starter-parent</artifactId> 15 <artifactId>spring-boot-starter-parent</artifactId>
17 - <version>1.5.2.RELEASE</version> 16 + <version>1.5.9.RELEASE</version>
18 <relativePath /> <!-- lookup parent from repository --> 17 <relativePath /> <!-- lookup parent from repository -->
19 </parent> 18 </parent>
20 19
@@ -33,10 +32,6 @@ @@ -33,10 +32,6 @@
33 <dependencies> 32 <dependencies>
34 <dependency> 33 <dependency>
35 <groupId>org.springframework.boot</groupId> 34 <groupId>org.springframework.boot</groupId>
36 - <artifactId>spring-boot-starter</artifactId>  
37 - </dependency>  
38 - <dependency>  
39 - <groupId>org.springframework.boot</groupId>  
40 <artifactId>spring-boot-starter-test</artifactId> 35 <artifactId>spring-boot-starter-test</artifactId>
41 <scope>test</scope> 36 <scope>test</scope>
42 </dependency> 37 </dependency>
@@ -49,9 +44,9 @@ @@ -49,9 +44,9 @@
49 <artifactId>spring-boot-starter-aop</artifactId> 44 <artifactId>spring-boot-starter-aop</artifactId>
50 </dependency> 45 </dependency>
51 <dependency> 46 <dependency>
52 - <groupId>org.springframework.boot</groupId>  
53 - <artifactId>spring-boot-starter-redis</artifactId>  
54 - <version>1.4.7.RELEASE</version> 47 + <groupId>org.springframework.boot</groupId>
  48 + <artifactId>spring-boot-starter-redis</artifactId>
  49 + <version>1.4.7.RELEASE</version>
55 </dependency> 50 </dependency>
56 <!-- spring session --> 51 <!-- spring session -->
57 <dependency> 52 <dependency>
@@ -77,17 +72,17 @@ @@ -77,17 +72,17 @@
77 <artifactId>hutool-all</artifactId> 72 <artifactId>hutool-all</artifactId>
78 <version>${hutool-all.version}</version> 73 <version>${hutool-all.version}</version>
79 </dependency> 74 </dependency>
80 - <!--mybatis--> 75 + <!--mybatis -->
81 <dependency> 76 <dependency>
82 <groupId>org.mybatis</groupId> 77 <groupId>org.mybatis</groupId>
83 <artifactId>mybatis</artifactId> 78 <artifactId>mybatis</artifactId>
84 <version>${org.mybatis.version}</version> 79 <version>${org.mybatis.version}</version>
85 </dependency> 80 </dependency>
86 <dependency> 81 <dependency>
87 - <groupId>com.github.pagehelper</groupId>  
88 - <artifactId>pagehelper-spring-boot-starter</artifactId>  
89 - <version>${pagehelper-spring-boot-starter.version}</version>  
90 - </dependency> 82 + <groupId>com.github.pagehelper</groupId>
  83 + <artifactId>pagehelper-spring-boot-starter</artifactId>
  84 + <version>${pagehelper-spring-boot-starter.version}</version>
  85 + </dependency>
91 <dependency> 86 <dependency>
92 <groupId>com.alibaba</groupId> 87 <groupId>com.alibaba</groupId>
93 <artifactId>druid</artifactId> 88 <artifactId>druid</artifactId>
@@ -98,7 +93,7 @@ @@ -98,7 +93,7 @@
98 <artifactId>fastjson</artifactId> 93 <artifactId>fastjson</artifactId>
99 <version>1.2.47</version> 94 <version>1.2.47</version>
100 </dependency> 95 </dependency>
101 - <!--swagger2--> 96 + <!--swagger2 -->
102 <dependency> 97 <dependency>
103 <groupId>io.springfox</groupId> 98 <groupId>io.springfox</groupId>
104 <artifactId>springfox-swagger2</artifactId> 99 <artifactId>springfox-swagger2</artifactId>
@@ -110,26 +105,44 @@ @@ -110,26 +105,44 @@
110 <version>2.7.0</version> 105 <version>2.7.0</version>
111 </dependency> 106 </dependency>
112 <dependency> 107 <dependency>
113 - <groupId>org.springframework.security</groupId>  
114 - <artifactId>spring-security-web</artifactId> 108 + <groupId>org.springframework.security</groupId>
  109 + <artifactId>spring-security-web</artifactId>
115 </dependency> 110 </dependency>
116 -  
117 </dependencies> 111 </dependencies>
118 112
119 <build> 113 <build>
120 <defaultGoal>compile</defaultGoal> 114 <defaultGoal>compile</defaultGoal>
121 - <finalName>zteits-oa</finalName> 115 + <finalName>zteits-oa</finalName>
122 <plugins> 116 <plugins>
123 - <plugin>  
124 - <groupId>org.springframework.boot</groupId>  
125 - <artifactId>spring-boot-maven-plugin</artifactId>  
126 - <configuration>  
127 - <mainClass>com.zteits.oa.DailyReportApplication</mainClass>  
128 - </configuration>  
129 - <version>1.3.5.RELEASE</version>  
130 - </plugin>  
131 - 117 + <plugin>
  118 + <groupId>org.springframework.boot</groupId>
  119 + <artifactId>spring-boot-maven-plugin</artifactId>
  120 + <configuration>
  121 + <mainClass>com.zteits.oa.DailyReportApplication</mainClass>
  122 + </configuration>
  123 + </plugin>
  124 + <plugin>
  125 + <groupId>org.apache.maven.plugins</groupId>
  126 + <artifactId>maven-compiler-plugin</artifactId>
  127 + <configuration>
  128 + <source>1.8</source>
  129 + <target>1.8</target>
  130 + </configuration>
  131 + </plugin>
132 </plugins> 132 </plugins>
  133 + <!-- <resources>
  134 + <resource>
  135 + <directory>src/lib</directory>
  136 + <targetPath>BOOT-INF/lib/</targetPath>
  137 + <includes>
  138 + <include>**/*.jar</include>
  139 + </includes>
  140 + </resource>
  141 + <resource>
  142 + <directory>src/main/resources</directory>
  143 + <targetPath>BOOT-INF/classes/</targetPath>
  144 + </resource>
  145 + </resources>-->
133 </build> 146 </build>
134 147
135 148
src/main/java/com/zteits/oa/configuration/WebMvcConfig.java
@@ -2,7 +2,8 @@ package com.zteits.oa.configuration; @@ -2,7 +2,8 @@ package com.zteits.oa.configuration;
2 2
3 import org.slf4j.Logger; 3 import org.slf4j.Logger;
4 import org.slf4j.LoggerFactory; 4 import org.slf4j.LoggerFactory;
5 -import org.springframework.beans.factory.annotation.Autowired; 5 +import org.springframework.context.annotation.Bean;
  6 +import org.springframework.context.annotation.ComponentScan;
6 import org.springframework.context.annotation.Configuration; 7 import org.springframework.context.annotation.Configuration;
7 import org.springframework.web.servlet.config.annotation.EnableWebMvc; 8 import org.springframework.web.servlet.config.annotation.EnableWebMvc;
8 import org.springframework.web.servlet.config.annotation.InterceptorRegistry; 9 import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
@@ -17,8 +18,13 @@ public class WebMvcConfig extends WebMvcConfigurerAdapter { @@ -17,8 +18,13 @@ public class WebMvcConfig extends WebMvcConfigurerAdapter {
17 18
18 private Logger logger = LoggerFactory.getLogger(WebMvcConfig.class); 19 private Logger logger = LoggerFactory.getLogger(WebMvcConfig.class);
19 20
20 - @Autowired  
21 - private AuthInterceptor authInterceptor; 21 + @Bean
  22 + AuthInterceptor myInterceptor(){
  23 + return new AuthInterceptor();
  24 + }
  25 +
  26 +
  27 +
22 28
23 @Override 29 @Override
24 public void addResourceHandlers(ResourceHandlerRegistry registry) { 30 public void addResourceHandlers(ResourceHandlerRegistry registry) {
@@ -34,8 +40,9 @@ public class WebMvcConfig extends WebMvcConfigurerAdapter { @@ -34,8 +40,9 @@ public class WebMvcConfig extends WebMvcConfigurerAdapter {
34 */ 40 */
35 @Override 41 @Override
36 public void addInterceptors(InterceptorRegistry registry) { 42 public void addInterceptors(InterceptorRegistry registry) {
  43 + System.out.println("--begin 执行拦截器addInterceptors方法...");
37 //添加验证拦截器 44 //添加验证拦截器
38 - registry.addInterceptor(authInterceptor) 45 + registry.addInterceptor(myInterceptor())
39 .addPathPatterns("/**") 46 .addPathPatterns("/**")
40 .excludePathPatterns("/oauth/**") 47 .excludePathPatterns("/oauth/**")
41 .excludePathPatterns("/selectItem/**") 48 .excludePathPatterns("/selectItem/**")
@@ -43,6 +50,8 @@ public class WebMvcConfig extends WebMvcConfigurerAdapter { @@ -43,6 +50,8 @@ public class WebMvcConfig extends WebMvcConfigurerAdapter {
43 .excludePathPatterns("/swagger-resources/**") 50 .excludePathPatterns("/swagger-resources/**")
44 .excludePathPatterns("/v2/**"); 51 .excludePathPatterns("/v2/**");
45 } 52 }
  53 +
  54 +
46 55
47 56
48 } 57 }
src/main/java/com/zteits/oa/configuration/auth/AuthInterceptor.java
@@ -35,7 +35,7 @@ import com.zteits.oa.api.dto.asraop.LoginOathRes; @@ -35,7 +35,7 @@ import com.zteits.oa.api.dto.asraop.LoginOathRes;
35 * ---------------------------------------------------------* 35 * ---------------------------------------------------------*
36 * 2017/5/11 atao v1.0.0 创建 36 * 2017/5/11 atao v1.0.0 创建
37 */ 37 */
38 -@Component 38 +//@Component
39 public class AuthInterceptor extends HandlerInterceptorAdapter { 39 public class AuthInterceptor extends HandlerInterceptorAdapter {
40 40
41 private static final Logger log = LoggerFactory.getLogger(AuthInterceptor.class); 41 private static final Logger log = LoggerFactory.getLogger(AuthInterceptor.class);
src/main/java/com/zteits/oa/configuration/swagger/SwaggerConfigAuto.java
@@ -16,7 +16,7 @@ import springfox.documentation.spring.web.plugins.Docket; @@ -16,7 +16,7 @@ import springfox.documentation.spring.web.plugins.Docket;
16 import springfox.documentation.swagger2.annotations.EnableSwagger2; 16 import springfox.documentation.swagger2.annotations.EnableSwagger2;
17 @Configuration // 配置注解,自动在本类上下文加载一些环境变量信息 17 @Configuration // 配置注解,自动在本类上下文加载一些环境变量信息
18 @EnableSwagger2 // 使swagger2生效 18 @EnableSwagger2 // 使swagger2生效
19 -public class SwaggerConfigAuto extends WebMvcConfigurationSupport{ 19 +public class SwaggerConfigAuto{
20 20
21 @Bean 21 @Bean
22 public Docket buildDocket(){ 22 public Docket buildDocket(){
src/main/java/com/zteits/oa/report/web/AsraDailyController.java
@@ -48,7 +48,7 @@ public class AsraDailyController { @@ -48,7 +48,7 @@ public class AsraDailyController {
48 /**1.根据当前登录人查询登录人下面管理的员工-缓存中获取*/ 48 /**1.根据当前登录人查询登录人下面管理的员工-缓存中获取*/
49 AsraOpDTO asraOpDTO = (AsraOpDTO)request.getSession().getAttribute(SessionEnum.USER_INFO.key()); 49 AsraOpDTO asraOpDTO = (AsraOpDTO)request.getSession().getAttribute(SessionEnum.USER_INFO.key());
50 if(asraOpDTO == null){ 50 if(asraOpDTO == null){
51 - throw new BizException(ErrorType.AUTH_TOKEN_NOT_EXISTS,"session过期或者已经失效"); 51 + throw new BizException(ErrorType.PARAMM_NULL,"session过期或者已经失效");
52 } 52 }
53 /**2.判断登录人和时间查询日报*/ 53 /**2.判断登录人和时间查询日报*/
54 Date dailyDate = DateUtil.parseDate(asraDailyQueryReq.getDailyDate()); 54 Date dailyDate = DateUtil.parseDate(asraDailyQueryReq.getDailyDate());
@@ -73,7 +73,7 @@ public class AsraDailyController { @@ -73,7 +73,7 @@ public class AsraDailyController {
73 logger.info("--begin工时查询-当天填报人数统计(汇总),入参={}",JSONObject.toJSON(request)); 73 logger.info("--begin工时查询-当天填报人数统计(汇总),入参={}",JSONObject.toJSON(request));
74 AsraOpDTO asraOpDTO = (AsraOpDTO)servletRequest.getSession().getAttribute(SessionEnum.USER_INFO.key()); 74 AsraOpDTO asraOpDTO = (AsraOpDTO)servletRequest.getSession().getAttribute(SessionEnum.USER_INFO.key());
75 if(asraOpDTO == null ){ 75 if(asraOpDTO == null ){
76 - throw new BizException(ErrorType.AUTH_TOKEN_NOT_EXISTS,"获取session为空"); 76 + throw new BizException(ErrorType.PARAMM_NULL,"获取session为空");
77 } 77 }
78 request.setOpIds(asraOpDTO.getOpIds()); 78 request.setOpIds(asraOpDTO.getOpIds());
79 BizResult<AsraDailyOpNumForCurrentDayDTO> result = asraDailyQueryService.queryAsraDailyOpNumForCurrentDay(request); 79 BizResult<AsraDailyOpNumForCurrentDayDTO> result = asraDailyQueryService.queryAsraDailyOpNumForCurrentDay(request);
@@ -94,7 +94,7 @@ public class AsraDailyController { @@ -94,7 +94,7 @@ public class AsraDailyController {
94 logger.info("--begin工时查询-所有员工及自己或者自己日报,入参={}",JSONObject.toJSON(request)); 94 logger.info("--begin工时查询-所有员工及自己或者自己日报,入参={}",JSONObject.toJSON(request));
95 AsraOpDTO asraOpDTO = (AsraOpDTO)servletRequest.getSession().getAttribute(SessionEnum.USER_INFO.key()); 95 AsraOpDTO asraOpDTO = (AsraOpDTO)servletRequest.getSession().getAttribute(SessionEnum.USER_INFO.key());
96 if(asraOpDTO == null ){ 96 if(asraOpDTO == null ){
97 - throw new BizException(ErrorType.AUTH_TOKEN_NOT_EXISTS,"获取session为空"); 97 + throw new BizException(ErrorType.PARAMM_NULL,"获取session为空");
98 } 98 }
99 request.setOpIds(asraOpDTO.getOpIds()); 99 request.setOpIds(asraOpDTO.getOpIds());
100 BizResult<QueryAsraDailyAllForListReqDTO> result = asraDailyQueryService.queryAsraDailyAllForList(request); 100 BizResult<QueryAsraDailyAllForListReqDTO> result = asraDailyQueryService.queryAsraDailyAllForList(request);
@@ -110,7 +110,7 @@ public class AsraDailyController { @@ -110,7 +110,7 @@ public class AsraDailyController {
110 /**1.根据当前登录人查询登录人下面管理的员工-缓存中获取*/ 110 /**1.根据当前登录人查询登录人下面管理的员工-缓存中获取*/
111 AsraOpDTO asraOpDTO = (AsraOpDTO)request.getSession().getAttribute(SessionEnum.USER_INFO.key()); 111 AsraOpDTO asraOpDTO = (AsraOpDTO)request.getSession().getAttribute(SessionEnum.USER_INFO.key());
112 if(asraOpDTO == null ){ 112 if(asraOpDTO == null ){
113 - throw new BizException(ErrorType.AUTH_TOKEN_NOT_EXISTS,"获取session为空"); 113 + throw new BizException(ErrorType.PARAMM_NULL,"获取session为空");
114 } 114 }
115 /**2.判断登录人和时间查询日报*/ 115 /**2.判断登录人和时间查询日报*/
116 Date dailyDate = DateUtil.parseDate(asraDailySaveOrUpdateReq.getDailyDate()); 116 Date dailyDate = DateUtil.parseDate(asraDailySaveOrUpdateReq.getDailyDate());
src/main/resources/application.properties
@@ -12,12 +12,14 @@ local.base.url=http://pay.service.rnting.com @@ -12,12 +12,14 @@ local.base.url=http://pay.service.rnting.com
12 12
13 13
14 druid.driverClass=com.mysql.jdbc.Driver 14 druid.driverClass=com.mysql.jdbc.Driver
15 -druid.url=jdbc:mysql://192.168.1.167:3306/zt_asra?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true  
16 -druid.username=root  
17 -druid.password=root  
18 -#druid.url=jdbc:mysql://47.96.41.38:3306/zt_order_n?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true  
19 -#druid.username=order  
20 -#druid.password=MySQL5.7@123 15 +#druid.url=jdbc:mysql://192.168.1.167:3306/zt_asra?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true
  16 +#druid.username=root
  17 +#druid.password=root
  18 +druid.url=jdbc:mysql://47.96.41.38:3306/zt_asra?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true
  19 +druid.username=asra
  20 +druid.password=MySQL57@123
  21 +
  22 +
21 23
22 druid.initialSize=1 24 druid.initialSize=1
23 druid.minIdle=1 25 druid.minIdle=1