Commit bf42f8e9ff7dbe2645523c682c7f2239e6e5f08e
1 parent
ecf72896
【增加CRM:产品以及产品分类】
Showing
29 changed files
with
1150 additions
and
0 deletions
sql/mysql/crm.sql
| ... | ... | @@ -63,3 +63,45 @@ CREATE TABLE `crm_receivable_plan` ( |
| 63 | 63 | `tenant_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '租户编号', |
| 64 | 64 | PRIMARY KEY (`id`) USING BTREE |
| 65 | 65 | ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '回款计划' ROW_FORMAT = DYNAMIC; |
| 66 | + | |
| 67 | +-- ---------------------------- | |
| 68 | +-- 产品表 | |
| 69 | +-- ---------------------------- | |
| 70 | +DROP TABLE IF EXISTS `crm_product`; | |
| 71 | +CREATE TABLE `crm_product` | |
| 72 | +( | |
| 73 | + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键id', | |
| 74 | + `name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '产品名称', | |
| 75 | + `no` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '产品编码', | |
| 76 | + `unit` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '单位', | |
| 77 | + `price` bigint(20) NULL DEFAULT 0 COMMENT '价格', | |
| 78 | + `status` tinyint(2) NOT NULL DEFAULT 1 COMMENT '状态 1-上架 0-下架', | |
| 79 | + `category_id` bigint(20) NOT NULL COMMENT '产品分类ID', | |
| 80 | + `description` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '产品描述', | |
| 81 | + `owner_user_id` bigint(20) NOT NULL COMMENT '负责人的用户编号', | |
| 82 | + `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者', | |
| 83 | + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', | |
| 84 | + `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者', | |
| 85 | + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', | |
| 86 | + `tenant_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '租户编号', | |
| 87 | + `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', | |
| 88 | + PRIMARY KEY (`id`) USING BTREE | |
| 89 | +) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '产品表' ROW_FORMAT = Dynamic; | |
| 90 | + | |
| 91 | +-- ---------------------------- | |
| 92 | +-- 产品分类表 | |
| 93 | +-- ---------------------------- | |
| 94 | +DROP TABLE IF EXISTS `crm_product_category`; | |
| 95 | +CREATE TABLE `crm_product_category` | |
| 96 | +( | |
| 97 | + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键id', | |
| 98 | + `name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '名称', | |
| 99 | + `parent_id` bigint(20) NOT NULL COMMENT '父级id', | |
| 100 | + `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者', | |
| 101 | + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', | |
| 102 | + `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者', | |
| 103 | + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', | |
| 104 | + `tenant_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '租户编号', | |
| 105 | + `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', | |
| 106 | + PRIMARY KEY (`id`) USING BTREE | |
| 107 | +) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '产品分类表' ROW_FORMAT = Dynamic; | |
| 66 | 108 | \ No newline at end of file | ... | ... |
sql/mysql/crm_data.sql
| ... | ... | @@ -17,4 +17,8 @@ INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `st |
| 17 | 17 | 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 | 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 (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 | 19 | |
| 20 | +INSERT INTO `system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES (604, '产品状态', 'crm_product_status', 0, '', '1', '2023-10-30 21:47:59', '1', '2023-10-30 21:48:45', b'0', '1970-01-01 00:00:00'); | |
| 21 | + | |
| 22 | +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 (1412, 1, '上架', '1', 'crm_product_status', 0, 'success', '', '', '1', '2023-10-30 21:49:34', '1', '2023-10-30 21:49:34', b'0'); | |
| 23 | +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 (1411, 0, '下架', '0', 'crm_product_status', 0, 'success', '', '', '1', '2023-10-30 21:49:13', '1', '2023-10-30 21:49:13', b'0'); | |
| 20 | 24 | ... | ... |
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 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.product.vo.*; | |
| 27 | +import cn.iocoder.yudao.module.crm.dal.dataobject.product.ProductDO; | |
| 28 | +import cn.iocoder.yudao.module.crm.convert.product.ProductConvert; | |
| 29 | +import cn.iocoder.yudao.module.crm.service.product.ProductService; | |
| 30 | + | |
| 31 | +@Tag(name = "管理后台 - 产品") | |
| 32 | +@RestController | |
| 33 | +@RequestMapping("/crm/product") | |
| 34 | +@Validated | |
| 35 | +public class ProductController { | |
| 36 | + | |
| 37 | + @Resource | |
| 38 | + private ProductService productService; | |
| 39 | + | |
| 40 | + @PostMapping("/create") | |
| 41 | + @Operation(summary = "创建产品") | |
| 42 | + @PreAuthorize("@ss.hasPermission('crm:product:create')") | |
| 43 | + public CommonResult<Long> createProduct(@Valid @RequestBody ProductCreateReqVO createReqVO) { | |
| 44 | + return success(productService.createProduct(createReqVO)); | |
| 45 | + } | |
| 46 | + | |
| 47 | + @PutMapping("/update") | |
| 48 | + @Operation(summary = "更新产品") | |
| 49 | + @PreAuthorize("@ss.hasPermission('crm:product:update')") | |
| 50 | + public CommonResult<Boolean> updateProduct(@Valid @RequestBody ProductUpdateReqVO updateReqVO) { | |
| 51 | + productService.updateProduct(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:delete')") | |
| 59 | + public CommonResult<Boolean> deleteProduct(@RequestParam("id") Long id) { | |
| 60 | + productService.deleteProduct(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:query')") | |
| 68 | + public CommonResult<ProductRespVO> getProduct(@RequestParam("id") Long id) { | |
| 69 | + ProductDO product = productService.getProduct(id); | |
| 70 | + return success(ProductConvert.INSTANCE.convert(product)); | |
| 71 | + } | |
| 72 | + | |
| 73 | + @GetMapping("/list") | |
| 74 | + @Operation(summary = "获得产品列表") | |
| 75 | + @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") | |
| 76 | + @PreAuthorize("@ss.hasPermission('crm:product:query')") | |
| 77 | + public CommonResult<List<ProductRespVO>> getProductList(@RequestParam("ids") Collection<Long> ids) { | |
| 78 | + List<ProductDO> list = productService.getProductList(ids); | |
| 79 | + return success(ProductConvert.INSTANCE.convertList(list)); | |
| 80 | + } | |
| 81 | + | |
| 82 | + @GetMapping("/page") | |
| 83 | + @Operation(summary = "获得产品分页") | |
| 84 | + @PreAuthorize("@ss.hasPermission('crm:product:query')") | |
| 85 | + public CommonResult<PageResult<ProductRespVO>> getProductPage(@Valid ProductPageReqVO pageVO) { | |
| 86 | + PageResult<ProductDO> pageResult = productService.getProductPage(pageVO); | |
| 87 | + return success(ProductConvert.INSTANCE.convertPage(pageResult)); | |
| 88 | + } | |
| 89 | + | |
| 90 | + @GetMapping("/export-excel") | |
| 91 | + @Operation(summary = "导出产品 Excel") | |
| 92 | + @PreAuthorize("@ss.hasPermission('crm:product:export')") | |
| 93 | + @OperateLog(type = EXPORT) | |
| 94 | + public void exportProductExcel(@Valid ProductExportReqVO exportReqVO, | |
| 95 | + HttpServletResponse response) throws IOException { | |
| 96 | + List<ProductDO> list = productService.getProductList(exportReqVO); | |
| 97 | + // 导出 Excel | |
| 98 | + List<ProductExcelVO> datas = ProductConvert.INSTANCE.convertList02(list); | |
| 99 | + ExcelUtils.write(response, "产品.xls", "数据", ProductExcelVO.class, datas); | |
| 100 | + } | |
| 101 | + | |
| 102 | +} | ... | ... |
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.*; | |
| 5 | +import java.util.*; | |
| 6 | +import java.time.LocalDateTime; | |
| 7 | +import java.time.LocalDateTime; | |
| 8 | +import javax.validation.constraints.*; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * 产品 Base VO,提供给添加、修改、详细的子 VO 使用 | |
| 12 | + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | |
| 13 | + */ | |
| 14 | +@Data | |
| 15 | +public class ProductBaseVO { | |
| 16 | + | |
| 17 | + @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") | |
| 18 | + @NotNull(message = "产品名称不能为空") | |
| 19 | + private String name; | |
| 20 | + | |
| 21 | + @Schema(description = "产品编码", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 22 | + @NotNull(message = "产品编码不能为空") | |
| 23 | + private String no; | |
| 24 | + | |
| 25 | + @Schema(description = "单位") | |
| 26 | + private String unit; | |
| 27 | + | |
| 28 | + @Schema(description = "价格", example = "8911") | |
| 29 | + private Long price; | |
| 30 | + | |
| 31 | + @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | |
| 32 | + @NotNull(message = "状态不能为空") | |
| 33 | + private Integer status; | |
| 34 | + | |
| 35 | + @Schema(description = "产品分类ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1738") | |
| 36 | + @NotNull(message = "产品分类ID不能为空") | |
| 37 | + private Long categoryId; | |
| 38 | + | |
| 39 | + @Schema(description = "产品描述", example = "你说的对") | |
| 40 | + private String description; | |
| 41 | + | |
| 42 | + @Schema(description = "负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31926") | |
| 43 | + @NotNull(message = "负责人的用户编号不能为空") | |
| 44 | + private Long ownerUserId; | |
| 45 | + | |
| 46 | +} | ... | ... |
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 io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.*; | |
| 5 | +import java.util.*; | |
| 6 | +import java.time.LocalDateTime; | |
| 7 | +import java.time.LocalDateTime; | |
| 8 | + | |
| 9 | +import com.alibaba.excel.annotation.ExcelProperty; | |
| 10 | +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; | |
| 11 | +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; | |
| 12 | + | |
| 13 | + | |
| 14 | +/** | |
| 15 | + * 产品 Excel VO | |
| 16 | + * | |
| 17 | + * @author ZanGe丶 | |
| 18 | + */ | |
| 19 | +@Data | |
| 20 | +public class ProductExcelVO { | |
| 21 | + | |
| 22 | + @ExcelProperty("主键id") | |
| 23 | + private Long id; | |
| 24 | + | |
| 25 | + @ExcelProperty("产品名称") | |
| 26 | + private String name; | |
| 27 | + | |
| 28 | + @ExcelProperty("产品编码") | |
| 29 | + private String no; | |
| 30 | + | |
| 31 | + @ExcelProperty("单位") | |
| 32 | + private String unit; | |
| 33 | + | |
| 34 | + @ExcelProperty("价格") | |
| 35 | + private Long price; | |
| 36 | + | |
| 37 | + @ExcelProperty(value = "状态", converter = DictConvert.class) | |
| 38 | + @DictFormat("crm_product_status") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中 | |
| 39 | + private Integer status; | |
| 40 | + | |
| 41 | + @ExcelProperty("产品分类ID") | |
| 42 | + private Long categoryId; | |
| 43 | + | |
| 44 | + @ExcelProperty("产品描述") | |
| 45 | + private String description; | |
| 46 | + | |
| 47 | + @ExcelProperty("负责人的用户编号") | |
| 48 | + private Long ownerUserId; | |
| 49 | + | |
| 50 | + @ExcelProperty("创建时间") | |
| 51 | + private LocalDateTime createTime; | |
| 52 | + | |
| 53 | +} | ... | ... |
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 lombok.*; | |
| 4 | +import java.util.*; | |
| 5 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 6 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 7 | +import java.time.LocalDateTime; | |
| 8 | +import org.springframework.format.annotation.DateTimeFormat; | |
| 9 | + | |
| 10 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 11 | + | |
| 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 lombok.*; | |
| 4 | +import java.util.*; | |
| 5 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 6 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 7 | +import org.springframework.format.annotation.DateTimeFormat; | |
| 8 | +import java.time.LocalDateTime; | |
| 9 | + | |
| 10 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 11 | + | |
| 12 | +@Schema(description = "管理后台 - 产品分页 Request VO") | |
| 13 | +@Data | |
| 14 | +@EqualsAndHashCode(callSuper = true) | |
| 15 | +@ToString(callSuper = true) | |
| 16 | +public class ProductPageReqVO extends PageParam { | |
| 17 | + | |
| 18 | + @Schema(description = "产品名称", example = "李四") | |
| 19 | + private String name; | |
| 20 | + | |
| 21 | + @Schema(description = "产品编码") | |
| 22 | + private String no; | |
| 23 | + | |
| 24 | + @Schema(description = "单位") | |
| 25 | + private String unit; | |
| 26 | + | |
| 27 | + @Schema(description = "价格", example = "8911") | |
| 28 | + private Long price; | |
| 29 | + | |
| 30 | + @Schema(description = "状态", example = "2") | |
| 31 | + private Integer status; | |
| 32 | + | |
| 33 | + @Schema(description = "产品分类ID", example = "1738") | |
| 34 | + private Long categoryId; | |
| 35 | + | |
| 36 | + @Schema(description = "产品描述", example = "你说的对") | |
| 37 | + private String description; | |
| 38 | + | |
| 39 | + @Schema(description = "负责人的用户编号", example = "31926") | |
| 40 | + private Long ownerUserId; | |
| 41 | + | |
| 42 | + @Schema(description = "创建时间") | |
| 43 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 44 | + private LocalDateTime[] createTime; | |
| 45 | + | |
| 46 | +} | ... | ... |
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.*; | |
| 5 | +import java.util.*; | |
| 6 | +import java.time.LocalDateTime; | |
| 7 | +import java.time.LocalDateTime; | |
| 8 | +import javax.validation.constraints.*; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * 产品分类 Base VO,提供给添加、修改、详细的子 VO 使用 | |
| 12 | + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | |
| 13 | + */ | |
| 14 | +@Data | |
| 15 | +public class ProductCategoryBaseVO { | |
| 16 | + | |
| 17 | + @Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") | |
| 18 | + @NotNull(message = "名称不能为空") | |
| 19 | + private String name; | |
| 20 | + | |
| 21 | + @Schema(description = "父级id", requiredMode = Schema.RequiredMode.REQUIRED, example = "4680") | |
| 22 | + @NotNull(message = "父级id不能为空") | |
| 23 | + private Long parentId; | |
| 24 | + | |
| 25 | +} | ... | ... |
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 | +/** | |
| 10 | + * 产品分类 List VO | |
| 11 | + * | |
| 12 | + * @author ZanGe丶 | |
| 13 | + */ | |
| 14 | +@Schema(description = "管理后台 - 产品分类列表 Request VO") | |
| 15 | +@Data | |
| 16 | +public class ProductCategoryListReqVO { | |
| 17 | + | |
| 18 | + @ExcelProperty("名称") | |
| 19 | + private String name; | |
| 20 | + | |
| 21 | + @ExcelProperty("父级id") | |
| 22 | + private Long parentId; | |
| 23 | + | |
| 24 | + @ExcelProperty("创建时间") | |
| 25 | + private LocalDateTime createTime; | |
| 26 | + | |
| 27 | +} | ... | ... |
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.*; | |
| 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 ProductCategoryUpdateReqVO extends ProductCategoryBaseVO { | |
| 13 | + | |
| 14 | + @Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "23902") | |
| 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/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 lombok.*; | |
| 4 | +import java.util.*; | |
| 5 | +import java.time.LocalDateTime; | |
| 6 | +import java.time.LocalDateTime; | |
| 7 | +import com.baomidou.mybatisplus.annotation.*; | |
| 8 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * 产品 DO | |
| 12 | + * | |
| 13 | + * @author ZanGe丶 | |
| 14 | + */ | |
| 15 | +@TableName("crm_product") | |
| 16 | +@KeySequence("crm_product_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | |
| 17 | +@Data | |
| 18 | +@EqualsAndHashCode(callSuper = true) | |
| 19 | +@ToString(callSuper = true) | |
| 20 | +@Builder | |
| 21 | +@NoArgsConstructor | |
| 22 | +@AllArgsConstructor | |
| 23 | +public class ProductDO extends BaseDO { | |
| 24 | + | |
| 25 | + /** | |
| 26 | + * 主键id | |
| 27 | + */ | |
| 28 | + @TableId | |
| 29 | + private Long id; | |
| 30 | + /** | |
| 31 | + * 产品名称 | |
| 32 | + */ | |
| 33 | + private String name; | |
| 34 | + /** | |
| 35 | + * 产品编码 | |
| 36 | + */ | |
| 37 | + private String no; | |
| 38 | + /** | |
| 39 | + * 单位 | |
| 40 | + */ | |
| 41 | + private String unit; | |
| 42 | + /** | |
| 43 | + * 价格 | |
| 44 | + */ | |
| 45 | + private Long price; | |
| 46 | + /** | |
| 47 | + * 状态 | |
| 48 | + * | |
| 49 | + * 枚举 {@link TODO crm_product_status 对应的类} | |
| 50 | + */ | |
| 51 | + private Integer status; | |
| 52 | + /** | |
| 53 | + * 产品分类ID | |
| 54 | + */ | |
| 55 | + private Long categoryId; | |
| 56 | + /** | |
| 57 | + * 产品描述 | |
| 58 | + */ | |
| 59 | + private String description; | |
| 60 | + /** | |
| 61 | + * 负责人的用户编号 | |
| 62 | + */ | |
| 63 | + private Long ownerUserId; | |
| 64 | + | |
| 65 | +} | ... | ... |
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 lombok.*; | |
| 4 | +import java.util.*; | |
| 5 | +import java.time.LocalDateTime; | |
| 6 | +import java.time.LocalDateTime; | |
| 7 | +import com.baomidou.mybatisplus.annotation.*; | |
| 8 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * 产品分类 DO | |
| 12 | + * | |
| 13 | + * @author ZanGe丶 | |
| 14 | + */ | |
| 15 | +@TableName("crm_product_category") | |
| 16 | +@KeySequence("crm_product_category_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | |
| 17 | +@Data | |
| 18 | +@EqualsAndHashCode(callSuper = true) | |
| 19 | +@ToString(callSuper = true) | |
| 20 | +@Builder | |
| 21 | +@NoArgsConstructor | |
| 22 | +@AllArgsConstructor | |
| 23 | +public class ProductCategoryDO extends BaseDO { | |
| 24 | + | |
| 25 | + /** | |
| 26 | + * 主键id | |
| 27 | + */ | |
| 28 | + @TableId | |
| 29 | + private Long id; | |
| 30 | + /** | |
| 31 | + * 名称 | |
| 32 | + */ | |
| 33 | + private String name; | |
| 34 | + /** | |
| 35 | + * 父级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 | + // 插入 | |
| 42 | + ProductDO product = ProductConvert.INSTANCE.convert(createReqVO); | |
| 43 | + productMapper.insert(product); | |
| 44 | + // 返回 | |
| 45 | + return product.getId(); | |
| 46 | + } | |
| 47 | + | |
| 48 | + @Override | |
| 49 | + public void updateProduct(ProductUpdateReqVO updateReqVO) { | |
| 50 | + // 校验存在 | |
| 51 | + validateProductExists(updateReqVO.getId(), updateReqVO.getNo()); | |
| 52 | + // 更新 | |
| 53 | + ProductDO updateObj = ProductConvert.INSTANCE.convert(updateReqVO); | |
| 54 | + productMapper.updateById(updateObj); | |
| 55 | + } | |
| 56 | + | |
| 57 | + @Override | |
| 58 | + public void deleteProduct(Long id) { | |
| 59 | + // 校验存在 | |
| 60 | + validateProductExists(id, null); | |
| 61 | + // 删除 | |
| 62 | + productMapper.deleteById(id); | |
| 63 | + } | |
| 64 | + | |
| 65 | + private void validateProductExists(Long id, String no) { | |
| 66 | + ProductDO product = productMapper.selectById(id); | |
| 67 | + if (product == null) { | |
| 68 | + throw exception(PRODUCT_NOT_EXISTS); | |
| 69 | + } | |
| 70 | + if (no != null && no.equals(product.getNo())) { | |
| 71 | + throw exception(PRODUCT_NO_EXISTS); | |
| 72 | + } | |
| 73 | + } | |
| 74 | + | |
| 75 | + @Override | |
| 76 | + public ProductDO getProduct(Long id) { | |
| 77 | + return productMapper.selectById(id); | |
| 78 | + } | |
| 79 | + | |
| 80 | + @Override | |
| 81 | + public List<ProductDO> getProductList(Collection<Long> ids) { | |
| 82 | + if (CollUtil.isEmpty(ids)) { | |
| 83 | + return ListUtil.empty(); | |
| 84 | + } | |
| 85 | + return productMapper.selectBatchIds(ids); | |
| 86 | + } | |
| 87 | + | |
| 88 | + @Override | |
| 89 | + public PageResult<ProductDO> getProductPage(ProductPageReqVO pageReqVO) { | |
| 90 | + return productMapper.selectPage(pageReqVO); | |
| 91 | + } | |
| 92 | + | |
| 93 | + @Override | |
| 94 | + public List<ProductDO> getProductList(ProductExportReqVO exportReqVO) { | |
| 95 | + return productMapper.selectList(exportReqVO); | |
| 96 | + } | |
| 97 | + | |
| 98 | + private void validateProductNo(String no) { | |
| 99 | + ProductDO product = productMapper.selectOne(new LambdaQueryWrapper<ProductDO>().eq(ProductDO::getNo, no)); | |
| 100 | + if (product != null) { | |
| 101 | + throw exception(PRODUCT_NO_EXISTS); | |
| 102 | + } | |
| 103 | + } | |
| 104 | +} | ... | ... |
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 org.springframework.stereotype.Service; | |
| 4 | +import javax.annotation.Resource; | |
| 5 | +import org.springframework.validation.annotation.Validated; | |
| 6 | + | |
| 7 | +import java.util.*; | |
| 8 | +import cn.iocoder.yudao.module.crm.controller.admin.productcategory.vo.*; | |
| 9 | +import cn.iocoder.yudao.module.crm.dal.dataobject.productcategory.ProductCategoryDO; | |
| 10 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 11 | + | |
| 12 | +import cn.iocoder.yudao.module.crm.convert.productcategory.ProductCategoryConvert; | |
| 13 | +import cn.iocoder.yudao.module.crm.dal.mysql.productcategory.ProductCategoryMapper; | |
| 14 | + | |
| 15 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 16 | +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; | |
| 17 | + | |
| 18 | +import cn.hutool.core.collection.CollUtil; | |
| 19 | +import cn.hutool.core.collection.ListUtil; | |
| 20 | + | |
| 21 | +/** | |
| 22 | + * 产品分类 Service 实现类 | |
| 23 | + * | |
| 24 | + * @author ZanGe丶 | |
| 25 | + */ | |
| 26 | +@Service | |
| 27 | +@Validated | |
| 28 | +public class ProductCategoryServiceImpl implements ProductCategoryService { | |
| 29 | + | |
| 30 | + @Resource | |
| 31 | + private ProductCategoryMapper productCategoryMapper; | |
| 32 | + | |
| 33 | + @Override | |
| 34 | + public Long createProductCategory(ProductCategoryCreateReqVO createReqVO) { | |
| 35 | + // 插入 | |
| 36 | + ProductCategoryDO productCategory = ProductCategoryConvert.INSTANCE.convert(createReqVO); | |
| 37 | + productCategoryMapper.insert(productCategory); | |
| 38 | + // 返回 | |
| 39 | + return productCategory.getId(); | |
| 40 | + } | |
| 41 | + | |
| 42 | + @Override | |
| 43 | + public void updateProductCategory(ProductCategoryUpdateReqVO updateReqVO) { | |
| 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 | + // 校验存在 | |
| 54 | + validateProductCategoryExists(id); | |
| 55 | + // 删除 | |
| 56 | + productCategoryMapper.deleteById(id); | |
| 57 | + } | |
| 58 | + | |
| 59 | + private void validateProductCategoryExists(Long id) { | |
| 60 | + if (productCategoryMapper.selectById(id) == null) { | |
| 61 | + throw exception(PRODUCT_CATEGORY_NOT_EXISTS); | |
| 62 | + } | |
| 63 | + } | |
| 64 | + | |
| 65 | + @Override | |
| 66 | + public ProductCategoryDO getProductCategory(Long id) { | |
| 67 | + return productCategoryMapper.selectById(id); | |
| 68 | + } | |
| 69 | + | |
| 70 | + @Override | |
| 71 | + public List<ProductCategoryDO> getProductCategoryList(ProductCategoryListReqVO treeListReqVO) { | |
| 72 | + return productCategoryMapper.selectList(treeListReqVO); | |
| 73 | + } | |
| 74 | + | |
| 75 | +} | ... | ... |
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> | ... | ... |