!727 crm联系人字段修改

Merge pull request !727 from zyna/feature/crm
This commit is contained in:
芋道源码 2023-11-18 12:12:08 +00:00 committed by Gitee
commit bf8bfef8cb
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
15 changed files with 342 additions and 216 deletions

View File

@ -1 +1,28 @@
SET NAMES utf8mb4;
CREATE TABLE `crm_contact` (
`id` bigint(20) 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` varchar(256) COLLATE utf8mb4_unicode_ci 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(20) DEFAULT NULL,
`parent_id` bigint(20) DEFAULT NULL COMMENT '直系上属',
`qq` int(11) DEFAULT NULL,
`webchat` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`sex` int(1) DEFAULT NULL COMMENT '性别',
`policy_makers` bit(1) DEFAULT NULL COMMENT '是否关键决策人',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUAUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='crm联系人';

View File

@ -1,32 +1,43 @@
package cn.iocoder.yudao.module.crm.controller.admin.contact;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*;
import cn.iocoder.yudao.module.crm.convert.contact.ContactConvert;
import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO;
import cn.iocoder.yudao.module.crm.service.contact.ContactService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.NumberUtil;
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerExportReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import com.google.common.collect.Lists;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
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 java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
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 static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
@Tag(name = "管理后台 - CRM 联系人")
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
@ -34,12 +45,16 @@ public class ContactController {
@Resource
private ContactService contactService;
@Resource
private AdminUserApi adminUserApi;
@Resource
private CrmCustomerService crmCustomerService;
@PostMapping("/create")
@Operation(summary = "创建crm联系人")
@PreAuthorize("@ss.hasPermission('crm:contact:create')")
public CommonResult<Long> createContact(@Valid @RequestBody ContactCreateReqVO createReqVO) {
return success(contactService.createContact(createReqVO, getLoginUserId()));
return success(contactService.createContact(createReqVO));
}
@PutMapping("/update")
@ -65,7 +80,12 @@ public class ContactController {
@PreAuthorize("@ss.hasPermission('crm:contact:query')")
public CommonResult<ContactRespVO> getContact(@RequestParam("id") Long id) {
ContactDO contact = contactService.getContact(id);
return success(ContactConvert.INSTANCE.convert(contact));
ContactRespVO contactRespVO = ContactConvert.INSTANCE.convert(contact);
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(CollUtil.removeNull(Lists.newArrayList(
NumberUtil.parseLong(contact.getCreator()))));
contactRespVO.setCreatorName(Optional.ofNullable(userMap.get(NumberUtil.parseLong(contact.getCreator()))).map(AdminUserRespDTO::getNickname).orElse(null));
contactRespVO.setCustomerName(Optional.ofNullable(crmCustomerService.getCustomer(contact.getCustomerId())).map(CrmCustomerDO::getName).orElse(null));
return success(contactRespVO);
}
@GetMapping("/list")
@ -76,13 +96,26 @@ public class ContactController {
List<ContactDO> list = contactService.getContactList(ids);
return success(ContactConvert.INSTANCE.convertList(list));
}
@GetMapping("/simpleAlllist")
@Operation(summary = "获得crm联系人列表")
@PreAuthorize("@ss.hasPermission('crm:contact:query')")
public CommonResult<List<ContactSimpleRespVO>> simpleAlllist() {
List<ContactDO> list = contactService.allContactList();
return success(ContactConvert.INSTANCE.convertAllList(list));
}
@GetMapping("/page")
@Operation(summary = "获得crm联系人分页")
@PreAuthorize("@ss.hasPermission('crm:contact:query')")
public CommonResult<PageResult<ContactRespVO>> getContactPage(@Valid ContactPageReqVO pageVO) {
PageResult<ContactDO> pageResult = contactService.getContactPage(pageVO);
return success(ContactConvert.INSTANCE.convertPage(pageResult));
PageResult<ContactDO> pageData = contactService.getContactPage(pageVO);
PageResult<ContactRespVO> pageResult =ContactConvert.INSTANCE.convertPage(pageData);
//待接口实现后修改
List<CrmCustomerDO> crmCustomerDOList = crmCustomerService.getCustomerList(new CrmCustomerExportReqVO());
Map<Long,CrmCustomerDO> crmCustomerDOMap = crmCustomerDOList.stream().collect(Collectors.toMap(CrmCustomerDO::getId,v->v));
pageResult.getList().forEach(item -> {
item.setCustomerName(Optional.ofNullable(crmCustomerDOMap.get(item.getCustomerId())).map(CrmCustomerDO::getName).orElse(null));
});
return success(pageResult);
}
@GetMapping("/export-excel")
@ -97,12 +130,4 @@ public class ContactController {
ExcelUtils.write(response, "crm联系人.xls", "数据", ContactExcelVO.class, datas);
}
@PutMapping("/transfer")
@Operation(summary = "联系人转移")
@PreAuthorize("@ss.hasPermission('crm:contact:update')")
public CommonResult<Boolean> transfer(@Valid @RequestBody CrmContactTransferReqVO reqVO) {
contactService.transferContact(reqVO, getLoginUserId());
return success(true);
}
}

View File

@ -1,12 +1,17 @@
package cn.iocoder.yudao.module.crm.controller.admin.contact.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.*;
import java.time.LocalDate;
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 javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
/**
@ -16,31 +21,19 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
@Data
public class ContactBaseVO {
// TODO @zyna部分字段缺少 example需要补充
@Schema(description = "联系人名称", example = "张三")
@NotNull(message = "姓名不能为空")
private String name;
@Schema(description = "下次联系时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY)
private LocalDateTime nextTime;
// TODO @zyna缺少 validator 的校验
@Schema(description = "手机号")
private String mobile;
// TODO @zyna缺少 validator 的校验
@Schema(description = "电话")
private String telephone;
// TODO @zyna缺少 validator 的校验
@Schema(description = "电子邮箱")
private String email;
@Schema(description = "职务")
private String post;
// TODO @zyna非空校验
@Schema(description = "客户编号", example = "10795")
private Long customerId;
@ -50,12 +43,32 @@ public class ContactBaseVO {
@Schema(description = "备注", example = "你说的对")
private String remark;
// TODO @zyna这个新建的时候应该不会传递而是后端默认设置自己为负责人
@Schema(description = "负责人用户编号", example = "7648")
private Long ownerUserId;
@Schema(description = "最后跟进时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime lastTime;
@Schema(description = "直属上级", example = "23457")
private Long parentId;
@Schema(description = "姓名", example = "芋艿")
private String name;
@Schema(description = "职位")
private String post;
@Schema(description = "QQ")
private Long qq;
@Schema(description = "微信")
private String webchat;
@Schema(description = "性别")
private Integer sex;
@Schema(description = "是否关键决策人")
private Boolean policyMakers;
@Schema(description = "负责人用户编号", example = "14334")
private String ownerUserId;
}

View File

@ -1,11 +1,11 @@
package cn.iocoder.yudao.module.crm.controller.admin.contact.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import javax.validation.constraints.*;
@Schema(description = "管理后台 - CRM 联系人创建 Request VO")
@Schema(description = "管理后台 - crm联系人创建 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)

View File

@ -2,6 +2,8 @@ package cn.iocoder.yudao.module.crm.controller.admin.contact.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.time.LocalDate;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
@ -17,12 +19,6 @@ import com.alibaba.excel.annotation.ExcelProperty;
@Data
public class ContactExcelVO {
@ExcelProperty("主键")
private Long id;
@ExcelProperty("联系人名称")
private String name;
@ExcelProperty("下次联系时间")
private LocalDateTime nextTime;
@ -35,9 +31,6 @@ public class ContactExcelVO {
@ExcelProperty("电子邮箱")
private String email;
@ExcelProperty("职务")
private String post;
@ExcelProperty("客户编号")
private Long customerId;
@ -47,13 +40,37 @@ public class ContactExcelVO {
@ExcelProperty("备注")
private String remark;
@ExcelProperty("负责人用户编号")
private Long ownerUserId;
@ExcelProperty("创建时间")
private LocalDateTime createTime;
@ExcelProperty("最后跟进时间")
private LocalDateTime lastTime;
@ExcelProperty("主键")
private Long id;
@ExcelProperty("直属上级")
private Long parentId;
@ExcelProperty("姓名")
private String name;
@ExcelProperty("职位")
private String post;
@ExcelProperty("QQ")
private Long qq;
@ExcelProperty("微信")
private String webchat;
@ExcelProperty("性别")
private Integer sex;
@ExcelProperty("是否关键决策人")
private Boolean policyMakers;
@ExcelProperty("负责人用户编号")
private String ownerUserId;
}

View File

@ -1,6 +1,8 @@
package cn.iocoder.yudao.module.crm.controller.admin.contact.vo;
import lombok.*;
import java.time.LocalDate;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
@ -9,13 +11,10 @@ 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 是一致的")
@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;
@ -29,9 +28,6 @@ public class ContactExportReqVO {
@Schema(description = "电子邮箱")
private String email;
@Schema(description = "职务")
private String post;
@Schema(description = "客户编号", example = "10795")
private Long customerId;
@ -41,9 +37,6 @@ public class ContactExportReqVO {
@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;
@ -52,4 +45,28 @@ public class ContactExportReqVO {
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] lastTime;
@Schema(description = "直属上级", example = "23457")
private Long parentId;
@Schema(description = "姓名", example = "芋艿")
private String name;
@Schema(description = "职位")
private String post;
@Schema(description = "QQ")
private Long qq;
@Schema(description = "微信")
private String webchat;
@Schema(description = "性别")
private Integer sex;
@Schema(description = "是否关键决策人")
private Boolean policyMakers;
@Schema(description = "负责人用户编号", example = "14334")
private String ownerUserId;
}

View File

@ -1,27 +1,22 @@
package cn.iocoder.yudao.module.crm.controller.admin.contact.vo;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;
import lombok.*;
import java.time.LocalDate;
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")
@Schema(description = "管理后台 - crm联系人分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ContactPageReqVO extends PageParam {
// TODO @芋艿需要查询的字段
@Schema(description = "联系人名称", example = "张三")
private String name;
@Schema(description = "下次联系时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] nextTime;
@ -35,9 +30,6 @@ public class ContactPageReqVO extends PageParam {
@Schema(description = "电子邮箱")
private String email;
@Schema(description = "职务")
private String post;
@Schema(description = "客户编号", example = "10795")
private Long customerId;
@ -47,9 +39,6 @@ public class ContactPageReqVO extends PageParam {
@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;
@ -58,4 +47,28 @@ public class ContactPageReqVO extends PageParam {
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] lastTime;
@Schema(description = "直属上级", example = "23457")
private Long parentId;
@Schema(description = "姓名", example = "芋艿")
private String name;
@Schema(description = "职位")
private String post;
@Schema(description = "QQ")
private Long qq;
@Schema(description = "微信")
private String webchat;
@Schema(description = "性别")
private Integer sex;
@Schema(description = "是否关键决策人")
private Boolean policyMakers;
@Schema(description = "负责人用户编号", example = "14334")
private String ownerUserId;
}

View File

@ -4,17 +4,19 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - CRM 联系人 Response VO")
@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;
private String creatorName;
@Schema(description = "客户")
private String customerName;
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "3167")
private Long id;
}

View File

@ -0,0 +1,20 @@
package cn.iocoder.yudao.module.crm.controller.admin.contact.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - crm联系人 Response VO")
@Data
@ToString(callSuper = true)
public class ContactSimpleRespVO {
@Schema(description = "姓名", example = "芋艿")
private String name;
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "3167")
private Long id;
}

View File

@ -1,17 +1,18 @@
package cn.iocoder.yudao.module.crm.controller.admin.contact.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.*;
import java.util.*;
import javax.validation.constraints.*;
@Schema(description = "管理后台 - CRM 联系人更新 Request VO")
@Schema(description = "管理后台 - crm联系人更新 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ContactUpdateReqVO extends ContactBaseVO {
@Schema(description = "主键", example = "23210")
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "3167")
@NotNull(message = "主键不能为空")
private Long id;
}

View File

@ -1,18 +1,16 @@
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;
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmTransferPermissionReqBO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
import java.util.List;
/**
* crm 联系人 Convert
* crm联系人 Convert
*
* @author 芋道源码
*/
@ -32,11 +30,6 @@ public interface ContactConvert {
PageResult<ContactRespVO> convertPage(PageResult<ContactDO> page);
List<ContactExcelVO> convertList02(List<ContactDO> list);
@Mappings({
@Mapping(target = "bizId", source = "reqVO.id"),
@Mapping(target = "newOwnerUserId", source = "reqVO.id")
})
CrmTransferPermissionReqBO convert(CrmContactTransferReqVO reqVO, Long userId);
List<ContactSimpleRespVO> convertAllList(List<ContactDO> list);
}

View File

@ -1,15 +1,17 @@
package cn.iocoder.yudao.module.crm.dal.dataobject.contact;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;
import java.time.LocalDate;
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
* crm联系人 DO
*
* @author 芋道源码
*/
@ -23,15 +25,6 @@ import java.time.LocalDateTime;
@AllArgsConstructor
public class ContactDO extends BaseDO {
/**
* 主键
*/
@TableId
private Long id;
/**
* 联系人名称
*/
private String name;
/**
* 下次联系时间
*/
@ -48,14 +41,8 @@ public class ContactDO extends BaseDO {
* 电子邮箱
*/
private String email;
/**
* 职务
*/
private String post;
/**
* 客户编号
*
* TODO @zyna关联的字段也要写下
*/
private Long customerId;
/**
@ -70,5 +57,42 @@ public class ContactDO extends BaseDO {
* 最后跟进时间
*/
private LocalDateTime lastTime;
/**
* 主键
*/
@TableId
private Long id;
/**
* 直属上级
*/
private Long parentId;
/**
* 姓名
*/
private String name;
/**
* 职位
*/
private String post;
/**
* QQ
*/
private Long qq;
/**
* 微信
*/
private String webchat;
/**
* 性别
*/
private Integer sex;
/**
* 是否关键决策人
*/
private Boolean policyMakers;
/**
* 负责人用户编号
*/
private String ownerUserId;
}

View File

@ -1,14 +1,13 @@
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.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.ContactExportReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.ContactPageReqVO;
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 java.util.List;
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*;
/**
* crm联系人 Mapper
@ -20,33 +19,45 @@ public interface ContactMapper extends BaseMapperX<ContactDO> {
default PageResult<ContactDO> selectPage(ContactPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<ContactDO>()
.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())
.betweenIfPresent(ContactDO::getCreateTime, reqVO.getCreateTime())
.betweenIfPresent(ContactDO::getLastTime, reqVO.getLastTime())
.eqIfPresent(ContactDO::getParentId, reqVO.getParentId())
.likeIfPresent(ContactDO::getName, reqVO.getName())
.eqIfPresent(ContactDO::getPost, reqVO.getPost())
.eqIfPresent(ContactDO::getQq, reqVO.getQq())
.eqIfPresent(ContactDO::getWebchat, reqVO.getWebchat())
.eqIfPresent(ContactDO::getSex, reqVO.getSex())
.eqIfPresent(ContactDO::getPolicyMakers, reqVO.getPolicyMakers())
.eqIfPresent(ContactDO::getOwnerUserId, reqVO.getOwnerUserId())
.orderByDesc(ContactDO::getId));
}
default List<ContactDO> selectList(ContactExportReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<ContactDO>()
.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())
.betweenIfPresent(ContactDO::getCreateTime, reqVO.getCreateTime())
.betweenIfPresent(ContactDO::getLastTime, reqVO.getLastTime())
.eqIfPresent(ContactDO::getParentId, reqVO.getParentId())
.likeIfPresent(ContactDO::getName, reqVO.getName())
.eqIfPresent(ContactDO::getPost, reqVO.getPost())
.eqIfPresent(ContactDO::getQq, reqVO.getQq())
.eqIfPresent(ContactDO::getWebchat, reqVO.getWebchat())
.eqIfPresent(ContactDO::getSex, reqVO.getSex())
.eqIfPresent(ContactDO::getPolicyMakers, reqVO.getPolicyMakers())
.eqIfPresent(ContactDO::getOwnerUserId, reqVO.getOwnerUserId())
.orderByDesc(ContactDO::getId));
}

View File

@ -1,12 +1,10 @@
package cn.iocoder.yudao.module.crm.service.contact;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
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 javax.validation.Valid;
import java.util.Collection;
import java.util.List;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
/**
* crm联系人 Service 接口
@ -19,10 +17,9 @@ public interface ContactService {
* 创建crm联系人
*
* @param createReqVO 创建信息
* @param userId 用户编号
* @return 编号
*/
Long createContact(@Valid ContactCreateReqVO createReqVO, Long userId);
Long createContact(@Valid ContactCreateReqVO createReqVO);
/**
* 更新crm联系人
@ -71,11 +68,8 @@ public interface ContactService {
List<ContactDO> getContactList(ContactExportReqVO exportReqVO);
/**
* 联系人编号
*
* @param reqVO 请求
* @param userId 用户编号
* 获取所有联系人列表只返回姓名和id
* @return 所有联系人列表
*/
void transferContact(CrmContactTransferReqVO reqVO, Long userId);
List<ContactDO> allContactList();
}

View File

@ -1,27 +1,22 @@
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;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*;
import cn.iocoder.yudao.module.crm.convert.contact.ContactConvert;
import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO;
import cn.iocoder.yudao.module.crm.dal.mysql.contact.ContactMapper;
import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission;
import cn.iocoder.yudao.module.crm.framework.enums.CrmBizTypeEnum;
import cn.iocoder.yudao.module.crm.framework.enums.CrmPermissionLevelEnum;
import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CONTACT_NOT_EXISTS;
/**
* crm联系人 Service 实现类
@ -35,41 +30,25 @@ public class ContactServiceImpl implements ContactService {
@Resource
private ContactMapper contactMapper;
@Resource
private CrmPermissionService crmPermissionService;
@Override
public Long createContact(ContactCreateReqVO createReqVO, Long userId) {
// TODO @customerId需要校验存在
public Long createContact(ContactCreateReqVO createReqVO) {
// 插入
ContactDO contact = ContactConvert.INSTANCE.convert(createReqVO);
contactMapper.insert(contact);
// 创建数据权限
crmPermissionService.createPermission(new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_CONTACTS.getType())
.setBizId(contact.getId()).setUserId(userId).setPermissionLevel(CrmPermissionLevelEnum.OWNER.getLevel())); // 设置当前操作的人为负责人
// 返回
return contact.getId();
}
@Override
@Transactional(rollbackFor = Exception.class)
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACTS, getIdFor = ContactUpdateReqVO.class,
permissionLevel = CrmPermissionLevelEnum.WRITE)
public void updateContact(ContactUpdateReqVO updateReqVO) {
// 校验存在
validateContactExists(updateReqVO.getId());
// TODO @customerId需要校验存在
// 更新
ContactDO updateObj = ContactConvert.INSTANCE.convert(updateReqVO);
contactMapper.updateById(updateObj);
}
@Override
@Transactional(rollbackFor = Exception.class)
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACTS, permissionLevel = CrmPermissionLevelEnum.WRITE)
public void deleteContact(Long id) {
// 校验存在
validateContactExists(id);
@ -77,16 +56,13 @@ public class ContactServiceImpl implements ContactService {
contactMapper.deleteById(id);
}
private ContactDO validateContactExists(Long id) {
ContactDO contact = contactMapper.selectById(id);
if (contact == null) {
private void validateContactExists(Long id) {
if (contactMapper.selectById(id) == null) {
throw exception(CONTACT_NOT_EXISTS);
}
return contact;
}
@Override
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACTS, permissionLevel = CrmPermissionLevelEnum.READ)
public ContactDO getContact(Long id) {
return contactMapper.selectById(id);
}
@ -110,15 +86,8 @@ public class ContactServiceImpl implements ContactService {
}
@Override
public void transferContact(CrmContactTransferReqVO reqVO, Long userId) {
// 1 校验联系人是否存在
validateContactExists(reqVO.getId());
// 2. 数据权限转移
crmPermissionService.transferPermission(
ContactConvert.INSTANCE.convert(reqVO, userId).setBizType(CrmBizTypeEnum.CRM_CONTACTS.getType()));
// 3. TODO 记录转移日志
public List<ContactDO> allContactList() {
return contactMapper.selectList();
}
}