From 5ec69ff66dec65164417d6705ecbe22d5922d64f Mon Sep 17 00:00:00 2001 From: qiankanghui <11284155+qian-kanghui@user.noreply.gitee.com> Date: Tue, 6 Jan 2026 13:20:55 +0800 Subject: [PATCH] =?UTF-8?q?fix(supplier):=20=E4=BF=AE=E5=A4=8D=E4=BE=9B?= =?UTF-8?q?=E5=BA=94=E5=95=86=E5=9C=B0=E5=9D=80=E7=AE=A1=E7=90=86=E4=B8=AD?= =?UTF-8?q?=E7=9A=84=E5=8F=82=E6=95=B0=E9=AA=8C=E8=AF=81=E5=92=8C=E5=88=86?= =?UTF-8?q?=E9=A1=B5=E6=9F=A5=E8=AF=A2=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修复QueryPage类中limit和page参数的默认值处理,防止负数或零值导致的查询异常 - 修改SrmSupplierAddressMapper接口方法签名,统一使用IPage参数类型 - 修复XML映射文件中supplier_id字段引用错误,保持与实体类属性名一致 - 移除未使用的jakarta.mail.Address导入 - 添加供应商ID和地址ID的空值验证,防止空数据插入和更新操作 - 优化分页查询的参数传递和处理逻辑 --- .../java/com/xujie/common/utils/QueryPage.java | 4 ++-- .../mapper/SrmSupplierAddressMapper.java | 2 +- .../impl/SrmSupplierAddressServiceImpl.java | 17 +++++++++++++++-- .../SrmSupplierAddressMapper.xml | 2 +- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/xujie/common/utils/QueryPage.java b/src/main/java/com/xujie/common/utils/QueryPage.java index bf80d74..62a4baf 100644 --- a/src/main/java/com/xujie/common/utils/QueryPage.java +++ b/src/main/java/com/xujie/common/utils/QueryPage.java @@ -13,7 +13,7 @@ public class QueryPage { public int getLimit() { - return limit; + return limit <= 0 ? 10 : limit; } public void setLimit(int limit) { @@ -21,7 +21,7 @@ public class QueryPage { } public int getPage() { - return page; + return page <= 0 ? 1 : page; } public void setPage(int page) { diff --git a/src/main/java/com/xujie/modules/baseInformation/mapper/SrmSupplierAddressMapper.java b/src/main/java/com/xujie/modules/baseInformation/mapper/SrmSupplierAddressMapper.java index f677456..155dad1 100644 --- a/src/main/java/com/xujie/modules/baseInformation/mapper/SrmSupplierAddressMapper.java +++ b/src/main/java/com/xujie/modules/baseInformation/mapper/SrmSupplierAddressMapper.java @@ -10,7 +10,7 @@ import org.apache.ibatis.annotations.Param; @Mapper public interface SrmSupplierAddressMapper extends BaseMapper { - IPage selectSupplierAddressWithPaging(Page page, @Param("query") SrmSupplierAddress query); + IPage selectSupplierAddressWithPaging(IPage page, @Param("query") SrmSupplierAddress query); int insertSupplierAddress(SrmSupplierAddress supplierAddress); diff --git a/src/main/java/com/xujie/modules/baseInformation/service/impl/SrmSupplierAddressServiceImpl.java b/src/main/java/com/xujie/modules/baseInformation/service/impl/SrmSupplierAddressServiceImpl.java index 6cdc28b..621fa41 100644 --- a/src/main/java/com/xujie/modules/baseInformation/service/impl/SrmSupplierAddressServiceImpl.java +++ b/src/main/java/com/xujie/modules/baseInformation/service/impl/SrmSupplierAddressServiceImpl.java @@ -7,7 +7,6 @@ import com.xujie.common.utils.R; import com.xujie.modules.baseInformation.entity.SrmSupplierAddress; import com.xujie.modules.baseInformation.mapper.SrmSupplierAddressMapper; import com.xujie.modules.baseInformation.service.SrmSupplierAddressService; -import jakarta.mail.Address; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -16,7 +15,7 @@ public class SrmSupplierAddressServiceImpl implements SrmSupplierAddressService @Autowired private SrmSupplierAddressMapper srmSupplierAddressMapper; - + @Override public PageUtils getSupplierAddressList(SrmSupplierAddress query) { Page page = new Page<>(query.getPage(), query.getLimit()); @@ -26,6 +25,13 @@ public class SrmSupplierAddressServiceImpl implements SrmSupplierAddressService @Override public R addSupplierAddress(SrmSupplierAddress supplierAddress) { + if (supplierAddress.getSupplierId() == null || supplierAddress.getSupplierId().trim().isEmpty()) { + return R.error("供应商ID不能为空"); + } + if (supplierAddress.getAddressId() == null || supplierAddress.getAddressId().trim().isEmpty()) { + return R.error("地址ID不能为空"); + } + // 检查供应商地址是否已存在 SrmSupplierAddress existing = srmSupplierAddressMapper.selectSupplierAddressByAddress(supplierAddress.getSupplierId(), supplierAddress.getAddressId(), supplierAddress.getSite()); if (existing != null) { @@ -42,6 +48,13 @@ public class SrmSupplierAddressServiceImpl implements SrmSupplierAddressService @Override public R updateSupplierAddress(SrmSupplierAddress supplierAddress) { + if (supplierAddress.getSupplierId() == null || supplierAddress.getSupplierId().trim().isEmpty()) { + return R.error("供应商ID不能为空"); + } + if (supplierAddress.getAddressId() == null || supplierAddress.getAddressId().trim().isEmpty()) { + return R.error("地址ID不能为空"); + } + // 检查供应商地址是否存在 SrmSupplierAddress existing = srmSupplierAddressMapper.selectSupplierAddressByAddress(supplierAddress.getSupplierId(), supplierAddress.getAddressId(), supplierAddress.getSite()); if (existing == null) { diff --git a/src/main/resources/mapper/baseInformation/SrmSupplierAddressMapper.xml b/src/main/resources/mapper/baseInformation/SrmSupplierAddressMapper.xml index ef45e24..58e0506 100644 --- a/src/main/resources/mapper/baseInformation/SrmSupplierAddressMapper.xml +++ b/src/main/resources/mapper/baseInformation/SrmSupplierAddressMapper.xml @@ -39,7 +39,7 @@ AND site = #{query.site} - AND supplier_id = #{query.supplierId} + AND supplierId = #{query.supplierId} AND addressType = #{query.addressType}