zjs преди 1 седмица
родител
ревизия
8f0d7eecad

+ 15 - 0
src/main/java/com/cn/esermis/config/CorsConfig.java

@@ -1,6 +1,10 @@
1 1
 package com.cn.esermis.config;
2 2
 
3
+import org.springframework.context.annotation.Bean;
3 4
 import org.springframework.context.annotation.Configuration;
5
+import org.springframework.web.cors.CorsConfiguration;
6
+import org.springframework.web.cors.CorsConfigurationSource;
7
+import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
4 8
 import org.springframework.web.servlet.config.annotation.CorsRegistry;
5 9
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
6 10
 
@@ -15,4 +19,15 @@ public class CorsConfig implements WebMvcConfigurer {
15 19
                 .allowedHeaders("*") // 允许的请求头
16 20
                 .allowCredentials(true); // 是否允许证书(cookies)
17 21
     }
22
+
23
+    @Bean
24
+    public CorsConfigurationSource corsConfigurationSource() {
25
+        CorsConfiguration configuration = new CorsConfiguration();
26
+        configuration.addAllowedOrigin("*"); // 允许所有域名访问,也可以指定特定的域名
27
+        configuration.addAllowedMethod("*"); // 允许所有HTTP方法
28
+        configuration.addAllowedHeader("*"); // 允许所有请求头
29
+        UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
30
+        source.registerCorsConfiguration("/**", configuration);
31
+        return source;
32
+    }
18 33
 }

+ 0 - 1
src/main/java/com/cn/esermis/config/MyBatisPlusConfig.java

@@ -11,5 +11,4 @@ public class MyBatisPlusConfig {
11 11
         PaginationInterceptor page = new PaginationInterceptor();
12 12
         return page;
13 13
     }
14
-
15 14
 }

+ 3 - 0
src/main/java/com/cn/esermis/config/MyInterceptor.java

@@ -21,6 +21,9 @@ public class MyInterceptor  implements HandlerInterceptor  {
21 21
     DataAcquisitionInstrumentMapper dataAcquisitionInstrumentMapper;
22 22
     @Override
23 23
     public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
24
+        // 获取 header 中的 Authorization 信息
25
+//        String token = request.getHeader("Authorization");
26
+
24 27
         String token = extractToken(request);
25 28
         if (token != null) {
26 29
             BaseUser userInfo = TokenUtils.getUserInfo(token);

+ 4 - 0
src/main/java/com/cn/esermis/dpld/entity/DataAcquisitionInstrument.java

@@ -4,7 +4,9 @@ import com.baomidou.mybatisplus.annotation.IdType;
4 4
 import com.baomidou.mybatisplus.annotation.TableField;
5 5
 import com.baomidou.mybatisplus.annotation.TableId;
6 6
 import com.baomidou.mybatisplus.annotation.TableName;
7
+import com.fasterxml.jackson.annotation.JsonFormat;
7 8
 import lombok.Data;
9
+import org.springframework.format.annotation.DateTimeFormat;
8 10
 
9 11
 import java.math.BigDecimal;
10 12
 import java.util.Date;
@@ -42,6 +44,8 @@ public class DataAcquisitionInstrument {
42 44
      *建设投用日期
43 45
      */
44 46
     @TableField(value = "use_data")
47
+    @DateTimeFormat(pattern = "yyyy")
48
+    @JsonFormat(pattern = "yyyy",timezone = "GMT+8")
45 49
     private Date useData;
46 50
     /**
47 51
      * 是否完成验收备案(0否 1是)

+ 6 - 1
src/main/java/com/cn/esermis/dpld/entity/DetectMonitoringFactor.java

@@ -73,9 +73,14 @@ public class DetectMonitoringFactor {
73 73
     /**
74 74
      * 量程单位
75 75
      */
76
-    @TableField(value = "rangeUnit")
76
+    @TableField(value = "range_unit")
77 77
     private String rangeUnit;
78 78
     /**
79
+     * 量程单位
80
+     */
81
+    @TableField(value = "factor_name")
82
+    private String factorName;
83
+    /**
79 84
      * 数据采集仪主键ID
80 85
      */
81 86
     @TableField(value = "data_acquisition_instrument_id")

+ 2 - 1
src/main/java/com/cn/esermis/dpld/model/AnalyticalInstrumentsVo.java

@@ -5,6 +5,7 @@ import com.cn.esermis.dpld.entity.DetectMonitoringFactor;
5 5
 import lombok.Data;
6 6
 import lombok.EqualsAndHashCode;
7 7
 
8
+import java.util.ArrayList;
8 9
 import java.util.List;
9 10
 
10 11
 @EqualsAndHashCode(callSuper = true)
@@ -12,6 +13,6 @@ import java.util.List;
12 13
 
13 14
 public class AnalyticalInstrumentsVo extends AnalyticalInstruments {
14 15
 
15
-    private List<DetectMonitoringFactor> detectMonitoringFactors;
16
+    private List<DetectMonitoringFactor> detectMonitoringFactors = new ArrayList<>();
16 17
 
17 18
 }