📈 CRM:code review 联系人商机功能
This commit is contained in:
parent
21a3870c00
commit
a36fe8c40e
|
@ -1,42 +1,33 @@
|
||||||
package cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink;
|
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.pojo.CommonResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessRespVO;
|
||||||
|
import cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo.CrmContactBusinessLinkPageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo.CrmContactBusinessLinkRespVO;
|
||||||
|
import cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo.CrmContactBusinessLinkSaveReqVO;
|
||||||
|
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
|
||||||
|
import cn.iocoder.yudao.module.crm.dal.dataobject.contactbusinesslink.CrmContactBusinessLinkDO;
|
||||||
|
import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService;
|
||||||
|
import cn.iocoder.yudao.module.crm.service.contactbusinesslink.CrmContactBusinessLinkService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
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 static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_NOT_EXISTS;
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo.*;
|
@Tag(name = "管理后台 - CRM 联系人商机关联")
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.contactbusinesslink.CrmContactBusinessLinkDO;
|
|
||||||
import cn.iocoder.yudao.module.crm.service.contactbusinesslink.CrmContactBusinessLinkService;
|
|
||||||
|
|
||||||
@Tag(name = "管理后台 - 联系人商机关联")
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/crm/contact-business-link")
|
@RequestMapping("/crm/contact-business-link")
|
||||||
@Validated
|
@Validated
|
||||||
|
@ -47,17 +38,20 @@ public class CrmContactBusinessLinkController {
|
||||||
@Resource
|
@Resource
|
||||||
private CrmBusinessService crmBusinessService;
|
private CrmBusinessService crmBusinessService;
|
||||||
|
|
||||||
|
// TODO @zyna:createContactBusinessLink 和 createContactBusinessLinkBatch 是不是合并成一个接口?contactId、List<businessId>
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@Operation(summary = "创建联系人商机关联")
|
@Operation(summary = "创建联系人商机关联")
|
||||||
@PreAuthorize("@ss.hasPermission('crm:contact-business-link:create')")
|
@PreAuthorize("@ss.hasPermission('crm:contact-business-link:create')")
|
||||||
public CommonResult<Long> createContactBusinessLink(@Valid @RequestBody CrmContactBusinessLinkSaveReqVO createReqVO) {
|
public CommonResult<Long> createContactBusinessLink(@Valid @RequestBody CrmContactBusinessLinkSaveReqVO createReqVO) {
|
||||||
return success(contactBusinessLinkService.createContactBusinessLink(createReqVO));
|
return success(contactBusinessLinkService.createContactBusinessLink(createReqVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/create-batch")
|
@PostMapping("/create-batch")
|
||||||
@Operation(summary = "创建联系人商机关联")
|
@Operation(summary = "创建联系人商机关联")
|
||||||
@PreAuthorize("@ss.hasPermission('crm:contact-business-link:create')")
|
@PreAuthorize("@ss.hasPermission('crm:contact-business-link:create')")
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public CommonResult<Boolean> createContactBusinessLinkBatch(@Valid @RequestBody List<CrmContactBusinessLinkSaveReqVO> createReqVO) {
|
public CommonResult<Boolean> createContactBusinessLinkBatch(
|
||||||
|
@Valid @RequestBody List<CrmContactBusinessLinkSaveReqVO> createReqVO) {
|
||||||
createReqVO.stream().forEach(item -> {
|
createReqVO.stream().forEach(item -> {
|
||||||
CrmBusinessDO crmBusinessDO = crmBusinessService.getBusiness(item.getBusinessId());
|
CrmBusinessDO crmBusinessDO = crmBusinessService.getBusiness(item.getBusinessId());
|
||||||
if(crmBusinessDO == null){
|
if(crmBusinessDO == null){
|
||||||
|
@ -67,6 +61,8 @@ public class CrmContactBusinessLinkController {
|
||||||
contactBusinessLinkService.createContactBusinessLinkBatch(createReqVO);
|
contactBusinessLinkService.createContactBusinessLinkBatch(createReqVO);
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO @zyna:这个接口是不是可以删除掉了哈?应该不存在更新。
|
||||||
@PutMapping("/update")
|
@PutMapping("/update")
|
||||||
@Operation(summary = "更新联系人商机关联")
|
@Operation(summary = "更新联系人商机关联")
|
||||||
@PreAuthorize("@ss.hasPermission('crm:contact-business-link:update')")
|
@PreAuthorize("@ss.hasPermission('crm:contact-business-link:update')")
|
||||||
|
@ -74,6 +70,8 @@ public class CrmContactBusinessLinkController {
|
||||||
contactBusinessLinkService.updateContactBusinessLink(updateReqVO);
|
contactBusinessLinkService.updateContactBusinessLink(updateReqVO);
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO @zyna:删除,是不是传递 ids?
|
||||||
@DeleteMapping("/delete-batch")
|
@DeleteMapping("/delete-batch")
|
||||||
@Operation(summary = "批量删除联系人商机关联")
|
@Operation(summary = "批量删除联系人商机关联")
|
||||||
@PreAuthorize("@ss.hasPermission('crm:contact-business-link:delete')")
|
@PreAuthorize("@ss.hasPermission('crm:contact-business-link:delete')")
|
||||||
|
@ -81,6 +79,8 @@ public class CrmContactBusinessLinkController {
|
||||||
contactBusinessLinkService.deleteContactBusinessLink(deleteList);
|
contactBusinessLinkService.deleteContactBusinessLink(deleteList);
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO @zyna:这个接口是不是可以删除掉了哈?应该不存在单个读取;
|
||||||
@GetMapping("/get")
|
@GetMapping("/get")
|
||||||
@Operation(summary = "获得联系人商机关联")
|
@Operation(summary = "获得联系人商机关联")
|
||||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
|
@ -89,33 +89,27 @@ public class CrmContactBusinessLinkController {
|
||||||
CrmContactBusinessLinkDO contactBusinessLink = contactBusinessLinkService.getContactBusinessLink(id);
|
CrmContactBusinessLinkDO contactBusinessLink = contactBusinessLinkService.getContactBusinessLink(id);
|
||||||
return success(BeanUtils.toBean(contactBusinessLink, CrmContactBusinessLinkRespVO.class));
|
return success(BeanUtils.toBean(contactBusinessLink, CrmContactBusinessLinkRespVO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO @zyna:这个可以转化下,使用客户编号去查询,就是使用 CrmBusinessController 的 getBusinessPageByCustomer 接口;目的是:复用
|
||||||
@GetMapping("/page-by-contact")
|
@GetMapping("/page-by-contact")
|
||||||
@Operation(summary = "获得联系人商机关联")
|
@Operation(summary = "获得联系人商机关联")
|
||||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
||||||
@PreAuthorize("@ss.hasPermission('crm:contact-business-link:query')")
|
@PreAuthorize("@ss.hasPermission('crm:contact-business-link:query')")
|
||||||
public CommonResult<PageResult<CrmBusinessRespVO>> getContactBusinessLinkByContact(@Valid CrmContactBusinessLinkPageReqVO pageReqVO) {
|
public CommonResult<PageResult<CrmBusinessRespVO>> getContactBusinessLinkByContact(
|
||||||
|
@Valid CrmContactBusinessLinkPageReqVO pageReqVO) {
|
||||||
PageResult<CrmBusinessRespVO> contactBusinessLink = contactBusinessLinkService.getContactBusinessLinkPageByContact(pageReqVO);
|
PageResult<CrmBusinessRespVO> contactBusinessLink = contactBusinessLinkService.getContactBusinessLinkPageByContact(pageReqVO);
|
||||||
return success(contactBusinessLink);
|
return success(contactBusinessLink);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO @zyna:这个优化下,搞到 CrmBusinessController 里去,加一个 CrmBusinessController 的 getBusinessPageByContact 接口;目的是:
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
@Operation(summary = "获得联系人商机关联分页")
|
@Operation(summary = "获得联系人商机关联分页")
|
||||||
@PreAuthorize("@ss.hasPermission('crm:contact-business-link:query')")
|
@PreAuthorize("@ss.hasPermission('crm:contact-business-link:query')")
|
||||||
public CommonResult<PageResult<CrmContactBusinessLinkRespVO>> getContactBusinessLinkPage(@Valid CrmContactBusinessLinkPageReqVO pageReqVO) {
|
public CommonResult<PageResult<CrmContactBusinessLinkRespVO>> getContactBusinessLinkPage(
|
||||||
|
@Valid CrmContactBusinessLinkPageReqVO pageReqVO) {
|
||||||
PageResult<CrmContactBusinessLinkDO> pageResult = contactBusinessLinkService.getContactBusinessLinkPage(pageReqVO);
|
PageResult<CrmContactBusinessLinkDO> pageResult = contactBusinessLinkService.getContactBusinessLinkPage(pageReqVO);
|
||||||
return success(BeanUtils.toBean(pageResult, CrmContactBusinessLinkRespVO.class));
|
return success(BeanUtils.toBean(pageResult, CrmContactBusinessLinkRespVO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/export-excel")
|
// TODO @zyna:最终梳理完后,应该就 2 个接口,要不直接合并到 CrmContactController 中,不作为独立模块,就关联、接触关联。其实和 user 设置它有哪些岗位、部门是类似的。
|
||||||
@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));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,24 +1,26 @@
|
||||||
package cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo;
|
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 cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.ToString;
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 联系人商机关联分页 Request VO")
|
@Schema(description = "管理后台 - CRM 联系人商机关联分页 Request VO")
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@ToString(callSuper = true)
|
@ToString(callSuper = true)
|
||||||
public class CrmContactBusinessLinkPageReqVO extends PageParam {
|
public class CrmContactBusinessLinkPageReqVO extends PageParam {
|
||||||
|
|
||||||
@Schema(description = "联系人id", example = "20878")
|
@Schema(description = "联系人编号", example = "20878")
|
||||||
private Long contactId;
|
private Long contactId;
|
||||||
|
|
||||||
@Schema(description = "商机id", example = "7638")
|
@Schema(description = "商机编号", example = "7638")
|
||||||
private Long businessId;
|
private Long businessId;
|
||||||
|
|
||||||
@Schema(description = "创建时间")
|
@Schema(description = "创建时间")
|
||||||
|
|
|
@ -1,32 +1,26 @@
|
||||||
package cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo;
|
package cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo;
|
||||||
|
|
||||||
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.*;
|
import lombok.Data;
|
||||||
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")
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - CRM 联系人商机关联 Response VO")
|
||||||
@Data
|
@Data
|
||||||
@ExcelIgnoreUnannotated
|
|
||||||
public class CrmContactBusinessLinkRespVO {
|
public class CrmContactBusinessLinkRespVO {
|
||||||
|
|
||||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "17220")
|
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "17220")
|
||||||
@ExcelProperty("主键")
|
@ExcelProperty("主键")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Schema(description = "联系人id", example = "20878")
|
@Schema(description = "联系人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20878")
|
||||||
@ExcelProperty("联系人id")
|
|
||||||
private Long contactId;
|
private Long contactId;
|
||||||
|
|
||||||
@Schema(description = "商机id", example = "7638")
|
@Schema(description = "商机编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7638")
|
||||||
@ExcelProperty("商机id")
|
|
||||||
private Long businessId;
|
private Long businessId;
|
||||||
|
|
||||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@ExcelProperty("创建时间")
|
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,23 +1,22 @@
|
||||||
package cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo;
|
package cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.*;
|
import lombok.Data;
|
||||||
import java.util.*;
|
|
||||||
import javax.validation.constraints.*;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 联系人商机关联新增/修改 Request VO")
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - CRM 联系人商机关联新增/修改 Request VO")
|
||||||
@Data
|
@Data
|
||||||
public class CrmContactBusinessLinkSaveReqVO {
|
public class CrmContactBusinessLinkSaveReqVO {
|
||||||
|
|
||||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "17220")
|
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "17220")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Schema(description = "联系人id", example = "20878")
|
@Schema(description = "联系人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20878")
|
||||||
@NotNull(message="联系人不能为空")
|
@NotNull(message="联系人不能为空")
|
||||||
private Long contactId;
|
private Long contactId;
|
||||||
|
|
||||||
@Schema(description = "商机id", example = "7638")
|
@Schema(description = "商机编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7638")
|
||||||
@NotNull(message="商机不能为空")
|
@NotNull(message="商机不能为空")
|
||||||
private Long businessId;
|
private Long businessId;
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
// TODO @zyna:使用 BeanUtils 慢慢替代现有的 mapstruct 哈
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface CrmContactBusinessLinkConvert {
|
public interface CrmContactBusinessLinkConvert {
|
||||||
CrmContactBusinessLinkConvert INSTANCE = Mappers.getMapper(CrmContactBusinessLinkConvert.class);
|
CrmContactBusinessLinkConvert INSTANCE = Mappers.getMapper(CrmContactBusinessLinkConvert.class);
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
package cn.iocoder.yudao.module.crm.dal.dataobject.contactbusinesslink;
|
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;
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||||
|
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
|
||||||
|
import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO;
|
||||||
|
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
|
// TODO @zyna:可以放到 contact 包下
|
||||||
/**
|
/**
|
||||||
* 联系人商机关联 DO
|
* CRM 联系人商机关联 DO
|
||||||
*
|
*
|
||||||
* @author 芋道源码
|
* @author 芋道源码
|
||||||
*/
|
*/
|
||||||
|
@ -28,11 +30,15 @@ public class CrmContactBusinessLinkDO extends BaseDO {
|
||||||
@TableId
|
@TableId
|
||||||
private Long id;
|
private Long id;
|
||||||
/**
|
/**
|
||||||
* 联系人id
|
* 联系人编号
|
||||||
|
*
|
||||||
|
* 关联 {@link CrmContactDO#getId()} 字段
|
||||||
*/
|
*/
|
||||||
private Long contactId;
|
private Long contactId;
|
||||||
/**
|
/**
|
||||||
* 商机id
|
* 商机编号
|
||||||
|
*
|
||||||
|
* 关联 {@link CrmBusinessDO#getId()} 字段
|
||||||
*/
|
*/
|
||||||
private Long businessId;
|
private Long businessId;
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,14 @@
|
||||||
package cn.iocoder.yudao.module.crm.dal.mysql.contactbusinesslink;
|
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.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.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
import cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo.CrmContactBusinessLinkPageReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.contactbusinesslink.CrmContactBusinessLinkDO;
|
import cn.iocoder.yudao.module.crm.dal.dataobject.contactbusinesslink.CrmContactBusinessLinkDO;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 联系人商机关联 Mapper
|
* CRM 联系人商机关联 Mapper
|
||||||
*
|
*
|
||||||
* @author 芋道源码
|
* @author 芋道源码
|
||||||
*/
|
*/
|
||||||
|
@ -23,7 +21,7 @@ public interface CrmContactBusinessLinkMapper extends BaseMapperX<CrmContactBusi
|
||||||
.eqIfPresent(CrmContactBusinessLinkDO::getBusinessId, reqVO.getBusinessId())
|
.eqIfPresent(CrmContactBusinessLinkDO::getBusinessId, reqVO.getBusinessId())
|
||||||
.betweenIfPresent(CrmContactBusinessLinkDO::getCreateTime, reqVO.getCreateTime())
|
.betweenIfPresent(CrmContactBusinessLinkDO::getCreateTime, reqVO.getCreateTime())
|
||||||
.orderByDesc(CrmContactBusinessLinkDO::getId));
|
.orderByDesc(CrmContactBusinessLinkDO::getId));
|
||||||
}
|
} // TODO @zyna:方法和方法之间要有空行
|
||||||
default PageResult<CrmContactBusinessLinkDO> selectPageByContact(CrmContactBusinessLinkPageReqVO reqVO) {
|
default PageResult<CrmContactBusinessLinkDO> selectPageByContact(CrmContactBusinessLinkPageReqVO reqVO) {
|
||||||
return selectPage(reqVO, new LambdaQueryWrapperX<CrmContactBusinessLinkDO>()
|
return selectPage(reqVO, new LambdaQueryWrapperX<CrmContactBusinessLinkDO>()
|
||||||
.eqIfPresent(CrmContactBusinessLinkDO::getContactId, reqVO.getContactId())
|
.eqIfPresent(CrmContactBusinessLinkDO::getContactId, reqVO.getContactId())
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
package cn.iocoder.yudao.module.crm.service.contactbusinesslink;
|
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.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessRespVO;
|
||||||
|
import cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo.CrmContactBusinessLinkPageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo.CrmContactBusinessLinkSaveReqVO;
|
||||||
|
import cn.iocoder.yudao.module.crm.dal.dataobject.contactbusinesslink.CrmContactBusinessLinkDO;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 联系人商机关联 Service 接口
|
* CRM 联系人商机关联 Service 接口
|
||||||
*
|
*
|
||||||
* @author 芋道源码
|
* @author 芋道源码
|
||||||
*/
|
*/
|
||||||
|
@ -23,13 +23,14 @@ public interface CrmContactBusinessLinkService {
|
||||||
* @return 编号
|
* @return 编号
|
||||||
*/
|
*/
|
||||||
Long createContactBusinessLink(@Valid CrmContactBusinessLinkSaveReqVO createReqVO);
|
Long createContactBusinessLink(@Valid CrmContactBusinessLinkSaveReqVO createReqVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建联系人商机关联
|
* 创建联系人商机关联
|
||||||
*
|
*
|
||||||
* @param createReqVO 创建信息
|
* @param createReqVO 创建信息
|
||||||
* @return 编号
|
|
||||||
*/
|
*/
|
||||||
void createContactBusinessLinkBatch(@Valid List<CrmContactBusinessLinkSaveReqVO> createReqVO);
|
void createContactBusinessLinkBatch(@Valid List<CrmContactBusinessLinkSaveReqVO> createReqVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新联系人商机关联
|
* 更新联系人商机关联
|
||||||
*
|
*
|
||||||
|
@ -51,6 +52,7 @@ public interface CrmContactBusinessLinkService {
|
||||||
* @return 联系人商机关联
|
* @return 联系人商机关联
|
||||||
*/
|
*/
|
||||||
CrmContactBusinessLinkDO getContactBusinessLink(Long id);
|
CrmContactBusinessLinkDO getContactBusinessLink(Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得联系人商机关联分页
|
* 获得联系人商机关联分页
|
||||||
*
|
*
|
||||||
|
@ -58,6 +60,7 @@ public interface CrmContactBusinessLinkService {
|
||||||
* @return 联系人商机关联
|
* @return 联系人商机关联
|
||||||
*/
|
*/
|
||||||
PageResult<CrmBusinessRespVO> getContactBusinessLinkPageByContact(CrmContactBusinessLinkPageReqVO pageReqVO);
|
PageResult<CrmBusinessRespVO> getContactBusinessLinkPageByContact(CrmContactBusinessLinkPageReqVO pageReqVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得联系人商机关联分页
|
* 获得联系人商机关联分页
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,33 +1,28 @@
|
||||||
package cn.iocoder.yudao.module.crm.service.contactbusinesslink;
|
package cn.iocoder.yudao.module.crm.service.contactbusinesslink;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
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.controller.admin.business.vo.business.CrmBusinessRespVO;
|
||||||
|
import cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo.CrmContactBusinessLinkPageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo.CrmContactBusinessLinkSaveReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert;
|
import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert;
|
||||||
import cn.iocoder.yudao.module.crm.convert.contactbusinessslink.CrmContactBusinessLinkConvert;
|
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.dal.dataobject.business.CrmBusinessDO;
|
||||||
|
import cn.iocoder.yudao.module.crm.dal.dataobject.contactbusinesslink.CrmContactBusinessLinkDO;
|
||||||
|
import cn.iocoder.yudao.module.crm.dal.mysql.contactbusinesslink.CrmContactBusinessLinkMapper;
|
||||||
import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService;
|
import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
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.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*;
|
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CONTACT_BUSINESS_LINK_NOT_EXISTS;
|
||||||
|
|
||||||
|
// TODO @puhui999:数据权限的校验;每个操作;
|
||||||
/**
|
/**
|
||||||
* 联系人商机关联 Service 实现类
|
* 联系人商机关联 Service 实现类
|
||||||
*
|
*
|
||||||
|
@ -44,16 +39,16 @@ public class CrmContactBusinessLinkServiceImpl implements CrmContactBusinessLink
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long createContactBusinessLink(CrmContactBusinessLinkSaveReqVO createReqVO) {
|
public Long createContactBusinessLink(CrmContactBusinessLinkSaveReqVO createReqVO) {
|
||||||
// 插入
|
|
||||||
CrmContactBusinessLinkDO contactBusinessLink = BeanUtils.toBean(createReqVO, CrmContactBusinessLinkDO.class);
|
CrmContactBusinessLinkDO contactBusinessLink = BeanUtils.toBean(createReqVO, CrmContactBusinessLinkDO.class);
|
||||||
contactBusinessLinkMapper.insert(contactBusinessLink);
|
contactBusinessLinkMapper.insert(contactBusinessLink);
|
||||||
// 返回
|
|
||||||
return contactBusinessLink.getId();
|
return contactBusinessLink.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createContactBusinessLinkBatch(List<CrmContactBusinessLinkSaveReqVO> createReqVOList) {
|
public void createContactBusinessLinkBatch(List<CrmContactBusinessLinkSaveReqVO> createReqVOList) {
|
||||||
// 插入
|
// 插入
|
||||||
|
// TODO @zyna:如果已经关联过,不用重复插入;
|
||||||
|
// TODO @zyna:contact 和 business 存在校验,挪到这里,Controller 不用 @Transactional 注解,添加到这里哈。尽量业务都在 Service;
|
||||||
List<CrmContactBusinessLinkDO> saveDoList = CrmContactBusinessLinkConvert.INSTANCE.convert(createReqVOList);
|
List<CrmContactBusinessLinkDO> saveDoList = CrmContactBusinessLinkConvert.INSTANCE.convert(createReqVOList);
|
||||||
contactBusinessLinkMapper.insertBatch(saveDoList);
|
contactBusinessLinkMapper.insertBatch(saveDoList);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue