Browse Source

加入拦截

wuweihao 3 years ago
parent
commit
d65a83b308

+ 3 - 1
gis_admin/src/main/java/com/gis/admin/controller/LogController.java

@@ -15,13 +15,15 @@ import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
+import springfox.documentation.annotations.ApiIgnore;
 
 
 /**
  * Created by owen on 2020/5/12 0018 12:17
  * 日志管理,只有admin权限访问
  */
-@Log4j2
+
+@ApiIgnore
 @Api(tags = "sys-日志管理")
 @RestController
 @RequestMapping("sys/log")

+ 3 - 1
gis_admin/src/main/java/com/gis/admin/controller/LoginController.java

@@ -13,6 +13,7 @@ import com.gis.admin.entity.dto.LoginDto;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.log4j.Log4j2;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.RedisTemplate;
@@ -32,9 +33,10 @@ import java.util.concurrent.TimeUnit;
 /**
  * Created by owen on 2020/2/19 0019 15:53
  */
+@ApiIgnore
 @Api(tags = "sys-登录")
 @RestController
-@Log4j2
+@Slf4j
 public class LoginController {
 
     @Autowired

+ 3 - 0
gis_admin/src/main/java/com/gis/admin/controller/SysUserController.java

@@ -10,6 +10,7 @@ import com.gis.admin.entity.po.SysUserEntity;
 import com.gis.admin.service.SysUserService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.shiro.authz.annotation.Logical;
 import org.apache.shiro.authz.annotation.RequiresRoles;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -21,6 +22,8 @@ import javax.validation.Valid;
 /**
  * Created by owen on 2021/12/8 0018 12:17
  */
+@ApiIgnore
+@Slf4j
 @Api(tags = "sys-用户管理")
 @RestController
 @RequestMapping("sys/user")

+ 11 - 0
gis_admin/src/main/java/com/gis/admin/shiro/JwtToken.java

@@ -11,10 +11,17 @@ public class JwtToken implements AuthenticationToken {
 	
 	private static final long serialVersionUID = 1L;
 	private String token;
+	private String jwtType;
+
  
     public JwtToken(String token) {
         this.token = token;
     }
+
+    public JwtToken(String token, String jwtType) {
+        this.token = token;
+        this.jwtType = jwtType;
+    }
  
     @Override
     public Object getPrincipal() {
@@ -25,4 +32,8 @@ public class JwtToken implements AuthenticationToken {
     public Object getCredentials() {
         return token;
     }
+
+    public String getJwtType() {
+        return jwtType;
+    }
 }

+ 64 - 34
gis_admin/src/main/java/com/gis/admin/shiro/ShiroConfig.java

@@ -2,10 +2,14 @@ package com.gis.admin.shiro;
 
 import com.gis.admin.shiro.filters.CustomShiroFilterFactoryBean;
 import com.gis.admin.shiro.filters.JwtFilter;
+import com.gis.admin.shiro.realm.UserJwtRealm;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.shiro.authc.pam.AtLeastOneSuccessfulStrategy;
+import org.apache.shiro.authc.pam.ModularRealmAuthenticator;
 import org.apache.shiro.mgt.DefaultSessionStorageEvaluator;
 import org.apache.shiro.mgt.DefaultSubjectDAO;
 import org.apache.shiro.mgt.SecurityManager;
+import org.apache.shiro.realm.Realm;
 import org.apache.shiro.spring.LifecycleBeanPostProcessor;
 import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor;
 import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
@@ -39,6 +43,11 @@ public class ShiroConfig {
     @Autowired
     private Environment env;
 
+    @Autowired
+    UserJwtRealm userJwtRealm;
+
+
+
 
     /**
      * Filter Chain定义说明
@@ -53,32 +62,7 @@ public class ShiroConfig {
         shiroFilterFactoryBean.setSecurityManager(securityManager);
         // 拦截器
         Map<String, String> filterChainDefinitionMap = new LinkedHashMap<String, String>();
-//        if(oConvertUtils.isNotEmpty(excludeUrls)){
-//            String[] permissionUrl = excludeUrls.split(",");
-//            for(String url : permissionUrl){
-//                filterChainDefinitionMap.put(url,"anon");
-//            }
-//        }
-        // 配置不会被拦截的链接 顺序判断
-//        filterChainDefinitionMap.put("/sys/cas/client/validateLogin", "anon"); //cas验证登录
-////        filterChainDefinitionMap.put("/sys/randomImage/**", "anon"); //登录验证码接口排除
-////        filterChainDefinitionMap.put("/sys/checkCaptcha", "anon"); //登录验证码接口排除
-////        filterChainDefinitionMap.put("/sys/login", "anon"); //登录接口排除
-////        filterChainDefinitionMap.put("/sys/mLogin", "anon"); //登录接口排除
-////        filterChainDefinitionMap.put("/sys/logout", "anon"); //登出接口排除
-////        filterChainDefinitionMap.put("/sys/thirdLogin/**", "anon"); //第三方登录
-////        filterChainDefinitionMap.put("/sys/getEncryptedString", "anon"); //获取加密串
-////        filterChainDefinitionMap.put("/sys/sms", "anon");//短信验证码
-////        filterChainDefinitionMap.put("/sys/phoneLogin", "anon");//手机登录
-////        filterChainDefinitionMap.put("/sys/user/checkOnlyUser", "anon");//校验用户是否存在
-////        filterChainDefinitionMap.put("/sys/user/register", "anon");//用户注册
-////        filterChainDefinitionMap.put("/sys/user/querySysUser", "anon");//根据手机号获取用户信息
-////        filterChainDefinitionMap.put("/sys/user/phoneVerification", "anon");//用户忘记密码验证手机号
-////        filterChainDefinitionMap.put("/sys/user/passwordChange", "anon");//用户更改密码
-////        filterChainDefinitionMap.put("/auth/2step-code", "anon");//登录验证码
-////        filterChainDefinitionMap.put("/sys/common/static/**", "anon");//图片预览 &下载文件不限制token
-////        filterChainDefinitionMap.put("/sys/common/pdf/**", "anon");//pdf预览
-////        filterChainDefinitionMap.put("/generic/**", "anon");//pdf预览需要文件
+
 
         // 不拦截
         filterChainDefinitionMap.put("/login", "anon");
@@ -128,9 +112,6 @@ public class ShiroConfig {
 
         //测试示例
         filterChainDefinitionMap.put("/test/bigScreen/**", "anon"); //大屏模板例子
-        //filterChainDefinitionMap.put("/test/jeecgDemo/rabbitMqClientTest/**", "anon"); //MQ测试
-        //filterChainDefinitionMap.put("/test/jeecgDemo/html", "anon"); //模板页面
-        //filterChainDefinitionMap.put("/test/jeecgDemo/redis/**", "anon"); //redis测试
 
         //websocket排除
         filterChainDefinitionMap.put("/websocket/**", "anon");//系统通知和公告
@@ -145,12 +126,13 @@ public class ShiroConfig {
         Map<String, Filter> filterMap = new HashMap<String, Filter>(1);
         //如果cloudServer为空 则说明是单体 需要加载跨域配置
         Object cloudServer = env.getProperty("");
-        filterMap.put("jwt", new JwtFilter(cloudServer==null));
+        filterMap.put("user_jwt", new JwtFilter(cloudServer==null));
         shiroFilterFactoryBean.setFilters(filterMap);
         // <!-- 过滤链定义,从上向下顺序执行,一般将/**放在最为下边
 //        filterChainDefinitionMap.put("/**", "jwt");
-        filterChainDefinitionMap.put("/sys/**", "jwt");
-        filterChainDefinitionMap.put("/cms/**", "jwt");
+        filterChainDefinitionMap.put("/sys/**", "user_jwt");
+        filterChainDefinitionMap.put("/cms/**", "user_jwt");
+//        filterChainDefinitionMap.put("/api/**", "app_jwt");
 
         // 未授权界面返回JSON
         shiroFilterFactoryBean.setUnauthorizedUrl("/sys/common/403");
@@ -159,10 +141,17 @@ public class ShiroConfig {
         return shiroFilterFactoryBean;
     }
 
+
+
     @Bean("securityManager")
-    public DefaultWebSecurityManager securityManager(ShiroRealm myRealm) {
+    public DefaultWebSecurityManager securityManager(UserJwtRealm userRealm) {
+
+
+
+
         DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
-        securityManager.setRealm(myRealm);
+        securityManager.setRealm(userRealm);
+
 
         /*
          * 关闭shiro自带的session,详情见文档
@@ -179,6 +168,47 @@ public class ShiroConfig {
         return securityManager;
     }
 
+//    @Bean("securityManager")
+////    public DefaultWebSecurityManager securityManager(UserJwtRealm myRealm) {
+//    public DefaultWebSecurityManager securityManager() {
+//
+//        List<Realm> realms = new ArrayList<>();
+//        realms.add(userJwtRealm);
+//
+//
+//        DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
+////        securityManager.setRealm(myRealm);
+//        securityManager.setRealms(realms);
+//
+//
+//        //设置realm.
+//        securityManager.setAuthenticator(modularRealmAuthenticator());
+//
+//        /*
+//         * 关闭shiro自带的session,详情见文档
+//         * http://shiro.apache.org/session-management.html#SessionManagement-
+//         * StatelessApplications%28Sessionless%29
+//         */
+//        DefaultSubjectDAO subjectDAO = new DefaultSubjectDAO();
+//        DefaultSessionStorageEvaluator defaultSessionStorageEvaluator = new DefaultSessionStorageEvaluator();
+//        defaultSessionStorageEvaluator.setSessionStorageEnabled(false);
+//        subjectDAO.setSessionStorageEvaluator(defaultSessionStorageEvaluator);
+//        securityManager.setSubjectDAO(subjectDAO);
+//        //自定义缓存实现,使用redis
+////        securityManager.setCacheManager(redisCacheManager());
+//        return securityManager;
+//    }
+
+
+//    @Bean
+//    public ModularRealmAuthenticator modularRealmAuthenticator() {
+//        //自己重写的ShiroModularRealmAuthenticator
+//        ShiroModularRealmAuthenticator modularRealmAuthenticator = new ShiroModularRealmAuthenticator();
+//        modularRealmAuthenticator.setAuthenticationStrategy(new AtLeastOneSuccessfulStrategy());
+//        return modularRealmAuthenticator;
+//    }
+
+
     /**
      * 下面的代码是添加注解支持
      * @return

+ 8 - 1
gis_admin/src/main/java/com/gis/admin/shiro/filters/JwtFilter.java

@@ -26,10 +26,17 @@ import java.time.LocalDateTime;
 public class JwtFilter extends BasicHttpAuthenticationFilter {
 
     private boolean allowOrigin = true;
+    private String jwtType;
 
     public JwtFilter(){}
+    public JwtFilter(boolean allowOrigin, String jwtType){
+        this.allowOrigin = allowOrigin;
+        this.jwtType = jwtType;
+    }
+
     public JwtFilter(boolean allowOrigin){
         this.allowOrigin = allowOrigin;
+
     }
 
     /**
@@ -67,7 +74,7 @@ public class JwtFilter extends BasicHttpAuthenticationFilter {
         }
         // update-end--Author:lvdandan Date:20210105 for:JT-355 OA聊天添加token验证,获取token参数
 
-        JwtToken jwtToken = new JwtToken(token);
+        JwtToken jwtToken = new JwtToken(token, jwtType);
         // 提交给realm进行登入,如果错误他会抛出异常并被捕获
         getSubject(request, response).login(jwtToken);
         // 如果没有抛出异常则代表登入成功,返回true

+ 5 - 5
gis_application/src/main/resources/application-sit.properties

@@ -48,19 +48,19 @@ spring.redis.jedis.pool.max-wait=-1ms
 
 
 #log
-logging.file.path=D:/log/${project.en}_log
+logging.file.path=/root/log/${project.en}_log
 logging.config=classpath:logback-spring.xml
 logging.level.com.gis=debug
 
 # file info
-server.file.path=D:/data/${project.en}_data
-
-
+server.file.path=/root/data/${project.en}_data
+#\u8BBF\u95EE\u57DF\u540D+\u7AEF\u53E3
+server.domain=http://8.135.106.227:${server.port}
 
 #
 spring.mvc.static-path-pattern=/**
 ### \u5339\u914D\u8DEF\u5F84\uFF0C \u6CE8\u610Ffile\u540E\u9762\u7684/ \uFF0Cwindows:\\  , linxu:\u5168\u8DEF\u5F84, \u4E0D\u9700\u8981\u7279\u522B\u52A0\u659C\u6760
-spring.resources.static-locations=file:\\${server.file.path}
+spring.resources.static-locations=file:${server.file.path}
 
 # swagger2 \u8BBE\u7F6E\u5168\u5C40\u5B57\u4F53\u683C\u5F0F\u4E3Autf-8
 swagger.package=com.gis

+ 1 - 1
gis_application/src/main/resources/sh/shutdown.sh

@@ -1,5 +1,5 @@
 #!/bin/bash
-RESOURCE_NAME=army_chongqing_college.jar
+RESOURCE_NAME=age_project_api.jar
    Pid=`awk '{print $1}' tpid`
 
 if [ ${Pid} ]; then

+ 2 - 2
gis_application/src/main/resources/sh/startup.sh

@@ -1,8 +1,8 @@
 #!/bin/sh
-RESOURCE_NAME=army_chongqing_college.jar
+RESOURCE_NAME=age_project_api.jar
 APP_DEBUG=5005
 rm -f tpid
-nohup java -jar -Xmx3072M -Xms512M ./$RESOURCE_NAME --spring.profiles.active=sit --server.port=8005 & echo $! > tpid
+nohup java -jar -Xmx3072M -Xms512M ./$RESOURCE_NAME --spring.profiles.active=sit --server.port=8013 & echo $! > tpid
 echo Start Success!
 
 

+ 57 - 1
gis_cms/src/main/java/com/gis/cms/controller/ArEnterController.java

@@ -1,6 +1,11 @@
 package com.gis.cms.controller;
 
 import com.gis.cms.entity.dto.ArEnterDto;
+import com.gis.cms.entity.dto.ArStopDto;
+import com.gis.cms.entity.po.ArClockInEntity;
+import com.gis.cms.entity.po.ArEnterEntity;
+import com.gis.cms.entity.po.ArPrizeEntity;
+import com.gis.cms.entity.po.ArStopEntity;
 import com.gis.cms.service.ArEnterService;
 import com.gis.common.util.Result;
 import io.swagger.annotations.Api;
@@ -24,8 +29,59 @@ public class ArEnterController {
     ArEnterService arEnterService;
 
     @ApiOperation(value = "记录进入状况")
-    @PostMapping("enterSave")
+    @PostMapping("saveEnter")
     public Result enterSave(@Valid @RequestBody ArEnterDto param) {
         return arEnterService.enterSave(param);
     }
+
+    @ApiOperation(value = "记录停留时长")
+    @PostMapping("saveStop")
+    public Result stopSave(@Valid @RequestBody ArStopDto param) {
+        return arEnterService.stopSave(param);
+    }
+
+    /**
+     * 只有2条数据
+     * */
+    @ApiOperation(value = "记录打卡", notes = "类型 1:泮浦湾, 2:新翼")
+    @PostMapping("saveClockIn/{type}")
+    public Result clockIn(@PathVariable String type) {
+        return arEnterService.clockIn(type);
+    }
+
+    /**
+     * 只有三条数据
+     * */
+    @ApiOperation(value = "记录领奖人数", notes = "类型type 1:泮浦湾, 2:新翼, 3:终极打卡, 人数:count")
+    @PostMapping("savePrize/{type}/{count}")
+    public Result prizeSave(@PathVariable String type,@PathVariable Integer count) {
+        return arEnterService.prizeSave(type, count);
+    }
+
+    @ApiOperation(value = "获取领奖人数", notes = "类型type 1:泮浦湾, 2:新翼, 3:终极打卡")
+    @GetMapping("getPrize/{type}")
+    public Result<ArPrizeEntity> getPrize(@PathVariable String type) {
+        return arEnterService.getPrize(type);
+    }
+
+    @ApiOperation(value = "获取记录打卡", notes = "类型 1:泮浦湾, 2:新翼")
+    @GetMapping("getClockIn/{type}")
+    public Result<ArClockInEntity> getClockIn(@PathVariable String type) {
+        return arEnterService.getClockIn(type);
+    }
+
+    @ApiOperation(value = "获取进入状况", notes = "类型type:error, success ")
+    @GetMapping("getEnter/{type}")
+    public Result<ArEnterEntity> getEnter(@PathVariable String type) {
+        return arEnterService.getEnter(type);
+    }
+
+    @ApiOperation(value = "获取停留时长", notes = "deviceId:设备id ")
+    @GetMapping("getStop/{deviceId}")
+    public Result<ArStopEntity> getTime(@PathVariable String deviceId) {
+        return arEnterService.getTime(deviceId);
+    }
+
+
+
 }

+ 2 - 0
gis_cms/src/main/java/com/gis/cms/controller/CommentController.java

@@ -13,12 +13,14 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
+import springfox.documentation.annotations.ApiIgnore;
 
 import javax.validation.Valid;
 
 /**
  * Created by owen on 2021/12/28 0008 9:54
  */
+@ApiIgnore
 @Slf4j
 @Api(tags = "留言管理")
 @RestController

+ 20 - 0
gis_cms/src/main/java/com/gis/cms/service/ArEnterService.java

@@ -1,14 +1,34 @@
 package com.gis.cms.service;
 
 import com.gis.cms.entity.dto.ArEnterDto;
+import com.gis.cms.entity.dto.ArStopDto;
+import com.gis.cms.entity.po.ArClockInEntity;
 import com.gis.cms.entity.po.ArEnterEntity;
+import com.gis.cms.entity.po.ArPrizeEntity;
+import com.gis.cms.entity.po.ArStopEntity;
 import com.gis.common.base.service.BaseService;
 import com.gis.common.util.Result;
 
+import javax.validation.Valid;
+
 /**
  * Created by owen on 2022/1/13 0013 19:11
  */
 public interface ArEnterService extends BaseService<ArEnterEntity> {
 
     Result enterSave(ArEnterDto param);
+
+    Result stopSave(@Valid ArStopDto param);
+
+    Result clockIn(String type);
+
+    Result prizeSave(String type, Integer count);
+
+    Result<ArPrizeEntity> getPrize(String type);
+
+    Result<ArClockInEntity> getClockIn(String type);
+
+    Result<ArEnterEntity> getEnter(String type);
+
+    Result<ArStopEntity> getTime(String deviceId);
 }

+ 70 - 1
gis_cms/src/main/java/com/gis/cms/service/impl/ArEnterServiceImpl.java

@@ -1,22 +1,42 @@
 package com.gis.cms.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.gis.cms.entity.dto.ArEnterDto;
+import com.gis.cms.entity.dto.ArStopDto;
+import com.gis.cms.entity.po.ArClockInEntity;
 import com.gis.cms.entity.po.ArEnterEntity;
+import com.gis.cms.entity.po.ArPrizeEntity;
+import com.gis.cms.entity.po.ArStopEntity;
+import com.gis.cms.mapper.ArClockInMapper;
 import com.gis.cms.mapper.ArEnterMapper;
+import com.gis.cms.mapper.ArPrizeMapper;
+import com.gis.cms.mapper.ArStopMapper;
 import com.gis.cms.service.ArEnterService;
 import com.gis.common.base.service.impl.BaseServiceImpl;
 import com.gis.common.util.Result;
 import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ;
 import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import javax.validation.Valid;
+
 /**
  * Created by owen on 2022/1/13 0013 19:25
  */
 @Service
 public class ArEnterServiceImpl extends BaseServiceImpl<ArEnterMapper, ArEnterEntity> implements ArEnterService {
 
+    @Autowired
+    ArStopMapper stopMapper;
+
+    @Autowired
+    ArClockInMapper clockInMapper;
+
+    @Autowired
+    ArPrizeMapper prizeMapper;
+
     /**
      * 根据设备id 跟类型 判断数据唯一
      * @param param
@@ -38,8 +58,57 @@ public class ArEnterServiceImpl extends BaseServiceImpl<ArEnterMapper, ArEnterEn
         return Result.success();
     }
 
+    @Override
+    public Result stopSave(@Valid ArStopDto param) {
+        ArStopEntity entity = new ArStopEntity();
+        BeanUtils.copyProperties(param, entity);
+        stopMapper.insert(entity);
+        return Result.success();
+    }
+
+    @Override
+    public Result clockIn(String type) {
+        clockInMapper.updateVisit(type);
+        return Result.success();
+    }
+
+    @Override
+    public Result prizeSave(String type, Integer count) {
+        prizeMapper.updateCount(type, count);
+        return Result.success();
+    }
+
+    @Override
+    public Result<ArPrizeEntity> getPrize(String type) {
+        LambdaQueryWrapper<ArPrizeEntity> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(ArPrizeEntity::getType, type);
+        ArPrizeEntity entity = prizeMapper.selectOne(wrapper);
+        return Result.success(entity);
+    }
+
+    @Override
+    public Result<ArClockInEntity> getClockIn(String type) {
+        LambdaQueryWrapper<ArClockInEntity> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(ArClockInEntity::getType, type);
+        ArClockInEntity entity = clockInMapper.selectOne(wrapper);
+        return Result.success(entity);
+    }
+
+    @Override
+    public Result<ArEnterEntity> getEnter(String type) {
+        LambdaQueryWrapper<ArEnterEntity> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(ArEnterEntity::getType, type);
+        ArEnterEntity entity = getBaseMapper().selectOne(wrapper);
+        return Result.success(entity);
+    }
+
+    @Override
+    public Result<ArStopEntity> getTime(String deviceId) {
+        Integer countTime = stopMapper.getTimeByDeviceId(deviceId);
+        return Result.success(countTime);
+    }
+
 
-    
     private ArEnterEntity findByDeviceIdAndType(ArEnterDto param){
         
         LambdaQueryWrapper<ArEnterEntity> wrapper = new LambdaQueryWrapper<>();

+ 7 - 0
gis_common/pom.xml

@@ -29,6 +29,12 @@
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-test</artifactId>
             <scope>test</scope>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.junit.Jupiter</groupId>
+                    <artifactId>junit-Jupiter-api</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
 
         <!--springboot中的redis依赖-->
@@ -46,6 +52,7 @@
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
+            <version>4.12</version>
         </dependency>
 
         <!-- lombok -->

+ 4 - 1
gis_common/src/main/java/com/gis/common/base/aop/WebLogAspect.java

@@ -50,7 +50,9 @@ public class WebLogAspect {
         startTime = System.currentTimeMillis();
 
         // 设置链路id, 在logback-spring.xml里用
-        MDC.put("TRACE_ID", startTime+"");
+        if (MDC.get("TRACE_ID") == null) {
+            MDC.put("TRACE_ID", startTime+"");
+        }
 
         // 记录下请求内容
         String remoteAddr = request.getRemoteAddr();
@@ -104,6 +106,7 @@ public class WebLogAspect {
     public void doAfterReturning(Object ret) throws Throwable {
         // 处理完请求,返回内容
         log.warn("end: {}, {}, uuid: {},  响应耗时:{} ms", request.getMethod(), request.getRequestURI(), startTime, (System.currentTimeMillis() - startTime));
+        MDC.clear();
     }
 
     /**

+ 16 - 0
gis_common/src/main/java/com/gis/common/config/WebMvcConfig.java

@@ -4,12 +4,14 @@ import com.alibaba.fastjson.serializer.SerializerFeature;
 import com.alibaba.fastjson.support.config.FastJsonConfig;
 import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
 import com.gis.common.constant.ConfigConstant;
+import com.gis.common.filter.ApiInterceptor;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.http.MediaType;
 import org.springframework.web.servlet.config.annotation.CorsRegistry;
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 
 import java.util.ArrayList;
@@ -24,6 +26,9 @@ public class WebMvcConfig implements WebMvcConfigurer {
     @Autowired
     ConfigConstant configConstant;
 
+    @Autowired
+    ApiInterceptor apiInterceptor;
+
     /**
      * 配置全局跨域
      * 开发、测试环境开启跨域, 正式环境不开启
@@ -75,5 +80,16 @@ public class WebMvcConfig implements WebMvcConfigurer {
     }
 
 
+    /**
+     * 自定义拦截规则
+     */
+    @Override
+    public void addInterceptors(InterceptorRegistry registry)
+    {
+        registry.addInterceptor(apiInterceptor).addPathPatterns("/api/**");
+    }
+
+
+
 
 }

+ 35 - 24
gis_common/src/main/java/com/gis/common/util/Base64Converter.java

@@ -59,30 +59,30 @@ public class Base64Converter {
         return result;
     }
 
-    public static void main(String[] args) throws UnsupportedEncodingException {
-
-//        String username = "Miracle Luna";
-//        String password = "AUPhhlhkExMTExMTExMQ==tGC1irnLMTLF9V7HLh";
-        String password = "1UxELRpIExMTExcWG627AcMTQBIN2mog";
-
-        password = password.substring(8);
-        System.out.println(password);
-        password = password.substring(0, password.length() - 8);
-        System.out.println(password);
-        String key = password.substring(password.length() - 2) + password.substring(0, password.length() - 10);
-        System.out.println(key);
-
-
-        // 加密
-//        System.out.println("====  [加密后] 用户名/密码  =====");
-//        System.out.println(Base64Converter.encode(username));
-//        System.out.println(Base64Converter.encode(password));
-
-        // 解密
-        System.out.println("\n====  [解密后] 用户名/密码  =====");
-//        System.out.println(Base64Converter.decode(Base64Converter.encode(username)));
-        System.out.println(Base64Converter.decode(key));
-    }
+//    public static void main(String[] args) throws UnsupportedEncodingException {
+//
+////        String username = "Miracle Luna";
+////        String password = "AUPhhlhkExMTExMTExMQ==tGC1irnLMTLF9V7HLh";
+//        String password = "1UxELRpIExMTExcWG627AcMTQBIN2mog";
+//
+//        password = password.substring(8);
+//        System.out.println(password);
+//        password = password.substring(0, password.length() - 8);
+//        System.out.println(password);
+//        String key = password.substring(password.length() - 2) + password.substring(0, password.length() - 10);
+//        System.out.println(key);
+//
+//
+//        // 加密
+////        System.out.println("====  [加密后] 用户名/密码  =====");
+////        System.out.println(Base64Converter.encode(username));
+////        System.out.println(Base64Converter.encode(password));
+//
+//        // 解密
+//        System.out.println("\n====  [解密后] 用户名/密码  =====");
+////        System.out.println(Base64Converter.decode(Base64Converter.encode(username)));
+//        System.out.println(Base64Converter.decode(key));
+//    }
 
 
     @Test
@@ -91,6 +91,11 @@ public class Base64Converter {
         System.out.println(decodePassword(password));
     }
 
+    @Test
+    public void testEncode(){
+        String password = "192.168.0.1:AAA";
+        System.out.println(encode(password));
+    }
 
     /**
      *
@@ -104,4 +109,10 @@ public class Base64Converter {
         return decode(key);
 
     }
+
+    public static void main(String[] args)  {
+        String str = "192.168.0.1:1111";
+        System.out.println(encode(str));
+//        System.out.println(desDecrypt("A44768AA1D87A1AF4C96749B990D2AC5481C1CCC8C7F010D"));
+    }
 }