From e4943f0dfa547c72eede7a72dc9e93f04a763552 Mon Sep 17 00:00:00 2001 From: zyna Date: Fri, 20 Oct 2023 23:42:22 +0800 Subject: [PATCH] =?UTF-8?q?crm=E8=81=94=E7=B3=BB=E4=BA=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/mysql/crm.sql | 26 ++++- .../module/crm/enums/ErrorCodeConstants.java | 1 + .../admin/contact/ContactController.java | 102 ++++++++++++++++++ .../admin/contact/vo/ContactBaseVO.java | 55 ++++++++++ .../admin/contact/vo/ContactCreateReqVO.java | 14 +++ .../admin/contact/vo/ContactExcelVO.java | 59 ++++++++++ .../admin/contact/vo/ContactExportReqVO.java | 55 ++++++++++ .../admin/contact/vo/ContactPageReqVO.java | 57 ++++++++++ .../admin/contact/vo/ContactRespVO.java | 20 ++++ .../admin/contact/vo/ContactUpdateReqVO.java | 17 +++ .../crm/convert/contact/ContactConvert.java | 34 ++++++ .../crm/dal/dataobject/contact/ContactDO.java | 76 +++++++++++++ .../crm/dal/mysql/contact/ContactMapper.java | 54 ++++++++++ .../crm/service/contact/ContactService.java | 70 ++++++++++++ .../service/contact/ContactServiceImpl.java | 88 +++++++++++++++ .../mapper/contact/ContactMapper.xml | 12 +++ 16 files changed, 739 insertions(+), 1 deletion(-) create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/ContactController.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactBaseVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactCreateReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactExcelVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactExportReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactPageReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactRespVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactUpdateReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/contact/ContactConvert.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/ContactDO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/ContactMapper.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactService.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactServiceImpl.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/contact/ContactMapper.xml diff --git a/sql/mysql/crm.sql b/sql/mysql/crm.sql index 6c5594068..c01abbe54 100644 --- a/sql/mysql/crm.sql +++ b/sql/mysql/crm.sql @@ -60,4 +60,28 @@ CREATE TABLE `crm_clue` ( `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '线索表' ROW_FORMAT = Dynamic; \ No newline at end of file +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '线索表' ROW_FORMAT = Dynamic; + +-- `ruoyi-vue-pro`.crm_contact definition + +CREATE TABLE `crm_contact` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键', + `name` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '联系人名称', + `next_time` datetime DEFAULT NULL COMMENT '下次联系时间', + `mobile` varchar(16) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '手机号', + `telephone` varchar(16) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '电话', + `email` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '电子邮箱', + `post` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '职务', + `customer_id` bigint(20) DEFAULT NULL COMMENT '客户编号', + `address` varchar(256) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '地址', + `remark` varchar(512) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注', + `creator` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '创建人', + `owner_user_id` bigint DEFAULT NULL COMMENT '负责人用户编号', + `create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间', + `update_time` timestamp NULL DEFAULT NULL COMMENT '更新时间', + `last_time` timestamp NULL DEFAULT NULL COMMENT '最后跟进时间', + `updater` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '更新人', + `deleted` bit(1) NOT NULL DEFAULT b'0', + `tenant_id` bigint DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='crm联系人'; \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java index 3538b16ee..18c35dda7 100644 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java +++ b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java @@ -14,5 +14,6 @@ public interface ErrorCodeConstants { // TODO @wanwan:要单独一个分段噢 ErrorCode CLUE_NOT_EXISTS = new ErrorCode(1_020_000_001, "线索不存在"); + ErrorCode CONTACT_NOT_EXISTS = new ErrorCode(1_020_000_002, "线索不存在"); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/ContactController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/ContactController.java new file mode 100644 index 000000000..bafec03c1 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/ContactController.java @@ -0,0 +1,102 @@ +package cn.iocoder.yudao.module.crm.controller.admin.contact; + +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.PageResult; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +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 cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*; +import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO; +import cn.iocoder.yudao.module.crm.convert.contact.ContactConvert; +import cn.iocoder.yudao.module.crm.service.contact.ContactService; + +@Tag(name = "管理后台 - crm联系人") +@RestController +@RequestMapping("/crm/contact") +@Validated +public class ContactController { + + @Resource + private ContactService contactService; + + @PostMapping("/create") + @Operation(summary = "创建crm联系人") + @PreAuthorize("@ss.hasPermission('crm:contact:create')") + public CommonResult createContact(@Valid @RequestBody ContactCreateReqVO createReqVO) { + return success(contactService.createContact(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新crm联系人") + @PreAuthorize("@ss.hasPermission('crm:contact:update')") + public CommonResult updateContact(@Valid @RequestBody ContactUpdateReqVO updateReqVO) { + contactService.updateContact(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除crm联系人") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('crm:contact:delete')") + public CommonResult deleteContact(@RequestParam("id") Long id) { + contactService.deleteContact(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得crm联系人") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('crm:contact:query')") + public CommonResult getContact(@RequestParam("id") Long id) { + ContactDO contact = contactService.getContact(id); + return success(ContactConvert.INSTANCE.convert(contact)); + } + + @GetMapping("/list") + @Operation(summary = "获得crm联系人列表") + @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") + @PreAuthorize("@ss.hasPermission('crm:contact:query')") + public CommonResult> getContactList(@RequestParam("ids") Collection ids) { + List list = contactService.getContactList(ids); + return success(ContactConvert.INSTANCE.convertList(list)); + } + + @GetMapping("/page") + @Operation(summary = "获得crm联系人分页") + @PreAuthorize("@ss.hasPermission('crm:contact:query')") + public CommonResult> getContactPage(@Valid ContactPageReqVO pageVO) { + PageResult pageResult = contactService.getContactPage(pageVO); + return success(ContactConvert.INSTANCE.convertPage(pageResult)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出crm联系人 Excel") + @PreAuthorize("@ss.hasPermission('crm:contact:export')") + @OperateLog(type = EXPORT) + public void exportContactExcel(@Valid ContactExportReqVO exportReqVO, + HttpServletResponse response) throws IOException { + List list = contactService.getContactList(exportReqVO); + // 导出 Excel + List datas = ContactConvert.INSTANCE.convertList02(list); + ExcelUtils.write(response, "crm联系人.xls", "数据", ContactExcelVO.class, datas); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactBaseVO.java new file mode 100644 index 000000000..5b39c1f41 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactBaseVO.java @@ -0,0 +1,55 @@ +package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import javax.validation.constraints.*; +import org.springframework.format.annotation.DateTimeFormat; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +/** + * crm联系人 Base VO,提供给添加、修改、详细的子 VO 使用 + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 + */ +@Data +public class ContactBaseVO { + + @Schema(description = "联系人名称", example = "张三") + @NotNull(message = "姓名不能为空") + private String name; + + @Schema(description = "下次联系时间") + private LocalDateTime nextTime; + + @Schema(description = "手机号") + private String mobile; + + @Schema(description = "电话") + private String telephone; + + @Schema(description = "电子邮箱") + private String email; + + @Schema(description = "职务") + private String post; + + @Schema(description = "客户编号", example = "10795") + private Long customerId; + + @Schema(description = "地址") + private String address; + + @Schema(description = "备注", example = "你说的对") + private String remark; + + @Schema(description = "负责人用户编号", example = "7648") + private Long ownerUserId; + + @Schema(description = "最后跟进时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime lastTime; +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactCreateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactCreateReqVO.java new file mode 100644 index 000000000..424d945dc --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactCreateReqVO.java @@ -0,0 +1,14 @@ +package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - crm联系人创建 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class ContactCreateReqVO extends ContactBaseVO { + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactExcelVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactExcelVO.java new file mode 100644 index 000000000..3ac5f3765 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactExcelVO.java @@ -0,0 +1,59 @@ +package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; + +import com.alibaba.excel.annotation.ExcelProperty; + +/** + * crm联系人 Excel VO + * + * @author 芋道源码 + */ +@Data +public class ContactExcelVO { + + @ExcelProperty("主键") + private Long id; + + @ExcelProperty("联系人名称") + private String name; + + @ExcelProperty("下次联系时间") + private LocalDateTime nextTime; + + @ExcelProperty("手机号") + private String mobile; + + @ExcelProperty("电话") + private String telephone; + + @ExcelProperty("电子邮箱") + private String email; + + @ExcelProperty("职务") + private String post; + + @ExcelProperty("客户编号") + private Long customerId; + + @ExcelProperty("地址") + private String address; + + @ExcelProperty("备注") + private String remark; + + @ExcelProperty("负责人用户编号") + private Long ownerUserId; + + @ExcelProperty("创建时间") + private LocalDateTime createTime; + + @ExcelProperty("最后跟进时间") + private LocalDateTime lastTime; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactExportReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactExportReqVO.java new file mode 100644 index 000000000..df4bd59e1 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactExportReqVO.java @@ -0,0 +1,55 @@ +package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import java.time.LocalDateTime; +import org.springframework.format.annotation.DateTimeFormat; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - crm联系人 Excel 导出 Request VO,参数和 ContactPageReqVO 是一致的") +@Data +public class ContactExportReqVO { + + @Schema(description = "联系人名称", example = "张三") + private String name; + + @Schema(description = "下次联系时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] nextTime; + + @Schema(description = "手机号") + private String mobile; + + @Schema(description = "电话") + private String telephone; + + @Schema(description = "电子邮箱") + private String email; + + @Schema(description = "职务") + private String post; + + @Schema(description = "客户编号", example = "10795") + private Long customerId; + + @Schema(description = "地址") + private String address; + + @Schema(description = "备注", example = "你说的对") + private String remark; + + @Schema(description = "负责人用户编号", example = "7648") + private Long ownerUserId; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + + @Schema(description = "最后跟进时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] lastTime; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactPageReqVO.java new file mode 100644 index 000000000..058483926 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactPageReqVO.java @@ -0,0 +1,57 @@ +package cn.iocoder.yudao.module.crm.controller.admin.contact.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 = "管理后台 - crm联系人分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class ContactPageReqVO extends PageParam { + + @Schema(description = "联系人名称", example = "张三") + private String name; + + @Schema(description = "下次联系时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] nextTime; + + @Schema(description = "手机号") + private String mobile; + + @Schema(description = "电话") + private String telephone; + + @Schema(description = "电子邮箱") + private String email; + + @Schema(description = "职务") + private String post; + + @Schema(description = "客户编号", example = "10795") + private Long customerId; + + @Schema(description = "地址") + private String address; + + @Schema(description = "备注", example = "你说的对") + private String remark; + + @Schema(description = "负责人用户编号", example = "7648") + private Long ownerUserId; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + + @Schema(description = "最后跟进时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] lastTime; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactRespVO.java new file mode 100644 index 000000000..acb6a737d --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactRespVO.java @@ -0,0 +1,20 @@ +package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.time.LocalDateTime; + +@Schema(description = "管理后台 - crm联系人 Response VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class ContactRespVO extends ContactBaseVO { + + @Schema(description = "主键", example = "23210") + private Long id; + + @Schema(description = "创建时间") + private LocalDateTime createTime; + @Schema(description = "创建人") + private String creator; +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactUpdateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactUpdateReqVO.java new file mode 100644 index 000000000..19db67297 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactUpdateReqVO.java @@ -0,0 +1,17 @@ +package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - crm联系人更新 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class ContactUpdateReqVO extends ContactBaseVO { + + @Schema(description = "主键", example = "23210") + private Long id; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/contact/ContactConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/contact/ContactConvert.java new file mode 100644 index 000000000..3892806c0 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/contact/ContactConvert.java @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.crm.convert.contact; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; +import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*; +import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO; + +/** + * crm联系人 Convert + * + * @author 芋道源码 + */ +@Mapper +public interface ContactConvert { + + ContactConvert INSTANCE = Mappers.getMapper(ContactConvert.class); + + ContactDO convert(ContactCreateReqVO bean); + + ContactDO convert(ContactUpdateReqVO bean); + + ContactRespVO convert(ContactDO bean); + + List convertList(List list); + + PageResult convertPage(PageResult page); + + List convertList02(List list); + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/ContactDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/ContactDO.java new file mode 100644 index 000000000..ee735ae61 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/ContactDO.java @@ -0,0 +1,76 @@ +package cn.iocoder.yudao.module.crm.dal.dataobject.contact; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * crm联系人 DO + * + * @author 芋道源码 + */ +@TableName("crm_contact") +@KeySequence("crm_contact_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ContactDO extends BaseDO { + + /** + * 主键 + */ + @TableId + private Long id; + /** + * 联系人名称 + */ + private String name; + /** + * 下次联系时间 + */ + private LocalDateTime nextTime; + /** + * 手机号 + */ + private String mobile; + /** + * 电话 + */ + private String telephone; + /** + * 电子邮箱 + */ + private String email; + /** + * 职务 + */ + private String post; + /** + * 客户编号 + */ + private Long customerId; + /** + * 地址 + */ + private String address; + /** + * 备注 + */ + private String remark; + /** + * 负责人用户编号 + */ + private Long ownerUserId; + /** + * 最后跟进时间 + */ + private LocalDateTime lastTime; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/ContactMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/ContactMapper.java new file mode 100644 index 000000000..dfefeba5d --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/ContactMapper.java @@ -0,0 +1,54 @@ +package cn.iocoder.yudao.module.crm.dal.mysql.contact; + +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.contact.ContactDO; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*; + +/** + * crm联系人 Mapper + * + * @author 芋道源码 + */ +@Mapper +public interface ContactMapper extends BaseMapperX { + + default PageResult selectPage(ContactPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .likeIfPresent(ContactDO::getName, reqVO.getName()) + .betweenIfPresent(ContactDO::getNextTime, reqVO.getNextTime()) + .eqIfPresent(ContactDO::getMobile, reqVO.getMobile()) + .eqIfPresent(ContactDO::getTelephone, reqVO.getTelephone()) + .eqIfPresent(ContactDO::getEmail, reqVO.getEmail()) + .eqIfPresent(ContactDO::getPost, reqVO.getPost()) + .eqIfPresent(ContactDO::getCustomerId, reqVO.getCustomerId()) + .eqIfPresent(ContactDO::getAddress, reqVO.getAddress()) + .eqIfPresent(ContactDO::getRemark, reqVO.getRemark()) + .eqIfPresent(ContactDO::getOwnerUserId, reqVO.getOwnerUserId()) + .betweenIfPresent(ContactDO::getCreateTime, reqVO.getCreateTime()) + .betweenIfPresent(ContactDO::getLastTime, reqVO.getLastTime()) + .orderByDesc(ContactDO::getId)); + } + + default List selectList(ContactExportReqVO reqVO) { + return selectList(new LambdaQueryWrapperX() + .likeIfPresent(ContactDO::getName, reqVO.getName()) + .betweenIfPresent(ContactDO::getNextTime, reqVO.getNextTime()) + .eqIfPresent(ContactDO::getMobile, reqVO.getMobile()) + .eqIfPresent(ContactDO::getTelephone, reqVO.getTelephone()) + .eqIfPresent(ContactDO::getEmail, reqVO.getEmail()) + .eqIfPresent(ContactDO::getPost, reqVO.getPost()) + .eqIfPresent(ContactDO::getCustomerId, reqVO.getCustomerId()) + .eqIfPresent(ContactDO::getAddress, reqVO.getAddress()) + .eqIfPresent(ContactDO::getRemark, reqVO.getRemark()) + .eqIfPresent(ContactDO::getOwnerUserId, reqVO.getOwnerUserId()) + .betweenIfPresent(ContactDO::getCreateTime, reqVO.getCreateTime()) + .betweenIfPresent(ContactDO::getLastTime, reqVO.getLastTime()) + .orderByDesc(ContactDO::getId)); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactService.java new file mode 100644 index 000000000..97a221ee4 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactService.java @@ -0,0 +1,70 @@ +package cn.iocoder.yudao.module.crm.service.contact; + +import java.util.*; +import javax.validation.*; +import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*; +import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +/** + * crm联系人 Service 接口 + * + * @author 芋道源码 + */ +public interface ContactService { + + /** + * 创建crm联系人 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createContact(@Valid ContactCreateReqVO createReqVO); + + /** + * 更新crm联系人 + * + * @param updateReqVO 更新信息 + */ + void updateContact(@Valid ContactUpdateReqVO updateReqVO); + + /** + * 删除crm联系人 + * + * @param id 编号 + */ + void deleteContact(Long id); + + /** + * 获得crm联系人 + * + * @param id 编号 + * @return crm联系人 + */ + ContactDO getContact(Long id); + + /** + * 获得crm联系人列表 + * + * @param ids 编号 + * @return crm联系人列表 + */ + List getContactList(Collection ids); + + /** + * 获得crm联系人分页 + * + * @param pageReqVO 分页查询 + * @return crm联系人分页 + */ + PageResult getContactPage(ContactPageReqVO pageReqVO); + + /** + * 获得crm联系人列表, 用于 Excel 导出 + * + * @param exportReqVO 查询条件 + * @return crm联系人列表 + */ + List getContactList(ContactExportReqVO exportReqVO); + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactServiceImpl.java new file mode 100644 index 000000000..85ce3c269 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactServiceImpl.java @@ -0,0 +1,88 @@ +package cn.iocoder.yudao.module.crm.service.contact; + +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; + +import java.util.*; +import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*; +import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import cn.iocoder.yudao.module.crm.convert.contact.ContactConvert; +import cn.iocoder.yudao.module.crm.dal.mysql.contact.ContactMapper; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.collection.ListUtil; + +/** + * crm联系人 Service 实现类 + * + * @author 芋道源码 + */ +@Service +@Validated +public class ContactServiceImpl implements ContactService { + + @Resource + private ContactMapper contactMapper; + + @Override + public Long createContact(ContactCreateReqVO createReqVO) { + // 插入 + ContactDO contact = ContactConvert.INSTANCE.convert(createReqVO); + contactMapper.insert(contact); + // 返回 + return contact.getId(); + } + + @Override + public void updateContact(ContactUpdateReqVO updateReqVO) { + // 校验存在 + validateContactExists(updateReqVO.getId()); + // 更新 + ContactDO updateObj = ContactConvert.INSTANCE.convert(updateReqVO); + contactMapper.updateById(updateObj); + } + + @Override + public void deleteContact(Long id) { + // 校验存在 + validateContactExists(id); + // 删除 + contactMapper.deleteById(id); + } + + private void validateContactExists(Long id) { + if (contactMapper.selectById(id) == null) { + throw exception(CONTACT_NOT_EXISTS); + } + } + + @Override + public ContactDO getContact(Long id) { + return contactMapper.selectById(id); + } + + @Override + public List getContactList(Collection ids) { + if (CollUtil.isEmpty(ids)) { + return ListUtil.empty(); + } + return contactMapper.selectBatchIds(ids); + } + + @Override + public PageResult getContactPage(ContactPageReqVO pageReqVO) { + return contactMapper.selectPage(pageReqVO); + } + + @Override + public List getContactList(ContactExportReqVO exportReqVO) { + return contactMapper.selectList(exportReqVO); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/contact/ContactMapper.xml b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/contact/ContactMapper.xml new file mode 100644 index 000000000..e2c69ca78 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/contact/ContactMapper.xml @@ -0,0 +1,12 @@ + + + + + + +