Pārlūkot izejas kodu

车型查询接口过滤中文

785834757 10 mēneši atpakaļ
vecāks
revīzija
baeca1a611

+ 5 - 0
tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/controller/CarModelController.java

@@ -3,6 +3,7 @@ package com.jzg.quotation.summary.controller;
 import com.alibaba.fastjson.JSONObject;
 import com.jzg.commons.core.page.HttpResult;
 import com.jzg.commons.entity.vo.CarModelDTO;
+import com.jzg.commons.exception.SystemException;
 import com.jzg.quotation.summary.entity.po.ModelsQueryQueryVo;
 import com.jzg.quotation.summary.service.CarModelService;
 import io.swagger.v3.oas.annotations.Operation;
@@ -45,6 +46,10 @@ public class  CarModelController {
     @PostMapping(value = "/modelsQuery")
     @Operation(description = "车型查询接口")
     public HttpResult<List<CarModelDTO>> modelsQuery(@RequestBody ModelsQueryQueryVo modelsQueryQueryVo) {
+        String filtered = modelsQueryQueryVo.getModelName().replaceAll("[\\u4e00-\\u9fa5]", "");
+        if("".equals(filtered)){
+            throw new SystemException("品牌型号不能为纯中文");
+        }
         List<CarModelDTO> map = carModelService.modelsQuery(modelsQueryQueryVo.getModelName());
         List<CarModelDTO> carModelDTOS =
                 map.stream().sorted(Comparator.comparing(CarModelDTO::getReplacementValue)).collect(Collectors.toList());