yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/followup/CrmFollowUpRecordServiceImpl.java
@@ -18,6 +18,7 @@
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
import cn.iocoder.yudao.module.crm.service.followup.bo.CrmFollowUpCreateReqBO;
import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
import cn.iocoder.yudao.module.system.api.storage.StorageAttachmentApi;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
@@ -60,6 +61,8 @@
    @Resource
    @Lazy
    private CrmCustomerService customerService;
    @Resource
    private StorageAttachmentApi storageAttachmentApi;
    @Override
    @CrmPermission(bizTypeValue = "#createReqVO.bizType", bizId = "#createReqVO.bizId", level = CrmPermissionLevelEnum.WRITE)
@@ -67,6 +70,8 @@
        // 1. 创建更进记录
        CrmFollowUpRecordDO record = BeanUtils.toBean(createReqVO, CrmFollowUpRecordDO.class);
        crmFollowUpRecordMapper.insert(record);
        storageAttachmentApi.bindAttachments("file", "crm_follow_up_record",
                record.getId(), createReqVO.getBlobIds());
        // 2. 更新 bizId 对应的记录
        if (ObjUtil.equal(CrmBizTypeEnum.CRM_CUSTOMER.getType(), record.getBizType())) { // 更新客户跟进信息
@@ -113,12 +118,18 @@
            throw exception(FOLLOW_UP_RECORD_DELETE_DENIED);
        }
        // 删除附件
        storageAttachmentApi.deleteAttachmentsByRecord("crm_follow_up_record", id);
        // 删除
        crmFollowUpRecordMapper.deleteById(id);
    }
    @Override
    public void deleteFollowUpRecordByBiz(Integer bizType, Long bizId) {
        List<CrmFollowUpRecordDO> records = crmFollowUpRecordMapper.selectListByBiz(bizType, List.of(bizId));
        for (CrmFollowUpRecordDO record : records) {
            storageAttachmentApi.deleteAttachmentsByRecord("crm_follow_up_record", record.getId());
        }
        crmFollowUpRecordMapper.deleteByBiz(bizType, bizId);
    }