From f888c180b052006c3fca72a10bdc0fb55a87a8fc Mon Sep 17 00:00:00 2001 From: liujiang <569804566@qq.com> Date: Fri, 19 Sep 2025 10:02:41 +0800 Subject: [PATCH] =?UTF-8?q?master=EF=BC=9A=E6=96=B0=E5=A2=9E=E5=AE=A2?= =?UTF-8?q?=E6=88=B7=E5=8F=AF=E4=BB=A5=E4=B8=8D=E8=BE=93=E5=85=A5=E6=89=8B?= =?UTF-8?q?=E6=9C=BA=E5=8F=B7=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/xkt/vo/storeCustomer/StoreCusVO.java | 1 - ruoyi-admin/src/main/resources/application.yml | 3 ++- .../xkt/service/impl/StoreCustomerServiceImpl.java | 13 +++++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/vo/storeCustomer/StoreCusVO.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/vo/storeCustomer/StoreCusVO.java index 7001cd01c..8f72d90b1 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/vo/storeCustomer/StoreCusVO.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/vo/storeCustomer/StoreCusVO.java @@ -27,7 +27,6 @@ public class StoreCusVO { @ApiModelProperty(value = "客户名称", required = true) private String cusName; @ApiModelProperty(value = "客户联系电话") - @Pattern(regexp = "^1[3-9]\\d{9}$", message = "联系电话格式不正确,请输入有效的中国大陆手机号") private String phone; @ApiModelProperty(value = "备注") private String remark; diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index caf4dfcd6..2cc0df181 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -1,3 +1,4 @@ spring: profiles: - active: dev \ No newline at end of file + active: dev +# active: prod \ No newline at end of file diff --git a/xkt/src/main/java/com/ruoyi/xkt/service/impl/StoreCustomerServiceImpl.java b/xkt/src/main/java/com/ruoyi/xkt/service/impl/StoreCustomerServiceImpl.java index 513654e3d..842293177 100644 --- a/xkt/src/main/java/com/ruoyi/xkt/service/impl/StoreCustomerServiceImpl.java +++ b/xkt/src/main/java/com/ruoyi/xkt/service/impl/StoreCustomerServiceImpl.java @@ -26,6 +26,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Objects; import java.util.Optional; +import java.util.regex.Pattern; import java.util.stream.Collectors; /** @@ -67,6 +68,12 @@ public class StoreCustomerServiceImpl implements IStoreCustomerService { if (!SecurityUtils.isAdmin() && !SecurityUtils.isStoreManagerOrSub(storeCusDTO.getStoreId())) { throw new ServiceException("当前用户非档口管理者或子账号,无权限操作!", HttpStatus.ERROR); } + if (StringUtils.isNotBlank(storeCusDTO.getPhone())) { + final String regex = "^1[3-9]\\d{9}$"; + if (!Pattern.matches(regex, storeCusDTO.getPhone().trim())) { + throw new ServiceException("请输入正确的手机号!", HttpStatus.ERROR); + } + } return this.storeCusMapper.insert(BeanUtil.toBean(storeCusDTO, StoreCustomer.class)); } @@ -119,6 +126,12 @@ public class StoreCustomerServiceImpl implements IStoreCustomerService { StoreCustomer storeCus = Optional.ofNullable(this.storeCusMapper.selectOne(new LambdaQueryWrapper() .eq(StoreCustomer::getId, storeCusDTO.getStoreCusId()).eq(StoreCustomer::getDelFlag, Constants.UNDELETED))) .orElseThrow(() -> new ServiceException("档口客户不存在!")); + if (StringUtils.isNotBlank(storeCusDTO.getPhone())) { + final String regex = "^1[3-9]\\d{9}$"; + if (!Pattern.matches(regex, storeCusDTO.getPhone().trim())) { + throw new ServiceException("请输入正确的手机号!", HttpStatus.ERROR); + } + } BeanUtil.copyProperties(storeCusDTO, storeCus); return storeCusMapper.updateById(storeCus); }