Commit e4943f0dfa547c72eede7a72dc9e93f04a763552
1 parent
439edcd1
crm联系人
Showing
16 changed files
with
739 additions
and
1 deletions
sql/mysql/crm.sql
| @@ -60,4 +60,28 @@ CREATE TABLE `crm_clue` ( | @@ -60,4 +60,28 @@ CREATE TABLE `crm_clue` ( | ||
| 60 | `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', | 60 | `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', |
| 61 | `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', | 61 | `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', |
| 62 | PRIMARY KEY (`id`) USING BTREE | 62 | PRIMARY KEY (`id`) USING BTREE |
| 63 | -) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '线索表' ROW_FORMAT = Dynamic; | ||
| 64 | \ No newline at end of file | 63 | \ No newline at end of file |
| 64 | +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '线索表' ROW_FORMAT = Dynamic; | ||
| 65 | + | ||
| 66 | +-- `ruoyi-vue-pro`.crm_contact definition | ||
| 67 | + | ||
| 68 | +CREATE TABLE `crm_contact` ( | ||
| 69 | + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键', | ||
| 70 | + `name` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '联系人名称', | ||
| 71 | + `next_time` datetime DEFAULT NULL COMMENT '下次联系时间', | ||
| 72 | + `mobile` varchar(16) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '手机号', | ||
| 73 | + `telephone` varchar(16) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '电话', | ||
| 74 | + `email` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '电子邮箱', | ||
| 75 | + `post` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '职务', | ||
| 76 | + `customer_id` bigint(20) DEFAULT NULL COMMENT '客户编号', | ||
| 77 | + `address` varchar(256) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '地址', | ||
| 78 | + `remark` varchar(512) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注', | ||
| 79 | + `creator` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '创建人', | ||
| 80 | + `owner_user_id` bigint DEFAULT NULL COMMENT '负责人用户编号', | ||
| 81 | + `create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间', | ||
| 82 | + `update_time` timestamp NULL DEFAULT NULL COMMENT '更新时间', | ||
| 83 | + `last_time` timestamp NULL DEFAULT NULL COMMENT '最后跟进时间', | ||
| 84 | + `updater` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '更新人', | ||
| 85 | + `deleted` bit(1) NOT NULL DEFAULT b'0', | ||
| 86 | + `tenant_id` bigint DEFAULT NULL, | ||
| 87 | + PRIMARY KEY (`id`) | ||
| 88 | +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='crm联系人'; | ||
| 65 | \ No newline at end of file | 89 | \ No newline at end of file |
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 { | @@ -14,5 +14,6 @@ public interface ErrorCodeConstants { | ||
| 14 | 14 | ||
| 15 | // TODO @wanwan:要单独一个分段噢 | 15 | // TODO @wanwan:要单独一个分段噢 |
| 16 | ErrorCode CLUE_NOT_EXISTS = new ErrorCode(1_020_000_001, "线索不存在"); | 16 | ErrorCode CLUE_NOT_EXISTS = new ErrorCode(1_020_000_001, "线索不存在"); |
| 17 | + ErrorCode CONTACT_NOT_EXISTS = new ErrorCode(1_020_000_002, "线索不存在"); | ||
| 17 | 18 | ||
| 18 | } | 19 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/ContactController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.controller.admin.contact; | ||
| 2 | + | ||
| 3 | +import org.springframework.web.bind.annotation.*; | ||
| 4 | +import javax.annotation.Resource; | ||
| 5 | +import org.springframework.validation.annotation.Validated; | ||
| 6 | +import org.springframework.security.access.prepost.PreAuthorize; | ||
| 7 | +import io.swagger.v3.oas.annotations.tags.Tag; | ||
| 8 | +import io.swagger.v3.oas.annotations.Parameter; | ||
| 9 | +import io.swagger.v3.oas.annotations.Operation; | ||
| 10 | + | ||
| 11 | +import javax.validation.constraints.*; | ||
| 12 | +import javax.validation.*; | ||
| 13 | +import javax.servlet.http.*; | ||
| 14 | +import java.util.*; | ||
| 15 | +import java.io.IOException; | ||
| 16 | + | ||
| 17 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 18 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 19 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
| 20 | + | ||
| 21 | +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | ||
| 22 | + | ||
| 23 | +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | ||
| 24 | +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; | ||
| 25 | + | ||
| 26 | +import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*; | ||
| 27 | +import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO; | ||
| 28 | +import cn.iocoder.yudao.module.crm.convert.contact.ContactConvert; | ||
| 29 | +import cn.iocoder.yudao.module.crm.service.contact.ContactService; | ||
| 30 | + | ||
| 31 | +@Tag(name = "管理后台 - crm联系人") | ||
| 32 | +@RestController | ||
| 33 | +@RequestMapping("/crm/contact") | ||
| 34 | +@Validated | ||
| 35 | +public class ContactController { | ||
| 36 | + | ||
| 37 | + @Resource | ||
| 38 | + private ContactService contactService; | ||
| 39 | + | ||
| 40 | + @PostMapping("/create") | ||
| 41 | + @Operation(summary = "创建crm联系人") | ||
| 42 | + @PreAuthorize("@ss.hasPermission('crm:contact:create')") | ||
| 43 | + public CommonResult<Long> createContact(@Valid @RequestBody ContactCreateReqVO createReqVO) { | ||
| 44 | + return success(contactService.createContact(createReqVO)); | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + @PutMapping("/update") | ||
| 48 | + @Operation(summary = "更新crm联系人") | ||
| 49 | + @PreAuthorize("@ss.hasPermission('crm:contact:update')") | ||
| 50 | + public CommonResult<Boolean> updateContact(@Valid @RequestBody ContactUpdateReqVO updateReqVO) { | ||
| 51 | + contactService.updateContact(updateReqVO); | ||
| 52 | + return success(true); | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + @DeleteMapping("/delete") | ||
| 56 | + @Operation(summary = "删除crm联系人") | ||
| 57 | + @Parameter(name = "id", description = "编号", required = true) | ||
| 58 | + @PreAuthorize("@ss.hasPermission('crm:contact:delete')") | ||
| 59 | + public CommonResult<Boolean> deleteContact(@RequestParam("id") Long id) { | ||
| 60 | + contactService.deleteContact(id); | ||
| 61 | + return success(true); | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + @GetMapping("/get") | ||
| 65 | + @Operation(summary = "获得crm联系人") | ||
| 66 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | ||
| 67 | + @PreAuthorize("@ss.hasPermission('crm:contact:query')") | ||
| 68 | + public CommonResult<ContactRespVO> getContact(@RequestParam("id") Long id) { | ||
| 69 | + ContactDO contact = contactService.getContact(id); | ||
| 70 | + return success(ContactConvert.INSTANCE.convert(contact)); | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + @GetMapping("/list") | ||
| 74 | + @Operation(summary = "获得crm联系人列表") | ||
| 75 | + @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") | ||
| 76 | + @PreAuthorize("@ss.hasPermission('crm:contact:query')") | ||
| 77 | + public CommonResult<List<ContactRespVO>> getContactList(@RequestParam("ids") Collection<Long> ids) { | ||
| 78 | + List<ContactDO> list = contactService.getContactList(ids); | ||
| 79 | + return success(ContactConvert.INSTANCE.convertList(list)); | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + @GetMapping("/page") | ||
| 83 | + @Operation(summary = "获得crm联系人分页") | ||
| 84 | + @PreAuthorize("@ss.hasPermission('crm:contact:query')") | ||
| 85 | + public CommonResult<PageResult<ContactRespVO>> getContactPage(@Valid ContactPageReqVO pageVO) { | ||
| 86 | + PageResult<ContactDO> pageResult = contactService.getContactPage(pageVO); | ||
| 87 | + return success(ContactConvert.INSTANCE.convertPage(pageResult)); | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + @GetMapping("/export-excel") | ||
| 91 | + @Operation(summary = "导出crm联系人 Excel") | ||
| 92 | + @PreAuthorize("@ss.hasPermission('crm:contact:export')") | ||
| 93 | + @OperateLog(type = EXPORT) | ||
| 94 | + public void exportContactExcel(@Valid ContactExportReqVO exportReqVO, | ||
| 95 | + HttpServletResponse response) throws IOException { | ||
| 96 | + List<ContactDO> list = contactService.getContactList(exportReqVO); | ||
| 97 | + // 导出 Excel | ||
| 98 | + List<ContactExcelVO> datas = ContactConvert.INSTANCE.convertList02(list); | ||
| 99 | + ExcelUtils.write(response, "crm联系人.xls", "数据", ContactExcelVO.class, datas); | ||
| 100 | + } | ||
| 101 | + | ||
| 102 | +} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactBaseVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import lombok.*; | ||
| 5 | +import java.util.*; | ||
| 6 | +import java.time.LocalDateTime; | ||
| 7 | +import java.time.LocalDateTime; | ||
| 8 | +import java.time.LocalDateTime; | ||
| 9 | +import javax.validation.constraints.*; | ||
| 10 | +import org.springframework.format.annotation.DateTimeFormat; | ||
| 11 | + | ||
| 12 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 13 | + | ||
| 14 | +/** | ||
| 15 | + * crm联系人 Base VO,提供给添加、修改、详细的子 VO 使用 | ||
| 16 | + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | ||
| 17 | + */ | ||
| 18 | +@Data | ||
| 19 | +public class ContactBaseVO { | ||
| 20 | + | ||
| 21 | + @Schema(description = "联系人名称", example = "张三") | ||
| 22 | + @NotNull(message = "姓名不能为空") | ||
| 23 | + private String name; | ||
| 24 | + | ||
| 25 | + @Schema(description = "下次联系时间") | ||
| 26 | + private LocalDateTime nextTime; | ||
| 27 | + | ||
| 28 | + @Schema(description = "手机号") | ||
| 29 | + private String mobile; | ||
| 30 | + | ||
| 31 | + @Schema(description = "电话") | ||
| 32 | + private String telephone; | ||
| 33 | + | ||
| 34 | + @Schema(description = "电子邮箱") | ||
| 35 | + private String email; | ||
| 36 | + | ||
| 37 | + @Schema(description = "职务") | ||
| 38 | + private String post; | ||
| 39 | + | ||
| 40 | + @Schema(description = "客户编号", example = "10795") | ||
| 41 | + private Long customerId; | ||
| 42 | + | ||
| 43 | + @Schema(description = "地址") | ||
| 44 | + private String address; | ||
| 45 | + | ||
| 46 | + @Schema(description = "备注", example = "你说的对") | ||
| 47 | + private String remark; | ||
| 48 | + | ||
| 49 | + @Schema(description = "负责人用户编号", example = "7648") | ||
| 50 | + private Long ownerUserId; | ||
| 51 | + | ||
| 52 | + @Schema(description = "最后跟进时间") | ||
| 53 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 54 | + private LocalDateTime lastTime; | ||
| 55 | +} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactCreateReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; | ||
| 2 | + | ||
| 3 | +import lombok.*; | ||
| 4 | +import java.util.*; | ||
| 5 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 6 | +import javax.validation.constraints.*; | ||
| 7 | + | ||
| 8 | +@Schema(description = "管理后台 - crm联系人创建 Request VO") | ||
| 9 | +@Data | ||
| 10 | +@EqualsAndHashCode(callSuper = true) | ||
| 11 | +@ToString(callSuper = true) | ||
| 12 | +public class ContactCreateReqVO extends ContactBaseVO { | ||
| 13 | + | ||
| 14 | +} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactExcelVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import lombok.*; | ||
| 5 | +import java.util.*; | ||
| 6 | +import java.time.LocalDateTime; | ||
| 7 | +import java.time.LocalDateTime; | ||
| 8 | +import java.time.LocalDateTime; | ||
| 9 | + | ||
| 10 | +import com.alibaba.excel.annotation.ExcelProperty; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * crm联系人 Excel VO | ||
| 14 | + * | ||
| 15 | + * @author 芋道源码 | ||
| 16 | + */ | ||
| 17 | +@Data | ||
| 18 | +public class ContactExcelVO { | ||
| 19 | + | ||
| 20 | + @ExcelProperty("主键") | ||
| 21 | + private Long id; | ||
| 22 | + | ||
| 23 | + @ExcelProperty("联系人名称") | ||
| 24 | + private String name; | ||
| 25 | + | ||
| 26 | + @ExcelProperty("下次联系时间") | ||
| 27 | + private LocalDateTime nextTime; | ||
| 28 | + | ||
| 29 | + @ExcelProperty("手机号") | ||
| 30 | + private String mobile; | ||
| 31 | + | ||
| 32 | + @ExcelProperty("电话") | ||
| 33 | + private String telephone; | ||
| 34 | + | ||
| 35 | + @ExcelProperty("电子邮箱") | ||
| 36 | + private String email; | ||
| 37 | + | ||
| 38 | + @ExcelProperty("职务") | ||
| 39 | + private String post; | ||
| 40 | + | ||
| 41 | + @ExcelProperty("客户编号") | ||
| 42 | + private Long customerId; | ||
| 43 | + | ||
| 44 | + @ExcelProperty("地址") | ||
| 45 | + private String address; | ||
| 46 | + | ||
| 47 | + @ExcelProperty("备注") | ||
| 48 | + private String remark; | ||
| 49 | + | ||
| 50 | + @ExcelProperty("负责人用户编号") | ||
| 51 | + private Long ownerUserId; | ||
| 52 | + | ||
| 53 | + @ExcelProperty("创建时间") | ||
| 54 | + private LocalDateTime createTime; | ||
| 55 | + | ||
| 56 | + @ExcelProperty("最后跟进时间") | ||
| 57 | + private LocalDateTime lastTime; | ||
| 58 | + | ||
| 59 | +} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactExportReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.controller.admin.contact.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 java.time.LocalDateTime; | ||
| 8 | +import org.springframework.format.annotation.DateTimeFormat; | ||
| 9 | + | ||
| 10 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 11 | + | ||
| 12 | +@Schema(description = "管理后台 - crm联系人 Excel 导出 Request VO,参数和 ContactPageReqVO 是一致的") | ||
| 13 | +@Data | ||
| 14 | +public class ContactExportReqVO { | ||
| 15 | + | ||
| 16 | + @Schema(description = "联系人名称", example = "张三") | ||
| 17 | + private String name; | ||
| 18 | + | ||
| 19 | + @Schema(description = "下次联系时间") | ||
| 20 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 21 | + private LocalDateTime[] nextTime; | ||
| 22 | + | ||
| 23 | + @Schema(description = "手机号") | ||
| 24 | + private String mobile; | ||
| 25 | + | ||
| 26 | + @Schema(description = "电话") | ||
| 27 | + private String telephone; | ||
| 28 | + | ||
| 29 | + @Schema(description = "电子邮箱") | ||
| 30 | + private String email; | ||
| 31 | + | ||
| 32 | + @Schema(description = "职务") | ||
| 33 | + private String post; | ||
| 34 | + | ||
| 35 | + @Schema(description = "客户编号", example = "10795") | ||
| 36 | + private Long customerId; | ||
| 37 | + | ||
| 38 | + @Schema(description = "地址") | ||
| 39 | + private String address; | ||
| 40 | + | ||
| 41 | + @Schema(description = "备注", example = "你说的对") | ||
| 42 | + private String remark; | ||
| 43 | + | ||
| 44 | + @Schema(description = "负责人用户编号", example = "7648") | ||
| 45 | + private Long ownerUserId; | ||
| 46 | + | ||
| 47 | + @Schema(description = "创建时间") | ||
| 48 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 49 | + private LocalDateTime[] createTime; | ||
| 50 | + | ||
| 51 | + @Schema(description = "最后跟进时间") | ||
| 52 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 53 | + private LocalDateTime[] lastTime; | ||
| 54 | + | ||
| 55 | +} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactPageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.controller.admin.contact.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 = "管理后台 - crm联系人分页 Request VO") | ||
| 13 | +@Data | ||
| 14 | +@EqualsAndHashCode(callSuper = true) | ||
| 15 | +@ToString(callSuper = true) | ||
| 16 | +public class ContactPageReqVO extends PageParam { | ||
| 17 | + | ||
| 18 | + @Schema(description = "联系人名称", example = "张三") | ||
| 19 | + private String name; | ||
| 20 | + | ||
| 21 | + @Schema(description = "下次联系时间") | ||
| 22 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 23 | + private LocalDateTime[] nextTime; | ||
| 24 | + | ||
| 25 | + @Schema(description = "手机号") | ||
| 26 | + private String mobile; | ||
| 27 | + | ||
| 28 | + @Schema(description = "电话") | ||
| 29 | + private String telephone; | ||
| 30 | + | ||
| 31 | + @Schema(description = "电子邮箱") | ||
| 32 | + private String email; | ||
| 33 | + | ||
| 34 | + @Schema(description = "职务") | ||
| 35 | + private String post; | ||
| 36 | + | ||
| 37 | + @Schema(description = "客户编号", example = "10795") | ||
| 38 | + private Long customerId; | ||
| 39 | + | ||
| 40 | + @Schema(description = "地址") | ||
| 41 | + private String address; | ||
| 42 | + | ||
| 43 | + @Schema(description = "备注", example = "你说的对") | ||
| 44 | + private String remark; | ||
| 45 | + | ||
| 46 | + @Schema(description = "负责人用户编号", example = "7648") | ||
| 47 | + private Long ownerUserId; | ||
| 48 | + | ||
| 49 | + @Schema(description = "创建时间") | ||
| 50 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 51 | + private LocalDateTime[] createTime; | ||
| 52 | + | ||
| 53 | + @Schema(description = "最后跟进时间") | ||
| 54 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 55 | + private LocalDateTime[] lastTime; | ||
| 56 | + | ||
| 57 | +} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import lombok.*; | ||
| 5 | +import java.time.LocalDateTime; | ||
| 6 | + | ||
| 7 | +@Schema(description = "管理后台 - crm联系人 Response VO") | ||
| 8 | +@Data | ||
| 9 | +@EqualsAndHashCode(callSuper = true) | ||
| 10 | +@ToString(callSuper = true) | ||
| 11 | +public class ContactRespVO extends ContactBaseVO { | ||
| 12 | + | ||
| 13 | + @Schema(description = "主键", example = "23210") | ||
| 14 | + private Long id; | ||
| 15 | + | ||
| 16 | + @Schema(description = "创建时间") | ||
| 17 | + private LocalDateTime createTime; | ||
| 18 | + @Schema(description = "创建人") | ||
| 19 | + private String creator; | ||
| 20 | +} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactUpdateReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import lombok.*; | ||
| 5 | +import java.util.*; | ||
| 6 | +import javax.validation.constraints.*; | ||
| 7 | + | ||
| 8 | +@Schema(description = "管理后台 - crm联系人更新 Request VO") | ||
| 9 | +@Data | ||
| 10 | +@EqualsAndHashCode(callSuper = true) | ||
| 11 | +@ToString(callSuper = true) | ||
| 12 | +public class ContactUpdateReqVO extends ContactBaseVO { | ||
| 13 | + | ||
| 14 | + @Schema(description = "主键", example = "23210") | ||
| 15 | + private Long id; | ||
| 16 | + | ||
| 17 | +} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/contact/ContactConvert.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.convert.contact; | ||
| 2 | + | ||
| 3 | +import java.util.*; | ||
| 4 | + | ||
| 5 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 6 | + | ||
| 7 | +import org.mapstruct.Mapper; | ||
| 8 | +import org.mapstruct.factory.Mappers; | ||
| 9 | +import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*; | ||
| 10 | +import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * crm联系人 Convert | ||
| 14 | + * | ||
| 15 | + * @author 芋道源码 | ||
| 16 | + */ | ||
| 17 | +@Mapper | ||
| 18 | +public interface ContactConvert { | ||
| 19 | + | ||
| 20 | + ContactConvert INSTANCE = Mappers.getMapper(ContactConvert.class); | ||
| 21 | + | ||
| 22 | + ContactDO convert(ContactCreateReqVO bean); | ||
| 23 | + | ||
| 24 | + ContactDO convert(ContactUpdateReqVO bean); | ||
| 25 | + | ||
| 26 | + ContactRespVO convert(ContactDO bean); | ||
| 27 | + | ||
| 28 | + List<ContactRespVO> convertList(List<ContactDO> list); | ||
| 29 | + | ||
| 30 | + PageResult<ContactRespVO> convertPage(PageResult<ContactDO> page); | ||
| 31 | + | ||
| 32 | + List<ContactExcelVO> convertList02(List<ContactDO> list); | ||
| 33 | + | ||
| 34 | +} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/ContactDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.dal.dataobject.contact; | ||
| 2 | + | ||
| 3 | +import lombok.*; | ||
| 4 | +import java.util.*; | ||
| 5 | +import java.time.LocalDateTime; | ||
| 6 | +import java.time.LocalDateTime; | ||
| 7 | +import java.time.LocalDateTime; | ||
| 8 | +import com.baomidou.mybatisplus.annotation.*; | ||
| 9 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | ||
| 10 | + | ||
| 11 | +/** | ||
| 12 | + * crm联系人 DO | ||
| 13 | + * | ||
| 14 | + * @author 芋道源码 | ||
| 15 | + */ | ||
| 16 | +@TableName("crm_contact") | ||
| 17 | +@KeySequence("crm_contact_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | ||
| 18 | +@Data | ||
| 19 | +@EqualsAndHashCode(callSuper = true) | ||
| 20 | +@ToString(callSuper = true) | ||
| 21 | +@Builder | ||
| 22 | +@NoArgsConstructor | ||
| 23 | +@AllArgsConstructor | ||
| 24 | +public class ContactDO extends BaseDO { | ||
| 25 | + | ||
| 26 | + /** | ||
| 27 | + * 主键 | ||
| 28 | + */ | ||
| 29 | + @TableId | ||
| 30 | + private Long id; | ||
| 31 | + /** | ||
| 32 | + * 联系人名称 | ||
| 33 | + */ | ||
| 34 | + private String name; | ||
| 35 | + /** | ||
| 36 | + * 下次联系时间 | ||
| 37 | + */ | ||
| 38 | + private LocalDateTime nextTime; | ||
| 39 | + /** | ||
| 40 | + * 手机号 | ||
| 41 | + */ | ||
| 42 | + private String mobile; | ||
| 43 | + /** | ||
| 44 | + * 电话 | ||
| 45 | + */ | ||
| 46 | + private String telephone; | ||
| 47 | + /** | ||
| 48 | + * 电子邮箱 | ||
| 49 | + */ | ||
| 50 | + private String email; | ||
| 51 | + /** | ||
| 52 | + * 职务 | ||
| 53 | + */ | ||
| 54 | + private String post; | ||
| 55 | + /** | ||
| 56 | + * 客户编号 | ||
| 57 | + */ | ||
| 58 | + private Long customerId; | ||
| 59 | + /** | ||
| 60 | + * 地址 | ||
| 61 | + */ | ||
| 62 | + private String address; | ||
| 63 | + /** | ||
| 64 | + * 备注 | ||
| 65 | + */ | ||
| 66 | + private String remark; | ||
| 67 | + /** | ||
| 68 | + * 负责人用户编号 | ||
| 69 | + */ | ||
| 70 | + private Long ownerUserId; | ||
| 71 | + /** | ||
| 72 | + * 最后跟进时间 | ||
| 73 | + */ | ||
| 74 | + private LocalDateTime lastTime; | ||
| 75 | + | ||
| 76 | +} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/ContactMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.dal.mysql.contact; | ||
| 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.contact.ContactDO; | ||
| 9 | +import org.apache.ibatis.annotations.Mapper; | ||
| 10 | +import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * crm联系人 Mapper | ||
| 14 | + * | ||
| 15 | + * @author 芋道源码 | ||
| 16 | + */ | ||
| 17 | +@Mapper | ||
| 18 | +public interface ContactMapper extends BaseMapperX<ContactDO> { | ||
| 19 | + | ||
| 20 | + default PageResult<ContactDO> selectPage(ContactPageReqVO reqVO) { | ||
| 21 | + return selectPage(reqVO, new LambdaQueryWrapperX<ContactDO>() | ||
| 22 | + .likeIfPresent(ContactDO::getName, reqVO.getName()) | ||
| 23 | + .betweenIfPresent(ContactDO::getNextTime, reqVO.getNextTime()) | ||
| 24 | + .eqIfPresent(ContactDO::getMobile, reqVO.getMobile()) | ||
| 25 | + .eqIfPresent(ContactDO::getTelephone, reqVO.getTelephone()) | ||
| 26 | + .eqIfPresent(ContactDO::getEmail, reqVO.getEmail()) | ||
| 27 | + .eqIfPresent(ContactDO::getPost, reqVO.getPost()) | ||
| 28 | + .eqIfPresent(ContactDO::getCustomerId, reqVO.getCustomerId()) | ||
| 29 | + .eqIfPresent(ContactDO::getAddress, reqVO.getAddress()) | ||
| 30 | + .eqIfPresent(ContactDO::getRemark, reqVO.getRemark()) | ||
| 31 | + .eqIfPresent(ContactDO::getOwnerUserId, reqVO.getOwnerUserId()) | ||
| 32 | + .betweenIfPresent(ContactDO::getCreateTime, reqVO.getCreateTime()) | ||
| 33 | + .betweenIfPresent(ContactDO::getLastTime, reqVO.getLastTime()) | ||
| 34 | + .orderByDesc(ContactDO::getId)); | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + default List<ContactDO> selectList(ContactExportReqVO reqVO) { | ||
| 38 | + return selectList(new LambdaQueryWrapperX<ContactDO>() | ||
| 39 | + .likeIfPresent(ContactDO::getName, reqVO.getName()) | ||
| 40 | + .betweenIfPresent(ContactDO::getNextTime, reqVO.getNextTime()) | ||
| 41 | + .eqIfPresent(ContactDO::getMobile, reqVO.getMobile()) | ||
| 42 | + .eqIfPresent(ContactDO::getTelephone, reqVO.getTelephone()) | ||
| 43 | + .eqIfPresent(ContactDO::getEmail, reqVO.getEmail()) | ||
| 44 | + .eqIfPresent(ContactDO::getPost, reqVO.getPost()) | ||
| 45 | + .eqIfPresent(ContactDO::getCustomerId, reqVO.getCustomerId()) | ||
| 46 | + .eqIfPresent(ContactDO::getAddress, reqVO.getAddress()) | ||
| 47 | + .eqIfPresent(ContactDO::getRemark, reqVO.getRemark()) | ||
| 48 | + .eqIfPresent(ContactDO::getOwnerUserId, reqVO.getOwnerUserId()) | ||
| 49 | + .betweenIfPresent(ContactDO::getCreateTime, reqVO.getCreateTime()) | ||
| 50 | + .betweenIfPresent(ContactDO::getLastTime, reqVO.getLastTime()) | ||
| 51 | + .orderByDesc(ContactDO::getId)); | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | +} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.service.contact; | ||
| 2 | + | ||
| 3 | +import java.util.*; | ||
| 4 | +import javax.validation.*; | ||
| 5 | +import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*; | ||
| 6 | +import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO; | ||
| 7 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * crm联系人 Service 接口 | ||
| 11 | + * | ||
| 12 | + * @author 芋道源码 | ||
| 13 | + */ | ||
| 14 | +public interface ContactService { | ||
| 15 | + | ||
| 16 | + /** | ||
| 17 | + * 创建crm联系人 | ||
| 18 | + * | ||
| 19 | + * @param createReqVO 创建信息 | ||
| 20 | + * @return 编号 | ||
| 21 | + */ | ||
| 22 | + Long createContact(@Valid ContactCreateReqVO createReqVO); | ||
| 23 | + | ||
| 24 | + /** | ||
| 25 | + * 更新crm联系人 | ||
| 26 | + * | ||
| 27 | + * @param updateReqVO 更新信息 | ||
| 28 | + */ | ||
| 29 | + void updateContact(@Valid ContactUpdateReqVO updateReqVO); | ||
| 30 | + | ||
| 31 | + /** | ||
| 32 | + * 删除crm联系人 | ||
| 33 | + * | ||
| 34 | + * @param id 编号 | ||
| 35 | + */ | ||
| 36 | + void deleteContact(Long id); | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * 获得crm联系人 | ||
| 40 | + * | ||
| 41 | + * @param id 编号 | ||
| 42 | + * @return crm联系人 | ||
| 43 | + */ | ||
| 44 | + ContactDO getContact(Long id); | ||
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * 获得crm联系人列表 | ||
| 48 | + * | ||
| 49 | + * @param ids 编号 | ||
| 50 | + * @return crm联系人列表 | ||
| 51 | + */ | ||
| 52 | + List<ContactDO> getContactList(Collection<Long> ids); | ||
| 53 | + | ||
| 54 | + /** | ||
| 55 | + * 获得crm联系人分页 | ||
| 56 | + * | ||
| 57 | + * @param pageReqVO 分页查询 | ||
| 58 | + * @return crm联系人分页 | ||
| 59 | + */ | ||
| 60 | + PageResult<ContactDO> getContactPage(ContactPageReqVO pageReqVO); | ||
| 61 | + | ||
| 62 | + /** | ||
| 63 | + * 获得crm联系人列表, 用于 Excel 导出 | ||
| 64 | + * | ||
| 65 | + * @param exportReqVO 查询条件 | ||
| 66 | + * @return crm联系人列表 | ||
| 67 | + */ | ||
| 68 | + List<ContactDO> getContactList(ContactExportReqVO exportReqVO); | ||
| 69 | + | ||
| 70 | +} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.service.contact; | ||
| 2 | + | ||
| 3 | +import org.springframework.stereotype.Service; | ||
| 4 | +import javax.annotation.Resource; | ||
| 5 | +import org.springframework.validation.annotation.Validated; | ||
| 6 | + | ||
| 7 | +import java.util.*; | ||
| 8 | +import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*; | ||
| 9 | +import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO; | ||
| 10 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 11 | + | ||
| 12 | +import cn.iocoder.yudao.module.crm.convert.contact.ContactConvert; | ||
| 13 | +import cn.iocoder.yudao.module.crm.dal.mysql.contact.ContactMapper; | ||
| 14 | + | ||
| 15 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||
| 16 | +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; | ||
| 17 | + | ||
| 18 | +import cn.hutool.core.collection.CollUtil; | ||
| 19 | +import cn.hutool.core.collection.ListUtil; | ||
| 20 | + | ||
| 21 | +/** | ||
| 22 | + * crm联系人 Service 实现类 | ||
| 23 | + * | ||
| 24 | + * @author 芋道源码 | ||
| 25 | + */ | ||
| 26 | +@Service | ||
| 27 | +@Validated | ||
| 28 | +public class ContactServiceImpl implements ContactService { | ||
| 29 | + | ||
| 30 | + @Resource | ||
| 31 | + private ContactMapper contactMapper; | ||
| 32 | + | ||
| 33 | + @Override | ||
| 34 | + public Long createContact(ContactCreateReqVO createReqVO) { | ||
| 35 | + // 插入 | ||
| 36 | + ContactDO contact = ContactConvert.INSTANCE.convert(createReqVO); | ||
| 37 | + contactMapper.insert(contact); | ||
| 38 | + // 返回 | ||
| 39 | + return contact.getId(); | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + @Override | ||
| 43 | + public void updateContact(ContactUpdateReqVO updateReqVO) { | ||
| 44 | + // 校验存在 | ||
| 45 | + validateContactExists(updateReqVO.getId()); | ||
| 46 | + // 更新 | ||
| 47 | + ContactDO updateObj = ContactConvert.INSTANCE.convert(updateReqVO); | ||
| 48 | + contactMapper.updateById(updateObj); | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + @Override | ||
| 52 | + public void deleteContact(Long id) { | ||
| 53 | + // 校验存在 | ||
| 54 | + validateContactExists(id); | ||
| 55 | + // 删除 | ||
| 56 | + contactMapper.deleteById(id); | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + private void validateContactExists(Long id) { | ||
| 60 | + if (contactMapper.selectById(id) == null) { | ||
| 61 | + throw exception(CONTACT_NOT_EXISTS); | ||
| 62 | + } | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + @Override | ||
| 66 | + public ContactDO getContact(Long id) { | ||
| 67 | + return contactMapper.selectById(id); | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + @Override | ||
| 71 | + public List<ContactDO> getContactList(Collection<Long> ids) { | ||
| 72 | + if (CollUtil.isEmpty(ids)) { | ||
| 73 | + return ListUtil.empty(); | ||
| 74 | + } | ||
| 75 | + return contactMapper.selectBatchIds(ids); | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + @Override | ||
| 79 | + public PageResult<ContactDO> getContactPage(ContactPageReqVO pageReqVO) { | ||
| 80 | + return contactMapper.selectPage(pageReqVO); | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + @Override | ||
| 84 | + public List<ContactDO> getContactList(ContactExportReqVO exportReqVO) { | ||
| 85 | + return contactMapper.selectList(exportReqVO); | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | +} |
yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/contact/ContactMapper.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | ||
| 3 | +<mapper namespace="cn.iocoder.yudao.module.crm.dal.mysql.contact.ContactMapper"> | ||
| 4 | + | ||
| 5 | + <!-- | ||
| 6 | + 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。 | ||
| 7 | + 无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。 | ||
| 8 | + 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。 | ||
| 9 | + 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/ | ||
| 10 | + --> | ||
| 11 | + | ||
| 12 | +</mapper> |