mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-25 00:15:06 +08:00
Merge branch 'feature/crm' of https://gitee.com/ljlleo/ruoyi-vue-pro into feature/crm
# Conflicts: # sql/mysql/crm.sql
This commit is contained in:
@ -17,6 +17,8 @@ public interface ErrorCodeConstants {
|
||||
|
||||
// ========== 商机管理 1-020-002-000 ==========
|
||||
ErrorCode BUSINESS_NOT_EXISTS = new ErrorCode(1_020_002_000, "商机不存在");
|
||||
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, "联系人不存在");
|
||||
|
@ -71,6 +71,7 @@ public class CrmBusinessController {
|
||||
@PreAuthorize("@ss.hasPermission('crm:business:query')")
|
||||
public CommonResult<PageResult<CrmBusinessRespVO>> getBusinessPage(@Valid CrmBusinessPageReqVO pageVO) {
|
||||
PageResult<CrmBusinessDO> pageResult = businessService.getBusinessPage(pageVO);
|
||||
|
||||
return success(CrmBusinessConvert.INSTANCE.convertPage(pageResult));
|
||||
}
|
||||
|
||||
|
@ -21,13 +21,11 @@ public class CrmBusinessBaseVO {
|
||||
@NotNull(message = "商机名称不能为空")
|
||||
private String name;
|
||||
|
||||
// TODO @ljileo:要写 requiredMode = Schema.RequiredMode.REQUIRED
|
||||
@Schema(description = "商机状态类型编号", example = "25714")
|
||||
@Schema(description = "商机状态类型编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "25714")
|
||||
@NotNull(message = "商机状态类型不能为空")
|
||||
private Long statusTypeId;
|
||||
|
||||
// TODO @ljileo:要写 requiredMode = Schema.RequiredMode.REQUIRED
|
||||
@Schema(description = "商机状态编号", example = "30320")
|
||||
@Schema(description = "商机状态编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320")
|
||||
@NotNull(message = "商机状态不能为空")
|
||||
private Long statusId;
|
||||
|
||||
@ -43,13 +41,12 @@ public class CrmBusinessBaseVO {
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime dealTime;
|
||||
|
||||
// TODO @ljileo:金额使用 Integer 类型,转换成分
|
||||
@Schema(description = "商机金额", example = "12371")
|
||||
private BigDecimal price;
|
||||
private Integer price;
|
||||
|
||||
// TODO @ljileo:折扣使用 Integer 类型,存储时,默认 * 100;展示的时候,前端需要 / 100;避免精度丢失问题
|
||||
@Schema(description = "整单折扣")
|
||||
private BigDecimal discountPercent;
|
||||
private Integer discountPercent;
|
||||
|
||||
@Schema(description = "产品总金额", example = "12025")
|
||||
private BigDecimal productPrice;
|
||||
@ -57,33 +54,4 @@ public class CrmBusinessBaseVO {
|
||||
@Schema(description = "备注", example = "随便")
|
||||
private String remark;
|
||||
|
||||
// TODO @ljileo:这个新建和修改的时候,应该不传递哈;应该新建的人,就是它的负责人
|
||||
@Schema(description = "负责人的用户编号", example = "25562")
|
||||
private Long ownerUserId;
|
||||
|
||||
// TODO @ljileo:这个新建和修改的时候,应该不传递哈
|
||||
@Schema(description = "只读权限的用户编号数组", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String roUserIds;
|
||||
|
||||
// TODO @ljileo:这个新建和修改的时候,应该不传递哈
|
||||
@Schema(description = "读写权限的用户编号数组", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String rwUserIds;
|
||||
|
||||
// TODO @lijieo:新建的时候,不传递这个字段哈;
|
||||
@Schema(description = "1赢单2输单3无效", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Integer endStatus;
|
||||
|
||||
// TODO @lijieo:新建的时候,不传递这个字段哈;
|
||||
@Schema(description = "结束时的备注", example = "你说的对")
|
||||
private String endRemark;
|
||||
|
||||
// TODO @lijieo:新建的时候,不传递这个字段哈;
|
||||
@Schema(description = "最后跟进时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime contactLastTime;
|
||||
|
||||
// TODO @lijieo:新建的时候,不传递这个字段哈;
|
||||
@Schema(description = "跟进状态", example = "1")
|
||||
private Integer followUpStatus;
|
||||
|
||||
}
|
||||
|
@ -5,12 +5,6 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 商机分页 Request VO")
|
||||
@Data
|
||||
@ -18,64 +12,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
|
||||
@ToString(callSuper = true)
|
||||
public class CrmBusinessPageReqVO extends PageParam {
|
||||
|
||||
// TODO @ljileo:目前就使用 name 检索即可;
|
||||
|
||||
@Schema(description = "商机名称", example = "李四")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "商机状态类型编号", example = "25714")
|
||||
private Long statusTypeId;
|
||||
|
||||
@Schema(description = "商机状态编号", example = "30320")
|
||||
private Long statusId;
|
||||
|
||||
@Schema(description = "下次联系时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] contactNextTime;
|
||||
|
||||
@Schema(description = "客户编号", example = "10299")
|
||||
private Long customerId;
|
||||
|
||||
@Schema(description = "预计成交日期")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] dealTime;
|
||||
|
||||
@Schema(description = "商机金额", example = "12371")
|
||||
private BigDecimal price;
|
||||
|
||||
@Schema(description = "整单折扣")
|
||||
private BigDecimal discountPercent;
|
||||
|
||||
@Schema(description = "产品总金额", example = "12025")
|
||||
private BigDecimal productPrice;
|
||||
|
||||
@Schema(description = "备注", example = "随便")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "负责人的用户编号", example = "25562")
|
||||
private Long ownerUserId;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
@Schema(description = "只读权限的用户编号数组")
|
||||
private String roUserIds;
|
||||
|
||||
@Schema(description = "读写权限的用户编号数组")
|
||||
private String rwUserIds;
|
||||
|
||||
@Schema(description = "1赢单2输单3无效", example = "1")
|
||||
private Integer endStatus;
|
||||
|
||||
@Schema(description = "结束时的备注", example = "你说的对")
|
||||
private String endRemark;
|
||||
|
||||
@Schema(description = "最后跟进时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] contactLastTime;
|
||||
|
||||
@Schema(description = "跟进状态", example = "1")
|
||||
private Integer followUpStatus;
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,115 @@
|
||||
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;
|
||||
|
||||
@Tag(name = "管理后台 - 商机状态")
|
||||
@RestController
|
||||
@RequestMapping("/crm/business-status")
|
||||
@Validated
|
||||
public class CrmBusinessStatusController {
|
||||
|
||||
@Resource
|
||||
private CrmBusinessStatusService businessStatusService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建商机状态")
|
||||
@PreAuthorize("@ss.hasPermission('crm:business-status:create')")
|
||||
public CommonResult<Long> createBusinessStatus(@Valid @RequestBody CrmBusinessStatusCreateReqVO createReqVO) {
|
||||
return success(businessStatusService.createBusinessStatus(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新商机状态")
|
||||
@PreAuthorize("@ss.hasPermission('crm:business-status:update')")
|
||||
public CommonResult<Boolean> updateBusinessStatus(@Valid @RequestBody CrmBusinessStatusUpdateReqVO updateReqVO) {
|
||||
businessStatusService.updateBusinessStatus(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除商机状态")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('crm:business-status:delete')")
|
||||
public CommonResult<Boolean> deleteBusinessStatus(@RequestParam("id") Long id) {
|
||||
businessStatusService.deleteBusinessStatus(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得商机状态")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('crm:business-status:query')")
|
||||
public CommonResult<CrmBusinessStatusRespVO> getBusinessStatus(@RequestParam("id") Long id) {
|
||||
CrmBusinessStatusDO businessStatus = businessStatusService.getBusinessStatus(id);
|
||||
return success(CrmBusinessStatusConvert.INSTANCE.convert(businessStatus));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获得商机状态列表")
|
||||
@Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
|
||||
@PreAuthorize("@ss.hasPermission('crm:business-status:query')")
|
||||
public CommonResult<List<CrmBusinessStatusRespVO>> getBusinessStatusList(@RequestParam("ids") Collection<Long> ids) {
|
||||
List<CrmBusinessStatusDO> list = businessStatusService.getBusinessStatusList(ids);
|
||||
return success(CrmBusinessStatusConvert.INSTANCE.convertList(list));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得商机状态分页")
|
||||
@PreAuthorize("@ss.hasPermission('crm:business-status:query')")
|
||||
public CommonResult<PageResult<CrmBusinessStatusRespVO>> getBusinessStatusPage(@Valid CrmBusinessStatusPageReqVO pageVO) {
|
||||
PageResult<CrmBusinessStatusDO> pageResult = businessStatusService.getBusinessStatusPage(pageVO);
|
||||
return success(CrmBusinessStatusConvert.INSTANCE.convertPage(pageResult));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出商机状态 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('crm:business-status:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportBusinessStatusExcel(@Valid CrmBusinessStatusExportReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
List<CrmBusinessStatusDO> list = businessStatusService.getBusinessStatusList(exportReqVO);
|
||||
// 导出 Excel
|
||||
List<CrmBusinessStatusExcelVO> datas = CrmBusinessStatusConvert.INSTANCE.convertList02(list);
|
||||
ExcelUtils.write(response, "商机状态.xls", "数据", CrmBusinessStatusExcelVO.class, datas);
|
||||
}
|
||||
|
||||
@GetMapping("/get-simple-list")
|
||||
@Operation(summary = "获得商机状态列表")
|
||||
@PreAuthorize("@ss.hasPermission('crm:business-status:query')")
|
||||
public CommonResult<List<CrmBusinessStatusRespVO>> getBusinessStatusListByTypeId(@RequestParam("typeId") Integer typeId) {
|
||||
List<CrmBusinessStatusDO> list = businessStatusService.getBusinessStatusListByTypeId(typeId);
|
||||
return success(CrmBusinessStatusConvert.INSTANCE.convertList(list));
|
||||
}
|
||||
|
||||
@GetMapping("/get-all-list")
|
||||
@Operation(summary = "获得商机状态列表")
|
||||
@PreAuthorize("@ss.hasPermission('crm:business-status:query')")
|
||||
public CommonResult<List<CrmBusinessStatusRespVO>> getBusinessStatusList() {
|
||||
List<CrmBusinessStatusDO> list = businessStatusService.getBusinessStatusList();
|
||||
return success(CrmBusinessStatusConvert.INSTANCE.convertList(list));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
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 {
|
||||
|
||||
@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;
|
||||
|
||||
@Schema(description = "赢单率")
|
||||
private String percent;
|
||||
|
||||
@Schema(description = "排序")
|
||||
private Integer sort;
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
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 {
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
|
||||
/**
|
||||
* 商机状态 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;
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
|
||||
@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;
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
@Schema(description = "管理后台 - 商机状态分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class CrmBusinessStatusPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "状态类型编号", example = "22882")
|
||||
private Long typeId;
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
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;
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@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;
|
||||
|
||||
}
|
@ -0,0 +1,108 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.businessstatustype;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
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.businessstatustype.vo.*;
|
||||
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 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;
|
||||
|
||||
@Tag(name = "管理后台 - 商机状态类型")
|
||||
@RestController
|
||||
@RequestMapping("/crm/business-status-type")
|
||||
@Validated
|
||||
public class CrmBusinessStatusTypeController {
|
||||
|
||||
@Resource
|
||||
private CrmBusinessStatusTypeService businessStatusTypeService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建商机状态类型")
|
||||
@PreAuthorize("@ss.hasPermission('crm:business-status-type:create')")
|
||||
public CommonResult<Long> createBusinessStatusType(@Valid @RequestBody CrmBusinessStatusTypeCreateReqVO createReqVO) {
|
||||
return success(businessStatusTypeService.createBusinessStatusType(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新商机状态类型")
|
||||
@PreAuthorize("@ss.hasPermission('crm:business-status-type:update')")
|
||||
public CommonResult<Boolean> updateBusinessStatusType(@Valid @RequestBody CrmBusinessStatusTypeUpdateReqVO updateReqVO) {
|
||||
businessStatusTypeService.updateBusinessStatusType(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除商机状态类型")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('crm:business-status-type:delete')")
|
||||
public CommonResult<Boolean> deleteBusinessStatusType(@RequestParam("id") Long id) {
|
||||
businessStatusTypeService.deleteBusinessStatusType(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得商机状态类型")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('crm:business-status-type:query')")
|
||||
public CommonResult<CrmBusinessStatusTypeRespVO> getBusinessStatusType(@RequestParam("id") Long id) {
|
||||
CrmBusinessStatusTypeDO businessStatusType = businessStatusTypeService.getBusinessStatusType(id);
|
||||
return success(CrmBusinessStatusTypeConvert.INSTANCE.convert(businessStatusType));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获得商机状态类型列表")
|
||||
@Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
|
||||
@PreAuthorize("@ss.hasPermission('crm:business-status-type:query')")
|
||||
public CommonResult<List<CrmBusinessStatusTypeRespVO>> getBusinessStatusTypeList(@RequestParam("ids") Collection<Long> ids) {
|
||||
List<CrmBusinessStatusTypeDO> list = businessStatusTypeService.getBusinessStatusTypeList(ids);
|
||||
return success(CrmBusinessStatusTypeConvert.INSTANCE.convertList(list));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得商机状态类型分页")
|
||||
@PreAuthorize("@ss.hasPermission('crm:business-status-type:query')")
|
||||
public CommonResult<PageResult<CrmBusinessStatusTypeRespVO>> getBusinessStatusTypePage(@Valid CrmBusinessStatusTypePageReqVO pageVO) {
|
||||
PageResult<CrmBusinessStatusTypeDO> pageResult = businessStatusTypeService.getBusinessStatusTypePage(pageVO);
|
||||
return success(CrmBusinessStatusTypeConvert.INSTANCE.convertPage(pageResult));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出商机状态类型 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('crm:business-status-type:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportBusinessStatusTypeExcel(@Valid CrmBusinessStatusTypeExportReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
List<CrmBusinessStatusTypeDO> list = businessStatusTypeService.getBusinessStatusTypeList(exportReqVO);
|
||||
// 导出 Excel
|
||||
List<CrmBusinessStatusTypeExcelVO> datas = CrmBusinessStatusTypeConvert.INSTANCE.convertList02(list);
|
||||
ExcelUtils.write(response, "商机状态类型.xls", "数据", CrmBusinessStatusTypeExcelVO.class, datas);
|
||||
}
|
||||
|
||||
@GetMapping("/get-simple-list")
|
||||
@Operation(summary = "获得商机状态类型列表")
|
||||
@PreAuthorize("@ss.hasPermission('crm:business-status-type:query')")
|
||||
public CommonResult<List<CrmBusinessStatusTypeRespVO>> getBusinessStatusTypeList() {
|
||||
List<CrmBusinessStatusTypeDO> list = businessStatusTypeService.getBusinessStatusTypeListByStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||
return success(CrmBusinessStatusTypeConvert.INSTANCE.convertList(list));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
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;
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
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;
|
||||
|
||||
@Schema(description = "管理后台 - 商机状态类型创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class CrmBusinessStatusTypeCreateReqVO extends CrmBusinessStatusTypeBaseVO {
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
|
||||
/**
|
||||
* 商机状态类型 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;
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import java.time.LocalDateTime;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@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;
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
@Schema(description = "管理后台 - 商机状态类型分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class CrmBusinessStatusTypePageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "状态类型名", example = "芋艿")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "开启状态", example = "1")
|
||||
private Boolean status;
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
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;
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@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;
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package cn.iocoder.yudao.module.crm.convert.businessstatus;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* 商机状态 Convert
|
||||
*
|
||||
* @author ljlleo
|
||||
*/
|
||||
@Mapper
|
||||
public interface CrmBusinessStatusConvert {
|
||||
|
||||
CrmBusinessStatusConvert INSTANCE = Mappers.getMapper(CrmBusinessStatusConvert.class);
|
||||
|
||||
CrmBusinessStatusDO convert(CrmBusinessStatusCreateReqVO bean);
|
||||
|
||||
CrmBusinessStatusDO convert(CrmBusinessStatusUpdateReqVO bean);
|
||||
|
||||
CrmBusinessStatusRespVO convert(CrmBusinessStatusDO bean);
|
||||
|
||||
List<CrmBusinessStatusRespVO> convertList(List<CrmBusinessStatusDO> list);
|
||||
|
||||
PageResult<CrmBusinessStatusRespVO> convertPage(PageResult<CrmBusinessStatusDO> page);
|
||||
|
||||
List<CrmBusinessStatusExcelVO> convertList02(List<CrmBusinessStatusDO> list);
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package cn.iocoder.yudao.module.crm.convert.businessstatustype;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* 商机状态类型 Convert
|
||||
*
|
||||
* @author ljlleo
|
||||
*/
|
||||
@Mapper
|
||||
public interface CrmBusinessStatusTypeConvert {
|
||||
|
||||
CrmBusinessStatusTypeConvert INSTANCE = Mappers.getMapper(CrmBusinessStatusTypeConvert.class);
|
||||
|
||||
CrmBusinessStatusTypeDO convert(CrmBusinessStatusTypeCreateReqVO bean);
|
||||
|
||||
CrmBusinessStatusTypeDO convert(CrmBusinessStatusTypeUpdateReqVO bean);
|
||||
|
||||
CrmBusinessStatusTypeRespVO convert(CrmBusinessStatusTypeDO bean);
|
||||
|
||||
List<CrmBusinessStatusTypeRespVO> convertList(List<CrmBusinessStatusTypeDO> list);
|
||||
|
||||
PageResult<CrmBusinessStatusTypeRespVO> convertPage(PageResult<CrmBusinessStatusTypeDO> page);
|
||||
|
||||
List<CrmBusinessStatusTypeExcelVO> convertList02(List<CrmBusinessStatusTypeDO> list);
|
||||
|
||||
}
|
@ -1,12 +1,13 @@
|
||||
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;
|
||||
import lombok.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
@ -36,13 +37,13 @@ public class CrmBusinessDO extends BaseDO {
|
||||
/**
|
||||
* 商机状态类型编号
|
||||
*
|
||||
* TODO @ljileo:这个字段,后续要写下关联的实体哈
|
||||
* 关联 {@link CrmBusinessStatusTypeDO#getId()}
|
||||
*/
|
||||
private Long statusTypeId;
|
||||
/**
|
||||
* 商机状态编号
|
||||
*
|
||||
* TODO @ljileo:这个字段,后续要写下关联的实体哈
|
||||
* 关联 {@link CrmBusinessStatusDO#getId()}
|
||||
*/
|
||||
private Long statusId;
|
||||
/**
|
||||
@ -62,21 +63,18 @@ public class CrmBusinessDO extends BaseDO {
|
||||
/**
|
||||
* 商机金额
|
||||
*
|
||||
* TODO @lijie:Integer
|
||||
*/
|
||||
private BigDecimal price;
|
||||
private Integer price;
|
||||
/**
|
||||
* 整单折扣
|
||||
*
|
||||
* TODO @lijie:Integer
|
||||
*/
|
||||
private BigDecimal discountPercent;
|
||||
private Integer discountPercent;
|
||||
/**
|
||||
* 产品总金额
|
||||
*
|
||||
* TODO @lijie:Integer
|
||||
*/
|
||||
private BigDecimal productPrice;
|
||||
private Integer productPrice;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
|
@ -0,0 +1,44 @@
|
||||
package cn.iocoder.yudao.module.crm.dal.dataobject.businessstatus;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* 商机状态 DO
|
||||
*
|
||||
* @author ljlleo
|
||||
*/
|
||||
@TableName("crm_business_status")
|
||||
@KeySequence("crm_business_status_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class CrmBusinessStatusDO {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 状态类型编号
|
||||
*/
|
||||
private Long typeId;
|
||||
/**
|
||||
* 状态名
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 赢单率
|
||||
*/
|
||||
private String percent;
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package cn.iocoder.yudao.module.crm.dal.dataobject.businessstatustype;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* 商机状态类型 DO
|
||||
*
|
||||
* @author ljlleo
|
||||
*/
|
||||
@TableName("crm_business_status_type")
|
||||
@KeySequence("crm_business_status_type_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class CrmBusinessStatusTypeDO {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 状态类型名
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 使用的部门编号
|
||||
*/
|
||||
private String deptIds;
|
||||
/**
|
||||
* 开启状态
|
||||
*/
|
||||
private Boolean status;
|
||||
|
||||
}
|
@ -21,23 +21,6 @@ public interface CrmBusinessMapper extends BaseMapperX<CrmBusinessDO> {
|
||||
default PageResult<CrmBusinessDO> selectPage(CrmBusinessPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<CrmBusinessDO>()
|
||||
.likeIfPresent(CrmBusinessDO::getName, reqVO.getName())
|
||||
.eqIfPresent(CrmBusinessDO::getStatusTypeId, reqVO.getStatusTypeId())
|
||||
.eqIfPresent(CrmBusinessDO::getStatusId, reqVO.getStatusId())
|
||||
.betweenIfPresent(CrmBusinessDO::getContactNextTime, reqVO.getContactNextTime())
|
||||
.eqIfPresent(CrmBusinessDO::getCustomerId, reqVO.getCustomerId())
|
||||
.betweenIfPresent(CrmBusinessDO::getDealTime, reqVO.getDealTime())
|
||||
.eqIfPresent(CrmBusinessDO::getPrice, reqVO.getPrice())
|
||||
.eqIfPresent(CrmBusinessDO::getDiscountPercent, reqVO.getDiscountPercent())
|
||||
.eqIfPresent(CrmBusinessDO::getProductPrice, reqVO.getProductPrice())
|
||||
.eqIfPresent(CrmBusinessDO::getRemark, reqVO.getRemark())
|
||||
.eqIfPresent(CrmBusinessDO::getOwnerUserId, reqVO.getOwnerUserId())
|
||||
.betweenIfPresent(CrmBusinessDO::getCreateTime, reqVO.getCreateTime())
|
||||
.eqIfPresent(CrmBusinessDO::getRoUserIds, reqVO.getRoUserIds())
|
||||
.eqIfPresent(CrmBusinessDO::getRwUserIds, reqVO.getRwUserIds())
|
||||
.eqIfPresent(CrmBusinessDO::getEndStatus, reqVO.getEndStatus())
|
||||
.eqIfPresent(CrmBusinessDO::getEndRemark, reqVO.getEndRemark())
|
||||
.betweenIfPresent(CrmBusinessDO::getContactLastTime, reqVO.getContactLastTime())
|
||||
.eqIfPresent(CrmBusinessDO::getFollowUpStatus, reqVO.getFollowUpStatus())
|
||||
.orderByDesc(CrmBusinessDO::getId));
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,40 @@
|
||||
package cn.iocoder.yudao.module.crm.dal.mysql.businessstatus;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo.CrmBusinessStatusExportReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo.CrmBusinessStatusPageReqVO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatus.CrmBusinessStatusDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商机状态 Mapper
|
||||
*
|
||||
* @author ljlleo
|
||||
*/
|
||||
@Mapper
|
||||
public interface CrmBusinessStatusMapper extends BaseMapperX<CrmBusinessStatusDO> {
|
||||
|
||||
default PageResult<CrmBusinessStatusDO> selectPage(CrmBusinessStatusPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<CrmBusinessStatusDO>()
|
||||
.eqIfPresent(CrmBusinessStatusDO::getTypeId, reqVO.getTypeId())
|
||||
.orderByDesc(CrmBusinessStatusDO::getId));
|
||||
}
|
||||
|
||||
default List<CrmBusinessStatusDO> selectList(CrmBusinessStatusExportReqVO reqVO) {
|
||||
return selectList(new LambdaQueryWrapperX<CrmBusinessStatusDO>()
|
||||
.eqIfPresent(CrmBusinessStatusDO::getTypeId, reqVO.getTypeId())
|
||||
.likeIfPresent(CrmBusinessStatusDO::getName, reqVO.getName())
|
||||
.eqIfPresent(CrmBusinessStatusDO::getPercent, reqVO.getPercent())
|
||||
.eqIfPresent(CrmBusinessStatusDO::getSort, reqVO.getSort())
|
||||
.orderByDesc(CrmBusinessStatusDO::getId));
|
||||
}
|
||||
|
||||
default List<CrmBusinessStatusDO> getBusinessStatusListByTypeId(Integer typeId) {
|
||||
return selectList(CrmBusinessStatusDO::getTypeId, typeId);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package cn.iocoder.yudao.module.crm.dal.mysql.businessstatustype;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo.CrmBusinessStatusTypeExportReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo.CrmBusinessStatusTypePageReqVO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatustype.CrmBusinessStatusTypeDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商机状态类型 Mapper
|
||||
*
|
||||
* @author ljlleo
|
||||
*/
|
||||
@Mapper
|
||||
public interface CrmBusinessStatusTypeMapper extends BaseMapperX<CrmBusinessStatusTypeDO> {
|
||||
|
||||
default PageResult<CrmBusinessStatusTypeDO> selectPage(CrmBusinessStatusTypePageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<CrmBusinessStatusTypeDO>()
|
||||
.likeIfPresent(CrmBusinessStatusTypeDO::getName, reqVO.getName())
|
||||
.eqIfPresent(CrmBusinessStatusTypeDO::getDeptIds, reqVO.getDeptIds())
|
||||
.eqIfPresent(CrmBusinessStatusTypeDO::getStatus, reqVO.getStatus())
|
||||
.orderByDesc(CrmBusinessStatusTypeDO::getId));
|
||||
}
|
||||
|
||||
default List<CrmBusinessStatusTypeDO> selectList(CrmBusinessStatusTypeExportReqVO reqVO) {
|
||||
return selectList(new LambdaQueryWrapperX<CrmBusinessStatusTypeDO>()
|
||||
.likeIfPresent(CrmBusinessStatusTypeDO::getName, reqVO.getName())
|
||||
.eqIfPresent(CrmBusinessStatusTypeDO::getDeptIds, reqVO.getDeptIds())
|
||||
.eqIfPresent(CrmBusinessStatusTypeDO::getStatus, reqVO.getStatus())
|
||||
.orderByDesc(CrmBusinessStatusTypeDO::getId));
|
||||
}
|
||||
|
||||
default List<CrmBusinessStatusTypeDO> getBusinessStatusTypeListByStatus(Integer status) {
|
||||
return selectList(CrmBusinessStatusTypeDO::getStatus, status.byteValue());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
package cn.iocoder.yudao.module.crm.service.businessstatus;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo.CrmBusinessStatusCreateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo.CrmBusinessStatusExportReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo.CrmBusinessStatusPageReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo.CrmBusinessStatusUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatus.CrmBusinessStatusDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商机状态 Service 接口
|
||||
*
|
||||
* @author ljlleo
|
||||
*/
|
||||
public interface CrmBusinessStatusService {
|
||||
|
||||
/**
|
||||
* 创建商机状态
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createBusinessStatus(@Valid CrmBusinessStatusCreateReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新商机状态
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateBusinessStatus(@Valid CrmBusinessStatusUpdateReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除商机状态
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteBusinessStatus(Long id);
|
||||
|
||||
/**
|
||||
* 获得商机状态
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 商机状态
|
||||
*/
|
||||
CrmBusinessStatusDO getBusinessStatus(Long id);
|
||||
|
||||
/**
|
||||
* 获得商机状态列表
|
||||
*
|
||||
* @param ids 编号
|
||||
* @return 商机状态列表
|
||||
*/
|
||||
List<CrmBusinessStatusDO> getBusinessStatusList(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得商机状态分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 商机状态分页
|
||||
*/
|
||||
PageResult<CrmBusinessStatusDO> getBusinessStatusPage(CrmBusinessStatusPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得商机状态列表, 用于 Excel 导出
|
||||
*
|
||||
* @param exportReqVO 查询条件
|
||||
* @return 商机状态列表
|
||||
*/
|
||||
List<CrmBusinessStatusDO> getBusinessStatusList(CrmBusinessStatusExportReqVO exportReqVO);
|
||||
|
||||
/**
|
||||
* 根据类型ID获得商机状态列表
|
||||
*
|
||||
* @param typeId 商机状态类型ID
|
||||
* @return 商机状态列表
|
||||
*/
|
||||
List<CrmBusinessStatusDO> getBusinessStatusListByTypeId(Integer typeId);
|
||||
|
||||
/**
|
||||
* 获得商机状态列表
|
||||
*
|
||||
* @return 商机状态列表
|
||||
*/
|
||||
List<CrmBusinessStatusDO> getBusinessStatusList();
|
||||
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
package cn.iocoder.yudao.module.crm.service.businessstatus;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo.CrmBusinessStatusCreateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo.CrmBusinessStatusExportReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo.CrmBusinessStatusPageReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo.CrmBusinessStatusUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.convert.businessstatus.CrmBusinessStatusConvert;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatus.CrmBusinessStatusDO;
|
||||
import cn.iocoder.yudao.module.crm.dal.mysql.businessstatus.CrmBusinessStatusMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_STATUS_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
* 商机状态 Service 实现类
|
||||
*
|
||||
* @author ljlleo
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class CrmBusinessStatusServiceImpl implements CrmBusinessStatusService {
|
||||
|
||||
@Resource
|
||||
private CrmBusinessStatusMapper businessStatusMapper;
|
||||
|
||||
@Override
|
||||
public Long createBusinessStatus(CrmBusinessStatusCreateReqVO createReqVO) {
|
||||
// 插入
|
||||
CrmBusinessStatusDO businessStatus = CrmBusinessStatusConvert.INSTANCE.convert(createReqVO);
|
||||
businessStatusMapper.insert(businessStatus);
|
||||
// 返回
|
||||
return businessStatus.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateBusinessStatus(CrmBusinessStatusUpdateReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateBusinessStatusExists(updateReqVO.getId());
|
||||
// 更新
|
||||
CrmBusinessStatusDO updateObj = CrmBusinessStatusConvert.INSTANCE.convert(updateReqVO);
|
||||
businessStatusMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteBusinessStatus(Long id) {
|
||||
// 校验存在
|
||||
validateBusinessStatusExists(id);
|
||||
// 删除
|
||||
businessStatusMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateBusinessStatusExists(Long id) {
|
||||
if (businessStatusMapper.selectById(id) == null) {
|
||||
throw exception(BUSINESS_STATUS_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CrmBusinessStatusDO getBusinessStatus(Long id) {
|
||||
return businessStatusMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CrmBusinessStatusDO> getBusinessStatusList(Collection<Long> ids) {
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
return ListUtil.empty();
|
||||
}
|
||||
return businessStatusMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<CrmBusinessStatusDO> getBusinessStatusPage(CrmBusinessStatusPageReqVO pageReqVO) {
|
||||
return businessStatusMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CrmBusinessStatusDO> getBusinessStatusList(CrmBusinessStatusExportReqVO exportReqVO) {
|
||||
return businessStatusMapper.selectList(exportReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CrmBusinessStatusDO> getBusinessStatusListByTypeId(Integer typeId) {
|
||||
return businessStatusMapper.getBusinessStatusListByTypeId(typeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CrmBusinessStatusDO> getBusinessStatusList() {
|
||||
return businessStatusMapper.selectList();
|
||||
}
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
package cn.iocoder.yudao.module.crm.service.businessstatustype;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo.CrmBusinessStatusTypeCreateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo.CrmBusinessStatusTypeExportReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo.CrmBusinessStatusTypePageReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo.CrmBusinessStatusTypeUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatustype.CrmBusinessStatusTypeDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商机状态类型 Service 接口
|
||||
*
|
||||
* @author ljlleo
|
||||
*/
|
||||
public interface CrmBusinessStatusTypeService {
|
||||
|
||||
/**
|
||||
* 创建商机状态类型
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createBusinessStatusType(@Valid CrmBusinessStatusTypeCreateReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新商机状态类型
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateBusinessStatusType(@Valid CrmBusinessStatusTypeUpdateReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除商机状态类型
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteBusinessStatusType(Long id);
|
||||
|
||||
/**
|
||||
* 获得商机状态类型
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 商机状态类型
|
||||
*/
|
||||
CrmBusinessStatusTypeDO getBusinessStatusType(Long id);
|
||||
|
||||
/**
|
||||
* 获得商机状态类型列表
|
||||
*
|
||||
* @param ids 编号
|
||||
* @return 商机状态类型列表
|
||||
*/
|
||||
List<CrmBusinessStatusTypeDO> getBusinessStatusTypeList(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得商机状态类型分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 商机状态类型分页
|
||||
*/
|
||||
PageResult<CrmBusinessStatusTypeDO> getBusinessStatusTypePage(CrmBusinessStatusTypePageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得商机状态类型列表, 用于 Excel 导出
|
||||
*
|
||||
* @param exportReqVO 查询条件
|
||||
* @return 商机状态类型列表
|
||||
*/
|
||||
List<CrmBusinessStatusTypeDO> getBusinessStatusTypeList(CrmBusinessStatusTypeExportReqVO exportReqVO);
|
||||
|
||||
/**
|
||||
* 获得商机状态类型列表
|
||||
*
|
||||
* @param status 状态
|
||||
* @return 商机状态类型列表
|
||||
*/
|
||||
List<CrmBusinessStatusTypeDO> getBusinessStatusTypeListByStatus(Integer status);
|
||||
|
||||
}
|
@ -0,0 +1,95 @@
|
||||
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) {
|
||||
// 插入
|
||||
CrmBusinessStatusTypeDO businessStatusType = CrmBusinessStatusTypeConvert.INSTANCE.convert(createReqVO);
|
||||
businessStatusTypeMapper.insert(businessStatusType);
|
||||
// 返回
|
||||
return businessStatusType.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateBusinessStatusType(CrmBusinessStatusTypeUpdateReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateBusinessStatusTypeExists(updateReqVO.getId());
|
||||
// 更新
|
||||
CrmBusinessStatusTypeDO updateObj = CrmBusinessStatusTypeConvert.INSTANCE.convert(updateReqVO);
|
||||
businessStatusTypeMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteBusinessStatusType(Long id) {
|
||||
// 校验存在
|
||||
validateBusinessStatusTypeExists(id);
|
||||
// 删除
|
||||
businessStatusTypeMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateBusinessStatusTypeExists(Long id) {
|
||||
if (businessStatusTypeMapper.selectById(id) == null) {
|
||||
throw exception(BUSINESS_STATUS_TYPE_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CrmBusinessStatusTypeDO getBusinessStatusType(Long id) {
|
||||
return businessStatusTypeMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CrmBusinessStatusTypeDO> getBusinessStatusTypeList(Collection<Long> ids) {
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
return ListUtil.empty();
|
||||
}
|
||||
return businessStatusTypeMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<CrmBusinessStatusTypeDO> getBusinessStatusTypePage(CrmBusinessStatusTypePageReqVO pageReqVO) {
|
||||
return businessStatusTypeMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CrmBusinessStatusTypeDO> getBusinessStatusTypeList(CrmBusinessStatusTypeExportReqVO exportReqVO) {
|
||||
return businessStatusTypeMapper.selectList(exportReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CrmBusinessStatusTypeDO> getBusinessStatusTypeListByStatus(Integer status) {
|
||||
return businessStatusTypeMapper.getBusinessStatusTypeListByStatus(status);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.iocoder.yudao.module.crm.dal.mysql.businessstatustype.CrmBusinessStatusTypeMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
</mapper>
|
@ -0,0 +1,170 @@
|
||||
package cn.iocoder.yudao.module.crm.service.businessstatus;
|
||||
|
||||
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.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 cn.iocoder.yudao.module.crm.dal.mysql.businessstatus.CrmBusinessStatusMapper;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
|
||||
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_NOT_EXISTS;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
/**
|
||||
* {@link CrmBusinessStatusServiceImpl} 的单元测试类
|
||||
*
|
||||
* @author ljlleo
|
||||
*/
|
||||
@Import(CrmBusinessStatusServiceImpl.class)
|
||||
public class CrmBusinessStatusServiceImplTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private CrmBusinessStatusServiceImpl businessStatusService;
|
||||
|
||||
@Resource
|
||||
private CrmBusinessStatusMapper businessStatusMapper;
|
||||
|
||||
@Test
|
||||
public void testCreateBusinessStatus_success() {
|
||||
// 准备参数
|
||||
CrmBusinessStatusCreateReqVO reqVO = randomPojo(CrmBusinessStatusCreateReqVO.class);
|
||||
|
||||
// 调用
|
||||
Long businessStatusId = businessStatusService.createBusinessStatus(reqVO);
|
||||
// 断言
|
||||
assertNotNull(businessStatusId);
|
||||
// 校验记录的属性是否正确
|
||||
CrmBusinessStatusDO businessStatus = businessStatusMapper.selectById(businessStatusId);
|
||||
assertPojoEquals(reqVO, businessStatus);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateBusinessStatus_success() {
|
||||
// mock 数据
|
||||
CrmBusinessStatusDO dbBusinessStatus = randomPojo(CrmBusinessStatusDO.class);
|
||||
businessStatusMapper.insert(dbBusinessStatus);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
CrmBusinessStatusUpdateReqVO reqVO = randomPojo(CrmBusinessStatusUpdateReqVO.class, o -> {
|
||||
o.setId(dbBusinessStatus.getId()); // 设置更新的 ID
|
||||
});
|
||||
|
||||
// 调用
|
||||
businessStatusService.updateBusinessStatus(reqVO);
|
||||
// 校验是否更新正确
|
||||
CrmBusinessStatusDO businessStatus = businessStatusMapper.selectById(reqVO.getId()); // 获取最新的
|
||||
assertPojoEquals(reqVO, businessStatus);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateBusinessStatus_notExists() {
|
||||
// 准备参数
|
||||
CrmBusinessStatusUpdateReqVO reqVO = randomPojo(CrmBusinessStatusUpdateReqVO.class);
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> businessStatusService.updateBusinessStatus(reqVO), BUSINESS_STATUS_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteBusinessStatus_success() {
|
||||
// mock 数据
|
||||
CrmBusinessStatusDO dbBusinessStatus = randomPojo(CrmBusinessStatusDO.class);
|
||||
businessStatusMapper.insert(dbBusinessStatus);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
Long id = dbBusinessStatus.getId();
|
||||
|
||||
// 调用
|
||||
businessStatusService.deleteBusinessStatus(id);
|
||||
// 校验数据不存在了
|
||||
assertNull(businessStatusMapper.selectById(id));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteBusinessStatus_notExists() {
|
||||
// 准备参数
|
||||
Long id = randomLongId();
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> businessStatusService.deleteBusinessStatus(id), BUSINESS_STATUS_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||
public void testGetBusinessStatusPage() {
|
||||
// mock 数据
|
||||
CrmBusinessStatusDO dbBusinessStatus = randomPojo(CrmBusinessStatusDO.class, o -> { // 等会查询到
|
||||
o.setTypeId(null);
|
||||
o.setName(null);
|
||||
o.setPercent(null);
|
||||
o.setSort(null);
|
||||
});
|
||||
businessStatusMapper.insert(dbBusinessStatus);
|
||||
// 测试 typeId 不匹配
|
||||
businessStatusMapper.insert(cloneIgnoreId(dbBusinessStatus, o -> o.setTypeId(null)));
|
||||
// 测试 name 不匹配
|
||||
businessStatusMapper.insert(cloneIgnoreId(dbBusinessStatus, o -> o.setName(null)));
|
||||
// 测试 percent 不匹配
|
||||
businessStatusMapper.insert(cloneIgnoreId(dbBusinessStatus, o -> o.setPercent(null)));
|
||||
// 测试 sort 不匹配
|
||||
businessStatusMapper.insert(cloneIgnoreId(dbBusinessStatus, o -> o.setSort(null)));
|
||||
// 准备参数
|
||||
CrmBusinessStatusPageReqVO reqVO = new CrmBusinessStatusPageReqVO();
|
||||
reqVO.setTypeId(null);
|
||||
reqVO.setName(null);
|
||||
reqVO.setPercent(null);
|
||||
reqVO.setSort(null);
|
||||
|
||||
// 调用
|
||||
PageResult<CrmBusinessStatusDO> pageResult = businessStatusService.getBusinessStatusPage(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, pageResult.getTotal());
|
||||
assertEquals(1, pageResult.getList().size());
|
||||
assertPojoEquals(dbBusinessStatus, pageResult.getList().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||
public void testGetBusinessStatusList() {
|
||||
// mock 数据
|
||||
CrmBusinessStatusDO dbBusinessStatus = randomPojo(CrmBusinessStatusDO.class, o -> { // 等会查询到
|
||||
o.setTypeId(null);
|
||||
o.setName(null);
|
||||
o.setPercent(null);
|
||||
o.setSort(null);
|
||||
});
|
||||
businessStatusMapper.insert(dbBusinessStatus);
|
||||
// 测试 typeId 不匹配
|
||||
businessStatusMapper.insert(cloneIgnoreId(dbBusinessStatus, o -> o.setTypeId(null)));
|
||||
// 测试 name 不匹配
|
||||
businessStatusMapper.insert(cloneIgnoreId(dbBusinessStatus, o -> o.setName(null)));
|
||||
// 测试 percent 不匹配
|
||||
businessStatusMapper.insert(cloneIgnoreId(dbBusinessStatus, o -> o.setPercent(null)));
|
||||
// 测试 sort 不匹配
|
||||
businessStatusMapper.insert(cloneIgnoreId(dbBusinessStatus, o -> o.setSort(null)));
|
||||
// 准备参数
|
||||
CrmBusinessStatusExportReqVO reqVO = new CrmBusinessStatusExportReqVO();
|
||||
reqVO.setTypeId(null);
|
||||
reqVO.setName(null);
|
||||
reqVO.setPercent(null);
|
||||
reqVO.setSort(null);
|
||||
|
||||
// 调用
|
||||
List<CrmBusinessStatusDO> list = businessStatusService.getBusinessStatusList(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, list.size());
|
||||
assertPojoEquals(dbBusinessStatus, list.get(0));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,171 @@
|
||||
package cn.iocoder.yudao.module.crm.service.businessstatustype;
|
||||
|
||||
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.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 cn.iocoder.yudao.module.crm.dal.mysql.businessstatustype.CrmBusinessStatusTypeMapper;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime;
|
||||
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
|
||||
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 CrmBusinessStatusTypeServiceImpl} 的单元测试类
|
||||
*
|
||||
* @author ljlleo
|
||||
*/
|
||||
@Import(CrmBusinessStatusTypeServiceImpl.class)
|
||||
public class CrmBusinessStatusTypeServiceImplTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private CrmBusinessStatusTypeServiceImpl businessStatusTypeService;
|
||||
|
||||
@Resource
|
||||
private CrmBusinessStatusTypeMapper businessStatusTypeMapper;
|
||||
|
||||
@Test
|
||||
public void testCreateBusinessStatusType_success() {
|
||||
// 准备参数
|
||||
CrmBusinessStatusTypeCreateReqVO reqVO = randomPojo(CrmBusinessStatusTypeCreateReqVO.class);
|
||||
|
||||
// 调用
|
||||
Long businessStatusTypeId = businessStatusTypeService.createBusinessStatusType(reqVO);
|
||||
// 断言
|
||||
assertNotNull(businessStatusTypeId);
|
||||
// 校验记录的属性是否正确
|
||||
CrmBusinessStatusTypeDO businessStatusType = businessStatusTypeMapper.selectById(businessStatusTypeId);
|
||||
assertPojoEquals(reqVO, businessStatusType);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateBusinessStatusType_success() {
|
||||
// mock 数据
|
||||
CrmBusinessStatusTypeDO dbBusinessStatusType = randomPojo(CrmBusinessStatusTypeDO.class);
|
||||
businessStatusTypeMapper.insert(dbBusinessStatusType);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
CrmBusinessStatusTypeUpdateReqVO reqVO = randomPojo(CrmBusinessStatusTypeUpdateReqVO.class, o -> {
|
||||
o.setId(dbBusinessStatusType.getId()); // 设置更新的 ID
|
||||
});
|
||||
|
||||
// 调用
|
||||
businessStatusTypeService.updateBusinessStatusType(reqVO);
|
||||
// 校验是否更新正确
|
||||
CrmBusinessStatusTypeDO businessStatusType = businessStatusTypeMapper.selectById(reqVO.getId()); // 获取最新的
|
||||
assertPojoEquals(reqVO, businessStatusType);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateBusinessStatusType_notExists() {
|
||||
// 准备参数
|
||||
CrmBusinessStatusTypeUpdateReqVO reqVO = randomPojo(CrmBusinessStatusTypeUpdateReqVO.class);
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> businessStatusTypeService.updateBusinessStatusType(reqVO), BUSINESS_STATUS_TYPE_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteBusinessStatusType_success() {
|
||||
// mock 数据
|
||||
CrmBusinessStatusTypeDO dbBusinessStatusType = randomPojo(CrmBusinessStatusTypeDO.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 数据
|
||||
CrmBusinessStatusTypeDO dbBusinessStatusType = randomPojo(CrmBusinessStatusTypeDO.class, o -> { // 等会查询到
|
||||
o.setName(null);
|
||||
o.setDeptIds(null);
|
||||
o.setStatus(null);
|
||||
o.setCreateTime(null);
|
||||
});
|
||||
businessStatusTypeMapper.insert(dbBusinessStatusType);
|
||||
// 测试 name 不匹配
|
||||
businessStatusTypeMapper.insert(cloneIgnoreId(dbBusinessStatusType, o -> o.setName(null)));
|
||||
// 测试 deptIds 不匹配
|
||||
businessStatusTypeMapper.insert(cloneIgnoreId(dbBusinessStatusType, o -> o.setDeptIds(null)));
|
||||
// 测试 status 不匹配
|
||||
businessStatusTypeMapper.insert(cloneIgnoreId(dbBusinessStatusType, o -> o.setStatus(null)));
|
||||
// 测试 createTime 不匹配
|
||||
businessStatusTypeMapper.insert(cloneIgnoreId(dbBusinessStatusType, o -> o.setCreateTime(null)));
|
||||
// 准备参数
|
||||
CrmBusinessStatusTypePageReqVO reqVO = new CrmBusinessStatusTypePageReqVO();
|
||||
reqVO.setName(null);
|
||||
reqVO.setDeptIds(null);
|
||||
reqVO.setStatus(null);
|
||||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
|
||||
// 调用
|
||||
PageResult<CrmBusinessStatusTypeDO> pageResult = businessStatusTypeService.getBusinessStatusTypePage(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, pageResult.getTotal());
|
||||
assertEquals(1, pageResult.getList().size());
|
||||
assertPojoEquals(dbBusinessStatusType, pageResult.getList().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||
public void testGetBusinessStatusTypeList() {
|
||||
// mock 数据
|
||||
CrmBusinessStatusTypeDO dbBusinessStatusType = randomPojo(CrmBusinessStatusTypeDO.class, o -> { // 等会查询到
|
||||
o.setName(null);
|
||||
o.setDeptIds(null);
|
||||
o.setStatus(null);
|
||||
o.setCreateTime(null);
|
||||
});
|
||||
businessStatusTypeMapper.insert(dbBusinessStatusType);
|
||||
// 测试 name 不匹配
|
||||
businessStatusTypeMapper.insert(cloneIgnoreId(dbBusinessStatusType, o -> o.setName(null)));
|
||||
// 测试 deptIds 不匹配
|
||||
businessStatusTypeMapper.insert(cloneIgnoreId(dbBusinessStatusType, o -> o.setDeptIds(null)));
|
||||
// 测试 status 不匹配
|
||||
businessStatusTypeMapper.insert(cloneIgnoreId(dbBusinessStatusType, o -> o.setStatus(null)));
|
||||
// 测试 createTime 不匹配
|
||||
businessStatusTypeMapper.insert(cloneIgnoreId(dbBusinessStatusType, o -> o.setCreateTime(null)));
|
||||
// 准备参数
|
||||
CrmBusinessStatusTypeExportReqVO reqVO = new CrmBusinessStatusTypeExportReqVO();
|
||||
reqVO.setName(null);
|
||||
reqVO.setDeptIds(null);
|
||||
reqVO.setStatus(null);
|
||||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
|
||||
// 调用
|
||||
List<CrmBusinessStatusTypeDO> list = businessStatusTypeService.getBusinessStatusTypeList(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, list.size());
|
||||
assertPojoEquals(dbBusinessStatusType, list.get(0));
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user