From 79a7391d396c3a7b76e96389f112c0dd17951833 Mon Sep 17 00:00:00 2001 From: DongZeLiang <2746733890@qq.com> Date: Wed, 6 Mar 2024 14:38:40 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=84=E6=A0=BC=E5=88=97=E8=A1=A8=E5=9B=9E?= =?UTF-8?q?=E6=98=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../model/TemplateAttributeGroupModel.java | 33 ++++++++++++++++ .../domain/model/TemplateAttributeModel.java | 36 +++++++++++++++++ .../resp/CategoryCommonElementResp.java | 39 +++++++++++++++++++ .../controller/BrandInfoController.java | 10 +++-- .../controller/CategoryInfoController.java | 12 ++++++ .../controller/RuleInfoController.java | 10 +++-- .../product/service/CategoryInfoService.java | 8 ++++ .../service/impl/BrandInfoServiceImpl.java | 2 +- .../service/impl/CategoryInfoServiceImpl.java | 27 +++++++++++++ .../service/impl/RuleInfoServiceImpl.java | 5 ++- 10 files changed, 174 insertions(+), 8 deletions(-) create mode 100644 muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/model/TemplateAttributeGroupModel.java create mode 100644 muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/model/TemplateAttributeModel.java create mode 100644 muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/resp/CategoryCommonElementResp.java diff --git a/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/model/TemplateAttributeGroupModel.java b/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/model/TemplateAttributeGroupModel.java new file mode 100644 index 0000000..c4b3e74 --- /dev/null +++ b/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/model/TemplateAttributeGroupModel.java @@ -0,0 +1,33 @@ +package com.muyu.product.domain.model; + +import com.muyu.common.core.web.domain.BaseEntity; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; + +import java.util.List; + +/** + * @author DongZl + * @description: 共有属性组 + * @Date 2024-3-6 下午 02:29 + */ +@Data +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class TemplateAttributeGroupModel extends BaseEntity { + + /** + * 组名称 + */ + private String groupName; + + /** + * 属性组下属性集合 + */ + private List attributeList; +} diff --git a/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/model/TemplateAttributeModel.java b/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/model/TemplateAttributeModel.java new file mode 100644 index 0000000..8cbeb02 --- /dev/null +++ b/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/model/TemplateAttributeModel.java @@ -0,0 +1,36 @@ +package com.muyu.product.domain.model; + +import com.muyu.common.core.web.domain.BaseEntity; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; + +/** + * @author DongZl + * @description: 共有属性 + * @Date 2024-3-6 下午 02:30 + */ +@Data +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class TemplateAttributeModel extends BaseEntity { + + /** + * 主键 + */ + private Long id; + + /** + * 属性名称 + */ + private String name; + + /** + * 编码 + */ + private String code; +} diff --git a/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/resp/CategoryCommonElementResp.java b/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/resp/CategoryCommonElementResp.java new file mode 100644 index 0000000..b69efda --- /dev/null +++ b/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/resp/CategoryCommonElementResp.java @@ -0,0 +1,39 @@ +package com.muyu.product.domain.resp; + +import com.muyu.common.core.web.domain.BaseEntity; +import com.muyu.product.domain.model.TemplateAttributeGroupModel; +import com.muyu.product.domain.model.TemplateAttributeModel; +import lombok.*; +import lombok.experimental.SuperBuilder; + +import java.util.List; + +/** + * @author DongZl + * @description: 商品类别公共元素 + * @Date 2024-3-6 下午 02:25 + */ +@Data +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class CategoryCommonElementResp extends BaseEntity { + + /** + * 共有属性组 + */ + private List templateAttributeGroupList; + + /** + * 共有属性 + */ + private List templateAttributeList; + + /** + * 自有属性(所有未包含属性) + */ + private List attributeList; + + +} diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/controller/BrandInfoController.java b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/controller/BrandInfoController.java index 80dac39..29d4305 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/controller/BrandInfoController.java +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/controller/BrandInfoController.java @@ -3,6 +3,7 @@ package com.muyu.product.controller; import java.util.List; import javax.servlet.http.HttpServletResponse; +import com.muyu.common.core.text.Convert; import io.swagger.annotations.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; @@ -45,10 +46,13 @@ public class BrandInfoController extends BaseController { @ApiOperation("获取品牌信息列表") @RequiresPermissions("product:brand:list") @GetMapping("/list") - public Result> list(BrandInfoQueryReq brandInfoQueryReq) { - startPage(); + public Result list(BrandInfoQueryReq brandInfoQueryReq) { + boolean isPage = brandInfoQueryReq.getParams().get("isPage") == null || Convert.toBool(brandInfoQueryReq.getParams().get("isPage"), true); + if (isPage){ + startPage(); + } List list = brandInfoService.list(BrandInfo.queryBuild(brandInfoQueryReq)); - return getDataTable(list); + return isPage ? getDataTable(list) : Result.success(list); } /** diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/controller/CategoryInfoController.java b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/controller/CategoryInfoController.java index 3bee271..55dbaef 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/controller/CategoryInfoController.java +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/controller/CategoryInfoController.java @@ -9,6 +9,7 @@ import com.muyu.product.domain.AttributeGroup; import com.muyu.product.domain.AttributeInfo; import com.muyu.product.domain.BrandInfo; import com.muyu.product.domain.model.CategoryInfoSaveModel; +import com.muyu.product.domain.resp.CategoryCommonElementResp; import com.muyu.product.domain.resp.CategoryParentCommonElementResp; import io.swagger.annotations.*; import org.springframework.beans.factory.annotation.Autowired; @@ -80,6 +81,17 @@ public class CategoryInfoController extends BaseController { return Result.success(categoryInfoService.getById(id)); } + /** + * 获取品类信息详细信息 + */ + @ApiOperation("获取品类信息共有属性信息") + @RequiresPermissions("product:category:query") + @GetMapping(value = "/getTemplateAttribute/{cateGoryId}") + @ApiImplicitParam(name = "cateGoryId", value = "cateGoryId", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class) + public Result getTemplateAttributeByCateGoryId(@PathVariable("cateGoryId") Long cateGoryId) { + return Result.success(categoryInfoService.getTemplateAttributeByCateGoryId(cateGoryId)); + } + /** * 新增品类信息 */ diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/controller/RuleInfoController.java b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/controller/RuleInfoController.java index b30039f..b6a9c73 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/controller/RuleInfoController.java +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/controller/RuleInfoController.java @@ -3,6 +3,7 @@ package com.muyu.product.controller; import java.util.List; import javax.servlet.http.HttpServletResponse; +import com.muyu.common.core.text.Convert; import com.muyu.product.domain.model.RuleInfoAddModel; import com.muyu.product.domain.resp.RuleInfoResp; import io.swagger.annotations.*; @@ -47,10 +48,13 @@ public class RuleInfoController extends BaseController { @ApiOperation("获取商品规格列表") @RequiresPermissions("product:rule:list") @GetMapping("/list") - public Result> list(RuleInfoQueryReq ruleInfoQueryReq) { - startPage(); + public Result list(RuleInfoQueryReq ruleInfoQueryReq) { + boolean isPage = ruleInfoQueryReq.getParams().get("isPage") == null || Convert.toBool(ruleInfoQueryReq.getParams().get("isPage"), true); + if (isPage){ + startPage(); + } TableDataInfo tableDataInfo = ruleInfoService.queryList(ruleInfoQueryReq); - return Result.success(tableDataInfo); + return isPage ? Result.success(tableDataInfo) : Result.success(tableDataInfo.getRows()); } /** diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/CategoryInfoService.java b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/CategoryInfoService.java index e24c0cb..f2661ae 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/CategoryInfoService.java +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/CategoryInfoService.java @@ -8,6 +8,7 @@ import com.muyu.product.domain.BrandInfo; import com.muyu.product.domain.CategoryInfo; import com.baomidou.mybatisplus.extension.service.IService; import com.muyu.product.domain.model.CategoryInfoSaveModel; +import com.muyu.product.domain.resp.CategoryCommonElementResp; import com.muyu.product.domain.resp.CategoryParentCommonElementResp; /** @@ -59,4 +60,11 @@ public interface CategoryInfoService extends IService { * @return 父级以上的属性、属性组、品牌集合 */ CategoryParentCommonElementResp parentCommonElement (Long categoryId); + + /** + * 通过品类ID获取品类共有属性 + * @param cateGoryId 品类ID + * @return 品类共有属性 + */ + CategoryCommonElementResp getTemplateAttributeByCateGoryId (Long cateGoryId); } diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/BrandInfoServiceImpl.java b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/BrandInfoServiceImpl.java index 5159f78..3c2f6c9 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/BrandInfoServiceImpl.java +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/BrandInfoServiceImpl.java @@ -35,7 +35,7 @@ public class BrandInfoServiceImpl extends ServiceImpl attributeGroupModelList = new ArrayList<>(); + + List templateAttributeModelList = new ArrayList<>(); + + List attributeModelList = new ArrayList<>(); + + + return CategoryCommonElementResp.builder() + .templateAttributeGroupList(attributeGroupModelList) + .templateAttributeList(templateAttributeModelList) + .attributeList(attributeModelList) + .build(); + } } diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/RuleInfoServiceImpl.java b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/RuleInfoServiceImpl.java index 38efbb0..3018b05 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/RuleInfoServiceImpl.java +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/RuleInfoServiceImpl.java @@ -8,6 +8,7 @@ import java.util.stream.Collectors; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; +import com.muyu.common.core.text.Convert; import com.muyu.common.core.utils.ObjUtils; import com.muyu.common.core.web.page.TableDataInfo; import com.muyu.common.security.utils.SecurityUtils; @@ -94,9 +95,11 @@ public class RuleInfoServiceImpl extends ServiceImpl return ruleAttrInfoService.list(queryWrapper).stream().map(RuleAttrAddModel::infoBuild).toList(); })) .toList(); + boolean isPage = ruleInfoQueryReq.getParams().get("isPage") == null || Convert.toBool(ruleInfoQueryReq.getParams().get("isPage"), true); + return TableDataInfo.builder() .rows(ruleInfoRespList) - .total(new PageInfo<>(list).getTotal()) + .total(isPage ? new PageInfo<>(list).getTotal() : 0) .build(); } }