|
|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
package cn.iocoder.yudao.module.crm.service.contact;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactBusiness2ReqVO;
|
|
|
|
|
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactBusinessReqVO;
|
|
|
|
|
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
|
|
|
|
|
import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactBusinessDO;
|
|
|
|
|
@ -67,6 +68,32 @@ public class CrmContactBusinessServiceImpl implements CrmContactBusinessService
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS, bizId = "#createReqVO.businessId", level = CrmPermissionLevelEnum.WRITE)
|
|
|
|
|
public void createContactBusinessList2(CrmContactBusiness2ReqVO createReqVO) {
|
|
|
|
|
CrmBusinessDO business = businessService.getBusiness(createReqVO.getBusinessId());
|
|
|
|
|
if (business == null) {
|
|
|
|
|
throw exception(BUSINESS_NOT_EXISTS);
|
|
|
|
|
}
|
|
|
|
|
// 遍历处理,考虑到一般数量不会太多,代码处理简单
|
|
|
|
|
List<CrmContactBusinessDO> saveDOList = new ArrayList<>();
|
|
|
|
|
createReqVO.getContactIds().forEach(contactId -> {
|
|
|
|
|
CrmContactDO contact = contactService.getContact(contactId);
|
|
|
|
|
if (contact == null) {
|
|
|
|
|
throw exception(CONTACT_NOT_EXISTS);
|
|
|
|
|
}
|
|
|
|
|
// 关联判重
|
|
|
|
|
if (contactBusinessMapper.selectByContactIdAndBusinessId(contactId, createReqVO.getBusinessId()) != null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
saveDOList.add(new CrmContactBusinessDO(null, contactId, createReqVO.getBusinessId()));
|
|
|
|
|
});
|
|
|
|
|
// 批量插入
|
|
|
|
|
if (CollUtil.isNotEmpty(saveDOList)) {
|
|
|
|
|
contactBusinessMapper.insertBatch(saveDOList);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#deleteReqVO.contactId", level = CrmPermissionLevelEnum.WRITE)
|
|
|
|
|
public void deleteContactBusinessList(CrmContactBusinessReqVO deleteReqVO) {
|
|
|
|
|
@ -79,6 +106,18 @@ public class CrmContactBusinessServiceImpl implements CrmContactBusinessService
|
|
|
|
|
deleteReqVO.getContactId(), deleteReqVO.getBusinessIds());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS, bizId = "#deleteReqVO.businessId", level = CrmPermissionLevelEnum.WRITE)
|
|
|
|
|
public void deleteContactBusinessList2(CrmContactBusiness2ReqVO deleteReqVO) {
|
|
|
|
|
CrmBusinessDO business = businessService.getBusiness(deleteReqVO.getBusinessId());
|
|
|
|
|
if (business == null) {
|
|
|
|
|
throw exception(BUSINESS_NOT_EXISTS);
|
|
|
|
|
}
|
|
|
|
|
// 直接删除
|
|
|
|
|
contactBusinessMapper.deleteByBusinessIdAndContactId(
|
|
|
|
|
deleteReqVO.getBusinessId(), deleteReqVO.getContactIds());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#contactId", level = CrmPermissionLevelEnum.WRITE)
|
|
|
|
|
public void deleteContactBusinessByContactId(Long contactId) {
|
|
|
|
|
|