Browse Source

添加
修复没有token 抛出异常后,还能访问数据

wuweihao 4 years ago
parent
commit
accf5ff0e2

+ 5 - 1
README.md

@@ -17,6 +17,10 @@
   
   2021-6-4
     史料管理-列表: 倒序
+    
+  2021-6-18
+    文物管理-音频上传、 上传文件校验
+    
   
 # pro   
   pro-服务器信息(可以使用远程工具上传资料)
@@ -34,7 +38,7 @@
   ALTER TABLE tb_material MODIFY COLUMN phone VARCHAR(60);
 
    
-  
+  已更新sit-2021-6-4 功能
 
 
     

+ 1 - 1
gis_common/src/main/java/com/gis/common/util/FileUtils.java

@@ -211,7 +211,7 @@ public class FileUtils {
 
     public static boolean checkFile(MultipartFile file) {
         //设置允许上传文件类型
-        String suffixList = ".jpg,.gif,.png,.ico,.bmp,.jpeg,.zip,.zp,.rar,.mp3,.mp4,.avi,.mov,.4dage";
+        String suffixList = ".jpg,.gif,.png,.ico,.bmp,.jpeg,.zip,.zp,.rar,.mp3,.mp4,.avi,.mov,.4dage,.wav,.wma,.m4a";
         // 获取文件后缀
         if(file == null){
             log.info("文件流为空不可上传");

+ 12 - 7
gis_common/src/main/java/com/gis/common/util/Result.java

@@ -6,6 +6,7 @@ import lombok.Data;
 import lombok.NoArgsConstructor;
 
 import java.io.Serializable;
+import java.time.LocalDateTime;
 
 /**
  * 通用返回类
@@ -21,11 +22,12 @@ public class Result<T> implements Serializable {
     public static int CODE_SUCCESS = 0;
     public static int CODE_FAILURE = -1;
     public static String[] NOOP = new String[]{};
+    public static LocalDateTime dataTime = LocalDateTime.now();
 
     /**
      * 处理状态:0: 成功, 1: 失败
      */
-    @ApiModelProperty(value = "处理状态:0: 成功, 1: 失败", name = "code")
+    @ApiModelProperty(value = "处理状态:0: 成功, -1: 失败", name = "code")
     private int code;
     /**
      * 消息
@@ -37,6 +39,9 @@ public class Result<T> implements Serializable {
      */
     @ApiModelProperty(value = "返回数据", name = "data")
     private T data;
+
+    @ApiModelProperty(value = "时间戳", name = "timestamp")
+    private LocalDateTime timestamp;
     /**
      * 处理成功,并返回数据
      *
@@ -44,7 +49,7 @@ public class Result<T> implements Serializable {
      * @return data
      */
     public static Result success(Object data) {
-        return new Result(CODE_SUCCESS, SUCCESS_MSG, data);
+        return new Result(CODE_SUCCESS, SUCCESS_MSG, data, dataTime);
     }
     /**
      * 处理成功
@@ -52,7 +57,7 @@ public class Result<T> implements Serializable {
      * @return data
      */
     public static Result success() {
-        return new Result(CODE_SUCCESS, SUCCESS_MSG, NOOP);
+        return new Result(CODE_SUCCESS, SUCCESS_MSG, NOOP, dataTime);
     }
     /**
      * 处理成功
@@ -61,7 +66,7 @@ public class Result<T> implements Serializable {
      * @return data
      */
     public static Result success(String msg) {
-        return new Result(CODE_SUCCESS, msg, NOOP);
+        return new Result(CODE_SUCCESS, msg, NOOP, dataTime);
     }
     /**
      * 处理成功
@@ -71,7 +76,7 @@ public class Result<T> implements Serializable {
      * @return data
      */
     public static Result success(String msg, Object data) {
-        return new Result(CODE_SUCCESS, msg, data);
+        return new Result(CODE_SUCCESS, msg, data, dataTime);
     }
     /**
      * 处理失败,并返回数据(一般为错误信息)
@@ -81,7 +86,7 @@ public class Result<T> implements Serializable {
      * @return data
      */
     public static Result failure(int code, String msg) {
-        return new Result(code, msg, NOOP);
+        return new Result(code, msg, NOOP , dataTime);
     }
     /**
      * 处理失败
@@ -96,6 +101,6 @@ public class Result<T> implements Serializable {
     @Override
     public String toString() {
         return "JsonResult [code=" + code + ", msg=" + msg + ", data="
-                + data + "]";
+                + data + ", timestamp="+ dataTime + "]";
     }
 }

+ 7 - 2
gis_service/src/main/java/com/gis/service/shiro/JWTFilter.java

@@ -14,6 +14,7 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.io.PrintWriter;
+import java.time.LocalDateTime;
 
 
 /**
@@ -56,6 +57,7 @@ public class JWTFilter extends BasicHttpAuthenticationFilter {
     protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) {
         try {
             executeLogin(request, response);
+            return true;
         } catch (Exception e) {
             /**
              * 这个异常需要自己写,全局捕获不了
@@ -63,8 +65,9 @@ public class JWTFilter extends BasicHttpAuthenticationFilter {
              */
             exceptionMsg(e, response);
         }
-        // return false 前端没有响应,接收不到异常
-        return true;
+        // 前端没有响应,接收不到异常
+         return false;
+
 
 
     }
@@ -127,7 +130,9 @@ public class JWTFilter extends BasicHttpAuthenticationFilter {
             log.error(msg);
             jsonObject.put("code", 5002);
             jsonObject.put("msg", "token invalid");
+
         }
+        jsonObject.put("timestamp", LocalDateTime.now());
         // 直接返回Response信息
         this.writeResponse(response, jsonObject);
 

+ 13 - 0
gis_web/src/main/java/com/gis/web/controller/ZoneController.java

@@ -7,8 +7,10 @@ import com.gis.service.ZoneService;
 import com.gis.service.aop.WebControllerLog;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
+import springfox.documentation.annotations.ApiIgnore;
 
 import javax.validation.Valid;
 import java.util.Date;
@@ -16,6 +18,7 @@ import java.util.Date;
 /**
  * Created by owen on 2021/5/14 0008 9:54
  */
+@Slf4j
 @Api(tags = "展区管理")
 @RestController
 @RequestMapping("manage/zone")
@@ -48,4 +51,14 @@ public class ZoneController extends BaseController {
         return Result.success();
     }
 
+
+//    @ApiIgnore
+//    @WebControllerLog(description = "展区管理-测试", addDb = false)
+//    @ApiOperation("测试")
+//    @GetMapping("test")
+//    public Result test() {
+//        log.info("测试shiro 没有token 能否调用此方法");
+//        return Result.success();
+//    }
+
 }