mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-26 17:21:53 +08:00
CRM: 新增关注数据模块
This commit is contained in:
parent
72969e921e
commit
9c1687dc25
@ -63,7 +63,10 @@ public interface ErrorCodeConstants {
|
||||
// ========== 商机状态 1_020_011_000 ==========
|
||||
ErrorCode BUSINESS_STATUS_NOT_EXISTS = new ErrorCode(1_020_011_000, "商机状态不存在");
|
||||
|
||||
// ========== 客户公海规则设置 1_020_011_000 ==========
|
||||
// ========== 客户公海规则设置 1_020_012_000 ==========
|
||||
ErrorCode CUSTOMER_LIMIT_CONFIG_NOT_EXISTS = new ErrorCode(1_020_012_000, "客户限制配置不存在");
|
||||
|
||||
// ========== 关注的数据 1_020_013_000 ==========
|
||||
ErrorCode CRM_CONCERNED_NOT_EXISTS = new ErrorCode(1_020_013_000, "关注数据不存在");
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,51 @@
|
||||
package cn.iocoder.yudao.module.crm.dal.dataobject.concerned;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* CRM 关注的数据 DO
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@TableName("crm_concerned")
|
||||
@KeySequence("crm_concerned_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class CrmConcernedDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 编号,主键自增
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 数据类型
|
||||
*
|
||||
* 枚举 {@link CrmBizTypeEnum}
|
||||
*/
|
||||
private Integer bizType;
|
||||
/**
|
||||
* 数据编号
|
||||
*
|
||||
* 关联 {@link CrmBizTypeEnum} 对应模块 DO 的 id 字段
|
||||
*/
|
||||
private Long bizId;
|
||||
|
||||
/**
|
||||
* 用户编号
|
||||
*
|
||||
* 关联 AdminUser 的 id 字段
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package cn.iocoder.yudao.module.crm.dal.mysql.concerned;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.concerned.CrmConcernedDO;
|
||||
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* CRM 关注的数据 Mapper
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Mapper
|
||||
public interface CrmConcernedMapper extends BaseMapperX<CrmConcernedDO> {
|
||||
|
||||
/**
|
||||
* 查询用户关注的数据
|
||||
*
|
||||
* @param bizType 数据类型,关联 {@link CrmBizTypeEnum}
|
||||
* @param bizIds 数据编号,关联 {@link CrmBizTypeEnum} 对应模块 DO#getId()
|
||||
* @param userId 用户编号
|
||||
* @return 关注的数据
|
||||
*/
|
||||
default List<CrmConcernedDO> selectList(Integer bizType, Collection<Long> bizIds, Long userId) {
|
||||
return selectList(new LambdaQueryWrapperX<CrmConcernedDO>()
|
||||
.eq(CrmConcernedDO::getBizType, bizType)
|
||||
.in(CrmConcernedDO::getBizId, bizIds)
|
||||
.eq(CrmConcernedDO::getUserId, userId));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package cn.iocoder.yudao.module.crm.service.concerned;
|
||||
|
||||
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
||||
import cn.iocoder.yudao.module.crm.service.concerned.bo.CrmConcernedCreateReqBO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* CRM 关注的数据 Service 接口
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
public interface CrmConcernedService {
|
||||
|
||||
/**
|
||||
* 创建关注数据
|
||||
*
|
||||
* @param createReqBO 创建请求
|
||||
* @return 编号
|
||||
*/
|
||||
Long createConcerned(@Valid CrmConcernedCreateReqBO createReqBO);
|
||||
|
||||
/**
|
||||
* 批量创建关注数据
|
||||
*
|
||||
* @param createReqBO 创建请求
|
||||
*/
|
||||
void createConcernedBatch(@Valid Collection<CrmConcernedCreateReqBO> createReqBO);
|
||||
|
||||
/**
|
||||
* 删除关注数据
|
||||
*
|
||||
* @param bizType 数据类型,关联 {@link CrmBizTypeEnum}
|
||||
* @param bizIds 数据编号,关联 {@link CrmBizTypeEnum} 对应模块 DO#getId()
|
||||
* @param userId 用户编号
|
||||
*/
|
||||
void deleteConcerned(Integer bizType, Collection<Long> bizIds, Long userId);
|
||||
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
package cn.iocoder.yudao.module.crm.service.concerned;
|
||||
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.concerned.CrmConcernedDO;
|
||||
import cn.iocoder.yudao.module.crm.dal.mysql.concerned.CrmConcernedMapper;
|
||||
import cn.iocoder.yudao.module.crm.service.concerned.bo.CrmConcernedCreateReqBO;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
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.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CRM_CONCERNED_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
* CRM 关注的数据 Service 接口实现类
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class CrmConcernedServiceImpl implements CrmConcernedService {
|
||||
|
||||
@Resource
|
||||
private CrmConcernedMapper concernedMapper;
|
||||
@Resource
|
||||
private AdminUserApi adminUserApi;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long createConcerned(CrmConcernedCreateReqBO createReqBO) {
|
||||
// 1. 校验用户是否存在
|
||||
adminUserApi.validateUserList(Collections.singletonList(createReqBO.getUserId()));
|
||||
|
||||
// 2. 创建
|
||||
CrmConcernedDO concerned = BeanUtils.toBean(createReqBO, CrmConcernedDO.class);
|
||||
concernedMapper.insert(concerned);
|
||||
return concerned.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createConcernedBatch(Collection<CrmConcernedCreateReqBO> createReqBO) {
|
||||
// 1. 校验用户是否存在
|
||||
adminUserApi.validateUserList(convertSet(createReqBO, CrmConcernedCreateReqBO::getUserId));
|
||||
|
||||
// 2. 创建
|
||||
List<CrmConcernedDO> concernedList = convertList(createReqBO, item -> BeanUtils.toBean(item, CrmConcernedDO.class));
|
||||
concernedMapper.insertBatch(concernedList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteConcerned(Integer bizType, Collection<Long> bizIds, Long userId) {
|
||||
// 1. 查询关注数据
|
||||
List<CrmConcernedDO> concernedList = concernedMapper.selectList(bizType, bizIds, userId);
|
||||
if (ObjUtil.notEqual(bizIds.size(), concernedList.size())) {
|
||||
throw exception(CRM_CONCERNED_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 删除
|
||||
concernedMapper.deleteBatchIds(convertList(concernedList, CrmConcernedDO::getId));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package cn.iocoder.yudao.module.crm.service.concerned.bo;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* CRM 关注的数据 Create Req BO
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Data
|
||||
public class CrmConcernedCreateReqBO {
|
||||
|
||||
/**
|
||||
* 当前登录用户编号
|
||||
*/
|
||||
@NotNull(message = "用户编号不能为空")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* Crm 类型
|
||||
*/
|
||||
@NotNull(message = "Crm 类型不能为空")
|
||||
@InEnum(CrmBizTypeEnum.class)
|
||||
private Integer bizType;
|
||||
/**
|
||||
* 数据编号
|
||||
*/
|
||||
@NotNull(message = "Crm 数据编号不能为空")
|
||||
private Long bizId;
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user