crm:code review 商机类型、状态

This commit is contained in:
YunaiV 2023-11-25 12:02:03 +08:00
parent 3e9eb59de3
commit 63f9bcb0a3
36 changed files with 136 additions and 111 deletions

View File

@ -1,16 +1,18 @@
package cn.iocoder.yudao.module.crm.controller.admin.business;
import cn.hutool.core.collection.CollUtil;
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.business.vo.*;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.*;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusQueryVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeQueryVO;
import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO;
import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService;
import cn.iocoder.yudao.module.crm.service.business.CrmBusinessStatusService;
import cn.iocoder.yudao.module.crm.service.business.CrmBusinessStatusTypeService;
@ -91,17 +93,21 @@ public class CrmBusinessController {
@PreAuthorize("@ss.hasPermission('crm:business:query')")
public CommonResult<PageResult<CrmBusinessRespVO>> getBusinessPage(@Valid CrmBusinessPageReqVO pageVO) {
PageResult<CrmBusinessDO> pageResult = businessService.getBusinessPage(pageVO, getLoginUserId());
//处理客户名称回显
if (CollUtil.isEmpty(pageResult.getList())) {
return success(PageResult.empty(pageResult.getTotal()));
}
// 处理客户名称回显
// TODO @ljlleo可以使用 CollectionUtils.convertSet 替代常用的 stream 操作更简洁一点下面几个也是哈
Set<Long> customerIds = pageResult.getList().stream()
.map(CrmBusinessDO::getCustomerId).filter(Objects::nonNull).collect(Collectors.toSet());
List<CrmCustomerDO> customerList = customerService.getCustomerList(customerIds);
//处理商机状态类型名称回显
// 处理商机状态类型名称回显
Set<Long> statusTypeIds = pageResult.getList().stream()
.map(CrmBusinessDO::getStatusTypeId).filter(Objects::nonNull).collect(Collectors.toSet());
CrmBusinessStatusTypeQueryVO queryStatusTypeVO = new CrmBusinessStatusTypeQueryVO();
queryStatusTypeVO.setIdList(statusTypeIds);
List<CrmBusinessStatusTypeDO> statusTypeList = businessStatusTypeService.selectList(queryStatusTypeVO);
//处理商机状态名称回显
// 处理商机状态名称回显
Set<Long> statusIds = pageResult.getList().stream()
.map(CrmBusinessDO::getCustomerId).filter(Objects::nonNull).collect(Collectors.toSet());
CrmBusinessStatusQueryVO queryVO = new CrmBusinessStatusQueryVO();

View File

@ -7,7 +7,12 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
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.business.vo.*;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusQueryVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusRespVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypePageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeQueryVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeRespVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeSaveReqVO;
import cn.iocoder.yudao.module.crm.convert.businessstatus.CrmBusinessStatusConvert;
import cn.iocoder.yudao.module.crm.convert.businessstatustype.CrmBusinessStatusTypeConvert;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO;
@ -81,7 +86,8 @@ public class CrmBusinessStatusTypeController {
@PreAuthorize("@ss.hasPermission('crm:business-status-type:query')")
public CommonResult<CrmBusinessStatusTypeRespVO> getBusinessStatusType(@RequestParam("id") Long id) {
CrmBusinessStatusTypeDO businessStatusType = businessStatusTypeService.getBusinessStatusType(id);
//处理状态回显
// 处理状态回显
// TODO @ljlleo可以使用 CollectionUtils.convertSet 替代常用的 stream 操作更简洁一点下面几个也是哈
CrmBusinessStatusQueryVO queryVO = new CrmBusinessStatusQueryVO();
queryVO.setTypeId(id);
List<CrmBusinessStatusDO> statusList = businessStatusService.selectList(queryVO);
@ -93,7 +99,8 @@ public class CrmBusinessStatusTypeController {
@PreAuthorize("@ss.hasPermission('crm:business-status-type:query')")
public CommonResult<PageResult<CrmBusinessStatusTypeRespVO>> getBusinessStatusTypePage(@Valid CrmBusinessStatusTypePageReqVO pageReqVO) {
PageResult<CrmBusinessStatusTypeDO> pageResult = businessStatusTypeService.getBusinessStatusTypePage(pageReqVO);
//处理部门回显
// 处理部门回显
// TODO @ljlleo可以使用 CollectionUtils.convertSet 替代常用的 stream 操作更简洁一点下面几个也是哈
Set<Long> deptIds = pageResult.getList().stream()
.map(CrmBusinessStatusTypeDO::getDeptIds)
.filter(Objects::nonNull)
@ -126,6 +133,7 @@ public class CrmBusinessStatusTypeController {
return success(BeanUtils.toBean(list, CrmBusinessStatusTypeRespVO.class));
}
// TODO @ljlleo 这个接口是不是可以和 getBusinessStatusTypeList 合并成一个
@GetMapping("/get-status-list")
@Operation(summary = "获得商机状态列表")
@PreAuthorize("@ss.hasPermission('crm:business-status:query')")
@ -135,4 +143,5 @@ public class CrmBusinessStatusTypeController {
List<CrmBusinessStatusDO> list = businessStatusService.selectList(queryVO);
return success(CrmBusinessStatusConvert.INSTANCE.convertList(list));
}
}

View File

@ -1,4 +0,0 @@
/**
* 商机销售机会
*/
package cn.iocoder.yudao.module.crm.controller.admin.business;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.crm.controller.admin.business.vo;
package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.crm.controller.admin.business.vo;
package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.crm.controller.admin.business.vo;
package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.crm.controller.admin.business.vo;
package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.crm.controller.admin.business.vo;
package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.crm.controller.admin.business.vo;
package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
@ -16,13 +16,13 @@ public class CrmBusinessRespVO extends CrmBusinessBaseVO {
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
private LocalDateTime createTime;
@Schema(description = "客户名称")
@Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
private String customerName;
@Schema(description = "状态类型名称")
@Schema(description = "状态类型名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "进行中")
private String statusTypeName;
@Schema(description = "状态名称")
@Schema(description = "状态名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "跟进中")
private String statusName;
}

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.crm.controller.admin.business.vo;
package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business;
import cn.iocoder.yudao.module.crm.framework.enums.CrmPermissionLevelEnum;
import io.swagger.v3.oas.annotations.media.Schema;

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.crm.controller.admin.business.vo;
package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessBaseVO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.crm.controller.admin.business.vo;
package cn.iocoder.yudao.module.crm.controller.admin.business.vo.status;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.crm.controller.admin.business.vo;
package cn.iocoder.yudao.module.crm.controller.admin.business.vo.status;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.crm.controller.admin.business.vo;
package cn.iocoder.yudao.module.crm.controller.admin.business.vo.status;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
@ -26,7 +26,7 @@ public class CrmBusinessStatusRespVO {
@ExcelProperty("赢单率")
private String percent;
@Schema(description = "排序")
@Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@ExcelProperty("排序")
private Integer sort;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.crm.controller.admin.business.vo;
package cn.iocoder.yudao.module.crm.controller.admin.business.vo.status;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@ -21,9 +21,11 @@ public class CrmBusinessStatusSaveReqVO {
@NotEmpty(message = "状态名不能为空")
private String name;
// TODO @lilleopercent 应该是 Integer
@Schema(description = "赢单率")
private String percent;
// TODO @lilleo这个是不是不用前端新增和修改的时候传递交给顺序计算出来存储起来就好了
@Schema(description = "排序")
private Integer sort;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.crm.controller.admin.business.vo;
package cn.iocoder.yudao.module.crm.controller.admin.business.vo.type;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.crm.controller.admin.business.vo;
package cn.iocoder.yudao.module.crm.controller.admin.business.vo.type;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.crm.controller.admin.business.vo;
package cn.iocoder.yudao.module.crm.controller.admin.business.vo.type;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
@ -22,13 +22,12 @@ public class CrmBusinessStatusTypeRespVO {
@ExcelProperty("状态类型名")
private String name;
@Schema(description = "使用的部门名称", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("使用的部门名称")
private List<String> deptNames;
@Schema(description = "使用的部门编号", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("使用的部门编号")
private List<Long> deptIds;
@Schema(description = "使用的部门名称", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("使用的部门名称")
private List<String> deptNames;
@Schema(description = "创建人", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建人")
@ -38,6 +37,7 @@ public class CrmBusinessStatusTypeRespVO {
@ExcelProperty("创建时间")
private LocalDateTime createTime;
// TODO @ljlleo 字段后缀改成 statuses保持和 deptIds 风格一致CrmBusinessStatusDO 改成 VO 一般不使用 do 直接返回
@Schema(description = "状态集合", requiredMode = Schema.RequiredMode.REQUIRED)
private List<CrmBusinessStatusDO> statusList;

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.crm.controller.admin.business.vo;
package cn.iocoder.yudao.module.crm.controller.admin.business.vo.type;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusSaveReqVO;
import com.google.common.collect.Lists;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@ -21,6 +22,7 @@ public class CrmBusinessStatusTypeSaveReqVO {
@Schema(description = "使用的部门编号", requiredMode = Schema.RequiredMode.REQUIRED)
private List<Long> deptIds = Lists.newArrayList();
// TODO @ljlleo VO 里面我们不使用默认值哈这里 Lists.newArrayList() 看看怎么去掉上面 deptIds 也是类似噢
@Schema(description = "商机状态集合", requiredMode = Schema.RequiredMode.REQUIRED)
private List<CrmBusinessStatusSaveReqVO> statusList = Lists.newArrayList();

View File

@ -1,7 +1,7 @@
package cn.iocoder.yudao.module.crm.convert.business;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.*;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.*;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO;
@ -46,14 +46,14 @@ public interface CrmBusinessConvert {
default PageResult<CrmBusinessRespVO> convertPage(PageResult<CrmBusinessDO> page, List<CrmCustomerDO> customerList,
List<CrmBusinessStatusTypeDO> statusTypeList, List<CrmBusinessStatusDO> statusList) {
PageResult<CrmBusinessRespVO> result = convertPage(page);
// 拼接关联字段
Map<Long, String> customerMap = convertMap(customerList, CrmCustomerDO::getId, CrmCustomerDO::getName);
Map<Long, String> statusTypeMap = convertMap(statusTypeList, CrmBusinessStatusTypeDO::getId, CrmBusinessStatusTypeDO::getName);
Map<Long, String> statusMap = convertMap(statusList, CrmBusinessStatusDO::getId, CrmBusinessStatusDO::getName);
result.getList().stream().forEach(t -> {
t.setCustomerName(customerMap.get(t.getCustomerId()));
t.setStatusTypeName(statusTypeMap.get(t.getStatusTypeId()));
t.setStatusName(statusMap.get(t.getStatusId()));
});
result.getList().forEach(type -> type
.setCustomerName(customerMap.get(type.getCustomerId()))
.setStatusTypeName(statusTypeMap.get(type.getStatusTypeId()))
.setStatusName(statusMap.get(type.getStatusId())));
return result;
}

View File

@ -1,8 +1,8 @@
package cn.iocoder.yudao.module.crm.convert.businessstatus;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessStatusRespVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessStatusSaveReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusRespVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusSaveReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

View File

@ -1,8 +1,8 @@
package cn.iocoder.yudao.module.crm.convert.businessstatustype;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessStatusTypeRespVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessStatusTypeSaveReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeRespVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeSaveReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO;
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
@ -33,18 +33,17 @@ public interface CrmBusinessStatusTypeConvert {
default PageResult<CrmBusinessStatusTypeRespVO> convertPage(PageResult<CrmBusinessStatusTypeDO> page, List<DeptRespDTO> deptList) {
PageResult<CrmBusinessStatusTypeRespVO> pageResult = convertPage(page);
// 拼接关联字段
Map<Long, String> deptMap = convertMap(deptList, DeptRespDTO::getId, DeptRespDTO::getName);
pageResult.getList().stream().forEach(r -> {
r.setDeptNames(convertList(r.getDeptIds(), deptMap::get));
});
pageResult.getList().forEach(type -> type.setDeptNames(convertList(type.getDeptIds(), deptMap::get)));
return pageResult;
}
default CrmBusinessStatusTypeRespVO convert(CrmBusinessStatusTypeDO bean, List<CrmBusinessStatusDO> statusList) {
// TODO @ljlleo 可以链式赋值简化成一行
CrmBusinessStatusTypeRespVO result = convert(bean);
result.setStatusList(statusList);
return result;
}
}

View File

@ -69,8 +69,7 @@ public class CrmBusinessDO extends BaseDO {
*/
private Integer discountPercent;
/**
* 产品总金额
*
* 产品总金额单位
*/
private Integer productPrice;
/**

View File

@ -26,6 +26,8 @@ public class CrmBusinessStatusDO {
private Long id;
/**
* 状态类型编号
*
* 关联 {@link CrmBusinessStatusTypeDO#getId()}
*/
private Long typeId;
/**
@ -34,6 +36,8 @@ public class CrmBusinessStatusDO {
private String name;
/**
* 赢单率
*
* TODO 这里是不是改成 Integer 存储百分比 * 100
*/
private String percent;
/**

View File

@ -41,6 +41,8 @@ public class CrmBusinessStatusTypeDO extends BaseDO {
private List<Long> deptIds;
/**
* 开启状态
*
* TODO 改成 Integer关联 CommonStatus
*/
private Boolean status;

View File

@ -3,8 +3,8 @@ package cn.iocoder.yudao.module.crm.dal.mysql.business;
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.business.vo.CrmBusinessExportReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessPageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessExportReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessPageReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
import org.apache.ibatis.annotations.Mapper;

View File

@ -3,8 +3,8 @@ package cn.iocoder.yudao.module.crm.dal.mysql.business;
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.business.vo.CrmBusinessStatusPageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessStatusQueryVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusPageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusQueryVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO;
import org.apache.ibatis.annotations.Mapper;
@ -31,8 +31,7 @@ public interface CrmBusinessStatusMapper extends BaseMapperX<CrmBusinessStatusDO
}
default int delete(Long typeId) {
return delete(new LambdaQueryWrapperX<CrmBusinessStatusDO>()
.eq(CrmBusinessStatusDO::getTypeId, typeId));
return delete(CrmBusinessStatusDO::getTypeId, typeId);
}
}

View File

@ -3,8 +3,8 @@ package cn.iocoder.yudao.module.crm.dal.mysql.business;
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.business.vo.CrmBusinessStatusTypePageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessStatusTypeQueryVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypePageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeQueryVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO;
import org.apache.ibatis.annotations.Mapper;

View File

@ -1,7 +1,7 @@
package cn.iocoder.yudao.module.crm.service.business;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.*;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.*;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
import javax.validation.Valid;

View File

@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.crm.service.business;
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.business.vo.*;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.*;
import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO;

View File

@ -1,9 +1,9 @@
package cn.iocoder.yudao.module.crm.service.business;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessStatusPageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessStatusQueryVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessStatusSaveReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusPageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusQueryVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusSaveReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO;
import javax.validation.Valid;
@ -54,6 +54,8 @@ public interface CrmBusinessStatusService {
*/
PageResult<CrmBusinessStatusDO> getBusinessStatusPage(CrmBusinessStatusPageReqVO pageReqVO);
// TODO @ljlleo 常用的 ids 之类的查询可以封装单独的方法不用走类似 QueryVO用起来更方便
// TODO @ljlleo 方法名用 getBusinessStatusList
/**
* 获得商机状态分页
*

View File

@ -2,9 +2,9 @@ package cn.iocoder.yudao.module.crm.service.business;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessStatusPageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessStatusQueryVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessStatusSaveReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusPageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusQueryVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusSaveReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO;
import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessStatusMapper;
import org.springframework.stereotype.Service;
@ -51,6 +51,7 @@ public class CrmBusinessStatusServiceImpl implements CrmBusinessStatusService {
public void deleteBusinessStatus(Long id) {
// 校验存在
validateBusinessStatusExists(id);
// TODO @ljlleo 这里可以考虑如果有商机在使用不允许删除
// 删除
businessStatusMapper.deleteById(id);
}

View File

@ -1,9 +1,9 @@
package cn.iocoder.yudao.module.crm.service.business;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessStatusTypePageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessStatusTypeQueryVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessStatusTypeSaveReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypePageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeQueryVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeSaveReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO;
import javax.validation.Valid;
@ -54,6 +54,7 @@ public interface CrmBusinessStatusTypeService {
*/
PageResult<CrmBusinessStatusTypeDO> getBusinessStatusTypePage(CrmBusinessStatusTypePageReqVO pageReqVO);
// TODO @ljlleo 常用的 ids 之类的查询可以封装单独的方法不用走类似 QueryVO用起来更方便
/**
* 获得商机状态类型列表
*
@ -61,4 +62,5 @@ public interface CrmBusinessStatusTypeService {
* @return 商机状态类型列表
*/
List<CrmBusinessStatusTypeDO> selectList(CrmBusinessStatusTypeQueryVO queryVO);
}

View File

@ -1,11 +1,12 @@
package cn.iocoder.yudao.module.crm.service.business;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessStatusTypePageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessStatusTypeQueryVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessStatusTypeSaveReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypePageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeQueryVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeSaveReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO;
import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessStatusMapper;
@ -42,15 +43,14 @@ public class CrmBusinessStatusTypeServiceImpl implements CrmBusinessStatusTypeSe
public Long createBusinessStatusType(CrmBusinessStatusTypeSaveReqVO createReqVO) {
//检验名称是否存在
validateBusinessStatusTypeExists(createReqVO.getName(), null);
// 插入
// 插入类型
CrmBusinessStatusTypeDO businessStatusType = BeanUtils.toBean(createReqVO, CrmBusinessStatusTypeDO.class);
businessStatusTypeMapper.insert(businessStatusType);
createReqVO.getStatusList().stream().forEach(status -> {
status.setTypeId(businessStatusType.getId());
});
//插入状态
// 插入状态
if (CollUtil.isNotEmpty(createReqVO.getStatusList())) {
createReqVO.getStatusList().forEach(status -> status.setTypeId(businessStatusType.getId()));
businessStatusMapper.insertBatch(BeanUtils.toBean(createReqVO.getStatusList(), CrmBusinessStatusDO.class));
// 返回
}
return businessStatusType.getId();
}
@ -61,29 +61,27 @@ public class CrmBusinessStatusTypeServiceImpl implements CrmBusinessStatusTypeSe
validateBusinessStatusTypeExists(updateReqVO.getId());
// 校验名称是否存在
validateBusinessStatusTypeExists(updateReqVO.getName(), updateReqVO.getId());
// 更新
// 更新类型
CrmBusinessStatusTypeDO updateObj = BeanUtils.toBean(updateReqVO, CrmBusinessStatusTypeDO.class);
businessStatusTypeMapper.updateById(updateObj);
//删除状态
// 更新状态删除 + 更新
// TODO @ljlleo 可以参考 DeliveryExpressTemplateServiceImpl updateExpressTemplateFree 方法主要没变化的还是不删除了哈
businessStatusMapper.delete(updateReqVO.getId());
//插入状态
updateReqVO.getStatusList().stream().forEach(status -> {
status.setTypeId(updateReqVO.getId());
});
updateReqVO.getStatusList().forEach(status -> status.setTypeId(updateReqVO.getId()));
businessStatusMapper.insertBatch(BeanUtils.toBean(updateReqVO.getStatusList(), CrmBusinessStatusDO.class));
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteBusinessStatusType(Long id) {
//TODO 待添加被引用校验
// TODO 待添加被引用校验
//...
// 校验存在
validateBusinessStatusTypeExists(id);
// 删除
// 删除类型
businessStatusTypeMapper.deleteById(id);
//删除状态
// 删除状态
businessStatusMapper.delete(id);
}
@ -93,6 +91,7 @@ public class CrmBusinessStatusTypeServiceImpl implements CrmBusinessStatusTypeSe
}
}
// TODO @ljlleo 这个方法这个参考 validateDeptNameUnique 实现
private void validateBusinessStatusTypeExists(String name, Long id) {
LambdaQueryWrapper<CrmBusinessStatusTypeDO> wrapper = new LambdaQueryWrapperX<>();
if(null != id) {
@ -118,4 +117,5 @@ public class CrmBusinessStatusTypeServiceImpl implements CrmBusinessStatusTypeSe
public List<CrmBusinessStatusTypeDO> selectList(CrmBusinessStatusTypeQueryVO queryVO) {
return businessStatusTypeMapper.selectList(queryVO);
}
}

View File

@ -2,10 +2,10 @@ package cn.iocoder.yudao.module.crm.service.business;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.BusinessStatusTypePageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.BusinessStatusTypeSaveReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.BusinessStatusTypeDO;
import cn.iocoder.yudao.module.crm.dal.mysql.business.BusinessStatusTypeMapper;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypePageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeSaveReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO;
import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessStatusTypeMapper;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.Import;
@ -19,55 +19,56 @@ import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo;
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_STATUS_TYPE_NOT_EXISTS;
import static org.junit.jupiter.api.Assertions.*;
// TODO 芋艿后续再 review
/**
* {@link BusinessStatusTypeServiceImpl} 的单元测试类
* {@link CrmBusinessStatusTypeServiceImpl} 的单元测试类
*
* @author ljlleo
*/
@Import(BusinessStatusTypeServiceImpl.class)
@Import(CrmBusinessStatusTypeServiceImpl.class)
public class BusinessStatusTypeServiceImplTest extends BaseDbUnitTest {
@Resource
private BusinessStatusTypeServiceImpl businessStatusTypeService;
private CrmBusinessStatusTypeServiceImpl businessStatusTypeService;
@Resource
private BusinessStatusTypeMapper businessStatusTypeMapper;
private CrmBusinessStatusTypeMapper businessStatusTypeMapper;
@Test
public void testCreateBusinessStatusType_success() {
// 准备参数
BusinessStatusTypeSaveReqVO createReqVO = randomPojo(BusinessStatusTypeSaveReqVO.class).setId(null);
CrmBusinessStatusTypeSaveReqVO createReqVO = randomPojo(CrmBusinessStatusTypeSaveReqVO.class).setId(null);
// 调用
Long businessStatusTypeId = businessStatusTypeService.createBusinessStatusType(createReqVO);
// 断言
assertNotNull(businessStatusTypeId);
// 校验记录的属性是否正确
BusinessStatusTypeDO businessStatusType = businessStatusTypeMapper.selectById(businessStatusTypeId);
CrmBusinessStatusTypeDO businessStatusType = businessStatusTypeMapper.selectById(businessStatusTypeId);
assertPojoEquals(createReqVO, businessStatusType, "id");
}
@Test
public void testUpdateBusinessStatusType_success() {
// mock 数据
BusinessStatusTypeDO dbBusinessStatusType = randomPojo(BusinessStatusTypeDO.class);
CrmBusinessStatusTypeDO dbBusinessStatusType = randomPojo(CrmBusinessStatusTypeDO.class);
businessStatusTypeMapper.insert(dbBusinessStatusType);// @Sql: 先插入出一条存在的数据
// 准备参数
BusinessStatusTypeSaveReqVO updateReqVO = randomPojo(BusinessStatusTypeSaveReqVO.class, o -> {
CrmBusinessStatusTypeSaveReqVO updateReqVO = randomPojo(CrmBusinessStatusTypeSaveReqVO.class, o -> {
o.setId(dbBusinessStatusType.getId()); // 设置更新的 ID
});
// 调用
businessStatusTypeService.updateBusinessStatusType(updateReqVO);
// 校验是否更新正确
BusinessStatusTypeDO businessStatusType = businessStatusTypeMapper.selectById(updateReqVO.getId()); // 获取最新的
CrmBusinessStatusTypeDO businessStatusType = businessStatusTypeMapper.selectById(updateReqVO.getId()); // 获取最新的
assertPojoEquals(updateReqVO, businessStatusType);
}
@Test
public void testUpdateBusinessStatusType_notExists() {
// 准备参数
BusinessStatusTypeSaveReqVO updateReqVO = randomPojo(BusinessStatusTypeSaveReqVO.class);
CrmBusinessStatusTypeSaveReqVO updateReqVO = randomPojo(CrmBusinessStatusTypeSaveReqVO.class);
// 调用, 并断言异常
assertServiceException(() -> businessStatusTypeService.updateBusinessStatusType(updateReqVO), BUSINESS_STATUS_TYPE_NOT_EXISTS);
@ -76,7 +77,7 @@ public class BusinessStatusTypeServiceImplTest extends BaseDbUnitTest {
@Test
public void testDeleteBusinessStatusType_success() {
// mock 数据
BusinessStatusTypeDO dbBusinessStatusType = randomPojo(BusinessStatusTypeDO.class);
CrmBusinessStatusTypeDO dbBusinessStatusType = randomPojo(CrmBusinessStatusTypeDO.class);
businessStatusTypeMapper.insert(dbBusinessStatusType);// @Sql: 先插入出一条存在的数据
// 准备参数
Long id = dbBusinessStatusType.getId();
@ -100,14 +101,14 @@ public class BusinessStatusTypeServiceImplTest extends BaseDbUnitTest {
@Disabled // TODO 请修改 null 为需要的值然后删除 @Disabled 注解
public void testGetBusinessStatusTypePage() {
// mock 数据
BusinessStatusTypeDO dbBusinessStatusType = randomPojo(BusinessStatusTypeDO.class, o -> { // 等会查询到
CrmBusinessStatusTypeDO dbBusinessStatusType = randomPojo(CrmBusinessStatusTypeDO.class, o -> { // 等会查询到
});
businessStatusTypeMapper.insert(dbBusinessStatusType);
// 准备参数
BusinessStatusTypePageReqVO reqVO = new BusinessStatusTypePageReqVO();
CrmBusinessStatusTypePageReqVO reqVO = new CrmBusinessStatusTypePageReqVO();
// 调用
PageResult<BusinessStatusTypeDO> pageResult = businessStatusTypeService.getBusinessStatusTypePage(reqVO);
PageResult<CrmBusinessStatusTypeDO> pageResult = businessStatusTypeService.getBusinessStatusTypePage(reqVO);
// 断言
assertEquals(1, pageResult.getTotal());
assertEquals(1, pageResult.getList().size());

View File

@ -1,9 +1,9 @@
package cn.iocoder.yudao.module.crm.service.business;
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessCreateReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessExportReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessUpdateReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessCreateReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessExportReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessUpdateReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessMapper;
import org.junit.jupiter.api.Disabled;