Commit 48c99f2ebce1611f7ad06e4fd4e554d2828065d3
1 parent
14519673
提交session 为空判断
Showing
6 changed files
with
68 additions
and
44 deletions
pom.xml
... | ... | @@ -10,11 +10,10 @@ |
10 | 10 | |
11 | 11 | <name>zteits_daily_report</name> |
12 | 12 | <description>Demo project for Spring Boot</description> |
13 | - | |
14 | 13 | <parent> |
15 | 14 | <groupId>org.springframework.boot</groupId> |
16 | 15 | <artifactId>spring-boot-starter-parent</artifactId> |
17 | - <version>1.5.2.RELEASE</version> | |
16 | + <version>1.5.9.RELEASE</version> | |
18 | 17 | <relativePath /> <!-- lookup parent from repository --> |
19 | 18 | </parent> |
20 | 19 | |
... | ... | @@ -33,10 +32,6 @@ |
33 | 32 | <dependencies> |
34 | 33 | <dependency> |
35 | 34 | <groupId>org.springframework.boot</groupId> |
36 | - <artifactId>spring-boot-starter</artifactId> | |
37 | - </dependency> | |
38 | - <dependency> | |
39 | - <groupId>org.springframework.boot</groupId> | |
40 | 35 | <artifactId>spring-boot-starter-test</artifactId> |
41 | 36 | <scope>test</scope> |
42 | 37 | </dependency> |
... | ... | @@ -49,9 +44,9 @@ |
49 | 44 | <artifactId>spring-boot-starter-aop</artifactId> |
50 | 45 | </dependency> |
51 | 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 | 50 | </dependency> |
56 | 51 | <!-- spring session --> |
57 | 52 | <dependency> |
... | ... | @@ -77,17 +72,17 @@ |
77 | 72 | <artifactId>hutool-all</artifactId> |
78 | 73 | <version>${hutool-all.version}</version> |
79 | 74 | </dependency> |
80 | - <!--mybatis--> | |
75 | + <!--mybatis --> | |
81 | 76 | <dependency> |
82 | 77 | <groupId>org.mybatis</groupId> |
83 | 78 | <artifactId>mybatis</artifactId> |
84 | 79 | <version>${org.mybatis.version}</version> |
85 | 80 | </dependency> |
86 | 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 | 86 | <dependency> |
92 | 87 | <groupId>com.alibaba</groupId> |
93 | 88 | <artifactId>druid</artifactId> |
... | ... | @@ -98,7 +93,7 @@ |
98 | 93 | <artifactId>fastjson</artifactId> |
99 | 94 | <version>1.2.47</version> |
100 | 95 | </dependency> |
101 | - <!--swagger2--> | |
96 | + <!--swagger2 --> | |
102 | 97 | <dependency> |
103 | 98 | <groupId>io.springfox</groupId> |
104 | 99 | <artifactId>springfox-swagger2</artifactId> |
... | ... | @@ -110,26 +105,44 @@ |
110 | 105 | <version>2.7.0</version> |
111 | 106 | </dependency> |
112 | 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 | 110 | </dependency> |
116 | - | |
117 | 111 | </dependencies> |
118 | 112 | |
119 | 113 | <build> |
120 | 114 | <defaultGoal>compile</defaultGoal> |
121 | - <finalName>zteits-oa</finalName> | |
115 | + <finalName>zteits-oa</finalName> | |
122 | 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 | 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 | 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 | 2 | |
3 | 3 | import org.slf4j.Logger; |
4 | 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 | 7 | import org.springframework.context.annotation.Configuration; |
7 | 8 | import org.springframework.web.servlet.config.annotation.EnableWebMvc; |
8 | 9 | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; |
... | ... | @@ -17,8 +18,13 @@ public class WebMvcConfig extends WebMvcConfigurerAdapter { |
17 | 18 | |
18 | 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 | 29 | @Override |
24 | 30 | public void addResourceHandlers(ResourceHandlerRegistry registry) { |
... | ... | @@ -34,8 +40,9 @@ public class WebMvcConfig extends WebMvcConfigurerAdapter { |
34 | 40 | */ |
35 | 41 | @Override |
36 | 42 | public void addInterceptors(InterceptorRegistry registry) { |
43 | + System.out.println("--begin 执行拦截器addInterceptors方法..."); | |
37 | 44 | //添加验证拦截器 |
38 | - registry.addInterceptor(authInterceptor) | |
45 | + registry.addInterceptor(myInterceptor()) | |
39 | 46 | .addPathPatterns("/**") |
40 | 47 | .excludePathPatterns("/oauth/**") |
41 | 48 | .excludePathPatterns("/selectItem/**") |
... | ... | @@ -43,6 +50,8 @@ public class WebMvcConfig extends WebMvcConfigurerAdapter { |
43 | 50 | .excludePathPatterns("/swagger-resources/**") |
44 | 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 | 35 | * ---------------------------------------------------------* |
36 | 36 | * 2017/5/11 atao v1.0.0 创建 |
37 | 37 | */ |
38 | -@Component | |
38 | +//@Component | |
39 | 39 | public class AuthInterceptor extends HandlerInterceptorAdapter { |
40 | 40 | |
41 | 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 | 16 | import springfox.documentation.swagger2.annotations.EnableSwagger2; |
17 | 17 | @Configuration // 配置注解,自动在本类上下文加载一些环境变量信息 |
18 | 18 | @EnableSwagger2 // 使swagger2生效 |
19 | -public class SwaggerConfigAuto extends WebMvcConfigurationSupport{ | |
19 | +public class SwaggerConfigAuto{ | |
20 | 20 | |
21 | 21 | @Bean |
22 | 22 | public Docket buildDocket(){ | ... | ... |
src/main/java/com/zteits/oa/report/web/AsraDailyController.java
... | ... | @@ -48,7 +48,7 @@ public class AsraDailyController { |
48 | 48 | /**1.根据当前登录人查询登录人下面管理的员工-缓存中获取*/ |
49 | 49 | AsraOpDTO asraOpDTO = (AsraOpDTO)request.getSession().getAttribute(SessionEnum.USER_INFO.key()); |
50 | 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 | 53 | /**2.判断登录人和时间查询日报*/ |
54 | 54 | Date dailyDate = DateUtil.parseDate(asraDailyQueryReq.getDailyDate()); |
... | ... | @@ -73,7 +73,7 @@ public class AsraDailyController { |
73 | 73 | logger.info("--begin工时查询-当天填报人数统计(汇总),入参={}",JSONObject.toJSON(request)); |
74 | 74 | AsraOpDTO asraOpDTO = (AsraOpDTO)servletRequest.getSession().getAttribute(SessionEnum.USER_INFO.key()); |
75 | 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 | 78 | request.setOpIds(asraOpDTO.getOpIds()); |
79 | 79 | BizResult<AsraDailyOpNumForCurrentDayDTO> result = asraDailyQueryService.queryAsraDailyOpNumForCurrentDay(request); |
... | ... | @@ -94,7 +94,7 @@ public class AsraDailyController { |
94 | 94 | logger.info("--begin工时查询-所有员工及自己或者自己日报,入参={}",JSONObject.toJSON(request)); |
95 | 95 | AsraOpDTO asraOpDTO = (AsraOpDTO)servletRequest.getSession().getAttribute(SessionEnum.USER_INFO.key()); |
96 | 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 | 99 | request.setOpIds(asraOpDTO.getOpIds()); |
100 | 100 | BizResult<QueryAsraDailyAllForListReqDTO> result = asraDailyQueryService.queryAsraDailyAllForList(request); |
... | ... | @@ -110,7 +110,7 @@ public class AsraDailyController { |
110 | 110 | /**1.根据当前登录人查询登录人下面管理的员工-缓存中获取*/ |
111 | 111 | AsraOpDTO asraOpDTO = (AsraOpDTO)request.getSession().getAttribute(SessionEnum.USER_INFO.key()); |
112 | 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 | 115 | /**2.判断登录人和时间查询日报*/ |
116 | 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 | |
13 | 13 | |
14 | 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 | 24 | druid.initialSize=1 |
23 | 25 | druid.minIdle=1 | ... | ... |