|
@@ -11,25 +11,24 @@ import javax.annotation.Resource;
|
11
|
11
|
import javax.servlet.http.HttpServletRequest;
|
12
|
12
|
import javax.servlet.http.HttpServletResponse;
|
13
|
13
|
|
14
|
|
-@Component
|
15
|
|
-public class JwtInterceptor implements HandlerInterceptor {
|
|
14
|
+@Component //
|
|
15
|
+public class MyInterceptor implements HandlerInterceptor {
|
|
16
|
+
|
16
|
17
|
|
17
|
18
|
private static final String AUTH_HEADER = "Authorization";
|
18
|
19
|
private static final String TOKEN_PREFIX = "Bearer ";
|
19
|
|
-
|
20
|
20
|
@Resource
|
21
|
21
|
DataAcquisitionInstrumentMapper dataAcquisitionInstrumentMapper;
|
22
|
|
-
|
23
|
22
|
@Override
|
24
|
|
- public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
|
|
23
|
+ public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
25
|
24
|
String token = extractToken(request);
|
26
|
25
|
if (token != null) {
|
27
|
26
|
BaseUser userInfo = TokenUtils.getUserInfo(token);
|
28
|
27
|
if (userInfo != null){
|
29
|
28
|
// 查询数据库是否有 公司和工厂信息
|
30
|
29
|
Boolean verifyCompany = dataAcquisitionInstrumentMapper.verifyCompany(userInfo.getCompanyId());
|
31
|
|
- Boolean verifydepartmen = dataAcquisitionInstrumentMapper.verifydepartmen(userInfo.getFactoryId());
|
32
|
|
- if (verifyCompany&&verifydepartmen){
|
|
30
|
+// Boolean verifydepartmen = dataAcquisitionInstrumentMapper.verifydepartmen(userInfo.getFactoryId());
|
|
31
|
+ if (verifyCompany){
|
33
|
32
|
// 将用户信息设置到请求属性中,便于后续使用
|
34
|
33
|
request.setAttribute("userInfo", JSON.toJSONString(userInfo));
|
35
|
34
|
return true;
|