feat: 调整客户表的字段

This commit is contained in:
Wanwan 2023-10-28 22:47:56 +08:00
parent 81b6aebf47
commit c18f5baa4b
15 changed files with 95 additions and 98 deletions

View File

@ -203,8 +203,6 @@ CREATE TABLE `crm_customer` (
`rw_user_ids` varchar(4096) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '读写权限的用户编号数组',
`area_id` bigint DEFAULT NULL COMMENT '地区编号',
`detail_address` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '详细地址',
`longitude` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '地理位置经度',
`latitude` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '地理位置维度',
`contact_last_time` datetime DEFAULT NULL COMMENT '最后跟进时间',
`contact_next_time` datetime DEFAULT NULL COMMENT '下次联系时间',
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '创建者',

View File

@ -19,7 +19,6 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.util.Collection;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

View File

@ -6,8 +6,10 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@ -23,16 +25,6 @@ public class CrmCustomerBaseVO {
@NotEmpty(message = "客户名称不能为空")
private String name;
// TODO wanwan这个字段应该只有 RespVO 会有创建和修改不传递
@Schema(description = "跟进状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
@NotNull(message = "跟进状态不能为空")
private Boolean followUpStatus;
// TODO wanwan这个字段应该只有 RespVO 会有创建和修改不传递
@Schema(description = "锁定状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
@NotNull(message = "锁定状态不能为空")
private Boolean lockStatus;
@Schema(description = "手机", example = "18000000000")
@Mobile
private String mobile;
@ -44,32 +36,32 @@ public class CrmCustomerBaseVO {
@Schema(description = "网址", example = "https://www.baidu.com")
private String website;
@Schema(description = "QQ", example = "123456789")
@Size(max = 20, message = "QQ长度不能超过20个字符")
private String qq;
@Schema(description = "wechat", example = "123456789")
@Size(max = 255, message = "微信长度不能超过255个字符")
private String wechat;
@Schema(description = "email", example = "123456789@qq.com")
@Email(message = "邮箱格式不正确")
@Size(max = 255, message = "邮箱长度不能超过255个字符")
private String email;
@Schema(description = "客户描述", example = "任意文字")
@Size(max = 4096, message = "客户描述长度不能超过255个字符")
private String description;
@Schema(description = "备注", example = "随便")
private String remark;
// TODO wanwan这个字段应该只有 RespVO 会有创建和修改不传递因为它会在移交里面做哈
@Schema(description = "负责人的用户编号", example = "25682")
@NotNull(message = "负责人不能为空")
private Long ownerUserId;
@Schema(description = "地区编号", example = "20158")
private Long areaId;
@Schema(description = "详细地址", example = "北京市海淀区")
private String detailAddress;
// TODO @芋艿longitudelatitude 这两个字段删除
@Schema(description = "地理位置经度", example = "116.40341")
private String longitude;
@Schema(description = "地理位置维度", example = "39.92409")
private String latitude;
// TODO wanwan这个字段应该只有 RespVO 会有创建和修改不传递
@Schema(description = "最后跟进时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime contactLastTime;
@Schema(description = "下次联系时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime contactNextTime;

View File

@ -11,12 +11,4 @@ import lombok.ToString;
@ToString(callSuper = true)
public class CrmCustomerCreateReqVO extends CrmCustomerBaseVO {
// TODO @wanwan类型应该是传递 List<Long>; 不过这个字段默认新建的时候不传递移交功能里管理
@Schema(description = "只读权限的用户编号数组")
private String roUserIds;
// TODO @wanwan类型应该是传递 List<Long>; 不过这个字段默认新建的时候不传递移交功能里管理
@Schema(description = "读写权限的用户编号数组")
private String rwUserIds;
}

View File

@ -44,6 +44,18 @@ public class CrmCustomerExcelVO {
@ExcelProperty("网址")
private String website;
@ExcelProperty("QQ")
private String qq;
@ExcelProperty("wechat")
private String wechat;
@ExcelProperty("email")
private String email;
@ExcelProperty("客户描述")
private String description;
@ExcelProperty("备注")
private String remark;
@ -56,12 +68,6 @@ public class CrmCustomerExcelVO {
@ExcelProperty("详细地址")
private String detailAddress;
@ExcelProperty("地理位置经度")
private String longitude;
@ExcelProperty("地理位置维度")
private String latitude;
@ExcelProperty("最后跟进时间")
private LocalDateTime contactLastTime;

View File

@ -14,10 +14,4 @@ public class CrmCustomerExportReqVO {
@Schema(description = "手机", example = "18000000000")
private String mobile;
@Schema(description = "电话", example = "18000000000")
private String telephone;
@Schema(description = "网址", example = "https://www.baidu.com")
private String website;
}

View File

@ -18,13 +18,5 @@ public class CrmCustomerPageReqVO extends PageParam {
@Schema(description = "手机", example = "18000000000")
private String mobile;
// TODO @wanwan这个字段不需要哈
@Schema(description = "电话", example = "18000000000")
private String telephone;
// TODO @wanwan这个字段不需要哈
@Schema(description = "网址", example = "https://www.baidu.com")
private String website;
// TODO @芋艿场景
}

View File

@ -4,9 +4,12 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
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 = "管理后台 - 客户 Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ -16,9 +19,22 @@ public class CrmCustomerRespVO extends CrmCustomerBaseVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563")
private Long id;
@Schema(description = "跟进状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
private Boolean followUpStatus;
@Schema(description = "锁定状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
private Boolean lockStatus;
@Schema(description = "成交状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
private Boolean dealStatus;
@Schema(description = "负责人的用户编号", example = "25682")
private Long ownerUserId;
@Schema(description = "最后跟进时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime contactLastTime;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
private LocalDateTime createTime;

View File

@ -17,11 +17,4 @@ public class CrmCustomerUpdateReqVO extends CrmCustomerBaseVO {
@NotNull(message = "编号不能为空")
private Long id;
// TODO @wanwan下面两个字段 CrmCustomerCreateReqVO
@Schema(description = "只读权限的用户编号数组")
private String roUserIds;
@Schema(description = "读写权限的用户编号数组")
private String rwUserIds;
}

View File

@ -1,12 +1,15 @@
package cn.iocoder.yudao.module.crm.dal.dataobject.customer;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;
import java.time.LocalDateTime;
import java.util.List;
// TODO 芋艿调整下字段
/**
@ -14,7 +17,7 @@ import java.time.LocalDateTime;
*
* @author Wanwan
*/
@TableName("crm_customer")
@TableName(value = "crm_customer", autoResultMap = true)
@KeySequence("crm_customer_seq") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写
@Data
@EqualsAndHashCode(callSuper = true)
@ -57,6 +60,22 @@ public class CrmCustomerDO extends BaseDO {
* 网址
*/
private String website;
/**
* QQ
*/
private String qq;
/**
* wechat
*/
private String wechat;
/**
* email
*/
private String email;
/**
* 客户描述
*/
private String description;
/**
* 备注
*/
@ -65,15 +84,16 @@ public class CrmCustomerDO extends BaseDO {
* 负责人的用户编号
*/
private Long ownerUserId;
// TODO @wanwan下面两个字段使用 List<Long>然后使用 typeHandler = LongListTypeHandler 解决持久化的问题注意类上需要加 autoResultMap = true
/**
* 只读权限的用户编号数组
*/
private String roUserIds;
@TableField(typeHandler = LongListTypeHandler.class)
private List<Long> roUserIds;
/**
* 读写权限的用户编号数组
*/
private String rwUserIds;
@TableField(typeHandler = LongListTypeHandler.class)
private List<Long> rwUserIds;
/**
* 地区编号
*/
@ -82,15 +102,6 @@ public class CrmCustomerDO extends BaseDO {
* 详细地址
*/
private String detailAddress;
// TODO @wanwan下面两个字段删除
/**
* 地理位置经度
*/
private String longitude;
/**
* 地理位置维度
*/
private String latitude;
/**
* 最后跟进时间
*/

View File

@ -22,8 +22,6 @@ public interface CrmCustomerMapper extends BaseMapperX<CrmCustomerDO> {
return selectPage(reqVO, new LambdaQueryWrapperX<CrmCustomerDO>()
.likeIfPresent(CrmCustomerDO::getName, reqVO.getName())
.eqIfPresent(CrmCustomerDO::getMobile, reqVO.getMobile())
.eqIfPresent(CrmCustomerDO::getTelephone, reqVO.getTelephone())
.likeIfPresent(CrmCustomerDO::getWebsite, reqVO.getWebsite())
.orderByDesc(CrmCustomerDO::getId));
}
@ -31,8 +29,6 @@ public interface CrmCustomerMapper extends BaseMapperX<CrmCustomerDO> {
return selectList(new LambdaQueryWrapperX<CrmCustomerDO>()
.likeIfPresent(CrmCustomerDO::getName, reqVO.getName())
.eqIfPresent(CrmCustomerDO::getMobile, reqVO.getMobile())
.eqIfPresent(CrmCustomerDO::getTelephone, reqVO.getTelephone())
.likeIfPresent(CrmCustomerDO::getWebsite, reqVO.getWebsite())
.orderByDesc(CrmCustomerDO::getId));
}

View File

@ -39,7 +39,7 @@ public class CrmClueServiceImpl implements CrmClueService {
@Override
public Long createClue(CrmClueCreateReqVO createReqVO) {
// 校验客户是否存在
validateCustomerExists(createReqVO.getCustomerId());
customerService.validateCustomer(createReqVO.getCustomerId());
// 插入
CrmClueDO clue = CrmClueConvert.INSTANCE.convert(createReqVO);
clueMapper.insert(clue);
@ -52,7 +52,7 @@ public class CrmClueServiceImpl implements CrmClueService {
// 校验存在
validateClueExists(updateReqVO.getId());
// 校验客户是否存在
validateCustomerExists(updateReqVO.getCustomerId());
customerService.validateCustomer(updateReqVO.getCustomerId());
// 更新
CrmClueDO updateObj = CrmClueConvert.INSTANCE.convert(updateReqVO);
@ -96,16 +96,4 @@ public class CrmClueServiceImpl implements CrmClueService {
return clueMapper.selectList(exportReqVO);
}
// TODO @wanwan可以在 CrmClueServiceImpl 增加一个方法用于校验客户是否存在validateCustomer然后其它方法可以调用它不过要注意需要把 CustomerDO 返回因为其它模块可能要它的信息
/**
* 校验客户是否存在
*
* @param customerId 客户id
*/
private void validateCustomerExists(Long customerId) {
if (customerService.getCustomer(customerId) == null) {
throw exception(CUSTOMER_NOT_EXISTS);
}
}
}

View File

@ -72,4 +72,12 @@ public interface CrmCustomerService {
*/
List<CrmCustomerDO> getCustomerList(CrmCustomerExportReqVO exportReqVO);
/**
* 校验客户是否存在
*
* @param customerId 客户id
* @return
*/
CrmCustomerDO validateCustomer(Long customerId);
}

View File

@ -85,4 +85,18 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
return customerMapper.selectList(exportReqVO);
}
/**
* 校验客户是否存在
*
* @param customerId 客户id
* @return
*/
@Override
public CrmCustomerDO validateCustomer(Long customerId) {
CrmCustomerDO customer = getCustomer(customerId);
if (Objects.isNull(customer)) {
throw exception(CUSTOMER_NOT_EXISTS);
}
return customer;
}
}

View File

@ -113,8 +113,6 @@ CREATE TABLE IF NOT EXISTS "crm_customer" (
"rw_user_ids" varchar,
"area_id" bigint,
"detail_address" varchar,
"longitude" varchar,
"latitude" varchar,
"contact_last_time" varchar,
"contact_next_time" varchar,
"creator" varchar DEFAULT '',