Commit 21a3870c006b4bdce6f2457ba1b93ea1619e287b
Committed by
Gitee
!775 crm联系人商机功能
Merge pull request !775 from zyna/feature/crm
Showing
13 changed files
with
489 additions
and
1 deletions
sql/mysql/optinal/crm.sql
| 1 | +-- `ruoyi-vue-pro`.crm_contact_business_link definition | ||
| 2 | + | ||
| 3 | +CREATE TABLE `crm_contact_business_link` ( | ||
| 4 | + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键', | ||
| 5 | + `contact_id` int(11) DEFAULT NULL COMMENT '联系人id', | ||
| 6 | + `business_id` int(11) DEFAULT NULL COMMENT '商机id', | ||
| 7 | + `creator` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '创建者', | ||
| 8 | + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', | ||
| 9 | + `updater` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '更新者', | ||
| 10 | + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', | ||
| 11 | + `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', | ||
| 12 | + `tenant_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '租户编号', | ||
| 13 | + PRIMARY KEY (`id`), | ||
| 14 | + UNIQUE KEY `crm_contact_business_link_un` (`contact_id`,`business_id`,`deleted`,`tenant_id`) | ||
| 15 | +) ENGINE=InnoDB AUTO_INCREMENT=29 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='联系人商机关联表'; | ||
| 0 | \ No newline at end of file | 16 | \ No newline at end of file |
yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java
| @@ -23,6 +23,7 @@ public interface ErrorCodeConstants { | @@ -23,6 +23,7 @@ public interface ErrorCodeConstants { | ||
| 23 | 23 | ||
| 24 | // ========== 联系人管理 1-020-003-000 ========== | 24 | // ========== 联系人管理 1-020-003-000 ========== |
| 25 | ErrorCode CONTACT_NOT_EXISTS = new ErrorCode(1_020_003_000, "联系人不存在"); | 25 | ErrorCode CONTACT_NOT_EXISTS = new ErrorCode(1_020_003_000, "联系人不存在"); |
| 26 | + ErrorCode CONTACT_BUSINESS_LINK_NOT_EXISTS = new ErrorCode( 1_020_003_001, "联系人商机关联不存在"); | ||
| 26 | 27 | ||
| 27 | // ========== 回款 1-020-004-000 ========== | 28 | // ========== 回款 1-020-004-000 ========== |
| 28 | ErrorCode RECEIVABLE_NOT_EXISTS = new ErrorCode(1_020_004_000, "回款不存在"); | 29 | ErrorCode RECEIVABLE_NOT_EXISTS = new ErrorCode(1_020_004_000, "回款不存在"); |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contactbusinesslink/CrmContactBusinessLinkController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessRespVO; | ||
| 4 | +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; | ||
| 5 | +import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; | ||
| 6 | +import org.springframework.transaction.annotation.Transactional; | ||
| 7 | +import org.springframework.web.bind.annotation.*; | ||
| 8 | +import javax.annotation.Resource; | ||
| 9 | +import org.springframework.validation.annotation.Validated; | ||
| 10 | +import org.springframework.security.access.prepost.PreAuthorize; | ||
| 11 | +import io.swagger.v3.oas.annotations.tags.Tag; | ||
| 12 | +import io.swagger.v3.oas.annotations.Parameter; | ||
| 13 | +import io.swagger.v3.oas.annotations.Operation; | ||
| 14 | + | ||
| 15 | +import javax.validation.constraints.*; | ||
| 16 | +import javax.validation.*; | ||
| 17 | +import javax.servlet.http.*; | ||
| 18 | +import java.util.*; | ||
| 19 | +import java.io.IOException; | ||
| 20 | + | ||
| 21 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 22 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 23 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 24 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 25 | + | ||
| 26 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||
| 27 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
| 28 | + | ||
| 29 | +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | ||
| 30 | + | ||
| 31 | +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | ||
| 32 | +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; | ||
| 33 | +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_NOT_EXISTS; | ||
| 34 | + | ||
| 35 | +import cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo.*; | ||
| 36 | +import cn.iocoder.yudao.module.crm.dal.dataobject.contactbusinesslink.CrmContactBusinessLinkDO; | ||
| 37 | +import cn.iocoder.yudao.module.crm.service.contactbusinesslink.CrmContactBusinessLinkService; | ||
| 38 | + | ||
| 39 | +@Tag(name = "管理后台 - 联系人商机关联") | ||
| 40 | +@RestController | ||
| 41 | +@RequestMapping("/crm/contact-business-link") | ||
| 42 | +@Validated | ||
| 43 | +public class CrmContactBusinessLinkController { | ||
| 44 | + | ||
| 45 | + @Resource | ||
| 46 | + private CrmContactBusinessLinkService contactBusinessLinkService; | ||
| 47 | + @Resource | ||
| 48 | + private CrmBusinessService crmBusinessService; | ||
| 49 | + | ||
| 50 | + @PostMapping("/create") | ||
| 51 | + @Operation(summary = "创建联系人商机关联") | ||
| 52 | + @PreAuthorize("@ss.hasPermission('crm:contact-business-link:create')") | ||
| 53 | + public CommonResult<Long> createContactBusinessLink(@Valid @RequestBody CrmContactBusinessLinkSaveReqVO createReqVO) { | ||
| 54 | + return success(contactBusinessLinkService.createContactBusinessLink(createReqVO)); | ||
| 55 | + } | ||
| 56 | + @PostMapping("/create-batch") | ||
| 57 | + @Operation(summary = "创建联系人商机关联") | ||
| 58 | + @PreAuthorize("@ss.hasPermission('crm:contact-business-link:create')") | ||
| 59 | + @Transactional(rollbackFor = Exception.class) | ||
| 60 | + public CommonResult<Boolean> createContactBusinessLinkBatch(@Valid @RequestBody List<CrmContactBusinessLinkSaveReqVO> createReqVO) { | ||
| 61 | + createReqVO.stream().forEach(item -> { | ||
| 62 | + CrmBusinessDO crmBusinessDO = crmBusinessService.getBusiness(item.getBusinessId()); | ||
| 63 | + if(crmBusinessDO == null){ | ||
| 64 | + throw exception(BUSINESS_NOT_EXISTS); | ||
| 65 | + } | ||
| 66 | + }); | ||
| 67 | + contactBusinessLinkService.createContactBusinessLinkBatch(createReqVO); | ||
| 68 | + return success(true); | ||
| 69 | + } | ||
| 70 | + @PutMapping("/update") | ||
| 71 | + @Operation(summary = "更新联系人商机关联") | ||
| 72 | + @PreAuthorize("@ss.hasPermission('crm:contact-business-link:update')") | ||
| 73 | + public CommonResult<Boolean> updateContactBusinessLink(@Valid @RequestBody CrmContactBusinessLinkSaveReqVO updateReqVO) { | ||
| 74 | + contactBusinessLinkService.updateContactBusinessLink(updateReqVO); | ||
| 75 | + return success(true); | ||
| 76 | + } | ||
| 77 | + @DeleteMapping("/delete-batch") | ||
| 78 | + @Operation(summary = "批量删除联系人商机关联") | ||
| 79 | + @PreAuthorize("@ss.hasPermission('crm:contact-business-link:delete')") | ||
| 80 | + public CommonResult<Boolean> deleteContactBusinessLinkBatch(@Valid @RequestBody List<CrmContactBusinessLinkSaveReqVO> deleteList) { | ||
| 81 | + contactBusinessLinkService.deleteContactBusinessLink(deleteList); | ||
| 82 | + return success(true); | ||
| 83 | + } | ||
| 84 | + @GetMapping("/get") | ||
| 85 | + @Operation(summary = "获得联系人商机关联") | ||
| 86 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | ||
| 87 | + @PreAuthorize("@ss.hasPermission('crm:contact-business-link:query')") | ||
| 88 | + public CommonResult<CrmContactBusinessLinkRespVO> getContactBusinessLink(@RequestParam("id") Long id) { | ||
| 89 | + CrmContactBusinessLinkDO contactBusinessLink = contactBusinessLinkService.getContactBusinessLink(id); | ||
| 90 | + return success(BeanUtils.toBean(contactBusinessLink, CrmContactBusinessLinkRespVO.class)); | ||
| 91 | + } | ||
| 92 | + @GetMapping("/page-by-contact") | ||
| 93 | + @Operation(summary = "获得联系人商机关联") | ||
| 94 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | ||
| 95 | + @PreAuthorize("@ss.hasPermission('crm:contact-business-link:query')") | ||
| 96 | + public CommonResult<PageResult<CrmBusinessRespVO>> getContactBusinessLinkByContact(@Valid CrmContactBusinessLinkPageReqVO pageReqVO) { | ||
| 97 | + PageResult<CrmBusinessRespVO> contactBusinessLink = contactBusinessLinkService.getContactBusinessLinkPageByContact(pageReqVO); | ||
| 98 | + return success(contactBusinessLink); | ||
| 99 | + } | ||
| 100 | + @GetMapping("/page") | ||
| 101 | + @Operation(summary = "获得联系人商机关联分页") | ||
| 102 | + @PreAuthorize("@ss.hasPermission('crm:contact-business-link:query')") | ||
| 103 | + public CommonResult<PageResult<CrmContactBusinessLinkRespVO>> getContactBusinessLinkPage(@Valid CrmContactBusinessLinkPageReqVO pageReqVO) { | ||
| 104 | + PageResult<CrmContactBusinessLinkDO> pageResult = contactBusinessLinkService.getContactBusinessLinkPage(pageReqVO); | ||
| 105 | + return success(BeanUtils.toBean(pageResult, CrmContactBusinessLinkRespVO.class)); | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | + @GetMapping("/export-excel") | ||
| 109 | + @Operation(summary = "导出联系人商机关联 Excel") | ||
| 110 | + @PreAuthorize("@ss.hasPermission('crm:contact-business-link:export')") | ||
| 111 | + @OperateLog(type = EXPORT) | ||
| 112 | + public void exportContactBusinessLinkExcel(@Valid CrmContactBusinessLinkPageReqVO pageReqVO, | ||
| 113 | + HttpServletResponse response) throws IOException { | ||
| 114 | + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); | ||
| 115 | + List<CrmContactBusinessLinkDO> list = contactBusinessLinkService.getContactBusinessLinkPage(pageReqVO).getList(); | ||
| 116 | + // 导出 Excel | ||
| 117 | + ExcelUtils.write(response, "联系人商机关联.xls", "数据", CrmContactBusinessLinkRespVO.class, | ||
| 118 | + BeanUtils.toBean(list, CrmContactBusinessLinkRespVO.class)); | ||
| 119 | + } | ||
| 120 | + | ||
| 121 | +} | ||
| 0 | \ No newline at end of file | 122 | \ No newline at end of file |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contactbusinesslink/vo/CrmContactBusinessLinkPageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo; | ||
| 2 | + | ||
| 3 | +import lombok.*; | ||
| 4 | +import java.util.*; | ||
| 5 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 6 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 7 | +import org.springframework.format.annotation.DateTimeFormat; | ||
| 8 | +import java.time.LocalDateTime; | ||
| 9 | + | ||
| 10 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 11 | + | ||
| 12 | +@Schema(description = "管理后台 - 联系人商机关联分页 Request VO") | ||
| 13 | +@Data | ||
| 14 | +@EqualsAndHashCode(callSuper = true) | ||
| 15 | +@ToString(callSuper = true) | ||
| 16 | +public class CrmContactBusinessLinkPageReqVO extends PageParam { | ||
| 17 | + | ||
| 18 | + @Schema(description = "联系人id", example = "20878") | ||
| 19 | + private Long contactId; | ||
| 20 | + | ||
| 21 | + @Schema(description = "商机id", example = "7638") | ||
| 22 | + private Long businessId; | ||
| 23 | + | ||
| 24 | + @Schema(description = "创建时间") | ||
| 25 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 26 | + private LocalDateTime[] createTime; | ||
| 27 | + | ||
| 28 | +} | ||
| 0 | \ No newline at end of file | 29 | \ No newline at end of file |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contactbusinesslink/vo/CrmContactBusinessLinkRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import lombok.*; | ||
| 5 | +import java.util.*; | ||
| 6 | +import java.util.*; | ||
| 7 | +import org.springframework.format.annotation.DateTimeFormat; | ||
| 8 | +import java.time.LocalDateTime; | ||
| 9 | +import com.alibaba.excel.annotation.*; | ||
| 10 | + | ||
| 11 | +@Schema(description = "管理后台 - 联系人商机关联 Response VO") | ||
| 12 | +@Data | ||
| 13 | +@ExcelIgnoreUnannotated | ||
| 14 | +public class CrmContactBusinessLinkRespVO { | ||
| 15 | + | ||
| 16 | + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "17220") | ||
| 17 | + @ExcelProperty("主键") | ||
| 18 | + private Long id; | ||
| 19 | + | ||
| 20 | + @Schema(description = "联系人id", example = "20878") | ||
| 21 | + @ExcelProperty("联系人id") | ||
| 22 | + private Long contactId; | ||
| 23 | + | ||
| 24 | + @Schema(description = "商机id", example = "7638") | ||
| 25 | + @ExcelProperty("商机id") | ||
| 26 | + private Long businessId; | ||
| 27 | + | ||
| 28 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 29 | + @ExcelProperty("创建时间") | ||
| 30 | + private LocalDateTime createTime; | ||
| 31 | + | ||
| 32 | +} | ||
| 0 | \ No newline at end of file | 33 | \ No newline at end of file |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contactbusinesslink/vo/CrmContactBusinessLinkSaveReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import lombok.*; | ||
| 5 | +import java.util.*; | ||
| 6 | +import javax.validation.constraints.*; | ||
| 7 | +import java.util.*; | ||
| 8 | + | ||
| 9 | +@Schema(description = "管理后台 - 联系人商机关联新增/修改 Request VO") | ||
| 10 | +@Data | ||
| 11 | +public class CrmContactBusinessLinkSaveReqVO { | ||
| 12 | + | ||
| 13 | + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "17220") | ||
| 14 | + private Long id; | ||
| 15 | + | ||
| 16 | + @Schema(description = "联系人id", example = "20878") | ||
| 17 | + @NotNull(message="联系人不能为空") | ||
| 18 | + private Long contactId; | ||
| 19 | + | ||
| 20 | + @Schema(description = "商机id", example = "7638") | ||
| 21 | + @NotNull(message="商机不能为空") | ||
| 22 | + private Long businessId; | ||
| 23 | + | ||
| 24 | +} | ||
| 0 | \ No newline at end of file | 25 | \ No newline at end of file |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/business/CrmBusinessConvert.java
| @@ -32,6 +32,7 @@ public interface CrmBusinessConvert { | @@ -32,6 +32,7 @@ public interface CrmBusinessConvert { | ||
| 32 | CrmBusinessDO convert(CrmBusinessUpdateReqVO bean); | 32 | CrmBusinessDO convert(CrmBusinessUpdateReqVO bean); |
| 33 | 33 | ||
| 34 | CrmBusinessRespVO convert(CrmBusinessDO bean); | 34 | CrmBusinessRespVO convert(CrmBusinessDO bean); |
| 35 | + List<CrmBusinessRespVO> convert(List<CrmBusinessDO> bean); | ||
| 35 | 36 | ||
| 36 | PageResult<CrmBusinessRespVO> convertPage(PageResult<CrmBusinessDO> page); | 37 | PageResult<CrmBusinessRespVO> convertPage(PageResult<CrmBusinessDO> page); |
| 37 | 38 |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/contactbusinessslink/CrmContactBusinessLinkConvert.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.convert.contactbusinessslink; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo.CrmContactBusinessLinkSaveReqVO; | ||
| 4 | +import cn.iocoder.yudao.module.crm.dal.dataobject.contactbusinesslink.CrmContactBusinessLinkDO; | ||
| 5 | +import org.mapstruct.Mapper; | ||
| 6 | +import org.mapstruct.factory.Mappers; | ||
| 7 | + | ||
| 8 | +import java.util.List; | ||
| 9 | + | ||
| 10 | +@Mapper | ||
| 11 | +public interface CrmContactBusinessLinkConvert { | ||
| 12 | + CrmContactBusinessLinkConvert INSTANCE = Mappers.getMapper(CrmContactBusinessLinkConvert.class); | ||
| 13 | + CrmContactBusinessLinkDO convert(CrmContactBusinessLinkSaveReqVO bean); | ||
| 14 | + List<CrmContactBusinessLinkDO> convert(List<CrmContactBusinessLinkSaveReqVO> bean); | ||
| 15 | +} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contactbusinesslink/CrmContactBusinessLinkDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.dal.dataobject.contactbusinesslink; | ||
| 2 | + | ||
| 3 | +import lombok.*; | ||
| 4 | +import java.util.*; | ||
| 5 | +import java.time.LocalDateTime; | ||
| 6 | +import java.time.LocalDateTime; | ||
| 7 | +import com.baomidou.mybatisplus.annotation.*; | ||
| 8 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * 联系人商机关联 DO | ||
| 12 | + * | ||
| 13 | + * @author 芋道源码 | ||
| 14 | + */ | ||
| 15 | +@TableName("crm_contact_business_link") | ||
| 16 | +@KeySequence("crm_contact_business_link_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | ||
| 17 | +@Data | ||
| 18 | +@EqualsAndHashCode(callSuper = true) | ||
| 19 | +@ToString(callSuper = true) | ||
| 20 | +@Builder | ||
| 21 | +@NoArgsConstructor | ||
| 22 | +@AllArgsConstructor | ||
| 23 | +public class CrmContactBusinessLinkDO extends BaseDO { | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * 主键 | ||
| 27 | + */ | ||
| 28 | + @TableId | ||
| 29 | + private Long id; | ||
| 30 | + /** | ||
| 31 | + * 联系人id | ||
| 32 | + */ | ||
| 33 | + private Long contactId; | ||
| 34 | + /** | ||
| 35 | + * 商机id | ||
| 36 | + */ | ||
| 37 | + private Long businessId; | ||
| 38 | + | ||
| 39 | +} | ||
| 0 | \ No newline at end of file | 40 | \ No newline at end of file |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contactbusinesslink/CrmContactBusinessLinkMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.dal.mysql.contactbusinesslink; | ||
| 2 | + | ||
| 3 | +import java.util.*; | ||
| 4 | + | ||
| 5 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 6 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||
| 7 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||
| 8 | +import cn.iocoder.yudao.module.crm.dal.dataobject.contactbusinesslink.CrmContactBusinessLinkDO; | ||
| 9 | +import org.apache.ibatis.annotations.Mapper; | ||
| 10 | +import cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo.*; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * 联系人商机关联 Mapper | ||
| 14 | + * | ||
| 15 | + * @author 芋道源码 | ||
| 16 | + */ | ||
| 17 | +@Mapper | ||
| 18 | +public interface CrmContactBusinessLinkMapper extends BaseMapperX<CrmContactBusinessLinkDO> { | ||
| 19 | + | ||
| 20 | + default PageResult<CrmContactBusinessLinkDO> selectPage(CrmContactBusinessLinkPageReqVO reqVO) { | ||
| 21 | + return selectPage(reqVO, new LambdaQueryWrapperX<CrmContactBusinessLinkDO>() | ||
| 22 | + .eqIfPresent(CrmContactBusinessLinkDO::getContactId, reqVO.getContactId()) | ||
| 23 | + .eqIfPresent(CrmContactBusinessLinkDO::getBusinessId, reqVO.getBusinessId()) | ||
| 24 | + .betweenIfPresent(CrmContactBusinessLinkDO::getCreateTime, reqVO.getCreateTime()) | ||
| 25 | + .orderByDesc(CrmContactBusinessLinkDO::getId)); | ||
| 26 | + } | ||
| 27 | + default PageResult<CrmContactBusinessLinkDO> selectPageByContact(CrmContactBusinessLinkPageReqVO reqVO) { | ||
| 28 | + return selectPage(reqVO, new LambdaQueryWrapperX<CrmContactBusinessLinkDO>() | ||
| 29 | + .eqIfPresent(CrmContactBusinessLinkDO::getContactId, reqVO.getContactId()) | ||
| 30 | + .orderByDesc(CrmContactBusinessLinkDO::getId)); | ||
| 31 | + } | ||
| 32 | +} | ||
| 0 | \ No newline at end of file | 33 | \ No newline at end of file |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java
| @@ -88,7 +88,7 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | @@ -88,7 +88,7 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | ||
| 88 | } | 88 | } |
| 89 | 89 | ||
| 90 | @Override | 90 | @Override |
| 91 | - @CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS, level = CrmPermissionLevelEnum.READ) | 91 | + @CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS,bizId = "#id", level = CrmPermissionLevelEnum.READ) |
| 92 | public CrmBusinessDO getBusiness(Long id) { | 92 | public CrmBusinessDO getBusiness(Long id) { |
| 93 | return businessMapper.selectById(id); | 93 | return businessMapper.selectById(id); |
| 94 | } | 94 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contactbusinesslink/CrmContactBusinessLinkService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.service.contactbusinesslink; | ||
| 2 | + | ||
| 3 | +import java.util.*; | ||
| 4 | +import javax.validation.*; | ||
| 5 | + | ||
| 6 | +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessRespVO; | ||
| 7 | +import cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo.*; | ||
| 8 | +import cn.iocoder.yudao.module.crm.dal.dataobject.contactbusinesslink.CrmContactBusinessLinkDO; | ||
| 9 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 10 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * 联系人商机关联 Service 接口 | ||
| 14 | + * | ||
| 15 | + * @author 芋道源码 | ||
| 16 | + */ | ||
| 17 | +public interface CrmContactBusinessLinkService { | ||
| 18 | + | ||
| 19 | + /** | ||
| 20 | + * 创建联系人商机关联 | ||
| 21 | + * | ||
| 22 | + * @param createReqVO 创建信息 | ||
| 23 | + * @return 编号 | ||
| 24 | + */ | ||
| 25 | + Long createContactBusinessLink(@Valid CrmContactBusinessLinkSaveReqVO createReqVO); | ||
| 26 | + /** | ||
| 27 | + * 创建联系人商机关联 | ||
| 28 | + * | ||
| 29 | + * @param createReqVO 创建信息 | ||
| 30 | + * @return 编号 | ||
| 31 | + */ | ||
| 32 | + void createContactBusinessLinkBatch(@Valid List<CrmContactBusinessLinkSaveReqVO> createReqVO); | ||
| 33 | + /** | ||
| 34 | + * 更新联系人商机关联 | ||
| 35 | + * | ||
| 36 | + * @param updateReqVO 更新信息 | ||
| 37 | + */ | ||
| 38 | + void updateContactBusinessLink(@Valid CrmContactBusinessLinkSaveReqVO updateReqVO); | ||
| 39 | + | ||
| 40 | + /** | ||
| 41 | + * 删除联系人商机关联 | ||
| 42 | + * | ||
| 43 | + * @param createReqVO 删除列表 | ||
| 44 | + */ | ||
| 45 | + void deleteContactBusinessLink(@Valid List<CrmContactBusinessLinkSaveReqVO> createReqVO); | ||
| 46 | + | ||
| 47 | + /** | ||
| 48 | + * 获得联系人商机关联 | ||
| 49 | + * | ||
| 50 | + * @param id 编号 | ||
| 51 | + * @return 联系人商机关联 | ||
| 52 | + */ | ||
| 53 | + CrmContactBusinessLinkDO getContactBusinessLink(Long id); | ||
| 54 | + /** | ||
| 55 | + * 获得联系人商机关联分页 | ||
| 56 | + * | ||
| 57 | + * @param pageReqVO 编号 | ||
| 58 | + * @return 联系人商机关联 | ||
| 59 | + */ | ||
| 60 | + PageResult<CrmBusinessRespVO> getContactBusinessLinkPageByContact(CrmContactBusinessLinkPageReqVO pageReqVO); | ||
| 61 | + /** | ||
| 62 | + * 获得联系人商机关联分页 | ||
| 63 | + * | ||
| 64 | + * @param pageReqVO 分页查询 | ||
| 65 | + * @return 联系人商机关联分页 | ||
| 66 | + */ | ||
| 67 | + PageResult<CrmContactBusinessLinkDO> getContactBusinessLinkPage(CrmContactBusinessLinkPageReqVO pageReqVO); | ||
| 68 | + | ||
| 69 | +} | ||
| 0 | \ No newline at end of file | 70 | \ No newline at end of file |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contactbusinesslink/CrmContactBusinessLinkServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.service.contactbusinesslink; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | ||
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||
| 5 | +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessRespVO; | ||
| 6 | +import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert; | ||
| 7 | +import cn.iocoder.yudao.module.crm.convert.contactbusinessslink.CrmContactBusinessLinkConvert; | ||
| 8 | +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; | ||
| 9 | +import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; | ||
| 10 | +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||
| 11 | +import org.springframework.stereotype.Service; | ||
| 12 | + | ||
| 13 | +import javax.annotation.Resource; | ||
| 14 | + | ||
| 15 | +import org.springframework.validation.annotation.Validated; | ||
| 16 | +import org.springframework.transaction.annotation.Transactional; | ||
| 17 | + | ||
| 18 | +import java.util.*; | ||
| 19 | + | ||
| 20 | +import cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo.*; | ||
| 21 | +import cn.iocoder.yudao.module.crm.dal.dataobject.contactbusinesslink.CrmContactBusinessLinkDO; | ||
| 22 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 23 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 24 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 25 | + | ||
| 26 | +import cn.iocoder.yudao.module.crm.dal.mysql.contactbusinesslink.CrmContactBusinessLinkMapper; | ||
| 27 | + | ||
| 28 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||
| 29 | +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; | ||
| 30 | + | ||
| 31 | +/** | ||
| 32 | + * 联系人商机关联 Service 实现类 | ||
| 33 | + * | ||
| 34 | + * @author 芋道源码 | ||
| 35 | + */ | ||
| 36 | +@Service | ||
| 37 | +@Validated | ||
| 38 | +public class CrmContactBusinessLinkServiceImpl implements CrmContactBusinessLinkService { | ||
| 39 | + | ||
| 40 | + @Resource | ||
| 41 | + private CrmContactBusinessLinkMapper contactBusinessLinkMapper; | ||
| 42 | + @Resource | ||
| 43 | + private CrmBusinessService crmBusinessService; | ||
| 44 | + | ||
| 45 | + @Override | ||
| 46 | + public Long createContactBusinessLink(CrmContactBusinessLinkSaveReqVO createReqVO) { | ||
| 47 | + // 插入 | ||
| 48 | + CrmContactBusinessLinkDO contactBusinessLink = BeanUtils.toBean(createReqVO, CrmContactBusinessLinkDO.class); | ||
| 49 | + contactBusinessLinkMapper.insert(contactBusinessLink); | ||
| 50 | + // 返回 | ||
| 51 | + return contactBusinessLink.getId(); | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + @Override | ||
| 55 | + public void createContactBusinessLinkBatch(List<CrmContactBusinessLinkSaveReqVO> createReqVOList) { | ||
| 56 | + // 插入 | ||
| 57 | + List<CrmContactBusinessLinkDO> saveDoList = CrmContactBusinessLinkConvert.INSTANCE.convert(createReqVOList); | ||
| 58 | + contactBusinessLinkMapper.insertBatch(saveDoList); | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + @Override | ||
| 62 | + public void updateContactBusinessLink(CrmContactBusinessLinkSaveReqVO updateReqVO) { | ||
| 63 | + // 校验存在 | ||
| 64 | + validateContactBusinessLinkExists(updateReqVO.getId()); | ||
| 65 | + // 更新 | ||
| 66 | + CrmContactBusinessLinkDO updateObj = BeanUtils.toBean(updateReqVO, CrmContactBusinessLinkDO.class); | ||
| 67 | + contactBusinessLinkMapper.updateById(updateObj); | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + @Override | ||
| 71 | + public void deleteContactBusinessLink(List<CrmContactBusinessLinkSaveReqVO> createReqVO) { | ||
| 72 | + // 删除 | ||
| 73 | + createReqVO.forEach(item -> { | ||
| 74 | + contactBusinessLinkMapper.delete(new LambdaQueryWrapperX<CrmContactBusinessLinkDO>() | ||
| 75 | + .eq(CrmContactBusinessLinkDO::getBusinessId,item.getBusinessId()) | ||
| 76 | + .eq(CrmContactBusinessLinkDO::getContactId,item.getContactId()) | ||
| 77 | + .eq(CrmContactBusinessLinkDO::getDeleted,0)); | ||
| 78 | + }); | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + private void validateContactBusinessLinkExists(Long id) { | ||
| 82 | + if (contactBusinessLinkMapper.selectById(id) == null) { | ||
| 83 | + throw exception(CONTACT_BUSINESS_LINK_NOT_EXISTS); | ||
| 84 | + } | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + @Override | ||
| 88 | + public CrmContactBusinessLinkDO getContactBusinessLink(Long id) { | ||
| 89 | + return contactBusinessLinkMapper.selectById(id); | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + @Override | ||
| 93 | + public PageResult<CrmBusinessRespVO> getContactBusinessLinkPageByContact(CrmContactBusinessLinkPageReqVO pageReqVO) { | ||
| 94 | + CrmContactBusinessLinkPageReqVO crmContactBusinessLinkPageReqVO = new CrmContactBusinessLinkPageReqVO(); | ||
| 95 | + crmContactBusinessLinkPageReqVO.setContactId(pageReqVO.getContactId()); | ||
| 96 | + PageResult<CrmContactBusinessLinkDO> businessLinkDOS = contactBusinessLinkMapper.selectPageByContact(crmContactBusinessLinkPageReqVO); | ||
| 97 | + List<CrmBusinessDO> businessDOS = crmBusinessService.getBusinessList(CollectionUtils.convertList(businessLinkDOS.getList(), | ||
| 98 | + CrmContactBusinessLinkDO::getBusinessId)); | ||
| 99 | + PageResult<CrmBusinessRespVO> pageResult = new PageResult<CrmBusinessRespVO>(); | ||
| 100 | + pageResult.setList(CrmBusinessConvert.INSTANCE.convert(businessDOS)); | ||
| 101 | + pageResult.setTotal(businessLinkDOS.getTotal()); | ||
| 102 | + return pageResult; | ||
| 103 | + | ||
| 104 | + } | ||
| 105 | + | ||
| 106 | + @Override | ||
| 107 | + public PageResult<CrmContactBusinessLinkDO> getContactBusinessLinkPage(CrmContactBusinessLinkPageReqVO pageReqVO) { | ||
| 108 | + return contactBusinessLinkMapper.selectPage(pageReqVO); | ||
| 109 | + } | ||
| 110 | + | ||
| 111 | +} | ||
| 0 | \ No newline at end of file | 112 | \ No newline at end of file |