From 8d5318e6615637850175b049c7d29582ac82bc37 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Wed, 27 Mar 2024 15:39:43 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE):=20?= =?UTF-8?q?=E5=9C=B0=E5=9B=BE=E8=AE=BE=E7=BD=AE-=E5=9C=B0=E7=90=86?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E4=B8=8D=E5=AE=89=E5=85=A8=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/dataease/map/manage/MapManage.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/core/core-backend/src/main/java/io/dataease/map/manage/MapManage.java b/core/core-backend/src/main/java/io/dataease/map/manage/MapManage.java index a5dcb5efef..2e6894c3d3 100644 --- a/core/core-backend/src/main/java/io/dataease/map/manage/MapManage.java +++ b/core/core-backend/src/main/java/io/dataease/map/manage/MapManage.java @@ -109,6 +109,7 @@ public class MapManage { @CacheEvict(cacheNames = WORLD_MAP_CACHE, key = "'world_map'") @Transactional public void saveMapGeo(GeometryNodeCreator request, MultipartFile file) { + validateCode(request.getCode()); if (ObjectUtils.isEmpty(file) || file.isEmpty()) { DEException.throwException("geometry file is require"); } @@ -154,6 +155,7 @@ public class MapManage { @CacheEvict(cacheNames = WORLD_MAP_CACHE, key = "'world_map'") @Transactional public void deleteGeo(String code) { + validateCode(code); if (!StringUtils.startsWith(code, GEO_PREFIX)) { DEException.throwException("内置Geometry,禁止删除"); } @@ -209,5 +211,20 @@ public class MapManage { return code.substring(0, 3); } + public void validateCode(String code) { + if (StringUtils.isBlank(code)) DEException.throwException("区域编码不能为空"); + String busiGeoCode = getBusiGeoCode(code); + if (!isNumeric(busiGeoCode)) { + DEException.throwException("有效区域编码只能是数字"); + } + } + public boolean isNumeric(String str) { + for (int i = str.length(); --i >= 0; ) { + int chr = str.charAt(i); + if (chr < 48 || chr > 57) + return false; + } + return true; + } }