10-25-供应商新增、删除添加校验

This commit is contained in:
2025-10-25 20:11:14 +08:00
parent f953a96c36
commit 570b0ce316
2 changed files with 28 additions and 5 deletions

View File

@ -1,9 +1,10 @@
package org.dromara.xzd.domain;
import org.dromara.common.mybatis.core.domain.BaseEntity;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.dromara.common.mybatis.core.domain.BaseEntity;
import java.io.Serial;
@ -22,13 +23,13 @@ public class XzdCustomerSupplier extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
*
*
*/
@TableId(value = "id")
private Long id;
/**
* 类型1、供应商2、客户
* 类型(2、客户 1、供应商
*/
private String type;

View File

@ -18,10 +18,11 @@ import org.dromara.system.service.impl.SysOssServiceImpl;
import org.dromara.system.service.impl.SysUserServiceImpl;
import org.dromara.xzd.domain.*;
import org.dromara.xzd.domain.bo.XzdSupplierInfoBo;
import org.dromara.xzd.domain.vo.XzdCustomerinformationVo;
import org.dromara.xzd.domain.vo.XzdCustomertypeVo;
import org.dromara.xzd.domain.vo.XzdSupplierInfoVo;
import org.dromara.xzd.mapper.XzdSupplierInfoMapper;
import org.dromara.xzd.service.IXzdCustomerSupplierService;
import org.dromara.xzd.service.IXzdCustomerSupplierYybService;
import org.dromara.xzd.service.IXzdSupplierInfoService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -77,6 +78,8 @@ public class XzdSupplierInfoServiceImpl extends ServiceImpl<XzdSupplierInfoMappe
@Autowired
private SysOssServiceImpl sysOssService;
private final IXzdCustomerSupplierService iXzdCustomerSupplierService;
private final IXzdCustomerSupplierYybService iXzdCustomerSupplierYybService;
/**
@ -208,6 +211,12 @@ public class XzdSupplierInfoServiceImpl extends ServiceImpl<XzdSupplierInfoMappe
}
bo.setId(add.getId());
//新增中间表
XzdCustomerSupplier xzdCustomerSupplier = new XzdCustomerSupplier();
xzdCustomerSupplier.setCSId(add.getId());
xzdCustomerSupplier.setType("2");
iXzdCustomerSupplierService.save(xzdCustomerSupplier);
//处理资质信息
if (bo.getQualifications() != null && !bo.getQualifications().isEmpty()){
for (XzdSupplierQualification qualification : bo.getQualifications()) {
@ -561,6 +570,19 @@ public class XzdSupplierInfoServiceImpl extends ServiceImpl<XzdSupplierInfoMappe
continue;
}
//查询引用表是否被引用
LambdaQueryWrapper<XzdCustomerSupplierYyb> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(XzdCustomerSupplierYyb::getCSId, id);
List<XzdCustomerSupplierYyb> yybList = iXzdCustomerSupplierYybService.list(wrapper);
if (yybList != null && !yybList.isEmpty()){
throw new RuntimeException("供应商id:{"+id+"}已被其他业务使用,删除失败");
}
//如果没有被引用 则进行删除中间表数据
LambdaQueryWrapper<XzdCustomerSupplier> wrapper2 = new LambdaQueryWrapper<>();
wrapper2.eq(XzdCustomerSupplier::getCSId, id);
wrapper2.eq(XzdCustomerSupplier::getType,"2");
iXzdCustomerSupplierService.remove(wrapper2);
//删除资质新信息
LambdaQueryWrapper<XzdSupplierQualification> qualificationLambdaQueryWrapper = new LambdaQueryWrapper<>();
qualificationLambdaQueryWrapper.eq(XzdSupplierQualification::getSupplierId, id);