Browse Source

fix(supplier): 修复供应商地址管理中的参数验证和分页查询问题

- 修复QueryPage类中limit和page参数的默认值处理,防止负数或零值导致的查询异常
- 修改SrmSupplierAddressMapper接口方法签名,统一使用IPage参数类型
- 修复XML映射文件中supplier_id字段引用错误,保持与实体类属性名一致
- 移除未使用的jakarta.mail.Address导入
- 添加供应商ID和地址ID的空值验证,防止空数据插入和更新操作
- 优化分页查询的参数传递和处理逻辑
master
qiankanghui 2 months ago
parent
commit
5ec69ff66d
  1. 4
      src/main/java/com/xujie/common/utils/QueryPage.java
  2. 2
      src/main/java/com/xujie/modules/baseInformation/mapper/SrmSupplierAddressMapper.java
  3. 17
      src/main/java/com/xujie/modules/baseInformation/service/impl/SrmSupplierAddressServiceImpl.java
  4. 2
      src/main/resources/mapper/baseInformation/SrmSupplierAddressMapper.xml

4
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) {

2
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<SrmSupplierAddress> {
IPage<SrmSupplierAddress> selectSupplierAddressWithPaging(Page<SrmSupplierAddress> page, @Param("query") SrmSupplierAddress query);
IPage<SrmSupplierAddress> selectSupplierAddressWithPaging(IPage<SrmSupplierAddress> page, @Param("query") SrmSupplierAddress query);
int insertSupplierAddress(SrmSupplierAddress supplierAddress);

17
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<SrmSupplierAddress> 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) {

2
src/main/resources/mapper/baseInformation/SrmSupplierAddressMapper.xml

@ -39,7 +39,7 @@
AND site = #{query.site}
</if>
<if test="query.supplierId != null and query.supplierId != ''">
AND supplier_id = #{query.supplierId}
AND supplierId = #{query.supplierId}
</if>
<if test="query.addressType != null and query.addressType != ''">
AND addressType = #{query.addressType}

Loading…
Cancel
Save