Forráskód Böngészése

公积金单位修改以及添加仅接受来自前端的请求

nahida 1 éve
szülő
commit
82a952055b

+ 1 - 0
zksy-admin/src/main/resources/application-druid.yml

@@ -1,3 +1,4 @@
+clientKey: 性与暴力
 # 项目相关配置
 zksy:
   # 名称

+ 1 - 0
zksy-admin/src/main/resources/application-prod.yml

@@ -1,3 +1,4 @@
+clientKey: 爱与和平
 # 项目相关配置
 zksy:
   # 名称

BIN
zksy-admin/src/main/resources/template/公积金信息汇总模板.xlsx


+ 26 - 0
zksy-framework/src/main/java/com/zksy/framework/config/ResourcesConfig.java

@@ -1,5 +1,6 @@
 package com.zksy.framework.config;
 
+import com.zksy.framework.interceptor.ComfirmClientInterceptor;
 import com.zksy.framework.interceptor.RepeatSubmitInterceptor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -23,6 +24,8 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 public class ResourcesConfig implements WebMvcConfigurer {
     @Autowired
     private RepeatSubmitInterceptor repeatSubmitInterceptor;
+    @Autowired
+    private ComfirmClientInterceptor comfirmClientInterceptor;
 
     /**
      * 在配置文件中配置的文件保存路径
@@ -63,6 +66,29 @@ public class ResourcesConfig implements WebMvcConfigurer {
         registry.addInterceptor(repeatSubmitInterceptor).addPathPatterns("/**").
                 excludePathPatterns("/swagger-resources/**", "/webjars/**", "/v2/**", "/swagger-ui.html/**", "/doc.html", "/static/**").
                 excludePathPatterns(localFileServerMappingPath + "/**");
+        registry.addInterceptor(comfirmClientInterceptor).addPathPatterns(
+                //get
+                "/crmNewsRelease/findByPage",
+                "/crmNewsRelease/getList",
+                "/crmNewsRelease/getById/{borrowId}",
+                "/system/dict/data/type/{dictType}",
+                "/crmHighTechZoneEnterprises/getCreditScoreList",
+                "/crmCreditRedlistInfo/findByPage",
+                "/crmDishonestExecutor/findByPage",
+                "/crmSeriouslyDishonestSubjects/findByPage",
+                "/crmAdministrativeLicense/findByPage",
+                "/crmAdministrativePenalty/findByPage",
+                "/crmBusinessLicenseInformation/findByPage",
+                "/crmBusinessLicenseInformation/getById/{borrowId}",
+                "/commonFile/deleteFileById",
+                "/owSelfReporting/downloadTemplateWord",
+                "/owSelfReporting/checkInformationByUnicode",
+                "/crmHighTechZoneEnterprises/getCreditScoreMostDetailsByUniCode",
+                //post
+                "/crmComplain/save",
+                "/owSelfReporting/save",
+                "/owLeavingMessage/save"
+        );
     }
 
     /**

+ 53 - 0
zksy-framework/src/main/java/com/zksy/framework/interceptor/ComfirmClientInterceptor.java

@@ -0,0 +1,53 @@
+package com.zksy.framework.interceptor;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.zksy.common.utils.StringUtils;
+import com.zksy.common.utils.result.Response;
+import com.zksy.common.utils.sign.Md5Utils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+import org.springframework.web.servlet.HandlerInterceptor;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.time.LocalDate;
+
+@Component
+public class ComfirmClientInterceptor implements HandlerInterceptor {
+
+    @Autowired
+    private ObjectMapper objectMapper;
+    @Value("${clientKey}")
+    private String CLIENT_KEY;
+
+    @Override
+    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
+        String s = request.getHeader("Loveandpeace");
+        int i = LocalDate.now().getDayOfMonth();
+        String key = CLIENT_KEY+i;
+        String k = Md5Utils.hash(key);
+        if(!k.equals(s)){
+            response.setStatus(403);
+            response.setContentType("text/html;charset=UTF-8");
+            response.getWriter().write(objectMapper.writeValueAsString(Response.error(403,"不准请求")));
+            return false;
+        }
+        String ua = request.getHeader("User-Agent");
+        if(StringUtils.isEmpty(ua) || !isBrowser(ua)){
+            response.setStatus(403);
+            response.setContentType("text/html;charset=UTF-8");
+            response.getWriter().write(objectMapper.writeValueAsString(Response.error(403,"不准请求")));
+            return false;
+        }
+        return true;
+    }
+
+    private boolean isBrowser(String userAgent) {
+        return userAgent.contains("Mozilla") &&
+                (userAgent.contains("Chrome") ||
+                        userAgent.contains("Safari") ||
+                        userAgent.contains("Firefox") ||
+                        userAgent.contains("Opera"));
+    }
+}

+ 5 - 3
zksy-system/src/main/java/com/zksy/system/basicData/domain/CrmAccumulationFundSummary.java

@@ -76,9 +76,11 @@ private static final long serialVersionUID=1L;
                 @ExcelExport(value = "连续缴存月份")
     private Long consecutiveContributingMonths;
 
-    @ApiModelProperty(value = "年份备注")
+@ApiModelProperty(value = "年份备注")
     /** 年份备注 */
-    @ExcelImport(value = "年份备注")
-    @ExcelExport(value = "年份备注")
+                @ExcelImport(value = "年份备注")
+                @ExcelExport(value = "年份备注")
     private String remarks;
+
+
         }