crm联系人商机功能
This commit is contained in:
parent
72969e921e
commit
910bc09e19
@ -0,0 +1,15 @@
|
||||
-- `ruoyi-vue-pro`.crm_contact_business_link definition
|
||||
|
||||
CREATE TABLE `crm_contact_business_link` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`contact_id` int(11) DEFAULT NULL COMMENT '联系人id',
|
||||
`business_id` int(11) DEFAULT NULL COMMENT '商机id',
|
||||
`creator` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '创建者',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`updater` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '更新者',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
|
||||
`tenant_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '租户编号',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `crm_contact_business_link_un` (`contact_id`,`business_id`,`deleted`,`tenant_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=29 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='联系人商机关联表';
|
@ -23,6 +23,7 @@ public interface ErrorCodeConstants {
|
||||
|
||||
// ========== 联系人管理 1-020-003-000 ==========
|
||||
ErrorCode CONTACT_NOT_EXISTS = new ErrorCode(1_020_003_000, "联系人不存在");
|
||||
ErrorCode CONTACT_BUSINESS_LINK_NOT_EXISTS = new ErrorCode( 1_020_003_001, "联系人商机关联不存在");
|
||||
|
||||
// ========== 回款 1-020-004-000 ==========
|
||||
ErrorCode RECEIVABLE_NOT_EXISTS = new ErrorCode(1_020_004_000, "回款不存在");
|
||||
|
@ -0,0 +1,121 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink;
|
||||
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessRespVO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
|
||||
import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;
|
||||
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_NOT_EXISTS;
|
||||
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo.*;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.contactbusinesslink.CrmContactBusinessLinkDO;
|
||||
import cn.iocoder.yudao.module.crm.service.contactbusinesslink.CrmContactBusinessLinkService;
|
||||
|
||||
@Tag(name = "管理后台 - 联系人商机关联")
|
||||
@RestController
|
||||
@RequestMapping("/crm/contact-business-link")
|
||||
@Validated
|
||||
public class CrmContactBusinessLinkController {
|
||||
|
||||
@Resource
|
||||
private CrmContactBusinessLinkService contactBusinessLinkService;
|
||||
@Resource
|
||||
private CrmBusinessService crmBusinessService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建联系人商机关联")
|
||||
@PreAuthorize("@ss.hasPermission('crm:contact-business-link:create')")
|
||||
public CommonResult<Long> createContactBusinessLink(@Valid @RequestBody CrmContactBusinessLinkSaveReqVO createReqVO) {
|
||||
return success(contactBusinessLinkService.createContactBusinessLink(createReqVO));
|
||||
}
|
||||
@PostMapping("/create-batch")
|
||||
@Operation(summary = "创建联系人商机关联")
|
||||
@PreAuthorize("@ss.hasPermission('crm:contact-business-link:create')")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public CommonResult<Boolean> createContactBusinessLinkBatch(@Valid @RequestBody List<CrmContactBusinessLinkSaveReqVO> createReqVO) {
|
||||
createReqVO.stream().forEach(item -> {
|
||||
CrmBusinessDO crmBusinessDO = crmBusinessService.getBusiness(item.getBusinessId());
|
||||
if(crmBusinessDO == null){
|
||||
throw exception(BUSINESS_NOT_EXISTS);
|
||||
}
|
||||
});
|
||||
contactBusinessLinkService.createContactBusinessLinkBatch(createReqVO);
|
||||
return success(true);
|
||||
}
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新联系人商机关联")
|
||||
@PreAuthorize("@ss.hasPermission('crm:contact-business-link:update')")
|
||||
public CommonResult<Boolean> updateContactBusinessLink(@Valid @RequestBody CrmContactBusinessLinkSaveReqVO updateReqVO) {
|
||||
contactBusinessLinkService.updateContactBusinessLink(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
@DeleteMapping("/delete-batch")
|
||||
@Operation(summary = "批量删除联系人商机关联")
|
||||
@PreAuthorize("@ss.hasPermission('crm:contact-business-link:delete')")
|
||||
public CommonResult<Boolean> deleteContactBusinessLinkBatch(@Valid @RequestBody List<CrmContactBusinessLinkSaveReqVO> deleteList) {
|
||||
contactBusinessLinkService.deleteContactBusinessLink(deleteList);
|
||||
return success(true);
|
||||
}
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得联系人商机关联")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('crm:contact-business-link:query')")
|
||||
public CommonResult<CrmContactBusinessLinkRespVO> getContactBusinessLink(@RequestParam("id") Long id) {
|
||||
CrmContactBusinessLinkDO contactBusinessLink = contactBusinessLinkService.getContactBusinessLink(id);
|
||||
return success(BeanUtils.toBean(contactBusinessLink, CrmContactBusinessLinkRespVO.class));
|
||||
}
|
||||
@GetMapping("/page-by-contact")
|
||||
@Operation(summary = "获得联系人商机关联")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('crm:contact-business-link:query')")
|
||||
public CommonResult<PageResult<CrmBusinessRespVO>> getContactBusinessLinkByContact(@Valid CrmContactBusinessLinkPageReqVO pageReqVO) {
|
||||
PageResult<CrmBusinessRespVO> contactBusinessLink = contactBusinessLinkService.getContactBusinessLinkPageByContact(pageReqVO);
|
||||
return success(contactBusinessLink);
|
||||
}
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得联系人商机关联分页")
|
||||
@PreAuthorize("@ss.hasPermission('crm:contact-business-link:query')")
|
||||
public CommonResult<PageResult<CrmContactBusinessLinkRespVO>> getContactBusinessLinkPage(@Valid CrmContactBusinessLinkPageReqVO pageReqVO) {
|
||||
PageResult<CrmContactBusinessLinkDO> pageResult = contactBusinessLinkService.getContactBusinessLinkPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, CrmContactBusinessLinkRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出联系人商机关联 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('crm:contact-business-link:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportContactBusinessLinkExcel(@Valid CrmContactBusinessLinkPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<CrmContactBusinessLinkDO> list = contactBusinessLinkService.getContactBusinessLinkPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "联系人商机关联.xls", "数据", CrmContactBusinessLinkRespVO.class,
|
||||
BeanUtils.toBean(list, CrmContactBusinessLinkRespVO.class));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 联系人商机关联分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class CrmContactBusinessLinkPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "联系人id", example = "20878")
|
||||
private Long contactId;
|
||||
|
||||
@Schema(description = "商机id", example = "7638")
|
||||
private Long businessId;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.util.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
|
||||
@Schema(description = "管理后台 - 联系人商机关联 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class CrmContactBusinessLinkRespVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "17220")
|
||||
@ExcelProperty("主键")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "联系人id", example = "20878")
|
||||
@ExcelProperty("联系人id")
|
||||
private Long contactId;
|
||||
|
||||
@Schema(description = "商机id", example = "7638")
|
||||
@ExcelProperty("商机id")
|
||||
private Long businessId;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.*;
|
||||
|
||||
@Schema(description = "管理后台 - 联系人商机关联新增/修改 Request VO")
|
||||
@Data
|
||||
public class CrmContactBusinessLinkSaveReqVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "17220")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "联系人id", example = "20878")
|
||||
@NotNull(message="联系人不能为空")
|
||||
private Long contactId;
|
||||
|
||||
@Schema(description = "商机id", example = "7638")
|
||||
@NotNull(message="商机不能为空")
|
||||
private Long businessId;
|
||||
|
||||
}
|
@ -32,6 +32,7 @@ public interface CrmBusinessConvert {
|
||||
CrmBusinessDO convert(CrmBusinessUpdateReqVO bean);
|
||||
|
||||
CrmBusinessRespVO convert(CrmBusinessDO bean);
|
||||
List<CrmBusinessRespVO> convert(List<CrmBusinessDO> bean);
|
||||
|
||||
PageResult<CrmBusinessRespVO> convertPage(PageResult<CrmBusinessDO> page);
|
||||
|
||||
|
@ -0,0 +1,15 @@
|
||||
package cn.iocoder.yudao.module.crm.convert.contactbusinessslink;
|
||||
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo.CrmContactBusinessLinkSaveReqVO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.contactbusinesslink.CrmContactBusinessLinkDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface CrmContactBusinessLinkConvert {
|
||||
CrmContactBusinessLinkConvert INSTANCE = Mappers.getMapper(CrmContactBusinessLinkConvert.class);
|
||||
CrmContactBusinessLinkDO convert(CrmContactBusinessLinkSaveReqVO bean);
|
||||
List<CrmContactBusinessLinkDO> convert(List<CrmContactBusinessLinkSaveReqVO> bean);
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package cn.iocoder.yudao.module.crm.dal.dataobject.contactbusinesslink;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 联系人商机关联 DO
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@TableName("crm_contact_business_link")
|
||||
@KeySequence("crm_contact_business_link_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class CrmContactBusinessLinkDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 联系人id
|
||||
*/
|
||||
private Long contactId;
|
||||
/**
|
||||
* 商机id
|
||||
*/
|
||||
private Long businessId;
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package cn.iocoder.yudao.module.crm.dal.mysql.contactbusinesslink;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.contactbusinesslink.CrmContactBusinessLinkDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo.*;
|
||||
|
||||
/**
|
||||
* 联系人商机关联 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface CrmContactBusinessLinkMapper extends BaseMapperX<CrmContactBusinessLinkDO> {
|
||||
|
||||
default PageResult<CrmContactBusinessLinkDO> selectPage(CrmContactBusinessLinkPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<CrmContactBusinessLinkDO>()
|
||||
.eqIfPresent(CrmContactBusinessLinkDO::getContactId, reqVO.getContactId())
|
||||
.eqIfPresent(CrmContactBusinessLinkDO::getBusinessId, reqVO.getBusinessId())
|
||||
.betweenIfPresent(CrmContactBusinessLinkDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(CrmContactBusinessLinkDO::getId));
|
||||
}
|
||||
default PageResult<CrmContactBusinessLinkDO> selectPageByContact(CrmContactBusinessLinkPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<CrmContactBusinessLinkDO>()
|
||||
.eqIfPresent(CrmContactBusinessLinkDO::getContactId, reqVO.getContactId())
|
||||
.orderByDesc(CrmContactBusinessLinkDO::getId));
|
||||
}
|
||||
}
|
@ -88,7 +88,7 @@ public class CrmBusinessServiceImpl implements CrmBusinessService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS, level = CrmPermissionLevelEnum.READ)
|
||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS,bizId = "#id", level = CrmPermissionLevelEnum.READ)
|
||||
public CrmBusinessDO getBusiness(Long id) {
|
||||
return businessMapper.selectById(id);
|
||||
}
|
||||
|
@ -0,0 +1,69 @@
|
||||
package cn.iocoder.yudao.module.crm.service.contactbusinesslink;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessRespVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo.*;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.contactbusinesslink.CrmContactBusinessLinkDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
|
||||
/**
|
||||
* 联系人商机关联 Service 接口
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface CrmContactBusinessLinkService {
|
||||
|
||||
/**
|
||||
* 创建联系人商机关联
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createContactBusinessLink(@Valid CrmContactBusinessLinkSaveReqVO createReqVO);
|
||||
/**
|
||||
* 创建联系人商机关联
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
void createContactBusinessLinkBatch(@Valid List<CrmContactBusinessLinkSaveReqVO> createReqVO);
|
||||
/**
|
||||
* 更新联系人商机关联
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateContactBusinessLink(@Valid CrmContactBusinessLinkSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除联系人商机关联
|
||||
*
|
||||
* @param createReqVO 删除列表
|
||||
*/
|
||||
void deleteContactBusinessLink(@Valid List<CrmContactBusinessLinkSaveReqVO> createReqVO);
|
||||
|
||||
/**
|
||||
* 获得联系人商机关联
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 联系人商机关联
|
||||
*/
|
||||
CrmContactBusinessLinkDO getContactBusinessLink(Long id);
|
||||
/**
|
||||
* 获得联系人商机关联分页
|
||||
*
|
||||
* @param pageReqVO 编号
|
||||
* @return 联系人商机关联
|
||||
*/
|
||||
PageResult<CrmBusinessRespVO> getContactBusinessLinkPageByContact(CrmContactBusinessLinkPageReqVO pageReqVO);
|
||||
/**
|
||||
* 获得联系人商机关联分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 联系人商机关联分页
|
||||
*/
|
||||
PageResult<CrmContactBusinessLinkDO> getContactBusinessLinkPage(CrmContactBusinessLinkPageReqVO pageReqVO);
|
||||
|
||||
}
|
@ -0,0 +1,111 @@
|
||||
package cn.iocoder.yudao.module.crm.service.contactbusinesslink;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessRespVO;
|
||||
import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert;
|
||||
import cn.iocoder.yudao.module.crm.convert.contactbusinessslink.CrmContactBusinessLinkConvert;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
|
||||
import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo.*;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.contactbusinesslink.CrmContactBusinessLinkDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
import cn.iocoder.yudao.module.crm.dal.mysql.contactbusinesslink.CrmContactBusinessLinkMapper;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 联系人商机关联 Service 实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class CrmContactBusinessLinkServiceImpl implements CrmContactBusinessLinkService {
|
||||
|
||||
@Resource
|
||||
private CrmContactBusinessLinkMapper contactBusinessLinkMapper;
|
||||
@Resource
|
||||
private CrmBusinessService crmBusinessService;
|
||||
|
||||
@Override
|
||||
public Long createContactBusinessLink(CrmContactBusinessLinkSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
CrmContactBusinessLinkDO contactBusinessLink = BeanUtils.toBean(createReqVO, CrmContactBusinessLinkDO.class);
|
||||
contactBusinessLinkMapper.insert(contactBusinessLink);
|
||||
// 返回
|
||||
return contactBusinessLink.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createContactBusinessLinkBatch(List<CrmContactBusinessLinkSaveReqVO> createReqVOList) {
|
||||
// 插入
|
||||
List<CrmContactBusinessLinkDO> saveDoList = CrmContactBusinessLinkConvert.INSTANCE.convert(createReqVOList);
|
||||
contactBusinessLinkMapper.insertBatch(saveDoList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateContactBusinessLink(CrmContactBusinessLinkSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateContactBusinessLinkExists(updateReqVO.getId());
|
||||
// 更新
|
||||
CrmContactBusinessLinkDO updateObj = BeanUtils.toBean(updateReqVO, CrmContactBusinessLinkDO.class);
|
||||
contactBusinessLinkMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteContactBusinessLink(List<CrmContactBusinessLinkSaveReqVO> createReqVO) {
|
||||
// 删除
|
||||
createReqVO.forEach(item -> {
|
||||
contactBusinessLinkMapper.delete(new LambdaQueryWrapperX<CrmContactBusinessLinkDO>()
|
||||
.eq(CrmContactBusinessLinkDO::getBusinessId,item.getBusinessId())
|
||||
.eq(CrmContactBusinessLinkDO::getContactId,item.getContactId())
|
||||
.eq(CrmContactBusinessLinkDO::getDeleted,0));
|
||||
});
|
||||
}
|
||||
|
||||
private void validateContactBusinessLinkExists(Long id) {
|
||||
if (contactBusinessLinkMapper.selectById(id) == null) {
|
||||
throw exception(CONTACT_BUSINESS_LINK_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CrmContactBusinessLinkDO getContactBusinessLink(Long id) {
|
||||
return contactBusinessLinkMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<CrmBusinessRespVO> getContactBusinessLinkPageByContact(CrmContactBusinessLinkPageReqVO pageReqVO) {
|
||||
CrmContactBusinessLinkPageReqVO crmContactBusinessLinkPageReqVO = new CrmContactBusinessLinkPageReqVO();
|
||||
crmContactBusinessLinkPageReqVO.setContactId(pageReqVO.getContactId());
|
||||
PageResult<CrmContactBusinessLinkDO> businessLinkDOS = contactBusinessLinkMapper.selectPageByContact(crmContactBusinessLinkPageReqVO);
|
||||
List<CrmBusinessDO> businessDOS = crmBusinessService.getBusinessList(CollectionUtils.convertList(businessLinkDOS.getList(),
|
||||
CrmContactBusinessLinkDO::getBusinessId));
|
||||
PageResult<CrmBusinessRespVO> pageResult = new PageResult<CrmBusinessRespVO>();
|
||||
pageResult.setList(CrmBusinessConvert.INSTANCE.convert(businessDOS));
|
||||
pageResult.setTotal(businessLinkDOS.getTotal());
|
||||
return pageResult;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<CrmContactBusinessLinkDO> getContactBusinessLinkPage(CrmContactBusinessLinkPageReqVO pageReqVO) {
|
||||
return contactBusinessLinkMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user