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