From efd49421298619d5828de9d29350f6015827c09c Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 30 Jul 2022 21:24:05 +0800 Subject: [PATCH] =?UTF-8?q?mall=EF=BC=9A=E5=AE=8C=E5=96=84=E5=95=86?= =?UTF-8?q?=E5=93=81=E5=88=86=E7=B1=BB=E7=9A=84=20APP=20=E5=90=8E=E7=AB=AF?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../category/ProductCategoryController.java | 6 ++--- .../app/category/AppCategoryController.java | 8 +++--- ...ListRespVO.java => AppCategoryRespVO.java} | 4 +-- ...nvert.java => ProductCategoryConvert.java} | 8 +++--- .../category/ProductCategoryDO.java | 6 ++--- .../category/ProductCategoryServiceImpl.java | 6 ++--- .../src/views/mall/product/category/index.vue | 26 +++++++++++++++---- yudao-ui-app/pages/category/category.vue | 6 ++--- 8 files changed, 43 insertions(+), 27 deletions(-) rename yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/category/vo/{AppCategoryListRespVO.java => AppCategoryRespVO.java} (90%) rename yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/category/{CategoryConvert.java => ProductCategoryConvert.java} (80%) diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/ProductCategoryController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/ProductCategoryController.java index 1f519e40d..4467d392a 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/ProductCategoryController.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/ProductCategoryController.java @@ -5,7 +5,7 @@ import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCateg import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryListReqVO; import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryCreateReqVO; import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryUpdateReqVO; -import cn.iocoder.yudao.module.product.convert.category.CategoryConvert; +import cn.iocoder.yudao.module.product.convert.category.ProductCategoryConvert; import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO; import cn.iocoder.yudao.module.product.service.category.ProductCategoryService; import io.swagger.annotations.Api; @@ -61,7 +61,7 @@ public class ProductCategoryController { @PreAuthorize("@ss.hasPermission('product:category:query')") public CommonResult getProductCategory(@RequestParam("id") Long id) { ProductCategoryDO category = categoryService.getProductCategory(id); - return success(CategoryConvert.INSTANCE.convert(category)); + return success(ProductCategoryConvert.INSTANCE.convert(category)); } @GetMapping("/list") @@ -70,7 +70,7 @@ public class ProductCategoryController { public CommonResult> getProductCategoryList(@Valid ProductCategoryListReqVO treeListReqVO) { List list = categoryService.getEnableProductCategoryList(treeListReqVO); list.sort(Comparator.comparing(ProductCategoryDO::getSort)); - return success(CategoryConvert.INSTANCE.convertList(list)); + return success(ProductCategoryConvert.INSTANCE.convertList(list)); } } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/category/AppCategoryController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/category/AppCategoryController.java index 5300c9c67..1b5664b85 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/category/AppCategoryController.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/category/AppCategoryController.java @@ -1,8 +1,8 @@ package cn.iocoder.yudao.module.product.controller.app.category; import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.product.controller.app.category.vo.AppCategoryListRespVO; -import cn.iocoder.yudao.module.product.convert.category.CategoryConvert; +import cn.iocoder.yudao.module.product.controller.app.category.vo.AppCategoryRespVO; +import cn.iocoder.yudao.module.product.convert.category.ProductCategoryConvert; import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO; import cn.iocoder.yudao.module.product.service.category.ProductCategoryService; import io.swagger.annotations.Api; @@ -29,10 +29,10 @@ public class AppCategoryController { @GetMapping("/list") @ApiOperation("获得商品分类列表") - public CommonResult> listByQuery() { + public CommonResult> getProductCategoryList() { List list = categoryService.getEnableProductCategoryList(); list.sort(Comparator.comparing(ProductCategoryDO::getSort)); - return success(CategoryConvert.INSTANCE.convertList03(list)); + return success(ProductCategoryConvert.INSTANCE.convertList03(list)); } } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/category/vo/AppCategoryListRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/category/vo/AppCategoryRespVO.java similarity index 90% rename from yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/category/vo/AppCategoryListRespVO.java rename to yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/category/vo/AppCategoryRespVO.java index 9ed47f9d7..e46a50cd3 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/category/vo/AppCategoryListRespVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/category/vo/AppCategoryRespVO.java @@ -8,8 +8,8 @@ import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; @Data -@ApiModel(value = "App - 商品分类 Response VO") -public class AppCategoryListRespVO { +@ApiModel(value = "用户 APP - 商品分类 Response VO") +public class AppCategoryRespVO { @ApiModelProperty(value = "分类编号", required = true, example = "2") private Long id; diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/category/CategoryConvert.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/category/ProductCategoryConvert.java similarity index 80% rename from yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/category/CategoryConvert.java rename to yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/category/ProductCategoryConvert.java index 637c52976..ae01ca9d5 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/category/CategoryConvert.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/category/ProductCategoryConvert.java @@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.product.convert.category; import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryCreateReqVO; import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryRespVO; import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryUpdateReqVO; -import cn.iocoder.yudao.module.product.controller.app.category.vo.AppCategoryListRespVO; +import cn.iocoder.yudao.module.product.controller.app.category.vo.AppCategoryRespVO; import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; @@ -16,9 +16,9 @@ import java.util.List; * @author 芋道源码 */ @Mapper -public interface CategoryConvert { +public interface ProductCategoryConvert { - CategoryConvert INSTANCE = Mappers.getMapper(CategoryConvert.class); + ProductCategoryConvert INSTANCE = Mappers.getMapper(ProductCategoryConvert.class); ProductCategoryDO convert(ProductCategoryCreateReqVO bean); @@ -28,5 +28,5 @@ public interface CategoryConvert { List convertList(List list); - List convertList03(List list); + List convertList03(List list); } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/category/ProductCategoryDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/category/ProductCategoryDO.java index cb63f7563..93ec925a9 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/category/ProductCategoryDO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/category/ProductCategoryDO.java @@ -9,9 +9,9 @@ import lombok.*; /** * 商品分类 DO * - * 商品分类一共两级: + * 商品分类一共两类: * 1)一级分类:{@link #parentId} 等于 0 - * 2)二级分类:{@link #parentId} 等于父分类 + * 2)二级 + 三级分类:{@link #parentId} 不等于 0 * * @author 芋道源码 */ @@ -46,7 +46,7 @@ public class ProductCategoryDO extends BaseDO { * 分类图片 * * 一级分类:推荐 200 x 100 分辨率 - * 二级分类:推荐 100 x 100 分辨率 + * 二级 + 三级分类:推荐 100 x 100 分辨率 */ private String picUrl; /** diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryServiceImpl.java index 65f61b323..95364f75a 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryServiceImpl.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryServiceImpl.java @@ -5,7 +5,7 @@ import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryCreateReqVO; import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryListReqVO; import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryUpdateReqVO; -import cn.iocoder.yudao.module.product.convert.category.CategoryConvert; +import cn.iocoder.yudao.module.product.convert.category.ProductCategoryConvert; import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO; import cn.iocoder.yudao.module.product.dal.mysql.category.ProductCategoryMapper; import org.springframework.stereotype.Service; @@ -37,7 +37,7 @@ public class ProductCategoryServiceImpl implements ProductCategoryService { validateParentProductCategory(createReqVO.getParentId()); // 插入 - ProductCategoryDO category = CategoryConvert.INSTANCE.convert(createReqVO); + ProductCategoryDO category = ProductCategoryConvert.INSTANCE.convert(createReqVO); productCategoryMapper.insert(category); // 返回 return category.getId(); @@ -51,7 +51,7 @@ public class ProductCategoryServiceImpl implements ProductCategoryService { validateParentProductCategory(updateReqVO.getParentId()); // 更新 - ProductCategoryDO updateObj = CategoryConvert.INSTANCE.convert(updateReqVO); + ProductCategoryDO updateObj = ProductCategoryConvert.INSTANCE.convert(updateReqVO); productCategoryMapper.updateById(updateObj); } diff --git a/yudao-ui-admin/src/views/mall/product/category/index.vue b/yudao-ui-admin/src/views/mall/product/category/index.vue index 615c44328..da600c589 100644 --- a/yudao-ui-admin/src/views/mall/product/category/index.vue +++ b/yudao-ui-admin/src/views/mall/product/category/index.vue @@ -61,15 +61,15 @@ - - - - + - +
推荐 200x100 图片分辨率
推荐 100x100 图片分辨率
@@ -164,6 +164,11 @@ export default { getProductCategoryList(params).then(response => { this.list = this.handleTree(response.data, "id", "parentId"); this.loading = false; + // 属性下拉框 + this.parentCategoryOptions = []; + const menu = {id: 0, name: '顶级分类', children: []}; + menu.children = this.handleTree(response.data, "id", "parentId"); + this.parentCategoryOptions.push(menu); }); }, /** 取消按钮 */ @@ -202,6 +207,17 @@ export default { this.refreshTable = true; }); }, + /** 转换菜单数据结构 */ + normalizer(node) { + if (node.children && !node.children.length) { + delete node.children; + } + return { + id: node.id, + label: node.name, + children: node.children + }; + }, /** 新增按钮操作 */ handleAdd() { this.reset(); diff --git a/yudao-ui-app/pages/category/category.vue b/yudao-ui-app/pages/category/category.vue index 70b993273..79092e91d 100644 --- a/yudao-ui-app/pages/category/category.vue +++ b/yudao-ui-app/pages/category/category.vue @@ -20,7 +20,7 @@ - + @@ -33,8 +33,8 @@ - - + + {{ subItem.name }}