diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java index 4dc209d7d..0669a3c03 100644 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java +++ b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java @@ -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, "商机状态不存在"); + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java index 5dd10d1da..524a078b1 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java @@ -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> getBusinessPage(@Valid CrmBusinessPageReqVO pageVO) { PageResult pageResult = businessService.getBusinessPage(pageVO, getLoginUserId()); - return success(CrmBusinessConvert.INSTANCE.convertPage(pageResult)); + //处理客户名称回显 + Set customerIds = pageResult.getList().stream() + .map(CrmBusinessDO::getCustomerId).filter(Objects::nonNull).collect(Collectors.toSet()); + List customerList = customerService.getCustomerList(customerIds); + //处理商机状态类型名称回显 + Set statusTypeIds = pageResult.getList().stream() + .map(CrmBusinessDO::getStatusTypeId).filter(Objects::nonNull).collect(Collectors.toSet()); + CrmBusinessStatusTypeQueryVO queryStatusTypeVO = new CrmBusinessStatusTypeQueryVO(); + queryStatusTypeVO.setIdList(statusTypeIds); + List statusTypeList = businessStatusTypeService.selectList(queryStatusTypeVO); + //处理商机状态名称回显 + Set statusIds = pageResult.getList().stream() + .map(CrmBusinessDO::getCustomerId).filter(Objects::nonNull).collect(Collectors.toSet()); + CrmBusinessStatusQueryVO queryVO = new CrmBusinessStatusQueryVO(); + queryVO.setIdList(statusIds); + List statusList = businessStatusService.selectList(queryVO); + return success(CrmBusinessConvert.INSTANCE.convertPage(pageResult, customerList, statusTypeList, statusList)); } @GetMapping("/pool-page") diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/CrmBusinessStatusTypeController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessStatusTypeController.java similarity index 59% rename from yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/CrmBusinessStatusTypeController.java rename to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessStatusTypeController.java index 25ba7448f..af35eb62e 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/CrmBusinessStatusTypeController.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessStatusTypeController.java @@ -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 createBusinessStatusType(@Valid @RequestBody CrmBusinessStatusTypeCreateReqVO createReqVO) { + public CommonResult createBusinessStatusType(@Valid @RequestBody CrmBusinessStatusTypeSaveReqVO createReqVO) { return success(businessStatusTypeService.createBusinessStatusType(createReqVO)); } @PutMapping("/update") @Operation(summary = "更新商机状态类型") @PreAuthorize("@ss.hasPermission('crm:business-status-type:update')") - public CommonResult updateBusinessStatusType(@Valid @RequestBody CrmBusinessStatusTypeUpdateReqVO updateReqVO) { + public CommonResult 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 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> getBusinessStatusTypeList(@RequestParam("ids") Collection ids) { - List list = businessStatusTypeService.getBusinessStatusTypeList(ids); - return success(CrmBusinessStatusTypeConvert.INSTANCE.convertList(list)); + //处理状态回显 + CrmBusinessStatusQueryVO queryVO = new CrmBusinessStatusQueryVO(); + queryVO.setTypeId(id); + List 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> getBusinessStatusTypePage(@Valid CrmBusinessStatusTypePageReqVO pageVO) { - PageResult pageResult = businessStatusTypeService.getBusinessStatusTypePage(pageVO); - return success(CrmBusinessStatusTypeConvert.INSTANCE.convertPage(pageResult)); + public CommonResult> getBusinessStatusTypePage(@Valid CrmBusinessStatusTypePageReqVO pageReqVO) { + PageResult pageResult = businessStatusTypeService.getBusinessStatusTypePage(pageReqVO); + //处理部门回显 + Set deptIds = pageResult.getList().stream() + .map(CrmBusinessStatusTypeDO::getDeptIds) + .filter(Objects::nonNull) + .flatMap(Collection::stream) + .collect(Collectors.toSet()); + List 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 list = businessStatusTypeService.getBusinessStatusTypeList(exportReqVO); + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = businessStatusTypeService.getBusinessStatusTypePage(pageReqVO).getList(); // 导出 Excel - List 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> getBusinessStatusTypeList() { - List list = businessStatusTypeService.getBusinessStatusTypeListByStatus(CommonStatusEnum.ENABLE.getStatus()); - return success(CrmBusinessStatusTypeConvert.INSTANCE.convertList(list)); + CrmBusinessStatusTypeQueryVO queryVO = new CrmBusinessStatusTypeQueryVO(); + queryVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); + List 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> getBusinessStatusListByTypeId(@RequestParam("typeId") Long typeId) { + CrmBusinessStatusQueryVO queryVO = new CrmBusinessStatusQueryVO(); + queryVO.setTypeId(typeId); + List list = businessStatusService.selectList(queryVO); + return success(CrmBusinessStatusConvert.INSTANCE.convertList(list)); + } } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessRespVO.java index 672f99ec3..57efd8e16 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessRespVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessRespVO.java @@ -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; + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessStatusPageReqVO.java similarity index 70% rename from yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusPageReqVO.java rename to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessStatusPageReqVO.java index af03512af..72e754eab 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusPageReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessStatusPageReqVO.java @@ -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; - } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessStatusQueryVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessStatusQueryVO.java new file mode 100644 index 000000000..0801b3fe4 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessStatusQueryVO.java @@ -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 idList; + + @Schema(description = "状态类型编号") + private Long typeId; +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessStatusRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessStatusRespVO.java new file mode 100644 index 000000000..d490d2bcc --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessStatusRespVO.java @@ -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; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessStatusSaveReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessStatusSaveReqVO.java new file mode 100644 index 000000000..9a3362291 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessStatusSaveReqVO.java @@ -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; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypePageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessStatusTypePageReqVO.java similarity index 61% rename from yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypePageReqVO.java rename to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessStatusTypePageReqVO.java index 4b15210ac..3e02fa5ac 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypePageReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessStatusTypePageReqVO.java @@ -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; - } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessStatusTypeQueryVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessStatusTypeQueryVO.java new file mode 100644 index 000000000..321a48426 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessStatusTypeQueryVO.java @@ -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 idList; + + @Schema(description = "状态") + private Integer status; +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessStatusTypeRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessStatusTypeRespVO.java new file mode 100644 index 000000000..0a43af12e --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessStatusTypeRespVO.java @@ -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 deptNames; + + @Schema(description = "使用的部门编号", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("使用的部门编号") + private List 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 statusList; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessStatusTypeSaveReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessStatusTypeSaveReqVO.java new file mode 100644 index 000000000..58e8f4229 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessStatusTypeSaveReqVO.java @@ -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 deptIds = Lists.newArrayList(); + + @Schema(description = "商机状态集合", requiredMode = Schema.RequiredMode.REQUIRED) + private List statusList = Lists.newArrayList(); + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/CrmBusinessStatusController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/CrmBusinessStatusController.java deleted file mode 100644 index 275285098..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/CrmBusinessStatusController.java +++ /dev/null @@ -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 createBusinessStatus(@Valid @RequestBody CrmBusinessStatusCreateReqVO createReqVO) { - return success(businessStatusService.createBusinessStatus(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新商机状态") - @PreAuthorize("@ss.hasPermission('crm:business-status:update')") - public CommonResult 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 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 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> getBusinessStatusList(@RequestParam("ids") Collection ids) { - List list = businessStatusService.getBusinessStatusList(ids); - return success(CrmBusinessStatusConvert.INSTANCE.convertList(list)); - } - - @GetMapping("/page") - @Operation(summary = "获得商机状态分页") - @PreAuthorize("@ss.hasPermission('crm:business-status:query')") - public CommonResult> getBusinessStatusPage(@Valid CrmBusinessStatusPageReqVO pageVO) { - PageResult 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 list = businessStatusService.getBusinessStatusList(exportReqVO); - // 导出 Excel - List 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> getBusinessStatusListByTypeId(@RequestParam("typeId") Integer typeId) { - List 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> getBusinessStatusList() { - List list = businessStatusService.getBusinessStatusList(); - return success(CrmBusinessStatusConvert.INSTANCE.convertList(list)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusBaseVO.java deleted file mode 100644 index 401e35fbe..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusBaseVO.java +++ /dev/null @@ -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 @lilleo:example 要写下 - - @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 @lilleo:percent 应该是 Integer; - @Schema(description = "赢单率") - private String percent; - - // TODO @lilleo:这个是不是不用前端新增和修改的时候传递,交给顺序计算出来,存储起来就好了; - @Schema(description = "排序") - private Integer sort; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusCreateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusCreateReqVO.java deleted file mode 100644 index 04e999474..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusCreateReqVO.java +++ /dev/null @@ -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 { - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusExcelVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusExcelVO.java deleted file mode 100644 index 78da092f7..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusExcelVO.java +++ /dev/null @@ -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; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusExportReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusExportReqVO.java deleted file mode 100644 index 7f7fba6c7..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusExportReqVO.java +++ /dev/null @@ -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; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusRespVO.java deleted file mode 100644 index 54f675272..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusRespVO.java +++ /dev/null @@ -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; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusUpdateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusUpdateReqVO.java deleted file mode 100644 index 429902164..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusUpdateReqVO.java +++ /dev/null @@ -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; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeBaseVO.java deleted file mode 100644 index c472a3471..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeBaseVO.java +++ /dev/null @@ -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; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeCreateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeCreateReqVO.java deleted file mode 100644 index 5000e25ee..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeCreateReqVO.java +++ /dev/null @@ -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 { - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeExcelVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeExcelVO.java deleted file mode 100644 index cc6ed8502..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeExcelVO.java +++ /dev/null @@ -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; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeExportReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeExportReqVO.java deleted file mode 100644 index 1345565be..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeExportReqVO.java +++ /dev/null @@ -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; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeRespVO.java deleted file mode 100644 index a4e21c58e..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeRespVO.java +++ /dev/null @@ -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; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeUpdateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeUpdateReqVO.java deleted file mode 100644 index 0eb93224c..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeUpdateReqVO.java +++ /dev/null @@ -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; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/business/CrmBusinessConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/business/CrmBusinessConvert.java index 8b7f7e83b..6de4c1241 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/business/CrmBusinessConvert.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/business/CrmBusinessConvert.java @@ -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 convertPage(PageResult page, List customerList, + List statusTypeList, List statusList) { + PageResult result = convertPage(page); + Map customerMap = convertMap(customerList, CrmCustomerDO::getId, CrmCustomerDO::getName); + Map statusTypeMap = convertMap(statusTypeList, CrmBusinessStatusTypeDO::getId, CrmBusinessStatusTypeDO::getName); + Map 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; + } + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/businessstatus/CrmBusinessStatusConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/businessstatus/CrmBusinessStatusConvert.java index c8b854144..19fb76171 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/businessstatus/CrmBusinessStatusConvert.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/businessstatus/CrmBusinessStatusConvert.java @@ -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 convertPage(PageResult page); - List convertList02(List list); - } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/businessstatustype/CrmBusinessStatusTypeConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/businessstatustype/CrmBusinessStatusTypeConvert.java index 75f1aed4c..ef3788233 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/businessstatustype/CrmBusinessStatusTypeConvert.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/businessstatustype/CrmBusinessStatusTypeConvert.java @@ -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 convertList(List list); - PageResult convertPage(PageResult page); - List convertList02(List list); + default PageResult convertPage(PageResult page, List deptList) { + PageResult pageResult = convertPage(page); + Map 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 statusList) { + CrmBusinessStatusTypeRespVO result = convert(bean); + result.setStatusList(statusList); + return result; + } + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessDO.java index 435bf1995..f748525d4 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessDO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessDO.java @@ -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; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/businessstatus/CrmBusinessStatusDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessStatusDO.java similarity index 87% rename from yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/businessstatus/CrmBusinessStatusDO.java rename to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessStatusDO.java index 3a1b66ad0..b6ae23bce 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/businessstatus/CrmBusinessStatusDO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessStatusDO.java @@ -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; /** diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/businessstatustype/CrmBusinessStatusTypeDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessStatusTypeDO.java similarity index 57% rename from yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/businessstatustype/CrmBusinessStatusTypeDO.java rename to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessStatusTypeDO.java index fbc2e6857..d5dcef0ba 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/businessstatustype/CrmBusinessStatusTypeDO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessStatusTypeDO.java @@ -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") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 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 @ljlleo:List 存储哈 /** * 使用的部门编号 */ - private String deptIds; + @TableField(typeHandler = LongListTypeHandler.class) + private List deptIds; /** * 开启状态 */ - // TODO @ljlleo:这个字段,使用 Integer,对应 CommonStatus private Boolean status; } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessStatusMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessStatusMapper.java new file mode 100644 index 000000000..d78ecab5c --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessStatusMapper.java @@ -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 { + + default PageResult selectPage(CrmBusinessStatusPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .orderByDesc(CrmBusinessStatusDO::getId)); + } + + default List selectList(CrmBusinessStatusQueryVO queryVO) { + return selectList(new LambdaQueryWrapperX() + .eqIfPresent(CrmBusinessStatusDO::getTypeId, queryVO.getTypeId()) + .inIfPresent(CrmBusinessStatusDO::getId, queryVO.getIdList()) + .orderByDesc(CrmBusinessStatusDO::getId)); + } + + default int delete(Long typeId) { + return delete(new LambdaQueryWrapperX() + .eq(CrmBusinessStatusDO::getTypeId, typeId)); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessStatusTypeMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessStatusTypeMapper.java new file mode 100644 index 000000000..d3f3e1e2e --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessStatusTypeMapper.java @@ -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 { + + default PageResult selectPage(CrmBusinessStatusTypePageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .orderByDesc(CrmBusinessStatusTypeDO::getId)); + } + + default List selectList(CrmBusinessStatusTypeQueryVO queryVO) { + return selectList(new LambdaQueryWrapperX() + .eqIfPresent(CrmBusinessStatusTypeDO::getStatus, queryVO.getStatus()) + .inIfPresent(CrmBusinessStatusTypeDO::getId, queryVO.getIdList())); + } +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/businessstatus/CrmBusinessStatusMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/businessstatus/CrmBusinessStatusMapper.java deleted file mode 100644 index 2b9eeb4ae..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/businessstatus/CrmBusinessStatusMapper.java +++ /dev/null @@ -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 { - - default PageResult selectPage(CrmBusinessStatusPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(CrmBusinessStatusDO::getTypeId, reqVO.getTypeId()) - .orderByDesc(CrmBusinessStatusDO::getId)); - } - - default List selectList(CrmBusinessStatusExportReqVO reqVO) { - return selectList(new LambdaQueryWrapperX() - .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 getBusinessStatusListByTypeId(Integer typeId) { - return selectList(CrmBusinessStatusDO::getTypeId, typeId); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/businessstatustype/CrmBusinessStatusTypeMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/businessstatustype/CrmBusinessStatusTypeMapper.java deleted file mode 100644 index 258477e4d..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/businessstatustype/CrmBusinessStatusTypeMapper.java +++ /dev/null @@ -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 { - - default PageResult selectPage(CrmBusinessStatusTypePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(CrmBusinessStatusTypeDO::getName, reqVO.getName()) -// .eqIfPresent(CrmBusinessStatusTypeDO::getDeptIds, reqVO.getDeptIds()) TODO 报错,临时注释掉 - .eqIfPresent(CrmBusinessStatusTypeDO::getStatus, reqVO.getStatus()) - .orderByDesc(CrmBusinessStatusTypeDO::getId)); - } - - default List selectList(CrmBusinessStatusTypeExportReqVO reqVO) { - return selectList(new LambdaQueryWrapperX() - .likeIfPresent(CrmBusinessStatusTypeDO::getName, reqVO.getName()) - .eqIfPresent(CrmBusinessStatusTypeDO::getDeptIds, reqVO.getDeptIds()) - .eqIfPresent(CrmBusinessStatusTypeDO::getStatus, reqVO.getStatus()) - .orderByDesc(CrmBusinessStatusTypeDO::getId)); - } - - default List getBusinessStatusTypeListByStatus(Integer status) { - return selectList(CrmBusinessStatusTypeDO::getStatus, status.byteValue()); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java index c9c38d5f0..cb409fbda 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java @@ -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 { .isNull(CrmCustomerDO::getOwnerUserId)); } + default List selectList(Collection ids) { + return selectList(new LambdaQueryWrapperX() + .inIfPresent(CrmCustomerDO::getId, ids)); + } + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusService.java new file mode 100644 index 000000000..48686de11 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusService.java @@ -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 getBusinessStatusPage(CrmBusinessStatusPageReqVO pageReqVO); + + /** + * 获得商机状态分页 + * + * @param queryVO 查询参数 + * @return 商机状态分页 + */ + List selectList(CrmBusinessStatusQueryVO queryVO); + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusServiceImpl.java new file mode 100644 index 000000000..1f68fc89e --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusServiceImpl.java @@ -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 getBusinessStatusPage(CrmBusinessStatusPageReqVO pageReqVO) { + return businessStatusMapper.selectPage(pageReqVO); + } + + @Override + public List selectList(CrmBusinessStatusQueryVO queryVO) { + return businessStatusMapper.selectList(queryVO); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusTypeService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusTypeService.java new file mode 100644 index 000000000..0b0bea7e0 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusTypeService.java @@ -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 getBusinessStatusTypePage(CrmBusinessStatusTypePageReqVO pageReqVO); + + /** + * 获得商机状态类型列表 + * + * @param queryVO 查询参数 + * @return 商机状态类型列表 + */ + List selectList(CrmBusinessStatusTypeQueryVO queryVO); +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusTypeServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusTypeServiceImpl.java new file mode 100644 index 000000000..d8226e8f8 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusTypeServiceImpl.java @@ -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 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 getBusinessStatusTypePage(CrmBusinessStatusTypePageReqVO pageReqVO) { + return businessStatusTypeMapper.selectPage(pageReqVO); + } + + @Override + public List selectList(CrmBusinessStatusTypeQueryVO queryVO) { + return businessStatusTypeMapper.selectList(queryVO); + } +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/businessstatus/CrmBusinessStatusService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/businessstatus/CrmBusinessStatusService.java deleted file mode 100644 index 44b3e9f1b..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/businessstatus/CrmBusinessStatusService.java +++ /dev/null @@ -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 getBusinessStatusList(Collection ids); - - /** - * 获得商机状态分页 - * - * @param pageReqVO 分页查询 - * @return 商机状态分页 - */ - PageResult getBusinessStatusPage(CrmBusinessStatusPageReqVO pageReqVO); - - /** - * 获得商机状态列表, 用于 Excel 导出 - * - * @param exportReqVO 查询条件 - * @return 商机状态列表 - */ - List getBusinessStatusList(CrmBusinessStatusExportReqVO exportReqVO); - - /** - * 根据类型 ID 获得商机状态列表 - * - * @param typeId 商机状态类型 ID - * @return 商机状态列表 - */ - List getBusinessStatusListByTypeId(Integer typeId); - - /** - * 获得商机状态列表 - * - * @return 商机状态列表 - */ - List getBusinessStatusList(); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/businessstatus/CrmBusinessStatusServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/businessstatus/CrmBusinessStatusServiceImpl.java deleted file mode 100644 index e927fac74..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/businessstatus/CrmBusinessStatusServiceImpl.java +++ /dev/null @@ -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 getBusinessStatusList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return ListUtil.empty(); - } - return businessStatusMapper.selectBatchIds(ids); - } - - @Override - public PageResult getBusinessStatusPage(CrmBusinessStatusPageReqVO pageReqVO) { - return businessStatusMapper.selectPage(pageReqVO); - } - - @Override - public List getBusinessStatusList(CrmBusinessStatusExportReqVO exportReqVO) { - return businessStatusMapper.selectList(exportReqVO); - } - - @Override - public List getBusinessStatusListByTypeId(Integer typeId) { - return businessStatusMapper.getBusinessStatusListByTypeId(typeId); - } - - @Override - public List getBusinessStatusList() { - return businessStatusMapper.selectList(); - } -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/businessstatustype/CrmBusinessStatusTypeService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/businessstatustype/CrmBusinessStatusTypeService.java deleted file mode 100644 index 3c473f62b..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/businessstatustype/CrmBusinessStatusTypeService.java +++ /dev/null @@ -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 getBusinessStatusTypeList(Collection ids); - - /** - * 获得商机状态类型分页 - * - * @param pageReqVO 分页查询 - * @return 商机状态类型分页 - */ - PageResult getBusinessStatusTypePage(CrmBusinessStatusTypePageReqVO pageReqVO); - - /** - * 获得商机状态类型列表, 用于 Excel 导出 - * - * @param exportReqVO 查询条件 - * @return 商机状态类型列表 - */ - List getBusinessStatusTypeList(CrmBusinessStatusTypeExportReqVO exportReqVO); - - /** - * 获得商机状态类型列表 - * - * @param status 状态 - * @return 商机状态类型列表 - */ - List getBusinessStatusTypeListByStatus(Integer status); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/businessstatustype/CrmBusinessStatusTypeServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/businessstatustype/CrmBusinessStatusTypeServiceImpl.java deleted file mode 100644 index f428c3836..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/businessstatustype/CrmBusinessStatusTypeServiceImpl.java +++ /dev/null @@ -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 ljlleo:name 应该需要唯一哈; - // 插入 - CrmBusinessStatusTypeDO businessStatusType = CrmBusinessStatusTypeConvert.INSTANCE.convert(createReqVO); - businessStatusTypeMapper.insert(businessStatusType); - // 返回 - return businessStatusType.getId(); - } - - @Override - public void updateBusinessStatusType(CrmBusinessStatusTypeUpdateReqVO updateReqVO) { - // TODO ljlleo:name 应该需要唯一哈; - // 校验存在 - 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 getBusinessStatusTypeList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return ListUtil.empty(); - } - return businessStatusTypeMapper.selectBatchIds(ids); - } - - @Override - public PageResult getBusinessStatusTypePage(CrmBusinessStatusTypePageReqVO pageReqVO) { - return businessStatusTypeMapper.selectPage(pageReqVO); - } - - @Override - public List getBusinessStatusTypeList(CrmBusinessStatusTypeExportReqVO exportReqVO) { - return businessStatusTypeMapper.selectList(exportReqVO); - } - - @Override - public List getBusinessStatusTypeListByStatus(Integer status) { - return businessStatusTypeMapper.getBusinessStatusTypeListByStatus(status); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java index 2aec682f7..24605d55c 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java @@ -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 getCustomerList(Collection ids); + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java index 9650b0e58..1156a2c98 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java @@ -249,4 +249,9 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { CrmPermissionLevelEnum.OWNER.getLevel()); } + @Override + public List getCustomerList(Collection ids) { + return customerMapper.selectList(ids); + } + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/business/BusinessStatusTypeServiceImplTest.java b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/business/BusinessStatusTypeServiceImplTest.java new file mode 100644 index 000000000..b28ccf6f7 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/business/BusinessStatusTypeServiceImplTest.java @@ -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 pageResult = businessStatusTypeService.getBusinessStatusTypePage(reqVO); + // 断言 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(dbBusinessStatusType, pageResult.getList().get(0)); + } + +}