Merge remote-tracking branch 'ljlleo/feature/crm' into feature/crm

# Conflicts:
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java
This commit is contained in:
YunaiV 2023-11-24 23:58:49 +08:00
commit d1579499f4
47 changed files with 883 additions and 921 deletions

View File

@ -20,8 +20,6 @@ public interface ErrorCodeConstants {
// TODO @lilleo商机状态商机类型都单独错误码段
ErrorCode BUSINESS_STATUS_TYPE_NOT_EXISTS = new ErrorCode(1_020_002_001, "商机状态类型不存在");
ErrorCode BUSINESS_STATUS_NOT_EXISTS = new ErrorCode(1_020_002_002, "商机状态不存在");
// ========== 联系人管理 1-020-003-000 ==========
ErrorCode CONTACT_NOT_EXISTS = new ErrorCode(1_020_003_000, "联系人不存在");
@ -61,4 +59,11 @@ public interface ErrorCodeConstants {
// ========== 产品分类 1_020_009_000 ==========
ErrorCode PRODUCT_CATEGORY_NOT_EXISTS = new ErrorCode(1_020_009_000, "产品分类不存在");
// ========== 商机状态类型 1_020_010_000 ==========
ErrorCode BUSINESS_STATUS_TYPE_NOT_EXISTS = new ErrorCode(1_020_010_000, "商机状态类型不存在");
ErrorCode BUSINESS_STATUS_TYPE_NAME_EXISTS = new ErrorCode(1_020_010_001, "商机状态类型名称已存在");
// ========== 商机状态 1_020_011_000 ==========
ErrorCode BUSINESS_STATUS_NOT_EXISTS = new ErrorCode(1_020_011_000, "商机状态不存在");
}

View File

@ -7,7 +7,14 @@ 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.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;
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
@ -20,6 +27,9 @@ import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
@ -34,6 +44,15 @@ public class CrmBusinessController {
@Resource
private CrmBusinessService businessService;
@Resource
private CrmCustomerService customerService;
@Resource
private CrmBusinessStatusTypeService businessStatusTypeService;
@Resource
private CrmBusinessStatusService businessStatusService;
@PostMapping("/create")
@Operation(summary = "创建商机")
@PreAuthorize("@ss.hasPermission('crm:business:create')")
@ -72,7 +91,23 @@ public class CrmBusinessController {
@PreAuthorize("@ss.hasPermission('crm:business:query')")
public CommonResult<PageResult<CrmBusinessRespVO>> getBusinessPage(@Valid CrmBusinessPageReqVO pageVO) {
PageResult<CrmBusinessDO> pageResult = businessService.getBusinessPage(pageVO, getLoginUserId());
return success(CrmBusinessConvert.INSTANCE.convertPage(pageResult));
//处理客户名称回显
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();
queryVO.setIdList(statusIds);
List<CrmBusinessStatusDO> statusList = businessStatusService.selectList(queryVO);
return success(CrmBusinessConvert.INSTANCE.convertPage(pageResult, customerList, statusTypeList, statusList));
}
@GetMapping("/pool-page")

View File

@ -1,14 +1,21 @@
package cn.iocoder.yudao.module.crm.controller.admin.businessstatustype;
package cn.iocoder.yudao.module.crm.controller.admin.business;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
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.businessstatustype.vo.*;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.*;
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.businessstatustype.CrmBusinessStatusTypeDO;
import cn.iocoder.yudao.module.crm.service.businessstatustype.CrmBusinessStatusTypeService;
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.service.business.CrmBusinessStatusService;
import cn.iocoder.yudao.module.crm.service.business.CrmBusinessStatusTypeService;
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
@ -22,11 +29,13 @@ import javax.validation.Valid;
import java.io.IOException;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
// TODO @lilleo这个模块可以挪到 business 这样我打开 business 包下就知道~原来里面有 business 商机 type 状态类型status 具体状态
@Tag(name = "管理后台 - 商机状态类型")
@RestController
@RequestMapping("/crm/business-status-type")
@ -36,17 +45,23 @@ public class CrmBusinessStatusTypeController {
@Resource
private CrmBusinessStatusTypeService businessStatusTypeService;
@Resource
private CrmBusinessStatusService businessStatusService;
@Resource
private DeptApi deptApi;
@PostMapping("/create")
@Operation(summary = "创建商机状态类型")
@PreAuthorize("@ss.hasPermission('crm:business-status-type:create')")
public CommonResult<Long> createBusinessStatusType(@Valid @RequestBody CrmBusinessStatusTypeCreateReqVO createReqVO) {
public CommonResult<Long> createBusinessStatusType(@Valid @RequestBody CrmBusinessStatusTypeSaveReqVO createReqVO) {
return success(businessStatusTypeService.createBusinessStatusType(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新商机状态类型")
@PreAuthorize("@ss.hasPermission('crm:business-status-type:update')")
public CommonResult<Boolean> updateBusinessStatusType(@Valid @RequestBody CrmBusinessStatusTypeUpdateReqVO updateReqVO) {
public CommonResult<Boolean> updateBusinessStatusType(@Valid @RequestBody CrmBusinessStatusTypeSaveReqVO updateReqVO) {
businessStatusTypeService.updateBusinessStatusType(updateReqVO);
return success(true);
}
@ -66,45 +81,58 @@ public class CrmBusinessStatusTypeController {
@PreAuthorize("@ss.hasPermission('crm:business-status-type:query')")
public CommonResult<CrmBusinessStatusTypeRespVO> getBusinessStatusType(@RequestParam("id") Long id) {
CrmBusinessStatusTypeDO businessStatusType = businessStatusTypeService.getBusinessStatusType(id);
return success(CrmBusinessStatusTypeConvert.INSTANCE.convert(businessStatusType));
}
// TODO @lilleo这个接口暂时用不到可以考虑先删除掉
@GetMapping("/list")
@Operation(summary = "获得商机状态类型列表")
@Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
@PreAuthorize("@ss.hasPermission('crm:business-status-type:query')")
public CommonResult<List<CrmBusinessStatusTypeRespVO>> getBusinessStatusTypeList(@RequestParam("ids") Collection<Long> ids) {
List<CrmBusinessStatusTypeDO> list = businessStatusTypeService.getBusinessStatusTypeList(ids);
return success(CrmBusinessStatusTypeConvert.INSTANCE.convertList(list));
//处理状态回显
CrmBusinessStatusQueryVO queryVO = new CrmBusinessStatusQueryVO();
queryVO.setTypeId(id);
List<CrmBusinessStatusDO> statusList = businessStatusService.selectList(queryVO);
return success(CrmBusinessStatusTypeConvert.INSTANCE.convert(businessStatusType, statusList));
}
@GetMapping("/page")
@Operation(summary = "获得商机状态类型分页")
@PreAuthorize("@ss.hasPermission('crm:business-status-type:query')")
public CommonResult<PageResult<CrmBusinessStatusTypeRespVO>> getBusinessStatusTypePage(@Valid CrmBusinessStatusTypePageReqVO pageVO) {
PageResult<CrmBusinessStatusTypeDO> pageResult = businessStatusTypeService.getBusinessStatusTypePage(pageVO);
return success(CrmBusinessStatusTypeConvert.INSTANCE.convertPage(pageResult));
public CommonResult<PageResult<CrmBusinessStatusTypeRespVO>> getBusinessStatusTypePage(@Valid CrmBusinessStatusTypePageReqVO pageReqVO) {
PageResult<CrmBusinessStatusTypeDO> pageResult = businessStatusTypeService.getBusinessStatusTypePage(pageReqVO);
//处理部门回显
Set<Long> deptIds = pageResult.getList().stream()
.map(CrmBusinessStatusTypeDO::getDeptIds)
.filter(Objects::nonNull)
.flatMap(Collection::stream)
.collect(Collectors.toSet());
List<DeptRespDTO> deptList = deptApi.getDeptList(deptIds);
return success(CrmBusinessStatusTypeConvert.INSTANCE.convertPage(pageResult, deptList));
}
@GetMapping("/export-excel")
@Operation(summary = "导出商机状态类型 Excel")
@PreAuthorize("@ss.hasPermission('crm:business-status-type:export')")
@OperateLog(type = EXPORT)
public void exportBusinessStatusTypeExcel(@Valid CrmBusinessStatusTypeExportReqVO exportReqVO,
public void exportBusinessStatusTypeExcel(@Valid CrmBusinessStatusTypePageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
List<CrmBusinessStatusTypeDO> list = businessStatusTypeService.getBusinessStatusTypeList(exportReqVO);
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<CrmBusinessStatusTypeDO> list = businessStatusTypeService.getBusinessStatusTypePage(pageReqVO).getList();
// 导出 Excel
List<CrmBusinessStatusTypeExcelVO> datas = CrmBusinessStatusTypeConvert.INSTANCE.convertList02(list);
ExcelUtils.write(response, "商机状态类型.xls", "数据", CrmBusinessStatusTypeExcelVO.class, datas);
ExcelUtils.write(response, "商机状态类型.xls", "数据", CrmBusinessStatusTypeRespVO.class,
BeanUtils.toBean(list, CrmBusinessStatusTypeRespVO.class));
}
@GetMapping("/get-simple-list")
@Operation(summary = "获得商机状态类型列表")
@PreAuthorize("@ss.hasPermission('crm:business-status-type:query')")
public CommonResult<List<CrmBusinessStatusTypeRespVO>> getBusinessStatusTypeList() {
List<CrmBusinessStatusTypeDO> list = businessStatusTypeService.getBusinessStatusTypeListByStatus(CommonStatusEnum.ENABLE.getStatus());
return success(CrmBusinessStatusTypeConvert.INSTANCE.convertList(list));
CrmBusinessStatusTypeQueryVO queryVO = new CrmBusinessStatusTypeQueryVO();
queryVO.setStatus(CommonStatusEnum.ENABLE.getStatus());
List<CrmBusinessStatusTypeDO> list = businessStatusTypeService.selectList(queryVO);
return success(BeanUtils.toBean(list, CrmBusinessStatusTypeRespVO.class));
}
@GetMapping("/get-status-list")
@Operation(summary = "获得商机状态列表")
@PreAuthorize("@ss.hasPermission('crm:business-status:query')")
public CommonResult<List<CrmBusinessStatusRespVO>> getBusinessStatusListByTypeId(@RequestParam("typeId") Long typeId) {
CrmBusinessStatusQueryVO queryVO = new CrmBusinessStatusQueryVO();
queryVO.setTypeId(typeId);
List<CrmBusinessStatusDO> list = businessStatusService.selectList(queryVO);
return success(CrmBusinessStatusConvert.INSTANCE.convertList(list));
}
}

View File

@ -16,4 +16,13 @@ public class CrmBusinessRespVO extends CrmBusinessBaseVO {
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
private LocalDateTime createTime;
@Schema(description = "客户名称")
private String customerName;
@Schema(description = "状态类型名称")
private String statusTypeName;
@Schema(description = "状态名称")
private String statusName;
}

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo;
package cn.iocoder.yudao.module.crm.controller.admin.business.vo;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
@ -12,7 +12,4 @@ import lombok.ToString;
@ToString(callSuper = true)
public class CrmBusinessStatusPageReqVO extends PageParam {
@Schema(description = "状态类型编号", example = "22882")
private Long typeId;
}

View File

@ -0,0 +1,19 @@
package cn.iocoder.yudao.module.crm.controller.admin.business.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.ToString;
import java.util.Collection;
@Schema(description = "管理后台 - 商机状态 Query VO")
@Data
@ToString(callSuper = true)
public class CrmBusinessStatusQueryVO {
@Schema(description = "主键集合")
private Collection<Long> idList;
@Schema(description = "状态类型编号")
private Long typeId;
}

View File

@ -0,0 +1,33 @@
package cn.iocoder.yudao.module.crm.controller.admin.business.vo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "管理后台 - 商机状态 Response VO")
@Data
@ExcelIgnoreUnannotated
public class CrmBusinessStatusRespVO {
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "23899")
@ExcelProperty("主键")
private Long id;
@Schema(description = "状态类型编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7139")
@ExcelProperty("状态类型编号")
private Long typeId;
@Schema(description = "状态名", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
@ExcelProperty("状态名")
private String name;
@Schema(description = "赢单率")
@ExcelProperty("赢单率")
private String percent;
@Schema(description = "排序")
@ExcelProperty("排序")
private Integer sort;
}

View File

@ -0,0 +1,30 @@
package cn.iocoder.yudao.module.crm.controller.admin.business.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
@Schema(description = "管理后台 - 商机状态新增/修改 Request VO")
@Data
public class CrmBusinessStatusSaveReqVO {
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "23899")
private Long id;
@Schema(description = "状态类型编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7139")
@NotNull(message = "状态类型编号不能为空")
private Long typeId;
@Schema(description = "状态名", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
@NotEmpty(message = "状态名不能为空")
private String name;
@Schema(description = "赢单率")
private String percent;
@Schema(description = "排序")
private Integer sort;
}

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo;
package cn.iocoder.yudao.module.crm.controller.admin.business.vo;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
@ -12,10 +12,4 @@ import lombok.ToString;
@ToString(callSuper = true)
public class CrmBusinessStatusTypePageReqVO extends PageParam {
@Schema(description = "状态类型名", example = "芋艿")
private String name;
@Schema(description = "开启状态", example = "1")
private Boolean status;
}

View File

@ -0,0 +1,19 @@
package cn.iocoder.yudao.module.crm.controller.admin.business.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.ToString;
import java.util.Collection;
@Schema(description = "管理后台 - 商机状态类型 Query VO")
@Data
@ToString(callSuper = true)
public class CrmBusinessStatusTypeQueryVO {
@Schema(description = "主键集合")
private Collection<Long> idList;
@Schema(description = "状态")
private Integer status;
}

View File

@ -0,0 +1,44 @@
package cn.iocoder.yudao.module.crm.controller.admin.business.vo;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.List;
@Schema(description = "管理后台 - 商机状态类型 Response VO")
@Data
@ExcelIgnoreUnannotated
public class CrmBusinessStatusTypeRespVO {
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "2934")
@ExcelProperty("主键")
private Long id;
@Schema(description = "状态类型名", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
@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 String creator;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
@Schema(description = "状态集合", requiredMode = Schema.RequiredMode.REQUIRED)
private List<CrmBusinessStatusDO> statusList;
}

View File

@ -0,0 +1,27 @@
package cn.iocoder.yudao.module.crm.controller.admin.business.vo;
import com.google.common.collect.Lists;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import java.util.List;
@Schema(description = "管理后台 - 商机状态类型新增/修改 Request VO")
@Data
public class CrmBusinessStatusTypeSaveReqVO {
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "2934")
private Long id;
@Schema(description = "状态类型名", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
@NotEmpty(message = "状态类型名不能为空")
private String name;
@Schema(description = "使用的部门编号", requiredMode = Schema.RequiredMode.REQUIRED)
private List<Long> deptIds = Lists.newArrayList();
@Schema(description = "商机状态集合", requiredMode = Schema.RequiredMode.REQUIRED)
private List<CrmBusinessStatusSaveReqVO> statusList = Lists.newArrayList();
}

View File

@ -1,119 +0,0 @@
package cn.iocoder.yudao.module.crm.controller.admin.businessstatus;
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.businessstatus.vo.*;
import cn.iocoder.yudao.module.crm.convert.businessstatus.CrmBusinessStatusConvert;
import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatus.CrmBusinessStatusDO;
import cn.iocoder.yudao.module.crm.service.businessstatus.CrmBusinessStatusService;
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 org.springframework.web.bind.annotation.*;
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;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
// TODO @lilleo这个模块可以挪到 business 这样我打开 business 包下就知道~原来里面有 business 商机 type 状态类型status 具体状态
@Tag(name = "管理后台 - 商机状态")
@RestController
@RequestMapping("/crm/business-status")
@Validated
public class CrmBusinessStatusController {
@Resource
private CrmBusinessStatusService businessStatusService;
@PostMapping("/create")
@Operation(summary = "创建商机状态")
@PreAuthorize("@ss.hasPermission('crm:business-status:create')")
public CommonResult<Long> createBusinessStatus(@Valid @RequestBody CrmBusinessStatusCreateReqVO createReqVO) {
return success(businessStatusService.createBusinessStatus(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新商机状态")
@PreAuthorize("@ss.hasPermission('crm:business-status:update')")
public CommonResult<Boolean> updateBusinessStatus(@Valid @RequestBody CrmBusinessStatusUpdateReqVO updateReqVO) {
businessStatusService.updateBusinessStatus(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除商机状态")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('crm:business-status:delete')")
public CommonResult<Boolean> deleteBusinessStatus(@RequestParam("id") Long id) {
businessStatusService.deleteBusinessStatus(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得商机状态")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('crm:business-status:query')")
public CommonResult<CrmBusinessStatusRespVO> getBusinessStatus(@RequestParam("id") Long id) {
CrmBusinessStatusDO businessStatus = businessStatusService.getBusinessStatus(id);
return success(CrmBusinessStatusConvert.INSTANCE.convert(businessStatus));
}
// TODO @lilleo这个接口暂时用不到可以考虑先删除掉
@GetMapping("/list")
@Operation(summary = "获得商机状态列表")
@Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
@PreAuthorize("@ss.hasPermission('crm:business-status:query')")
public CommonResult<List<CrmBusinessStatusRespVO>> getBusinessStatusList(@RequestParam("ids") Collection<Long> ids) {
List<CrmBusinessStatusDO> list = businessStatusService.getBusinessStatusList(ids);
return success(CrmBusinessStatusConvert.INSTANCE.convertList(list));
}
@GetMapping("/page")
@Operation(summary = "获得商机状态分页")
@PreAuthorize("@ss.hasPermission('crm:business-status:query')")
public CommonResult<PageResult<CrmBusinessStatusRespVO>> getBusinessStatusPage(@Valid CrmBusinessStatusPageReqVO pageVO) {
PageResult<CrmBusinessStatusDO> pageResult = businessStatusService.getBusinessStatusPage(pageVO);
return success(CrmBusinessStatusConvert.INSTANCE.convertPage(pageResult));
}
@GetMapping("/export-excel")
@Operation(summary = "导出商机状态 Excel")
@PreAuthorize("@ss.hasPermission('crm:business-status:export')")
@OperateLog(type = EXPORT)
public void exportBusinessStatusExcel(@Valid CrmBusinessStatusExportReqVO exportReqVO,
HttpServletResponse response) throws IOException {
List<CrmBusinessStatusDO> list = businessStatusService.getBusinessStatusList(exportReqVO);
// 导出 Excel
List<CrmBusinessStatusExcelVO> datas = CrmBusinessStatusConvert.INSTANCE.convertList02(list);
ExcelUtils.write(response, "商机状态.xls", "数据", CrmBusinessStatusExcelVO.class, datas);
}
// TODO 芋艿后续再看看
@GetMapping("/get-simple-list")
@Operation(summary = "获得商机状态列表")
@PreAuthorize("@ss.hasPermission('crm:business-status:query')")
public CommonResult<List<CrmBusinessStatusRespVO>> getBusinessStatusListByTypeId(@RequestParam("typeId") Integer typeId) {
List<CrmBusinessStatusDO> list = businessStatusService.getBusinessStatusListByTypeId(typeId);
return success(CrmBusinessStatusConvert.INSTANCE.convertList(list));
}
// TODO 芋艿后续再看看
@GetMapping("/get-all-list")
@Operation(summary = "获得商机状态列表")
@PreAuthorize("@ss.hasPermission('crm:business-status:query')")
public CommonResult<List<CrmBusinessStatusRespVO>> getBusinessStatusList() {
List<CrmBusinessStatusDO> list = businessStatusService.getBusinessStatusList();
return success(CrmBusinessStatusConvert.INSTANCE.convertList(list));
}
}

View File

@ -1,33 +0,0 @@
package cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotNull;
/**
* 商机状态 Base VO提供给添加修改详细的子 VO 使用
* 如果子 VO 存在差异的字段请不要添加到这里影响 Swagger 文档生成
*/
@Data
public class CrmBusinessStatusBaseVO {
// TODO @lilleoexample 要写下
@Schema(description = "状态类型编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22882")
@NotNull(message = "状态类型编号不能为空")
private Long typeId;
@Schema(description = "状态名", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
@NotNull(message = "状态名不能为空")
private String name;
// TODO @lilleopercent 应该是 Integer
@Schema(description = "赢单率")
private String percent;
// TODO @lilleo这个是不是不用前端新增和修改的时候传递交给顺序计算出来存储起来就好了
@Schema(description = "排序")
private Integer sort;
}

View File

@ -1,14 +0,0 @@
package cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import javax.validation.constraints.*;
@Schema(description = "管理后台 - 商机状态创建 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CrmBusinessStatusCreateReqVO extends CrmBusinessStatusBaseVO {
}

View File

@ -1,30 +0,0 @@
package cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
// TODO @lilleo这个暂时不需要嘿嘿~不是每个模块都需要导出哈
/**
* 商机状态 Excel VO
*
* @author ljlleo
*/
@Data
public class CrmBusinessStatusExcelVO {
@ExcelProperty("主键")
private Long id;
@ExcelProperty("状态类型编号")
private Long typeId;
@ExcelProperty("状态名")
private String name;
@ExcelProperty("赢单率")
private String percent;
@ExcelProperty("排序")
private Integer sort;
}

View File

@ -1,23 +0,0 @@
package cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
// TODO @lilleo这个暂时不需要嘿嘿~不是每个模块都需要导出哈
@Schema(description = "管理后台 - 商机状态 Excel 导出 Request VO参数和 CrmBusinessStatusPageReqVO 是一致的")
@Data
public class CrmBusinessStatusExportReqVO {
@Schema(description = "状态类型编号", example = "22882")
private Long typeId;
@Schema(description = "状态名", example = "李四")
private String name;
@Schema(description = "赢单率")
private String percent;
@Schema(description = "排序")
private Integer sort;
}

View File

@ -1,15 +0,0 @@
package cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
@Schema(description = "管理后台 - 商机状态 Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CrmBusinessStatusRespVO extends CrmBusinessStatusBaseVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "6802")
private Long id;
}

View File

@ -1,20 +0,0 @@
package cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import javax.validation.constraints.NotNull;
@Schema(description = "管理后台 - 商机状态更新 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CrmBusinessStatusUpdateReqVO extends CrmBusinessStatusBaseVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "6802")
@NotNull(message = "编号不能为空")
private Long id;
}

View File

@ -1,27 +0,0 @@
package cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotNull;
/**
* 商机状态类型 Base VO提供给添加修改详细的子 VO 使用
* 如果子 VO 存在差异的字段请不要添加到这里影响 Swagger 文档生成
*/
@Data
public class CrmBusinessStatusTypeBaseVO {
@Schema(description = "状态类型名", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
@NotNull(message = "状态类型名不能为空")
private String name;
@Schema(description = "使用的部门编号", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "使用的部门编号不能为空")
private String deptIds;
@Schema(description = "开启状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "开启状态不能为空")
private Boolean status;
}

View File

@ -1,15 +0,0 @@
package cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
// TODO 状态类型和状态添加是在一个请求里所以需要把 CrmBusinessStatusCreateReqVO 融合进来
@Schema(description = "管理后台 - 商机状态类型创建 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CrmBusinessStatusTypeCreateReqVO extends CrmBusinessStatusTypeBaseVO {
}

View File

@ -1,32 +0,0 @@
package cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
import java.time.LocalDateTime;
// TODO @lilleo这个暂时不需要嘿嘿~不是每个模块都需要导出哈
/**
* 商机状态类型 Excel VO
*
* @author ljlleo
*/
@Data
public class CrmBusinessStatusTypeExcelVO {
@ExcelProperty("主键")
private Long id;
@ExcelProperty("状态类型名")
private String name;
@ExcelProperty("使用的部门编号")
private String deptIds;
@ExcelProperty("开启状态")
private Boolean status;
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

View File

@ -1,29 +0,0 @@
package cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
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;
// TODO @lilleo这个暂时不需要嘿嘿~不是每个模块都需要导出哈
@Schema(description = "管理后台 - 商机状态类型 Excel 导出 Request VO参数和 CrmBusinessStatusTypePageReqVO 是一致的")
@Data
public class CrmBusinessStatusTypeExportReqVO {
@Schema(description = "状态类型名", example = "芋艿")
private String name;
@Schema(description = "使用的部门编号")
private String deptIds;
@Schema(description = "开启状态", example = "1")
private Boolean status;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

View File

@ -1,19 +0,0 @@
package cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 商机状态类型 Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CrmBusinessStatusTypeRespVO extends CrmBusinessStatusTypeBaseVO {
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "24019")
private Long id;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
private LocalDateTime createTime;
}

View File

@ -1,21 +0,0 @@
package cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import javax.validation.constraints.NotNull;
// TODO 状态类型和状态添加是在一个请求里所以需要把 CrmBusinessStatusUpdateReqVO 融合进来
@Schema(description = "管理后台 - 商机状态类型更新 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CrmBusinessStatusTypeUpdateReqVO extends CrmBusinessStatusTypeBaseVO {
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "24019")
@NotNull(message = "主键不能为空")
private Long id;
}

View File

@ -3,6 +3,9 @@ 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.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.service.permission.bo.CrmPermissionTransferReqBO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
@ -10,6 +13,9 @@ import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
import java.util.List;
import java.util.Map;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
/**
* 商机 Convert
@ -37,4 +43,18 @@ public interface CrmBusinessConvert {
})
CrmPermissionTransferReqBO convert(CrmBusinessTransferReqVO reqVO, Long userId);
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()));
});
return result;
}
}

View File

@ -1,13 +1,13 @@
package cn.iocoder.yudao.module.crm.convert.businessstatus;
import java.util.*;
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.dal.dataobject.business.CrmBusinessStatusDO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo.*;
import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatus.CrmBusinessStatusDO;
import java.util.List;
/**
* 商机状态 Convert
@ -19,9 +19,7 @@ public interface CrmBusinessStatusConvert {
CrmBusinessStatusConvert INSTANCE = Mappers.getMapper(CrmBusinessStatusConvert.class);
CrmBusinessStatusDO convert(CrmBusinessStatusCreateReqVO bean);
CrmBusinessStatusDO convert(CrmBusinessStatusUpdateReqVO bean);
CrmBusinessStatusDO convert(CrmBusinessStatusSaveReqVO bean);
CrmBusinessStatusRespVO convert(CrmBusinessStatusDO bean);
@ -29,6 +27,4 @@ public interface CrmBusinessStatusConvert {
PageResult<CrmBusinessStatusRespVO> convertPage(PageResult<CrmBusinessStatusDO> page);
List<CrmBusinessStatusExcelVO> convertList02(List<CrmBusinessStatusDO> list);
}

View File

@ -1,13 +1,19 @@
package cn.iocoder.yudao.module.crm.convert.businessstatustype;
import java.util.*;
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.dal.dataobject.business.CrmBusinessStatusDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO;
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo.*;
import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatustype.CrmBusinessStatusTypeDO;
import java.util.List;
import java.util.Map;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
/**
* 商机状态类型 Convert
@ -19,16 +25,26 @@ public interface CrmBusinessStatusTypeConvert {
CrmBusinessStatusTypeConvert INSTANCE = Mappers.getMapper(CrmBusinessStatusTypeConvert.class);
CrmBusinessStatusTypeDO convert(CrmBusinessStatusTypeCreateReqVO bean);
CrmBusinessStatusTypeDO convert(CrmBusinessStatusTypeUpdateReqVO bean);
CrmBusinessStatusTypeDO convert(CrmBusinessStatusTypeSaveReqVO bean);
CrmBusinessStatusTypeRespVO convert(CrmBusinessStatusTypeDO bean);
List<CrmBusinessStatusTypeRespVO> convertList(List<CrmBusinessStatusTypeDO> list);
PageResult<CrmBusinessStatusTypeRespVO> convertPage(PageResult<CrmBusinessStatusTypeDO> page);
List<CrmBusinessStatusTypeExcelVO> convertList02(List<CrmBusinessStatusTypeDO> list);
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));
});
return pageResult;
}
default CrmBusinessStatusTypeRespVO convert(CrmBusinessStatusTypeDO bean, List<CrmBusinessStatusDO> statusList) {
CrmBusinessStatusTypeRespVO result = convert(bean);
result.setStatusList(statusList);
return result;
}
}

View File

@ -1,8 +1,6 @@
package cn.iocoder.yudao.module.crm.dal.dataobject.business;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatus.CrmBusinessStatusDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatustype.CrmBusinessStatusTypeDO;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.crm.dal.dataobject.businessstatus;
package cn.iocoder.yudao.module.crm.dal.dataobject.business;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableId;
@ -26,8 +26,6 @@ public class CrmBusinessStatusDO {
private Long id;
/**
* 状态类型编号
*
* // TODO @ljlleo要写下关联字段噢
*/
private Long typeId;
/**

View File

@ -1,23 +1,29 @@
package cn.iocoder.yudao.module.crm.dal.dataobject.businessstatustype;
package cn.iocoder.yudao.module.crm.dal.dataobject.business;
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.util.List;
/**
* 商机状态类型 DO
*
* @author ljlleo
*/
@TableName("crm_business_status_type")
@TableName(value = "crm_business_status_type", autoResultMap = true)
@KeySequence("crm_business_status_type_seq") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class CrmBusinessStatusTypeDO {
public class CrmBusinessStatusTypeDO extends BaseDO {
/**
* 主键
@ -28,15 +34,14 @@ public class CrmBusinessStatusTypeDO {
* 状态类型名
*/
private String name;
// TODO @ljlleoList 存储哈
/**
* 使用的部门编号
*/
private String deptIds;
@TableField(typeHandler = LongListTypeHandler.class)
private List<Long> deptIds;
/**
* 开启状态
*/
// TODO @ljlleo这个字段使用 Integer对应 CommonStatus
private Boolean status;
}

View File

@ -0,0 +1,38 @@
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.dal.dataobject.business.CrmBusinessStatusDO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 商机状态 Mapper
*
* @author ljlleo
*/
@Mapper
public interface CrmBusinessStatusMapper extends BaseMapperX<CrmBusinessStatusDO> {
default PageResult<CrmBusinessStatusDO> selectPage(CrmBusinessStatusPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<CrmBusinessStatusDO>()
.orderByDesc(CrmBusinessStatusDO::getId));
}
default List<CrmBusinessStatusDO> selectList(CrmBusinessStatusQueryVO queryVO) {
return selectList(new LambdaQueryWrapperX<CrmBusinessStatusDO>()
.eqIfPresent(CrmBusinessStatusDO::getTypeId, queryVO.getTypeId())
.inIfPresent(CrmBusinessStatusDO::getId, queryVO.getIdList())
.orderByDesc(CrmBusinessStatusDO::getId));
}
default int delete(Long typeId) {
return delete(new LambdaQueryWrapperX<CrmBusinessStatusDO>()
.eq(CrmBusinessStatusDO::getTypeId, typeId));
}
}

View File

@ -0,0 +1,31 @@
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.dal.dataobject.business.CrmBusinessStatusTypeDO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 商机状态类型 Mapper
*
* @author ljlleo
*/
@Mapper
public interface CrmBusinessStatusTypeMapper extends BaseMapperX<CrmBusinessStatusTypeDO> {
default PageResult<CrmBusinessStatusTypeDO> selectPage(CrmBusinessStatusTypePageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<CrmBusinessStatusTypeDO>()
.orderByDesc(CrmBusinessStatusTypeDO::getId));
}
default List<CrmBusinessStatusTypeDO> selectList(CrmBusinessStatusTypeQueryVO queryVO) {
return selectList(new LambdaQueryWrapperX<CrmBusinessStatusTypeDO>()
.eqIfPresent(CrmBusinessStatusTypeDO::getStatus, queryVO.getStatus())
.inIfPresent(CrmBusinessStatusTypeDO::getId, queryVO.getIdList()));
}
}

View File

@ -1,40 +0,0 @@
package cn.iocoder.yudao.module.crm.dal.mysql.businessstatus;
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.businessstatus.vo.CrmBusinessStatusExportReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo.CrmBusinessStatusPageReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatus.CrmBusinessStatusDO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 商机状态 Mapper
*
* @author ljlleo
*/
@Mapper
public interface CrmBusinessStatusMapper extends BaseMapperX<CrmBusinessStatusDO> {
default PageResult<CrmBusinessStatusDO> selectPage(CrmBusinessStatusPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<CrmBusinessStatusDO>()
.eqIfPresent(CrmBusinessStatusDO::getTypeId, reqVO.getTypeId())
.orderByDesc(CrmBusinessStatusDO::getId));
}
default List<CrmBusinessStatusDO> selectList(CrmBusinessStatusExportReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<CrmBusinessStatusDO>()
.eqIfPresent(CrmBusinessStatusDO::getTypeId, reqVO.getTypeId())
.likeIfPresent(CrmBusinessStatusDO::getName, reqVO.getName())
.eqIfPresent(CrmBusinessStatusDO::getPercent, reqVO.getPercent())
.eqIfPresent(CrmBusinessStatusDO::getSort, reqVO.getSort())
.orderByDesc(CrmBusinessStatusDO::getId));
}
default List<CrmBusinessStatusDO> getBusinessStatusListByTypeId(Integer typeId) {
return selectList(CrmBusinessStatusDO::getTypeId, typeId);
}
}

View File

@ -1,41 +0,0 @@
package cn.iocoder.yudao.module.crm.dal.mysql.businessstatustype;
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.businessstatustype.vo.CrmBusinessStatusTypeExportReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo.CrmBusinessStatusTypePageReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatustype.CrmBusinessStatusTypeDO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 商机状态类型 Mapper
*
* @author ljlleo
*/
@Mapper
public interface CrmBusinessStatusTypeMapper extends BaseMapperX<CrmBusinessStatusTypeDO> {
default PageResult<CrmBusinessStatusTypeDO> selectPage(CrmBusinessStatusTypePageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<CrmBusinessStatusTypeDO>()
.likeIfPresent(CrmBusinessStatusTypeDO::getName, reqVO.getName())
// .eqIfPresent(CrmBusinessStatusTypeDO::getDeptIds, reqVO.getDeptIds()) TODO 报错临时注释掉
.eqIfPresent(CrmBusinessStatusTypeDO::getStatus, reqVO.getStatus())
.orderByDesc(CrmBusinessStatusTypeDO::getId));
}
default List<CrmBusinessStatusTypeDO> selectList(CrmBusinessStatusTypeExportReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<CrmBusinessStatusTypeDO>()
.likeIfPresent(CrmBusinessStatusTypeDO::getName, reqVO.getName())
.eqIfPresent(CrmBusinessStatusTypeDO::getDeptIds, reqVO.getDeptIds())
.eqIfPresent(CrmBusinessStatusTypeDO::getStatus, reqVO.getStatus())
.orderByDesc(CrmBusinessStatusTypeDO::getId));
}
default List<CrmBusinessStatusTypeDO> getBusinessStatusTypeListByStatus(Integer status) {
return selectList(CrmBusinessStatusTypeDO::getStatus, status.byteValue());
}
}

View File

@ -14,6 +14,9 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import java.util.Collection;
import java.util.List;
/**
* 客户 Mapper
*
@ -114,4 +117,9 @@ public interface CrmCustomerMapper extends BaseMapperX<CrmCustomerDO> {
.isNull(CrmCustomerDO::getOwnerUserId));
}
default List<CrmCustomerDO> selectList(Collection<Long> ids) {
return selectList(new LambdaQueryWrapperX<CrmCustomerDO>()
.inIfPresent(CrmCustomerDO::getId, ids));
}
}

View File

@ -0,0 +1,65 @@
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.dal.dataobject.business.CrmBusinessStatusDO;
import javax.validation.Valid;
import java.util.List;
/**
* 商机状态 Service 接口
*
* @author ljlleo
*/
public interface CrmBusinessStatusService {
/**
* 创建商机状态
*
* @param createReqVO 创建信息
* @return 编号
*/
Long createBusinessStatus(@Valid CrmBusinessStatusSaveReqVO createReqVO);
/**
* 更新商机状态
*
* @param updateReqVO 更新信息
*/
void updateBusinessStatus(@Valid CrmBusinessStatusSaveReqVO updateReqVO);
/**
* 删除商机状态
*
* @param id 编号
*/
void deleteBusinessStatus(Long id);
/**
* 获得商机状态
*
* @param id 编号
* @return 商机状态
*/
CrmBusinessStatusDO getBusinessStatus(Long id);
/**
* 获得商机状态分页
*
* @param pageReqVO 分页查询
* @return 商机状态分页
*/
PageResult<CrmBusinessStatusDO> getBusinessStatusPage(CrmBusinessStatusPageReqVO pageReqVO);
/**
* 获得商机状态分页
*
* @param queryVO 查询参数
* @return 商机状态分页
*/
List<CrmBusinessStatusDO> selectList(CrmBusinessStatusQueryVO queryVO);
}

View File

@ -0,0 +1,79 @@
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.dal.dataobject.business.CrmBusinessStatusDO;
import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessStatusMapper;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.List;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_STATUS_NOT_EXISTS;
/**
* 商机状态 Service 实现类
*
* @author ljlleo
*/
@Service
@Validated
public class CrmBusinessStatusServiceImpl implements CrmBusinessStatusService {
@Resource
private CrmBusinessStatusMapper businessStatusMapper;
@Override
public Long createBusinessStatus(CrmBusinessStatusSaveReqVO createReqVO) {
// 插入
CrmBusinessStatusDO businessStatus = BeanUtils.toBean(createReqVO, CrmBusinessStatusDO.class);
businessStatusMapper.insert(businessStatus);
// 返回
return businessStatus.getId();
}
@Override
public void updateBusinessStatus(CrmBusinessStatusSaveReqVO updateReqVO) {
// 校验存在
validateBusinessStatusExists(updateReqVO.getId());
// 更新
CrmBusinessStatusDO updateObj = BeanUtils.toBean(updateReqVO, CrmBusinessStatusDO.class);
businessStatusMapper.updateById(updateObj);
}
@Override
public void deleteBusinessStatus(Long id) {
// 校验存在
validateBusinessStatusExists(id);
// 删除
businessStatusMapper.deleteById(id);
}
private void validateBusinessStatusExists(Long id) {
if (businessStatusMapper.selectById(id) == null) {
throw exception(BUSINESS_STATUS_NOT_EXISTS);
}
}
@Override
public CrmBusinessStatusDO getBusinessStatus(Long id) {
return businessStatusMapper.selectById(id);
}
@Override
public PageResult<CrmBusinessStatusDO> getBusinessStatusPage(CrmBusinessStatusPageReqVO pageReqVO) {
return businessStatusMapper.selectPage(pageReqVO);
}
@Override
public List<CrmBusinessStatusDO> selectList(CrmBusinessStatusQueryVO queryVO) {
return businessStatusMapper.selectList(queryVO);
}
}

View File

@ -0,0 +1,64 @@
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.dal.dataobject.business.CrmBusinessStatusTypeDO;
import javax.validation.Valid;
import java.util.List;
/**
* 商机状态类型 Service 接口
*
* @author ljlleo
*/
public interface CrmBusinessStatusTypeService {
/**
* 创建商机状态类型
*
* @param createReqVO 创建信息
* @return 编号
*/
Long createBusinessStatusType(@Valid CrmBusinessStatusTypeSaveReqVO createReqVO);
/**
* 更新商机状态类型
*
* @param updateReqVO 更新信息
*/
void updateBusinessStatusType(@Valid CrmBusinessStatusTypeSaveReqVO updateReqVO);
/**
* 删除商机状态类型
*
* @param id 编号
*/
void deleteBusinessStatusType(Long id);
/**
* 获得商机状态类型
*
* @param id 编号
* @return 商机状态类型
*/
CrmBusinessStatusTypeDO getBusinessStatusType(Long id);
/**
* 获得商机状态类型分页
*
* @param pageReqVO 分页查询
* @return 商机状态类型分页
*/
PageResult<CrmBusinessStatusTypeDO> getBusinessStatusTypePage(CrmBusinessStatusTypePageReqVO pageReqVO);
/**
* 获得商机状态类型列表
*
* @param queryVO 查询参数
* @return 商机状态类型列表
*/
List<CrmBusinessStatusTypeDO> selectList(CrmBusinessStatusTypeQueryVO queryVO);
}

View File

@ -0,0 +1,121 @@
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.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.dal.dataobject.business.CrmBusinessStatusDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO;
import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessStatusMapper;
import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessStatusTypeMapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.List;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_STATUS_TYPE_NOT_EXISTS;
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_STATUS_TYPE_NAME_EXISTS;
/**
* 商机状态类型 Service 实现类
*
* @author ljlleo
*/
@Service
@Validated
public class CrmBusinessStatusTypeServiceImpl implements CrmBusinessStatusTypeService {
@Resource
private CrmBusinessStatusTypeMapper businessStatusTypeMapper;
@Resource
private CrmBusinessStatusMapper businessStatusMapper;
@Override
@Transactional(rollbackFor = Exception.class)
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());
});
//插入状态
businessStatusMapper.insertBatch(BeanUtils.toBean(createReqVO.getStatusList(), CrmBusinessStatusDO.class));
// 返回
return businessStatusType.getId();
}
@Override
@Transactional(rollbackFor = Exception.class)
public void updateBusinessStatusType(CrmBusinessStatusTypeSaveReqVO updateReqVO) {
// 校验存在
validateBusinessStatusTypeExists(updateReqVO.getId());
// 校验名称是否存在
validateBusinessStatusTypeExists(updateReqVO.getName(), updateReqVO.getId());
// 更新
CrmBusinessStatusTypeDO updateObj = BeanUtils.toBean(updateReqVO, CrmBusinessStatusTypeDO.class);
businessStatusTypeMapper.updateById(updateObj);
//删除状态
businessStatusMapper.delete(updateReqVO.getId());
//插入状态
updateReqVO.getStatusList().stream().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 待添加被引用校验
//...
// 校验存在
validateBusinessStatusTypeExists(id);
// 删除
businessStatusTypeMapper.deleteById(id);
//删除状态
businessStatusMapper.delete(id);
}
private void validateBusinessStatusTypeExists(Long id) {
if (businessStatusTypeMapper.selectById(id) == null) {
throw exception(BUSINESS_STATUS_TYPE_NOT_EXISTS);
}
}
private void validateBusinessStatusTypeExists(String name, Long id) {
LambdaQueryWrapper<CrmBusinessStatusTypeDO> wrapper = new LambdaQueryWrapperX<>();
if(null != id) {
wrapper.ne(CrmBusinessStatusTypeDO::getId, id);
}
long cnt = businessStatusTypeMapper.selectCount(wrapper.eq(CrmBusinessStatusTypeDO::getName, name));
if (cnt > 0) {
throw exception(BUSINESS_STATUS_TYPE_NAME_EXISTS);
}
}
@Override
public CrmBusinessStatusTypeDO getBusinessStatusType(Long id) {
return businessStatusTypeMapper.selectById(id);
}
@Override
public PageResult<CrmBusinessStatusTypeDO> getBusinessStatusTypePage(CrmBusinessStatusTypePageReqVO pageReqVO) {
return businessStatusTypeMapper.selectPage(pageReqVO);
}
@Override
public List<CrmBusinessStatusTypeDO> selectList(CrmBusinessStatusTypeQueryVO queryVO) {
return businessStatusTypeMapper.selectList(queryVO);
}
}

View File

@ -1,90 +0,0 @@
package cn.iocoder.yudao.module.crm.service.businessstatus;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo.CrmBusinessStatusCreateReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo.CrmBusinessStatusExportReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo.CrmBusinessStatusPageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo.CrmBusinessStatusUpdateReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatus.CrmBusinessStatusDO;
import javax.validation.Valid;
import java.util.Collection;
import java.util.List;
/**
* 商机状态 Service 接口
*
* @author ljlleo
*/
public interface CrmBusinessStatusService {
/**
* 创建商机状态
*
* @param createReqVO 创建信息
* @return 编号
*/
Long createBusinessStatus(@Valid CrmBusinessStatusCreateReqVO createReqVO);
/**
* 更新商机状态
*
* @param updateReqVO 更新信息
*/
void updateBusinessStatus(@Valid CrmBusinessStatusUpdateReqVO updateReqVO);
/**
* 删除商机状态
*
* @param id 编号
*/
void deleteBusinessStatus(Long id);
/**
* 获得商机状态
*
* @param id 编号
* @return 商机状态
*/
CrmBusinessStatusDO getBusinessStatus(Long id);
/**
* 获得商机状态列表
*
* @param ids 编号
* @return 商机状态列表
*/
List<CrmBusinessStatusDO> getBusinessStatusList(Collection<Long> ids);
/**
* 获得商机状态分页
*
* @param pageReqVO 分页查询
* @return 商机状态分页
*/
PageResult<CrmBusinessStatusDO> getBusinessStatusPage(CrmBusinessStatusPageReqVO pageReqVO);
/**
* 获得商机状态列表, 用于 Excel 导出
*
* @param exportReqVO 查询条件
* @return 商机状态列表
*/
List<CrmBusinessStatusDO> getBusinessStatusList(CrmBusinessStatusExportReqVO exportReqVO);
/**
* 根据类型 ID 获得商机状态列表
*
* @param typeId 商机状态类型 ID
* @return 商机状态列表
*/
List<CrmBusinessStatusDO> getBusinessStatusListByTypeId(Integer typeId);
/**
* 获得商机状态列表
*
* @return 商机状态列表
*/
List<CrmBusinessStatusDO> getBusinessStatusList();
}

View File

@ -1,99 +0,0 @@
package cn.iocoder.yudao.module.crm.service.businessstatus;
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.businessstatus.vo.CrmBusinessStatusCreateReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo.CrmBusinessStatusExportReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo.CrmBusinessStatusPageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo.CrmBusinessStatusUpdateReqVO;
import cn.iocoder.yudao.module.crm.convert.businessstatus.CrmBusinessStatusConvert;
import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatus.CrmBusinessStatusDO;
import cn.iocoder.yudao.module.crm.dal.mysql.businessstatus.CrmBusinessStatusMapper;
import org.springframework.stereotype.Service;
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.BUSINESS_STATUS_NOT_EXISTS;
/**
* 商机状态 Service 实现类
*
* @author ljlleo
*/
@Service
@Validated
public class CrmBusinessStatusServiceImpl implements CrmBusinessStatusService {
@Resource
private CrmBusinessStatusMapper businessStatusMapper;
@Override
public Long createBusinessStatus(CrmBusinessStatusCreateReqVO createReqVO) {
// 插入
CrmBusinessStatusDO businessStatus = CrmBusinessStatusConvert.INSTANCE.convert(createReqVO);
businessStatusMapper.insert(businessStatus);
// 返回
return businessStatus.getId();
}
@Override
public void updateBusinessStatus(CrmBusinessStatusUpdateReqVO updateReqVO) {
// 校验存在
validateBusinessStatusExists(updateReqVO.getId());
// 更新
CrmBusinessStatusDO updateObj = CrmBusinessStatusConvert.INSTANCE.convert(updateReqVO);
businessStatusMapper.updateById(updateObj);
}
@Override
public void deleteBusinessStatus(Long id) {
// 校验存在
validateBusinessStatusExists(id);
// 删除
businessStatusMapper.deleteById(id);
}
private void validateBusinessStatusExists(Long id) {
if (businessStatusMapper.selectById(id) == null) {
throw exception(BUSINESS_STATUS_NOT_EXISTS);
}
}
@Override
public CrmBusinessStatusDO getBusinessStatus(Long id) {
return businessStatusMapper.selectById(id);
}
@Override
public List<CrmBusinessStatusDO> getBusinessStatusList(Collection<Long> ids) {
if (CollUtil.isEmpty(ids)) {
return ListUtil.empty();
}
return businessStatusMapper.selectBatchIds(ids);
}
@Override
public PageResult<CrmBusinessStatusDO> getBusinessStatusPage(CrmBusinessStatusPageReqVO pageReqVO) {
return businessStatusMapper.selectPage(pageReqVO);
}
@Override
public List<CrmBusinessStatusDO> getBusinessStatusList(CrmBusinessStatusExportReqVO exportReqVO) {
return businessStatusMapper.selectList(exportReqVO);
}
@Override
public List<CrmBusinessStatusDO> getBusinessStatusListByTypeId(Integer typeId) {
return businessStatusMapper.getBusinessStatusListByTypeId(typeId);
}
@Override
public List<CrmBusinessStatusDO> getBusinessStatusList() {
return businessStatusMapper.selectList();
}
}

View File

@ -1,83 +0,0 @@
package cn.iocoder.yudao.module.crm.service.businessstatustype;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo.CrmBusinessStatusTypeCreateReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo.CrmBusinessStatusTypeExportReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo.CrmBusinessStatusTypePageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo.CrmBusinessStatusTypeUpdateReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatustype.CrmBusinessStatusTypeDO;
import javax.validation.Valid;
import java.util.Collection;
import java.util.List;
/**
* 商机状态类型 Service 接口
*
* @author ljlleo
*/
public interface CrmBusinessStatusTypeService {
/**
* 创建商机状态类型
*
* @param createReqVO 创建信息
* @return 编号
*/
Long createBusinessStatusType(@Valid CrmBusinessStatusTypeCreateReqVO createReqVO);
/**
* 更新商机状态类型
*
* @param updateReqVO 更新信息
*/
void updateBusinessStatusType(@Valid CrmBusinessStatusTypeUpdateReqVO updateReqVO);
/**
* 删除商机状态类型
*
* @param id 编号
*/
void deleteBusinessStatusType(Long id);
/**
* 获得商机状态类型
*
* @param id 编号
* @return 商机状态类型
*/
CrmBusinessStatusTypeDO getBusinessStatusType(Long id);
/**
* 获得商机状态类型列表
*
* @param ids 编号
* @return 商机状态类型列表
*/
List<CrmBusinessStatusTypeDO> getBusinessStatusTypeList(Collection<Long> ids);
/**
* 获得商机状态类型分页
*
* @param pageReqVO 分页查询
* @return 商机状态类型分页
*/
PageResult<CrmBusinessStatusTypeDO> getBusinessStatusTypePage(CrmBusinessStatusTypePageReqVO pageReqVO);
/**
* 获得商机状态类型列表, 用于 Excel 导出
*
* @param exportReqVO 查询条件
* @return 商机状态类型列表
*/
List<CrmBusinessStatusTypeDO> getBusinessStatusTypeList(CrmBusinessStatusTypeExportReqVO exportReqVO);
/**
* 获得商机状态类型列表
*
* @param status 状态
* @return 商机状态类型列表
*/
List<CrmBusinessStatusTypeDO> getBusinessStatusTypeListByStatus(Integer status);
}

View File

@ -1,98 +0,0 @@
package cn.iocoder.yudao.module.crm.service.businessstatustype;
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.businessstatustype.vo.CrmBusinessStatusTypeCreateReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo.CrmBusinessStatusTypeExportReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo.CrmBusinessStatusTypePageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo.CrmBusinessStatusTypeUpdateReqVO;
import cn.iocoder.yudao.module.crm.convert.businessstatustype.CrmBusinessStatusTypeConvert;
import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatustype.CrmBusinessStatusTypeDO;
import cn.iocoder.yudao.module.crm.dal.mysql.businessstatustype.CrmBusinessStatusTypeMapper;
import org.springframework.stereotype.Service;
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.BUSINESS_STATUS_TYPE_NOT_EXISTS;
/**
* 商机状态类型 Service 实现类
*
* @author ljlleo
*/
@Service
@Validated
public class CrmBusinessStatusTypeServiceImpl implements CrmBusinessStatusTypeService {
@Resource
private CrmBusinessStatusTypeMapper businessStatusTypeMapper;
@Override
public Long createBusinessStatusType(CrmBusinessStatusTypeCreateReqVO createReqVO) {
// TODO ljlleoname 应该需要唯一哈
// 插入
CrmBusinessStatusTypeDO businessStatusType = CrmBusinessStatusTypeConvert.INSTANCE.convert(createReqVO);
businessStatusTypeMapper.insert(businessStatusType);
// 返回
return businessStatusType.getId();
}
@Override
public void updateBusinessStatusType(CrmBusinessStatusTypeUpdateReqVO updateReqVO) {
// TODO ljlleoname 应该需要唯一哈
// 校验存在
validateBusinessStatusTypeExists(updateReqVO.getId());
// 更新
CrmBusinessStatusTypeDO updateObj = CrmBusinessStatusTypeConvert.INSTANCE.convert(updateReqVO);
businessStatusTypeMapper.updateById(updateObj);
}
@Override
public void deleteBusinessStatusType(Long id) {
// 校验存在
validateBusinessStatusTypeExists(id);
// TODO 艿艿这里在看看是不是要校验业务是否在使用
// 删除
businessStatusTypeMapper.deleteById(id);
}
private void validateBusinessStatusTypeExists(Long id) {
if (businessStatusTypeMapper.selectById(id) == null) {
throw exception(BUSINESS_STATUS_TYPE_NOT_EXISTS);
}
}
@Override
public CrmBusinessStatusTypeDO getBusinessStatusType(Long id) {
return businessStatusTypeMapper.selectById(id);
}
@Override
public List<CrmBusinessStatusTypeDO> getBusinessStatusTypeList(Collection<Long> ids) {
if (CollUtil.isEmpty(ids)) {
return ListUtil.empty();
}
return businessStatusTypeMapper.selectBatchIds(ids);
}
@Override
public PageResult<CrmBusinessStatusTypeDO> getBusinessStatusTypePage(CrmBusinessStatusTypePageReqVO pageReqVO) {
return businessStatusTypeMapper.selectPage(pageReqVO);
}
@Override
public List<CrmBusinessStatusTypeDO> getBusinessStatusTypeList(CrmBusinessStatusTypeExportReqVO exportReqVO) {
return businessStatusTypeMapper.selectList(exportReqVO);
}
@Override
public List<CrmBusinessStatusTypeDO> getBusinessStatusTypeListByStatus(Integer status) {
return businessStatusTypeMapper.getBusinessStatusTypeListByStatus(status);
}
}

View File

@ -5,6 +5,7 @@ import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.*;
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
import javax.validation.Valid;
import java.util.Collection;
import java.util.List;
/**
@ -116,4 +117,12 @@ public interface CrmCustomerService {
*/
void putPool(Long id);
/**
* 根据客户ID集合查询客户集合
* @param ids
* @author ljlleo
* @return
*/
List<CrmCustomerDO> getCustomerList(Collection<Long> ids);
}

View File

@ -249,4 +249,9 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
CrmPermissionLevelEnum.OWNER.getLevel());
}
@Override
public List<CrmCustomerDO> getCustomerList(Collection<Long> ids) {
return customerMapper.selectList(ids);
}
}

View File

@ -0,0 +1,117 @@
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 org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.Import;
import javax.annotation.Resource;
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException;
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId;
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.*;
/**
* {@link BusinessStatusTypeServiceImpl} 的单元测试类
*
* @author ljlleo
*/
@Import(BusinessStatusTypeServiceImpl.class)
public class BusinessStatusTypeServiceImplTest extends BaseDbUnitTest {
@Resource
private BusinessStatusTypeServiceImpl businessStatusTypeService;
@Resource
private BusinessStatusTypeMapper businessStatusTypeMapper;
@Test
public void testCreateBusinessStatusType_success() {
// 准备参数
BusinessStatusTypeSaveReqVO createReqVO = randomPojo(BusinessStatusTypeSaveReqVO.class).setId(null);
// 调用
Long businessStatusTypeId = businessStatusTypeService.createBusinessStatusType(createReqVO);
// 断言
assertNotNull(businessStatusTypeId);
// 校验记录的属性是否正确
BusinessStatusTypeDO businessStatusType = businessStatusTypeMapper.selectById(businessStatusTypeId);
assertPojoEquals(createReqVO, businessStatusType, "id");
}
@Test
public void testUpdateBusinessStatusType_success() {
// mock 数据
BusinessStatusTypeDO dbBusinessStatusType = randomPojo(BusinessStatusTypeDO.class);
businessStatusTypeMapper.insert(dbBusinessStatusType);// @Sql: 先插入出一条存在的数据
// 准备参数
BusinessStatusTypeSaveReqVO updateReqVO = randomPojo(BusinessStatusTypeSaveReqVO.class, o -> {
o.setId(dbBusinessStatusType.getId()); // 设置更新的 ID
});
// 调用
businessStatusTypeService.updateBusinessStatusType(updateReqVO);
// 校验是否更新正确
BusinessStatusTypeDO businessStatusType = businessStatusTypeMapper.selectById(updateReqVO.getId()); // 获取最新的
assertPojoEquals(updateReqVO, businessStatusType);
}
@Test
public void testUpdateBusinessStatusType_notExists() {
// 准备参数
BusinessStatusTypeSaveReqVO updateReqVO = randomPojo(BusinessStatusTypeSaveReqVO.class);
// 调用, 并断言异常
assertServiceException(() -> businessStatusTypeService.updateBusinessStatusType(updateReqVO), BUSINESS_STATUS_TYPE_NOT_EXISTS);
}
@Test
public void testDeleteBusinessStatusType_success() {
// mock 数据
BusinessStatusTypeDO dbBusinessStatusType = randomPojo(BusinessStatusTypeDO.class);
businessStatusTypeMapper.insert(dbBusinessStatusType);// @Sql: 先插入出一条存在的数据
// 准备参数
Long id = dbBusinessStatusType.getId();
// 调用
businessStatusTypeService.deleteBusinessStatusType(id);
// 校验数据不存在了
assertNull(businessStatusTypeMapper.selectById(id));
}
@Test
public void testDeleteBusinessStatusType_notExists() {
// 准备参数
Long id = randomLongId();
// 调用, 并断言异常
assertServiceException(() -> businessStatusTypeService.deleteBusinessStatusType(id), BUSINESS_STATUS_TYPE_NOT_EXISTS);
}
@Test
@Disabled // TODO 请修改 null 为需要的值然后删除 @Disabled 注解
public void testGetBusinessStatusTypePage() {
// mock 数据
BusinessStatusTypeDO dbBusinessStatusType = randomPojo(BusinessStatusTypeDO.class, o -> { // 等会查询到
});
businessStatusTypeMapper.insert(dbBusinessStatusType);
// 准备参数
BusinessStatusTypePageReqVO reqVO = new BusinessStatusTypePageReqVO();
// 调用
PageResult<BusinessStatusTypeDO> pageResult = businessStatusTypeService.getBusinessStatusTypePage(reqVO);
// 断言
assertEquals(1, pageResult.getTotal());
assertEquals(1, pageResult.getList().size());
assertPojoEquals(dbBusinessStatusType, pageResult.getList().get(0));
}
}