瀏覽代碼

fix 提交解决跨域, 提交反提交注释了时间

Administrator 4 年之前
父節點
當前提交
eb48d91018

+ 50 - 4
boman-gateway/src/main/java/com/boman/gateway/config/CorsConfig.java → boman-gateway/src/main/java/com/boman/gateway/config/CrosConfig.java

@@ -1,3 +1,4 @@
+/*
 package com.boman.gateway.config;
 
 import org.springframework.context.annotation.Bean;
@@ -7,10 +8,12 @@ import org.springframework.web.cors.reactive.CorsWebFilter;
 import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource;
 import org.springframework.web.util.pattern.PathPatternParser;
 
-/** 跨域请求
- * @author shiqian
- * @date 2021年06月04日 14:28
- **/
+//* 跨域请求
+// * @author shiqian
+// * @date 2021年06月04日 14:28
+// *
+
+
 @Configuration
 public class CorsConfig {
 
@@ -59,3 +62,46 @@ public class CorsConfig {
 //    }
 
 }
+*/
+
+package com.boman.gateway.config;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.server.reactive.ServerHttpRequest;
+import org.springframework.http.server.reactive.ServerHttpResponse;
+import org.springframework.web.cors.reactive.CorsUtils;
+import org.springframework.web.server.ServerWebExchange;
+import org.springframework.web.server.WebFilter;
+import org.springframework.web.server.WebFilterChain;
+import reactor.core.publisher.Mono;
+
+/** 跨域请求
+ * @author shiqian
+ * @date 2021年06月04日 14:28
+ **/
+@Configuration
+public class CrosConfig {
+
+    @Bean
+    public WebFilter corsFilter() {
+        return (ServerWebExchange ctx, WebFilterChain chain) -> {
+            ServerHttpRequest request = ctx.getRequest();
+            if (CorsUtils.isCorsRequest(request)) {
+                ServerHttpResponse response = ctx.getResponse();
+                HttpHeaders headers = response.getHeaders();
+                headers.add("Access-Control-Allow-Origin", "*");
+                headers.add("Access-Control-Allow-Methods", "*");
+                headers.add("Access-Control-Allow-Headers", "*");
+                headers.add("Access-Control-Allow-Credentials", "true");
+                if (request.getMethod() == HttpMethod.OPTIONS) {
+                    response.setStatusCode(HttpStatus.OK);
+                    return Mono.empty();
+                }
+            }
+            return chain.filter(ctx);
+        };
+    }
+}

+ 7 - 1
boman-gateway/src/main/java/com/boman/gateway/filter/CorsResponseHeaderFilter.java

@@ -1,3 +1,4 @@
+/*
 package com.boman.gateway.filter;
 
 import com.google.common.collect.Lists;
@@ -10,10 +11,14 @@ import org.springframework.stereotype.Component;
 import org.springframework.web.server.ServerWebExchange;
 import reactor.core.publisher.Mono;
 
+*/
 /** 跨域请求头重复处理过滤器防止出现多个
  * @author shiqian
  * @date 2021年06月04日 14:53
- **/
+ **//*
+
+
+
 @Component("corsResponseHeaderFilter")
 public class CorsResponseHeaderFilter implements GlobalFilter, Ordered {
 
@@ -36,3 +41,4 @@ public class CorsResponseHeaderFilter implements GlobalFilter, Ordered {
         }));
     }
 }
+*/

+ 2 - 2
boman-web-core/src/main/java/com/boman/web/core/service/TableServiceCmdService.java

@@ -590,8 +590,8 @@ public class TableServiceCmdService {
      * @param commitDatum 返回给前台的数据
      */
     private void handlerSubmit(String tableName, String pkName, JSONObject commitDatum) {
-        commitDatum.put(FormDataConstant.CREATE_BY, SecurityUtils.getUserId());
-        commitDatum.put(FormDataConstant.CREATE_TIME, new Timestamp(System.currentTimeMillis()));
+        //commitDatum.put(FormDataConstant.CREATE_BY, SecurityUtils.getUserId());
+        //commitDatum.put(FormDataConstant.CREATE_TIME, new Timestamp(System.currentTimeMillis()));
         int effective = submitService.handlerSubmit(tableName, pkName, commitDatum, commitDatum.getLong(FormDataConstant.ID));
         if (effective > 0) {
             commitDatum.put(SubmitConstant.SUBMIT_RESULT, SubmitConstant.SUCCESS);

+ 5 - 1
boman-web-core/src/main/java/com/boman/web/core/service/attendance/AttendanceServiceImpl.java

@@ -21,8 +21,10 @@ import java.util.List;
 import java.util.Map;
 import java.util.concurrent.locks.Condition;
 
+import static com.boman.common.core.utils.obj.ObjectUtils.ifNullSetEmpty;
 import static com.boman.common.core.utils.obj.ObjectUtils.requireNonNull;
 import static com.boman.domain.constant.AttendanceConst.*;
+import static com.boman.domain.constant.FormDataConstant.CONDITION;
 
 /**
  * @author shiqian
@@ -103,7 +105,9 @@ public class AttendanceServiceImpl implements AttendanceService {
      */
     @Override
     public AjaxResult detailedRecord(FormDataDto dto) {
-        List<JSONObject> byMap = commonService.getByMap(dto.getTable(), dto.getFixedData());
+        // 查询条件
+        JSONObject condition = ifNullSetEmpty(dto.getFixedData().getJSONObject(CONDITION));
+        List<JSONObject> byMap = commonService.getByMap(dto.getTable(), condition);
         List<Map<String,Object>> detailedRecordList = new ArrayList<>();
         if (ObjectUtils.isNotEmpty(byMap)){
             for (JSONObject jsonObject : byMap) {