mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 23:31:52 +08:00
✨ CRM:增加商机关联联系人
This commit is contained in:
parent
53ebd39c73
commit
e7bd2a568d
@ -199,6 +199,15 @@ public class CrmContactController {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/create-business-list2")
|
||||
@Operation(summary = "创建联系人与商机的关联")
|
||||
@PreAuthorize("@ss.hasPermission('crm:contact:create-business')")
|
||||
public CommonResult<Boolean> createContactBusinessList2(@Valid @RequestBody CrmContactBusiness2ReqVO createReqVO) {
|
||||
contactBusinessLinkService.createContactBusinessList2(createReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete-business-list")
|
||||
@Operation(summary = "删除联系人与联系人的关联")
|
||||
@PreAuthorize("@ss.hasPermission('crm:contact:delete-business')")
|
||||
@ -207,4 +216,12 @@ public class CrmContactController {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete-business-list2")
|
||||
@Operation(summary = "删除联系人与联系人的关联")
|
||||
@PreAuthorize("@ss.hasPermission('crm:contact:delete-business')")
|
||||
public CommonResult<Boolean> deleteContactBusinessList(@Valid @RequestBody CrmContactBusiness2ReqVO deleteReqVO) {
|
||||
contactBusinessLinkService.deleteContactBusinessList2(deleteReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,22 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.contact.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "管理后台 - CRM 联系人商机 Request VO") // 【商机关联联系人】用于关联,取消关联的操作
|
||||
@Data
|
||||
public class CrmContactBusiness2ReqVO {
|
||||
|
||||
@Schema(description = "商机编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7638")
|
||||
@NotNull(message="商机不能为空")
|
||||
private Long businessId;
|
||||
|
||||
@Schema(description = "联系人编号数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "20878")
|
||||
@NotEmpty(message="联系人数组不能为空")
|
||||
private List<Long> contactIds;
|
||||
|
||||
}
|
@ -7,7 +7,7 @@ import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "管理后台 - CRM 联系人商机 Request VO") // 用于关联,取消关联的操作
|
||||
@Schema(description = "管理后台 - CRM 联系人商机 Request VO") // 【联系人关联商机】用于关联,取消关联的操作
|
||||
@Data
|
||||
public class CrmContactBusinessReqVO {
|
||||
|
||||
|
@ -27,6 +27,12 @@ public interface CrmContactBusinessMapper extends BaseMapperX<CrmContactBusiness
|
||||
.in(CrmContactBusinessDO::getBusinessId, businessIds));
|
||||
}
|
||||
|
||||
default void deleteByBusinessIdAndContactId(Long businessId, List<Long> contactIds) {
|
||||
delete(new LambdaQueryWrapper<CrmContactBusinessDO>()
|
||||
.eq(CrmContactBusinessDO::getBusinessId, businessId)
|
||||
.in(CrmContactBusinessDO::getContactId, contactIds));
|
||||
}
|
||||
|
||||
default List<CrmContactBusinessDO> selectListByContactId(Long contactId) {
|
||||
return selectList(CrmContactBusinessDO::getContactId, contactId);
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.module.crm.service.contact;
|
||||
|
||||
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.contact.CrmContactBusinessDO;
|
||||
import jakarta.validation.Valid;
|
||||
@ -14,19 +15,33 @@ import java.util.List;
|
||||
public interface CrmContactBusinessService {
|
||||
|
||||
/**
|
||||
* 创建联系人与商机的关联
|
||||
* 创建联系人与商机的关联【通过联系人,关联商机】
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
*/
|
||||
void createContactBusinessList(@Valid CrmContactBusinessReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 删除联系人与商机的关联
|
||||
* 创建联系人与商机的关联【通过商机,关联联系人】
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
*/
|
||||
void createContactBusinessList2(@Valid CrmContactBusiness2ReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 删除联系人与商机的关联【通过联系人,取关商机】
|
||||
*
|
||||
* @param deleteReqVO 删除信息
|
||||
*/
|
||||
void deleteContactBusinessList(@Valid CrmContactBusinessReqVO deleteReqVO);
|
||||
|
||||
/**
|
||||
* 删除联系人与商机的关联【通过商机,取关联系人】
|
||||
*
|
||||
* @param deleteReqVO 删除信息
|
||||
*/
|
||||
void deleteContactBusinessList2(@Valid CrmContactBusiness2ReqVO deleteReqVO);
|
||||
|
||||
/**
|
||||
* 删除联系人与商机的关联,基于联系人编号
|
||||
*
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user