Commit 54362f20 by 陶光胜

经纬度校验

parent 2fd81dab
...@@ -52,6 +52,8 @@ import java.text.SimpleDateFormat; ...@@ -52,6 +52,8 @@ import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
...@@ -64,6 +66,7 @@ import java.util.stream.Stream; ...@@ -64,6 +66,7 @@ import java.util.stream.Stream;
public class StoreApiServiceImpl implements StoreApiService { public class StoreApiServiceImpl implements StoreApiService {
private static final Logger logger = LogManager.getLogger(StoreApiServiceImpl.class); private static final Logger logger = LogManager.getLogger(StoreApiServiceImpl.class);
private Long storeExpiredTime = 1L; private Long storeExpiredTime = 1L;
private static Pattern NUMBER_PATTERN = Pattern.compile("\\d+\\.\\d+$|-\\d+\\.\\d+$");
@Autowired @Autowired
private StoreService storeService; private StoreService storeService;
@Autowired @Autowired
...@@ -260,6 +263,16 @@ public class StoreApiServiceImpl implements StoreApiService { ...@@ -260,6 +263,16 @@ public class StoreApiServiceImpl implements StoreApiService {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "门店分组必须为叶子节点"); return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "门店分组必须为叶子节点");
} }
} }
if(org.apache.commons.lang.StringUtils.isNotBlank(storeDTO.getLatitude()) || org.apache.commons.lang.StringUtils.isNotBlank(storeDTO.getLongitude())){
Matcher matcher = NUMBER_PATTERN.matcher(storeDTO.getLatitude());
if(!matcher.matches()){
storeDTO.setLatitude(null);
}
matcher = NUMBER_PATTERN.matcher(storeDTO.getLongitude());
if(!matcher.matches()){
storeDTO.setLongitude(null);
}
}
return null; return null;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment