Commit 4235beec3b412d61d79b59be3c33e859ba13553d

Authored by Wanwan
2 parents a24919e5 8efdf314

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

Showing 29 changed files with 1098 additions and 66 deletions
sql/mysql/crm.sql
1 1 SET NAMES utf8mb4;
2   -
3   -
4   -
5   -
6   --- ----------------------------
7   --- 回款表
8   --- ----------------------------
9   -DROP TABLE IF EXISTS `crm_receivable`;
10   -CREATE TABLE `crm_receivable` (
11   - `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
12   - `no` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '回款编号',
13   - `plan_id` bigint(20) NULL DEFAULT NULL COMMENT '回款计划ID',
14   - `customer_id` bigint(20) NULL DEFAULT NULL COMMENT '客户ID',
15   - `contract_id` bigint(20) NULL DEFAULT NULL COMMENT '合同ID',
16   - `check_status` tinyint(4) NULL DEFAULT NULL COMMENT '审批状态',
17   - `process_instance_id` bigint(20) NULL DEFAULT NULL COMMENT '工作流编号',
18   - `return_time` datetime NULL DEFAULT NULL COMMENT '回款日期',
19   - `return_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '回款方式',
20   - `price` decimal(10, 2) NULL DEFAULT NULL COMMENT '回款金额',
21   - `owner_user_id` bigint(20) NULL DEFAULT NULL COMMENT '负责人的用户编号',
22   - `batch_id` bigint(20) NULL DEFAULT NULL COMMENT '批次',
23   - `sort` int(11) NULL DEFAULT NULL COMMENT '显示顺序',
24   - `data_scope` tinyint(4) NULL DEFAULT 1 COMMENT '数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限)',
25   - `data_scope_dept_ids` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '数据范围(指定部门数组)',
26   - `status` tinyint(4) NOT NULL COMMENT '状态(0正常 1停用)',
27   - `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '备注',
28   - `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
29   - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
30   - `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
31   - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
32   - `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
33   - `tenant_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '租户编号',
34   - PRIMARY KEY (`id`) USING BTREE
35   -) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '回款管理' ROW_FORMAT = DYNAMIC;
36   -
37   -
38   --- ----------------------------
39   --- 回款计划表
40   --- ----------------------------
41   -DROP TABLE IF EXISTS `crm_receivable_plan`;
42   -CREATE TABLE `crm_receivable_plan` (
43   - `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
44   - `period` tinyint(4) DEFAULT NULL COMMENT '期数',
45   - `receivable_id` bigint(20) NULL DEFAULT NULL COMMENT '回款ID',
46   - `status` tinyint(4) NOT NULL COMMENT '完成状态',
47   - `check_status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '审批状态',
48   - `process_instance_id` bigint(20) NULL DEFAULT NULL COMMENT '工作流编号',
49   - `price` decimal(10, 2) NULL DEFAULT NULL COMMENT '计划回款金额',
50   - `return_time` datetime NULL DEFAULT NULL COMMENT '计划回款日期',
51   - `remind_days` bigint(20) NULL DEFAULT NULL COMMENT '提前几天提醒',
52   - `remind_time` datetime NULL DEFAULT NULL COMMENT '提醒日期',
53   - `customer_id` bigint(20) NULL DEFAULT NULL COMMENT '客户ID',
54   - `contract_id` bigint(20) NULL DEFAULT NULL COMMENT '合同ID',
55   - `owner_user_id` bigint(20) NULL DEFAULT NULL COMMENT '负责人',
56   - `sort` int(11) NULL DEFAULT NULL COMMENT '显示顺序',
57   - `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '备注',
58   - `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
59   - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
60   - `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
61   - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
62   - `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
63   - `tenant_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '租户编号',
64   - PRIMARY KEY (`id`) USING BTREE
65   -) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '回款计划' ROW_FORMAT = DYNAMIC;
... ...
sql/mysql/crm_data.sql
1 1  
2 2 INSERT INTO `system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES (184, '回款管理审批状态', 'crm_receivable_check_status', 0, '回款管理审批状态(0 未审核 1 审核通过 2 审核拒绝 3 审核中 4 已撤回)', '1', '2023-10-18 21:44:24', '1', '2023-10-18 21:44:24', b'0', '1970-01-01 00:00:00');
  3 +
3 4 INSERT INTO `system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES (185, '回款管理-回款方式', 'crm_return_type', 0, '回款管理-回款方式', '1', '2023-10-18 21:54:10', '1', '2023-10-18 21:54:10', b'0', '1970-01-01 00:00:00');
4 5  
5 6  
... ... @@ -8,6 +9,7 @@ INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `st
8 9 INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1391, 2, '审核拒绝', '2', 'crm_receivable_check_status', 0, 'default', '', ' 2 审核拒绝', '1', '2023-10-18 21:46:58', '1', '2023-10-18 21:47:21', b'0');
9 10 INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1392, 3, '审核中', '3', 'crm_receivable_check_status', 0, 'default', '', ' 3 审核中', '1', '2023-10-18 21:47:35', '1', '2023-10-18 21:47:35', b'0');
10 11 INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1393, 4, '已撤回', '4', 'crm_receivable_check_status', 0, 'default', '', ' 4 已撤回', '1', '2023-10-18 21:47:46', '1', '2023-10-18 21:47:46', b'0');
  12 +
11 13 INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1394, 1, '支票', '1', 'crm_return_type', 0, 'default', '', '', '1', '2023-10-18 21:54:29', '1', '2023-10-18 21:54:29', b'0');
12 14 INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1395, 2, '现金', '2', 'crm_return_type', 0, 'default', '', '', '1', '2023-10-18 21:54:41', '1', '2023-10-18 21:54:41', b'0');
13 15 INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1396, 3, '邮政汇款', '3', 'crm_return_type', 0, 'default', '', '', '1', '2023-10-18 21:54:53', '1', '2023-10-18 21:54:53', b'0');
... ... @@ -16,5 +18,3 @@ INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `st
16 18 INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1399, 6, '支付宝', '6', 'crm_return_type', 0, 'default', '', '', '1', '2023-10-18 21:55:38', '1', '2023-10-18 21:55:38', b'0');
17 19 INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1400, 7, '微信支付', '7', 'crm_return_type', 0, 'default', '', '', '1', '2023-10-18 21:55:53', '1', '2023-10-18 21:55:53', b'0');
18 20 INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1401, 8, '其他', '8', 'crm_return_type', 0, 'default', '', '', '1', '2023-10-18 21:56:06', '1', '2023-10-18 21:56:06', b'0');
19   -
20   -
... ...
yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java
... ... @@ -41,4 +41,11 @@ public interface ErrorCodeConstants {
41 41 ErrorCode CRM_PERMISSION_MODEL_NOT_EXISTS = new ErrorCode(1_020_007_002, "{}不存在");
42 42 ErrorCode CRM_PERMISSION_MODEL_TRANSFER_FAIL_OWNER_USER_EXISTS = new ErrorCode(1_020_007_003, "{}操作失败,原因:转移对象已经是该负责人");
43 43  
  44 + // ========== 产品 1_020_008_000 ==========
  45 + ErrorCode PRODUCT_NOT_EXISTS = new ErrorCode(1_020_008_000, "产品不存在");
  46 + ErrorCode PRODUCT_NO_EXISTS = new ErrorCode(1_020_008_001, "产品编号已存在");
  47 +
  48 + // ========== 产品分类 1_020_009_000 ==========
  49 + ErrorCode PRODUCT_CATEGORY_NOT_EXISTS = new ErrorCode(1_020_009_000, "产品分类不存在");
  50 +
44 51 }
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/ProductController.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.controller.admin.product;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.CommonResult;
  4 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  5 +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
  6 +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
  7 +import cn.iocoder.yudao.module.crm.controller.admin.product.vo.*;
  8 +import cn.iocoder.yudao.module.crm.convert.product.ProductConvert;
  9 +import cn.iocoder.yudao.module.crm.dal.dataobject.product.ProductDO;
  10 +import cn.iocoder.yudao.module.crm.service.product.ProductService;
  11 +import io.swagger.v3.oas.annotations.Operation;
  12 +import io.swagger.v3.oas.annotations.Parameter;
  13 +import io.swagger.v3.oas.annotations.tags.Tag;
  14 +import org.springframework.security.access.prepost.PreAuthorize;
  15 +import org.springframework.validation.annotation.Validated;
  16 +import org.springframework.web.bind.annotation.*;
  17 +
  18 +import javax.annotation.Resource;
  19 +import javax.servlet.http.HttpServletResponse;
  20 +import javax.validation.Valid;
  21 +import java.io.IOException;
  22 +import java.util.List;
  23 +
  24 +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
  25 +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
  26 +
  27 +@Tag(name = "管理后台 - 产品")
  28 +@RestController
  29 +@RequestMapping("/crm/product")
  30 +@Validated
  31 +public class ProductController {
  32 +
  33 + @Resource
  34 + private ProductService productService;
  35 +
  36 + @PostMapping("/create")
  37 + @Operation(summary = "创建产品")
  38 + @PreAuthorize("@ss.hasPermission('crm:product:create')")
  39 + public CommonResult<Long> createProduct(@Valid @RequestBody ProductCreateReqVO createReqVO) {
  40 + return success(productService.createProduct(createReqVO));
  41 + }
  42 +
  43 + @PutMapping("/update")
  44 + @Operation(summary = "更新产品")
  45 + @PreAuthorize("@ss.hasPermission('crm:product:update')")
  46 + public CommonResult<Boolean> updateProduct(@Valid @RequestBody ProductUpdateReqVO updateReqVO) {
  47 + productService.updateProduct(updateReqVO);
  48 + return success(true);
  49 + }
  50 +
  51 + @DeleteMapping("/delete")
  52 + @Operation(summary = "删除产品")
  53 + @Parameter(name = "id", description = "编号", required = true)
  54 + @PreAuthorize("@ss.hasPermission('crm:product:delete')")
  55 + public CommonResult<Boolean> deleteProduct(@RequestParam("id") Long id) {
  56 + productService.deleteProduct(id);
  57 + return success(true);
  58 + }
  59 +
  60 + @GetMapping("/get")
  61 + @Operation(summary = "获得产品")
  62 + @Parameter(name = "id", description = "编号", required = true, example = "1024")
  63 + @PreAuthorize("@ss.hasPermission('crm:product:query')")
  64 + public CommonResult<ProductRespVO> getProduct(@RequestParam("id") Long id) {
  65 + ProductDO product = productService.getProduct(id);
  66 + return success(ProductConvert.INSTANCE.convert(product));
  67 + }
  68 +
  69 + @GetMapping("/page")
  70 + @Operation(summary = "获得产品分页")
  71 + @PreAuthorize("@ss.hasPermission('crm:product:query')")
  72 + public CommonResult<PageResult<ProductRespVO>> getProductPage(@Valid ProductPageReqVO pageVO) {
  73 + PageResult<ProductDO> pageResult = productService.getProductPage(pageVO);
  74 + return success(ProductConvert.INSTANCE.convertPage(pageResult));
  75 + }
  76 +
  77 + @GetMapping("/export-excel")
  78 + @Operation(summary = "导出产品 Excel")
  79 + @PreAuthorize("@ss.hasPermission('crm:product:export')")
  80 + @OperateLog(type = EXPORT)
  81 + public void exportProductExcel(@Valid ProductExportReqVO exportReqVO,
  82 + HttpServletResponse response) throws IOException {
  83 + List<ProductDO> list = productService.getProductList(exportReqVO);
  84 + // 导出 Excel
  85 + List<ProductExcelVO> datas = ProductConvert.INSTANCE.convertList02(list);
  86 + ExcelUtils.write(response, "产品.xls", "数据", ProductExcelVO.class, datas);
  87 + }
  88 +
  89 +}
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/ProductBaseVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.controller.admin.product.vo;
  2 +
  3 +import io.swagger.v3.oas.annotations.media.Schema;
  4 +import lombok.Data;
  5 +
  6 +import javax.validation.constraints.NotNull;
  7 +
  8 +// TODO @zange:需要加 CRM 前置噢
  9 +/**
  10 + * 产品 Base VO,提供给添加、修改、详细的子 VO 使用
  11 + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
  12 + */
  13 +@Data
  14 +public class ProductBaseVO {
  15 +
  16 + // TODO @zange:example 要写哈;主要是接口文档,可以基于 example 可以生产请求参数
  17 +
  18 + @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
  19 + @NotNull(message = "产品名称不能为空")
  20 + private String name;
  21 +
  22 + @Schema(description = "产品编码", requiredMode = Schema.RequiredMode.REQUIRED)
  23 + @NotNull(message = "产品编码不能为空")
  24 + private String no;
  25 +
  26 + @Schema(description = "单位")
  27 + private String unit;
  28 +
  29 + @Schema(description = "价格", example = "8911")
  30 + private Long price;
  31 +
  32 + @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
  33 + @NotNull(message = "状态不能为空")
  34 + private Integer status;
  35 +
  36 + @Schema(description = "产品分类ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1738")
  37 + @NotNull(message = "产品分类ID不能为空")
  38 + private Long categoryId;
  39 +
  40 + @Schema(description = "产品描述", example = "你说的对")
  41 + private String description;
  42 +
  43 + // TODO @zange:这个字段只有 create 可以传递,update 不传递;所以放到 create 和 resp 里;
  44 +
  45 + @Schema(description = "负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31926")
  46 + @NotNull(message = "负责人的用户编号不能为空")
  47 + private Long ownerUserId;
  48 +
  49 +}
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/ProductCreateReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.controller.admin.product.vo;
  2 +
  3 +import lombok.*;
  4 +import java.util.*;
  5 +import io.swagger.v3.oas.annotations.media.Schema;
  6 +import javax.validation.constraints.*;
  7 +
  8 +@Schema(description = "管理后台 - 产品创建 Request VO")
  9 +@Data
  10 +@EqualsAndHashCode(callSuper = true)
  11 +@ToString(callSuper = true)
  12 +public class ProductCreateReqVO extends ProductBaseVO {
  13 +
  14 +}
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/ProductExcelVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.controller.admin.product.vo;
  2 +
  3 +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
  4 +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
  5 +import com.alibaba.excel.annotation.ExcelProperty;
  6 +import lombok.Data;
  7 +
  8 +import java.time.LocalDateTime;
  9 +
  10 +// TODO 芋艿:这个导出最后搞
  11 +/**
  12 + * 产品 Excel VO
  13 + *
  14 + * @author ZanGe丶
  15 + */
  16 +@Data
  17 +public class ProductExcelVO {
  18 +
  19 + @ExcelProperty("主键id")
  20 + private Long id;
  21 +
  22 + @ExcelProperty("产品名称")
  23 + private String name;
  24 +
  25 + @ExcelProperty("产品编码")
  26 + private String no;
  27 +
  28 + @ExcelProperty("单位")
  29 + private String unit;
  30 +
  31 + @ExcelProperty("价格")
  32 + private Long price;
  33 +
  34 + @ExcelProperty(value = "状态", converter = DictConvert.class)
  35 + @DictFormat("crm_product_status") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中
  36 + private Integer status;
  37 +
  38 + @ExcelProperty("产品分类ID")
  39 + private Long categoryId;
  40 +
  41 + @ExcelProperty("产品描述")
  42 + private String description;
  43 +
  44 + @ExcelProperty("负责人的用户编号")
  45 + private Long ownerUserId;
  46 +
  47 + @ExcelProperty("创建时间")
  48 + private LocalDateTime createTime;
  49 +
  50 +}
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/ProductExportReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.controller.admin.product.vo;
  2 +
  3 +import io.swagger.v3.oas.annotations.media.Schema;
  4 +import lombok.Data;
  5 +import org.springframework.format.annotation.DateTimeFormat;
  6 +
  7 +import java.time.LocalDateTime;
  8 +
  9 +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
  10 +
  11 +// TODO 芋艿:这个导出最后搞
  12 +@Schema(description = "管理后台 - 产品 Excel 导出 Request VO,参数和 ProductPageReqVO 是一致的")
  13 +@Data
  14 +public class ProductExportReqVO {
  15 +
  16 + @Schema(description = "产品名称", example = "李四")
  17 + private String name;
  18 +
  19 + @Schema(description = "产品编码")
  20 + private String no;
  21 +
  22 + @Schema(description = "单位")
  23 + private String unit;
  24 +
  25 + @Schema(description = "价格", example = "8911")
  26 + private Long price;
  27 +
  28 + @Schema(description = "状态", example = "2")
  29 + private Integer status;
  30 +
  31 + @Schema(description = "产品分类ID", example = "1738")
  32 + private Long categoryId;
  33 +
  34 + @Schema(description = "产品描述", example = "你说的对")
  35 + private String description;
  36 +
  37 + @Schema(description = "负责人的用户编号", example = "31926")
  38 + private Long ownerUserId;
  39 +
  40 + @Schema(description = "创建时间")
  41 + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
  42 + private LocalDateTime[] createTime;
  43 +
  44 +}
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/ProductPageReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.controller.admin.product.vo;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.PageParam;
  4 +import io.swagger.v3.oas.annotations.media.Schema;
  5 +import lombok.Data;
  6 +import lombok.EqualsAndHashCode;
  7 +import lombok.ToString;
  8 +import org.springframework.format.annotation.DateTimeFormat;
  9 +
  10 +import java.time.LocalDateTime;
  11 +
  12 +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
  13 +
  14 +// TODO @zange:按照需求,裁剪下筛选的字段,目前应该只要 name 和 status
  15 +@Schema(description = "管理后台 - 产品分页 Request VO")
  16 +@Data
  17 +@EqualsAndHashCode(callSuper = true)
  18 +@ToString(callSuper = true)
  19 +public class ProductPageReqVO extends PageParam {
  20 +
  21 + @Schema(description = "产品名称", example = "李四")
  22 + private String name;
  23 +
  24 + @Schema(description = "产品编码")
  25 + private String no;
  26 +
  27 + @Schema(description = "单位")
  28 + private String unit;
  29 +
  30 + @Schema(description = "价格", example = "8911")
  31 + private Long price;
  32 +
  33 + @Schema(description = "状态", example = "2")
  34 + private Integer status;
  35 +
  36 + @Schema(description = "产品分类ID", example = "1738")
  37 + private Long categoryId;
  38 +
  39 + @Schema(description = "产品描述", example = "你说的对")
  40 + private String description;
  41 +
  42 + @Schema(description = "负责人的用户编号", example = "31926")
  43 + private Long ownerUserId;
  44 +
  45 + @Schema(description = "创建时间")
  46 + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
  47 + private LocalDateTime[] createTime;
  48 +
  49 +}
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/ProductRespVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.controller.admin.product.vo;
  2 +
  3 +import io.swagger.v3.oas.annotations.media.Schema;
  4 +import lombok.*;
  5 +import java.time.LocalDateTime;
  6 +
  7 +@Schema(description = "管理后台 - 产品 Response VO")
  8 +@Data
  9 +@EqualsAndHashCode(callSuper = true)
  10 +@ToString(callSuper = true)
  11 +public class ProductRespVO extends ProductBaseVO {
  12 +
  13 + @Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "20529")
  14 + private Long id;
  15 +
  16 + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
  17 + private LocalDateTime createTime;
  18 +
  19 +}
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/ProductUpdateReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.controller.admin.product.vo;
  2 +
  3 +import io.swagger.v3.oas.annotations.media.Schema;
  4 +import lombok.*;
  5 +import java.util.*;
  6 +import javax.validation.constraints.*;
  7 +
  8 +@Schema(description = "管理后台 - 产品更新 Request VO")
  9 +@Data
  10 +@EqualsAndHashCode(callSuper = true)
  11 +@ToString(callSuper = true)
  12 +public class ProductUpdateReqVO extends ProductBaseVO {
  13 +
  14 + @Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "20529")
  15 + @NotNull(message = "主键id不能为空")
  16 + private Long id;
  17 +
  18 +}
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/productcategory/ProductCategoryController.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.controller.admin.productcategory;
  2 +
  3 +import org.springframework.web.bind.annotation.*;
  4 +import javax.annotation.Resource;
  5 +import org.springframework.validation.annotation.Validated;
  6 +import org.springframework.security.access.prepost.PreAuthorize;
  7 +import io.swagger.v3.oas.annotations.tags.Tag;
  8 +import io.swagger.v3.oas.annotations.Parameter;
  9 +import io.swagger.v3.oas.annotations.Operation;
  10 +
  11 +import javax.validation.constraints.*;
  12 +import javax.validation.*;
  13 +import javax.servlet.http.*;
  14 +import java.util.*;
  15 +import java.io.IOException;
  16 +
  17 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  18 +import cn.iocoder.yudao.framework.common.pojo.CommonResult;
  19 +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
  20 +
  21 +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
  22 +
  23 +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
  24 +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;
  25 +
  26 +import cn.iocoder.yudao.module.crm.controller.admin.productcategory.vo.*;
  27 +import cn.iocoder.yudao.module.crm.dal.dataobject.productcategory.ProductCategoryDO;
  28 +import cn.iocoder.yudao.module.crm.convert.productcategory.ProductCategoryConvert;
  29 +import cn.iocoder.yudao.module.crm.service.productcategory.ProductCategoryService;
  30 +
  31 +@Tag(name = "管理后台 - 产品分类")
  32 +@RestController
  33 +@RequestMapping("/crm/product-category")
  34 +@Validated
  35 +public class ProductCategoryController {
  36 +
  37 + @Resource
  38 + private ProductCategoryService productCategoryService;
  39 +
  40 + @PostMapping("/create")
  41 + @Operation(summary = "创建产品分类")
  42 + @PreAuthorize("@ss.hasPermission('crm:product-category:create')")
  43 + public CommonResult<Long> createProductCategory(@Valid @RequestBody ProductCategoryCreateReqVO createReqVO) {
  44 + return success(productCategoryService.createProductCategory(createReqVO));
  45 + }
  46 +
  47 + @PutMapping("/update")
  48 + @Operation(summary = "更新产品分类")
  49 + @PreAuthorize("@ss.hasPermission('crm:product-category:update')")
  50 + public CommonResult<Boolean> updateProductCategory(@Valid @RequestBody ProductCategoryUpdateReqVO updateReqVO) {
  51 + productCategoryService.updateProductCategory(updateReqVO);
  52 + return success(true);
  53 + }
  54 +
  55 + @DeleteMapping("/delete")
  56 + @Operation(summary = "删除产品分类")
  57 + @Parameter(name = "id", description = "编号", required = true)
  58 + @PreAuthorize("@ss.hasPermission('crm:product-category:delete')")
  59 + public CommonResult<Boolean> deleteProductCategory(@RequestParam("id") Long id) {
  60 + productCategoryService.deleteProductCategory(id);
  61 + return success(true);
  62 + }
  63 +
  64 + @GetMapping("/get")
  65 + @Operation(summary = "获得产品分类")
  66 + @Parameter(name = "id", description = "编号", required = true, example = "1024")
  67 + @PreAuthorize("@ss.hasPermission('crm:product-category:query')")
  68 + public CommonResult<ProductCategoryRespVO> getProductCategory(@RequestParam("id") Long id) {
  69 + ProductCategoryDO productCategory = productCategoryService.getProductCategory(id);
  70 + return success(ProductCategoryConvert.INSTANCE.convert(productCategory));
  71 + }
  72 +
  73 + @GetMapping("/list")
  74 + @Operation(summary = "获得产品分类列表")
  75 + @PreAuthorize("@ss.hasPermission('crm:product-category:query')")
  76 + public CommonResult<List<ProductCategoryRespVO>> getProductCategoryList(@Valid ProductCategoryListReqVO treeListReqVO) {
  77 + List<ProductCategoryDO> list = productCategoryService.getProductCategoryList(treeListReqVO);
  78 + return success(ProductCategoryConvert.INSTANCE.convertList(list));
  79 + }
  80 +
  81 +}
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/productcategory/vo/ProductCategoryBaseVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.controller.admin.productcategory.vo;
  2 +
  3 +import io.swagger.v3.oas.annotations.media.Schema;
  4 +import lombok.Data;
  5 +
  6 +import javax.validation.constraints.NotNull;
  7 +
  8 +/**
  9 + * 产品分类 Base VO,提供给添加、修改、详细的子 VO 使用
  10 + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
  11 + */
  12 +@Data
  13 +public class ProductCategoryBaseVO {
  14 +
  15 + @Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
  16 + @NotNull(message = "名称不能为空")
  17 + private String name;
  18 +
  19 + @Schema(description = "父级 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "4680")
  20 + @NotNull(message = "父级 id 不能为空")
  21 + private Long parentId;
  22 +
  23 +}
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/productcategory/vo/ProductCategoryCreateReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.controller.admin.productcategory.vo;
  2 +
  3 +import lombok.*;
  4 +import java.util.*;
  5 +import io.swagger.v3.oas.annotations.media.Schema;
  6 +import javax.validation.constraints.*;
  7 +
  8 +@Schema(description = "管理后台 - 产品分类创建 Request VO")
  9 +@Data
  10 +@EqualsAndHashCode(callSuper = true)
  11 +@ToString(callSuper = true)
  12 +public class ProductCategoryCreateReqVO extends ProductCategoryBaseVO {
  13 +
  14 +}
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/productcategory/vo/ProductCategoryListReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.controller.admin.productcategory.vo;
  2 +
  3 +import com.alibaba.excel.annotation.ExcelProperty;
  4 +import io.swagger.v3.oas.annotations.media.Schema;
  5 +import lombok.Data;
  6 +
  7 +import java.time.LocalDateTime;
  8 +
  9 +// TODO 芋艿:这个导出最后搞;命名应该是按照 ProductExportReqVO 风格
  10 +@Schema(description = "管理后台 - 产品分类列表 Request VO")
  11 +@Data
  12 +public class ProductCategoryListReqVO {
  13 +
  14 + @ExcelProperty("名称")
  15 + private String name;
  16 +
  17 + @ExcelProperty("父级 id")
  18 + private Long parentId;
  19 +
  20 + @ExcelProperty("创建时间")
  21 + private LocalDateTime createTime;
  22 +
  23 +}
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/productcategory/vo/ProductCategoryRespVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.controller.admin.productcategory.vo;
  2 +
  3 +import io.swagger.v3.oas.annotations.media.Schema;
  4 +import lombok.*;
  5 +import java.time.LocalDateTime;
  6 +
  7 +@Schema(description = "管理后台 - 产品分类 Response VO")
  8 +@Data
  9 +@EqualsAndHashCode(callSuper = true)
  10 +@ToString(callSuper = true)
  11 +public class ProductCategoryRespVO extends ProductCategoryBaseVO {
  12 +
  13 + @Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "23902")
  14 + private Long id;
  15 +
  16 + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
  17 + private LocalDateTime createTime;
  18 +
  19 +}
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/productcategory/vo/ProductCategoryUpdateReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.controller.admin.productcategory.vo;
  2 +
  3 +import io.swagger.v3.oas.annotations.media.Schema;
  4 +import lombok.Data;
  5 +import lombok.EqualsAndHashCode;
  6 +import lombok.ToString;
  7 +
  8 +import javax.validation.constraints.NotNull;
  9 +
  10 +@Schema(description = "管理后台 - 产品分类更新 Request VO")
  11 +@Data
  12 +@EqualsAndHashCode(callSuper = true)
  13 +@ToString(callSuper = true)
  14 +public class ProductCategoryUpdateReqVO extends ProductCategoryBaseVO {
  15 +
  16 + @Schema(description = "主键 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "23902")
  17 + @NotNull(message = "主键 id 不能为空")
  18 + private Long id;
  19 +
  20 +}
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/product/ProductConvert.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.convert.product;
  2 +
  3 +import java.util.*;
  4 +
  5 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  6 +
  7 +import org.mapstruct.Mapper;
  8 +import org.mapstruct.factory.Mappers;
  9 +import cn.iocoder.yudao.module.crm.controller.admin.product.vo.*;
  10 +import cn.iocoder.yudao.module.crm.dal.dataobject.product.ProductDO;
  11 +
  12 +/**
  13 + * 产品 Convert
  14 + *
  15 + * @author ZanGe丶
  16 + */
  17 +@Mapper
  18 +public interface ProductConvert {
  19 +
  20 + ProductConvert INSTANCE = Mappers.getMapper(ProductConvert.class);
  21 +
  22 + ProductDO convert(ProductCreateReqVO bean);
  23 +
  24 + ProductDO convert(ProductUpdateReqVO bean);
  25 +
  26 + ProductRespVO convert(ProductDO bean);
  27 +
  28 + List<ProductRespVO> convertList(List<ProductDO> list);
  29 +
  30 + PageResult<ProductRespVO> convertPage(PageResult<ProductDO> page);
  31 +
  32 + List<ProductExcelVO> convertList02(List<ProductDO> list);
  33 +
  34 +}
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/productcategory/ProductCategoryConvert.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.convert.productcategory;
  2 +
  3 +import java.util.*;
  4 +
  5 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  6 +
  7 +import org.mapstruct.Mapper;
  8 +import org.mapstruct.factory.Mappers;
  9 +import cn.iocoder.yudao.module.crm.controller.admin.productcategory.vo.*;
  10 +import cn.iocoder.yudao.module.crm.dal.dataobject.productcategory.ProductCategoryDO;
  11 +
  12 +/**
  13 + * 产品分类 Convert
  14 + *
  15 + * @author ZanGe丶
  16 + */
  17 +@Mapper
  18 +public interface ProductCategoryConvert {
  19 +
  20 + ProductCategoryConvert INSTANCE = Mappers.getMapper(ProductCategoryConvert.class);
  21 +
  22 + ProductCategoryDO convert(ProductCategoryCreateReqVO bean);
  23 +
  24 + ProductCategoryDO convert(ProductCategoryUpdateReqVO bean);
  25 +
  26 + ProductCategoryRespVO convert(ProductCategoryDO bean);
  27 +
  28 + List<ProductCategoryRespVO> convertList(List<ProductCategoryDO> list);
  29 +
  30 +}
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/product/ProductDO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.dal.dataobject.product;
  2 +
  3 +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
  4 +import com.baomidou.mybatisplus.annotation.KeySequence;
  5 +import com.baomidou.mybatisplus.annotation.TableId;
  6 +import com.baomidou.mybatisplus.annotation.TableName;
  7 +import lombok.*;
  8 +
  9 +/**
  10 + * 产品 DO
  11 + *
  12 + * @author ZanGe丶
  13 + */
  14 +@TableName("crm_product")
  15 +@KeySequence("crm_product_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
  16 +@Data
  17 +@EqualsAndHashCode(callSuper = true)
  18 +@ToString(callSuper = true)
  19 +@Builder
  20 +@NoArgsConstructor
  21 +@AllArgsConstructor
  22 +public class ProductDO extends BaseDO {
  23 +
  24 + /**
  25 + * 主键 id
  26 + */
  27 + @TableId
  28 + private Long id;
  29 + /**
  30 + * 产品名称
  31 + */
  32 + private String name;
  33 + /**
  34 + * 产品编码
  35 + */
  36 + private String no;
  37 + /**
  38 + * 单位
  39 + */
  40 + private String unit;
  41 + /**
  42 + * 价格
  43 + */
  44 + private Long price;
  45 + /**
  46 + * 状态
  47 + *
  48 + * 枚举 {@link TODO crm_product_status 对应的类}
  49 + * // TODO @zange:这个写个枚举类,然后 {@link关联下
  50 + */
  51 + private Integer status;
  52 + /**
  53 + * 产品分类 ID
  54 + * // TODO @zange:这个要写下关联 CategoryDO 的 id 字段;参考下别的模块哈
  55 + */
  56 + private Long categoryId;
  57 + /**
  58 + * 产品描述
  59 + */
  60 + private String description;
  61 + /**
  62 + * 负责人的用户编号
  63 + */
  64 + private Long ownerUserId;
  65 +
  66 +}
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/productcategory/ProductCategoryDO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.dal.dataobject.productcategory;
  2 +
  3 +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
  4 +import com.baomidou.mybatisplus.annotation.KeySequence;
  5 +import com.baomidou.mybatisplus.annotation.TableId;
  6 +import com.baomidou.mybatisplus.annotation.TableName;
  7 +import lombok.*;
  8 +
  9 +/**
  10 + * 产品分类 DO
  11 + *
  12 + * @author ZanGe丶
  13 + */
  14 +@TableName("crm_product_category")
  15 +@KeySequence("crm_product_category_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
  16 +@Data
  17 +@EqualsAndHashCode(callSuper = true)
  18 +@ToString(callSuper = true)
  19 +@Builder
  20 +@NoArgsConstructor
  21 +@AllArgsConstructor
  22 +public class ProductCategoryDO extends BaseDO {
  23 +
  24 + /**
  25 + * 主键id
  26 + */
  27 + @TableId
  28 + private Long id;
  29 + /**
  30 + * 名称
  31 + */
  32 + private String name;
  33 + /**
  34 + * 父级 id
  35 + * // TODO @zange:这个要写下关联 CategoryDO 的 id 字段;参考下别的模块哈
  36 + */
  37 + private Long parentId;
  38 +
  39 +}
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/product/ProductMapper.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.dal.mysql.product;
  2 +
  3 +import java.util.*;
  4 +
  5 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  6 +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
  7 +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
  8 +import cn.iocoder.yudao.module.crm.dal.dataobject.product.ProductDO;
  9 +import org.apache.ibatis.annotations.Mapper;
  10 +import cn.iocoder.yudao.module.crm.controller.admin.product.vo.*;
  11 +
  12 +/**
  13 + * 产品 Mapper
  14 + *
  15 + * @author ZanGe丶
  16 + */
  17 +@Mapper
  18 +public interface ProductMapper extends BaseMapperX<ProductDO> {
  19 +
  20 + default PageResult<ProductDO> selectPage(ProductPageReqVO reqVO) {
  21 + return selectPage(reqVO, new LambdaQueryWrapperX<ProductDO>()
  22 + .likeIfPresent(ProductDO::getName, reqVO.getName())
  23 + .likeIfPresent(ProductDO::getNo, reqVO.getNo())
  24 + .eqIfPresent(ProductDO::getUnit, reqVO.getUnit())
  25 + .eqIfPresent(ProductDO::getPrice, reqVO.getPrice())
  26 + .eqIfPresent(ProductDO::getStatus, reqVO.getStatus())
  27 + .eqIfPresent(ProductDO::getCategoryId, reqVO.getCategoryId())
  28 + .eqIfPresent(ProductDO::getDescription, reqVO.getDescription())
  29 + .eqIfPresent(ProductDO::getOwnerUserId, reqVO.getOwnerUserId())
  30 + .betweenIfPresent(ProductDO::getCreateTime, reqVO.getCreateTime())
  31 + .orderByDesc(ProductDO::getId));
  32 + }
  33 +
  34 + default List<ProductDO> selectList(ProductExportReqVO reqVO) {
  35 + return selectList(new LambdaQueryWrapperX<ProductDO>()
  36 + .likeIfPresent(ProductDO::getName, reqVO.getName())
  37 + .likeIfPresent(ProductDO::getNo, reqVO.getNo())
  38 + .eqIfPresent(ProductDO::getUnit, reqVO.getUnit())
  39 + .eqIfPresent(ProductDO::getPrice, reqVO.getPrice())
  40 + .eqIfPresent(ProductDO::getStatus, reqVO.getStatus())
  41 + .eqIfPresent(ProductDO::getCategoryId, reqVO.getCategoryId())
  42 + .eqIfPresent(ProductDO::getDescription, reqVO.getDescription())
  43 + .eqIfPresent(ProductDO::getOwnerUserId, reqVO.getOwnerUserId())
  44 + .betweenIfPresent(ProductDO::getCreateTime, reqVO.getCreateTime())
  45 + .orderByDesc(ProductDO::getId));
  46 + }
  47 +
  48 +}
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/productcategory/ProductCategoryMapper.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.dal.mysql.productcategory;
  2 +
  3 +import java.util.*;
  4 +
  5 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  6 +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
  7 +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
  8 +import cn.iocoder.yudao.module.crm.dal.dataobject.productcategory.ProductCategoryDO;
  9 +import org.apache.ibatis.annotations.Mapper;
  10 +import cn.iocoder.yudao.module.crm.controller.admin.productcategory.vo.*;
  11 +
  12 +/**
  13 + * 产品分类 Mapper
  14 + *
  15 + * @author ZanGe丶
  16 + */
  17 +@Mapper
  18 +public interface ProductCategoryMapper extends BaseMapperX<ProductCategoryDO> {
  19 +
  20 +
  21 + default List<ProductCategoryDO> selectList(ProductCategoryListReqVO reqVO) {
  22 + return selectList(new LambdaQueryWrapperX<ProductCategoryDO>()
  23 + .likeIfPresent(ProductCategoryDO::getName, reqVO.getName())
  24 + .eqIfPresent(ProductCategoryDO::getParentId, reqVO.getParentId())
  25 + .orderByDesc(ProductCategoryDO::getId));
  26 + }
  27 +
  28 +}
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/ProductService.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.service.product;
  2 +
  3 +import java.util.*;
  4 +import javax.validation.*;
  5 +import cn.iocoder.yudao.module.crm.controller.admin.product.vo.*;
  6 +import cn.iocoder.yudao.module.crm.dal.dataobject.product.ProductDO;
  7 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  8 +
  9 +/**
  10 + * 产品 Service 接口
  11 + *
  12 + * @author ZanGe丶
  13 + */
  14 +public interface ProductService {
  15 +
  16 + /**
  17 + * 创建产品
  18 + *
  19 + * @param createReqVO 创建信息
  20 + * @return 编号
  21 + */
  22 + Long createProduct(@Valid ProductCreateReqVO createReqVO);
  23 +
  24 + /**
  25 + * 更新产品
  26 + *
  27 + * @param updateReqVO 更新信息
  28 + */
  29 + void updateProduct(@Valid ProductUpdateReqVO updateReqVO);
  30 +
  31 + /**
  32 + * 删除产品
  33 + *
  34 + * @param id 编号
  35 + */
  36 + void deleteProduct(Long id);
  37 +
  38 + /**
  39 + * 获得产品
  40 + *
  41 + * @param id 编号
  42 + * @return 产品
  43 + */
  44 + ProductDO getProduct(Long id);
  45 +
  46 + /**
  47 + * 获得产品列表
  48 + *
  49 + * @param ids 编号
  50 + * @return 产品列表
  51 + */
  52 + List<ProductDO> getProductList(Collection<Long> ids);
  53 +
  54 + /**
  55 + * 获得产品分页
  56 + *
  57 + * @param pageReqVO 分页查询
  58 + * @return 产品分页
  59 + */
  60 + PageResult<ProductDO> getProductPage(ProductPageReqVO pageReqVO);
  61 +
  62 + /**
  63 + * 获得产品列表, 用于 Excel 导出
  64 + *
  65 + * @param exportReqVO 查询条件
  66 + * @return 产品列表
  67 + */
  68 + List<ProductDO> getProductList(ProductExportReqVO exportReqVO);
  69 +
  70 +}
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/ProductServiceImpl.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.service.product;
  2 +
  3 +import cn.hutool.core.collection.CollUtil;
  4 +import cn.hutool.core.collection.ListUtil;
  5 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  6 +import cn.iocoder.yudao.module.crm.controller.admin.product.vo.ProductCreateReqVO;
  7 +import cn.iocoder.yudao.module.crm.controller.admin.product.vo.ProductExportReqVO;
  8 +import cn.iocoder.yudao.module.crm.controller.admin.product.vo.ProductPageReqVO;
  9 +import cn.iocoder.yudao.module.crm.controller.admin.product.vo.ProductUpdateReqVO;
  10 +import cn.iocoder.yudao.module.crm.convert.product.ProductConvert;
  11 +import cn.iocoder.yudao.module.crm.dal.dataobject.product.ProductDO;
  12 +import cn.iocoder.yudao.module.crm.dal.mysql.product.ProductMapper;
  13 +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  14 +import org.springframework.stereotype.Service;
  15 +import org.springframework.validation.annotation.Validated;
  16 +
  17 +import javax.annotation.Resource;
  18 +import java.util.Collection;
  19 +import java.util.List;
  20 +
  21 +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
  22 +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.PRODUCT_NOT_EXISTS;
  23 +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.PRODUCT_NO_EXISTS;
  24 +
  25 +/**
  26 + * 产品 Service 实现类
  27 + *
  28 + * @author ZanGe丶
  29 + */
  30 +@Service
  31 +@Validated
  32 +public class ProductServiceImpl implements ProductService {
  33 +
  34 + @Resource
  35 + private ProductMapper productMapper;
  36 +
  37 + @Override
  38 + public Long createProduct(ProductCreateReqVO createReqVO) {
  39 + // 校验产品编号是否存在
  40 + validateProductNo(createReqVO.getNo());
  41 + // TODO @zange:需要校验 categoryId 是否存在;
  42 + // 插入
  43 + ProductDO product = ProductConvert.INSTANCE.convert(createReqVO);
  44 + productMapper.insert(product);
  45 + // 返回
  46 + return product.getId();
  47 + }
  48 +
  49 + @Override
  50 + public void updateProduct(ProductUpdateReqVO updateReqVO) {
  51 + // 校验存在
  52 + validateProductExists(updateReqVO.getId(), updateReqVO.getNo());
  53 + // TODO @zange:需要校验 categoryId 是否存在;
  54 + // 更新
  55 + ProductDO updateObj = ProductConvert.INSTANCE.convert(updateReqVO);
  56 + productMapper.updateById(updateObj);
  57 + }
  58 +
  59 + @Override
  60 + public void deleteProduct(Long id) {
  61 + // 校验存在
  62 + validateProductExists(id, null);
  63 + // 删除
  64 + productMapper.deleteById(id);
  65 + }
  66 +
  67 + // TODO @zange:validateProductExists 要不只校验是否存在;然后是否 no 重复,交给 validateProductNo,名字改成 validateProductNoDuplicate,和别的模块保持一致哈;
  68 + private void validateProductExists(Long id, String no) {
  69 + ProductDO product = productMapper.selectById(id);
  70 + if (product == null) {
  71 + throw exception(PRODUCT_NOT_EXISTS);
  72 + }
  73 + if (no != null && no.equals(product.getNo())) {
  74 + throw exception(PRODUCT_NO_EXISTS);
  75 + }
  76 + }
  77 +
  78 + @Override
  79 + public ProductDO getProduct(Long id) {
  80 + return productMapper.selectById(id);
  81 + }
  82 +
  83 + @Override
  84 + public List<ProductDO> getProductList(Collection<Long> ids) {
  85 + if (CollUtil.isEmpty(ids)) {
  86 + return ListUtil.empty();
  87 + }
  88 + return productMapper.selectBatchIds(ids);
  89 + }
  90 +
  91 + @Override
  92 + public PageResult<ProductDO> getProductPage(ProductPageReqVO pageReqVO) {
  93 + return productMapper.selectPage(pageReqVO);
  94 + }
  95 +
  96 + @Override
  97 + public List<ProductDO> getProductList(ProductExportReqVO exportReqVO) {
  98 + return productMapper.selectList(exportReqVO);
  99 + }
  100 +
  101 + private void validateProductNo(String no) {
  102 + ProductDO product = productMapper.selectOne(new LambdaQueryWrapper<ProductDO>().eq(ProductDO::getNo, no));
  103 + if (product != null) {
  104 + throw exception(PRODUCT_NO_EXISTS);
  105 + }
  106 + }
  107 +
  108 +}
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/productcategory/ProductCategoryService.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.service.productcategory;
  2 +
  3 +import java.util.*;
  4 +import javax.validation.*;
  5 +import cn.iocoder.yudao.module.crm.controller.admin.productcategory.vo.*;
  6 +import cn.iocoder.yudao.module.crm.dal.dataobject.productcategory.ProductCategoryDO;
  7 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  8 +
  9 +/**
  10 + * 产品分类 Service 接口
  11 + *
  12 + * @author ZanGe丶
  13 + */
  14 +public interface ProductCategoryService {
  15 +
  16 + /**
  17 + * 创建产品分类
  18 + *
  19 + * @param createReqVO 创建信息
  20 + * @return 编号
  21 + */
  22 + Long createProductCategory(@Valid ProductCategoryCreateReqVO createReqVO);
  23 +
  24 + /**
  25 + * 更新产品分类
  26 + *
  27 + * @param updateReqVO 更新信息
  28 + */
  29 + void updateProductCategory(@Valid ProductCategoryUpdateReqVO updateReqVO);
  30 +
  31 + /**
  32 + * 删除产品分类
  33 + *
  34 + * @param id 编号
  35 + */
  36 + void deleteProductCategory(Long id);
  37 +
  38 + /**
  39 + * 获得产品分类
  40 + *
  41 + * @param id 编号
  42 + * @return 产品分类
  43 + */
  44 + ProductCategoryDO getProductCategory(Long id);
  45 +
  46 + /**
  47 + * 获得产品分类列表
  48 + *
  49 + * @param ids 编号
  50 + * @return 产品分类列表
  51 + */
  52 + List<ProductCategoryDO> getProductCategoryList(ProductCategoryListReqVO treeListReqVO);
  53 +
  54 +}
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/productcategory/ProductCategoryServiceImpl.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.service.productcategory;
  2 +
  3 +import cn.iocoder.yudao.module.crm.controller.admin.productcategory.vo.ProductCategoryCreateReqVO;
  4 +import cn.iocoder.yudao.module.crm.controller.admin.productcategory.vo.ProductCategoryListReqVO;
  5 +import cn.iocoder.yudao.module.crm.controller.admin.productcategory.vo.ProductCategoryUpdateReqVO;
  6 +import cn.iocoder.yudao.module.crm.convert.productcategory.ProductCategoryConvert;
  7 +import cn.iocoder.yudao.module.crm.dal.dataobject.productcategory.ProductCategoryDO;
  8 +import cn.iocoder.yudao.module.crm.dal.mysql.productcategory.ProductCategoryMapper;
  9 +import org.springframework.stereotype.Service;
  10 +import org.springframework.validation.annotation.Validated;
  11 +
  12 +import javax.annotation.Resource;
  13 +import java.util.List;
  14 +
  15 +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
  16 +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.PRODUCT_CATEGORY_NOT_EXISTS;
  17 +
  18 +// TODO @zange:这个类所在的包,放到 product 下;
  19 +/**
  20 + * 产品分类 Service 实现类
  21 + *
  22 + * @author ZanGe丶
  23 + */
  24 +@Service
  25 +@Validated
  26 +public class ProductCategoryServiceImpl implements ProductCategoryService {
  27 +
  28 + @Resource
  29 + private ProductCategoryMapper productCategoryMapper;
  30 +
  31 + @Override
  32 + public Long createProductCategory(ProductCategoryCreateReqVO createReqVO) {
  33 + // TODO zange:参考 mall: ProductCategoryServiceImpl 补充下必要的参数校验;
  34 + // 插入
  35 + ProductCategoryDO productCategory = ProductCategoryConvert.INSTANCE.convert(createReqVO);
  36 + productCategoryMapper.insert(productCategory);
  37 + // 返回
  38 + return productCategory.getId();
  39 + }
  40 +
  41 + @Override
  42 + public void updateProductCategory(ProductCategoryUpdateReqVO updateReqVO) {
  43 + // TODO zange:参考 mall: ProductCategoryServiceImpl 补充下必要的参数校验;
  44 + // 校验存在
  45 + validateProductCategoryExists(updateReqVO.getId());
  46 + // 更新
  47 + ProductCategoryDO updateObj = ProductCategoryConvert.INSTANCE.convert(updateReqVO);
  48 + productCategoryMapper.updateById(updateObj);
  49 + }
  50 +
  51 + @Override
  52 + public void deleteProductCategory(Long id) {
  53 + // TODO zange:参考 mall: ProductCategoryServiceImpl 补充下必要的参数校验;
  54 + // 校验存在
  55 + validateProductCategoryExists(id);
  56 + // 删除
  57 + productCategoryMapper.deleteById(id);
  58 + }
  59 +
  60 + private void validateProductCategoryExists(Long id) {
  61 + if (productCategoryMapper.selectById(id) == null) {
  62 + throw exception(PRODUCT_CATEGORY_NOT_EXISTS);
  63 + }
  64 + }
  65 +
  66 + @Override
  67 + public ProductCategoryDO getProductCategory(Long id) {
  68 + return productCategoryMapper.selectById(id);
  69 + }
  70 +
  71 + @Override
  72 + public List<ProductCategoryDO> getProductCategoryList(ProductCategoryListReqVO treeListReqVO) {
  73 + return productCategoryMapper.selectList(treeListReqVO);
  74 + }
  75 +
  76 +}
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/product/ProductMapper.xml 0 → 100644
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3 +<mapper namespace="cn.iocoder.yudao.module.crm.dal.mysql.product.ProductMapper">
  4 +
  5 + <!--
  6 + 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
  7 + 无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
  8 + 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
  9 + 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
  10 + -->
  11 +
  12 +</mapper>
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/productcategory/ProductCategoryMapper.xml 0 → 100644
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3 +<mapper namespace="cn.iocoder.yudao.module.crm.dal.mysql.productcategory.ProductCategoryMapper">
  4 +
  5 + <!--
  6 + 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
  7 + 无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
  8 + 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
  9 + 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
  10 + -->
  11 +
  12 +</mapper>
... ...