From b063dfca726686c3b6c052334eda927ede88835b Mon Sep 17 00:00:00 2001 From: Saisai Liu <1374434128@qq.com> Date: Fri, 22 Mar 2024 21:08:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=93=81=E7=B1=BB=E7=BB=84=E4=BB=B6=E5=93=8D?= =?UTF-8?q?=E5=BA=94=EF=BC=8C=E5=B1=9E=E6=80=A7=E7=BB=84bug=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../muyu/product/domain/AttributeGroup.java | 1 - .../muyu/product/domain/BrandCategory.java | 15 ++- .../product/domain/CategoryAttribute.java | 4 +- .../domain/CategoryAttributeGroup.java | 4 +- .../com/muyu/product/domain/CategoryInfo.java | 5 +- .../com/muyu/product/domain/ProductInfo.java | 111 +----------------- .../com/muyu/product/domain/RuleProduct.java | 7 +- .../product/domain/model/AttrValueModel.java | 21 ++++ .../product/domain/model/ProductAddModel.java | 62 ++++++++++ .../product/domain/model/ProductSkuModel.java | 25 ++++ .../domain/req/ProductInfoSaveReq.java | 34 ++++++ .../domain/req/ProductSkuInfoEditReq.java | 30 +++++ .../controller/CategoryInfoController.java | 62 ++++------ .../product/service/ICategoryInfoService.java | 26 ++-- .../service/impl/CategoryInfoServiceImpl.java | 77 ++++++------ .../mapper/product/ProductInfoMapper.xml | 12 +- 16 files changed, 269 insertions(+), 227 deletions(-) create mode 100644 muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/model/AttrValueModel.java create mode 100644 muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/model/ProductAddModel.java create mode 100644 muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/model/ProductSkuModel.java create mode 100644 muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/req/ProductInfoSaveReq.java create mode 100644 muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/req/ProductSkuInfoEditReq.java diff --git a/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/AttributeGroup.java b/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/AttributeGroup.java index a910a89..889ca39 100644 --- a/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/AttributeGroup.java +++ b/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/AttributeGroup.java @@ -37,7 +37,6 @@ public class AttributeGroup extends BaseEntity @Excel(name = "组名") private String name; - private List attributeList; /** 状态 */ @Excel(name = "状态") diff --git a/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/BrandCategory.java b/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/BrandCategory.java index c5d5063..80a9d5e 100644 --- a/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/BrandCategory.java +++ b/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/BrandCategory.java @@ -2,7 +2,7 @@ package com.muyu.product.domain; import com.muyu.common.core.annotation.Excel; import com.muyu.common.core.web.domain.BaseEntity; -import com.muyu.product.domain.model.CategoryInfoSaveModel; +import com.muyu.product.domain.req.CategoryReq; import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; @@ -40,13 +40,13 @@ public class BrandCategory extends BaseEntity private Long brandId; - public static List saveBuilderList(CategoryInfoSaveModel categoryReq, Supplier getUsername) { + public static List saveBuilderList(CategoryReq categoryReq, Supplier getUsername) { return categoryReq.getCheckedBrandIds().stream().map( brandId -> BrandCategory.saveBuilder(categoryReq.getId(),brandId,getUsername) ).toList(); } - private static BrandCategory saveBuilder(Long categoryId, Long brandId, Supplier getUsername) { + public static BrandCategory saveBuilder(Long categoryId, Long brandId, Supplier getUsername) { return BrandCategory.builder() .brandId(brandId) .categoryId(categoryId) @@ -54,4 +54,13 @@ public class BrandCategory extends BaseEntity .createTime(new Date()) .build(); } + + public static BrandCategory saveBrandBuilder(Long id, Long brandId, Supplier username) { + return BrandCategory.builder() + .categoryId(id) + .brandId(brandId) + .createBy(username.get()) + .createTime(new Date()) + .build(); + } } diff --git a/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/CategoryAttribute.java b/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/CategoryAttribute.java index fc0df9d..45c7ca6 100644 --- a/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/CategoryAttribute.java +++ b/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/CategoryAttribute.java @@ -2,7 +2,7 @@ package com.muyu.product.domain; import com.muyu.common.core.annotation.Excel; import com.muyu.common.core.web.domain.BaseEntity; -import com.muyu.product.domain.model.CategoryInfoSaveModel; +import com.muyu.product.domain.req.CategoryReq; import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; @@ -48,7 +48,7 @@ public class CategoryAttribute extends BaseEntity .build(); } - public static List saveBuilder(CategoryInfoSaveModel categoryReq, Supplier username) { + public static List saveBuilder(CategoryReq categoryReq, Supplier username) { return categoryReq.getCheckedAttributeIds().stream().map( attributeId -> categoryBuilder(categoryReq.getId(),attributeId,username) ).toList(); diff --git a/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/CategoryAttributeGroup.java b/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/CategoryAttributeGroup.java index b05397d..47e00e6 100644 --- a/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/CategoryAttributeGroup.java +++ b/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/CategoryAttributeGroup.java @@ -2,7 +2,7 @@ package com.muyu.product.domain; import com.muyu.common.core.annotation.Excel; import com.muyu.common.core.web.domain.BaseEntity; -import com.muyu.product.domain.model.CategoryInfoSaveModel; +import com.muyu.product.domain.req.CategoryReq; import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; @@ -61,7 +61,7 @@ public class CategoryAttributeGroup extends BaseEntity { .build(); } - public static List saveBuilderList(CategoryInfoSaveModel categoryReq, Supplier username) { + public static List saveBuilderList(CategoryReq categoryReq, Supplier username) { return categoryReq.getCheckedAttributeGroupIds().stream().map( groupId -> saveBuilder(categoryReq.getId(), groupId, username) ).toList(); diff --git a/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/CategoryInfo.java b/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/CategoryInfo.java index ad1f984..2282242 100644 --- a/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/CategoryInfo.java +++ b/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/CategoryInfo.java @@ -2,7 +2,6 @@ package com.muyu.product.domain; import com.muyu.common.core.annotation.Excel; import com.muyu.common.core.web.domain.TreeEntity; -import com.muyu.product.domain.model.CategoryInfoSaveModel; import com.muyu.product.domain.req.CategoryReq; import lombok.AllArgsConstructor; import lombok.Data; @@ -57,7 +56,7 @@ public class CategoryInfo extends TreeEntity /** 响应值对象 */ - public static CategoryInfo saveCategoryBuilder(CategoryInfoSaveModel req){ + public static CategoryInfo saveCategoryBuilder(CategoryReq req){ return CategoryInfo.builder() .name(req.getName()) .status(req.getStatus()) @@ -69,7 +68,7 @@ public class CategoryInfo extends TreeEntity .build(); } - public static CategoryInfo saveBuilder(CategoryInfoSaveModel categoryReq) { + public static CategoryInfo saveBuilder(CategoryReq categoryReq) { return CategoryInfo.builder() .id(categoryReq.getId()) .name(categoryReq.getName()) diff --git a/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/ProductInfo.java b/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/ProductInfo.java index 83eb430..bac94f1 100644 --- a/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/ProductInfo.java +++ b/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/ProductInfo.java @@ -48,8 +48,8 @@ public class ProductInfo extends BaseEntity private String images; /** 发货地 */ - @Excel(name = "发货地") - private String addressSend; + @Excel(name = "轮播图") + private String slideshow; /** 商品状态 */ @Excel(name = "商品状态") @@ -64,112 +64,5 @@ public class ProductInfo extends BaseEntity /** 更新人 */ private String updatedBy; - public void setId(Long id) - { - this.id = id; - } - public Long getId() - { - return id; - } - public void setName(String name) - { - this.name = name; - } - - public String getName() - { - return name; - } - public void setIntroduction(String introduction) - { - this.introduction = introduction; - } - - public String getIntroduction() - { - return introduction; - } - public void setBrandId(Long brandId) - { - this.brandId = brandId; - } - - public Long getBrandId() - { - return brandId; - } - public void setImages(String images) - { - this.images = images; - } - - public String getImages() - { - return images; - } - public void setAddressSend(String addressSend) - { - this.addressSend = addressSend; - } - - public String getAddressSend() - { - return addressSend; - } - public void setStatus(String status) - { - this.status = status; - } - - public String getStatus() - { - return status; - } - public void setCreatedBy(String createdBy) - { - this.createdBy = createdBy; - } - - public String getCreatedBy() - { - return createdBy; - } - public void setCreatedTime(Date createdTime) - { - this.createdTime = createdTime; - } - - public Date getCreatedTime() - { - return createdTime; - } - public void setUpdatedBy(String updatedBy) - { - this.updatedBy = updatedBy; - } - - public String getUpdatedBy() - { - return updatedBy; - } - - @Override - public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("id", getId()) - .append("name", getName()) - .append("introduction", getIntroduction()) - .append("brandId", getBrandId()) - .append("images", getImages()) - .append("addressSend", getAddressSend()) - .append("status", getStatus()) - .append("remark", getRemark()) - .append("createdBy", getCreatedBy()) - .append("createdTime", getCreatedTime()) - .append("updatedBy", getUpdatedBy()) - .append("updateTime", getUpdateTime()) - .toString(); - } } diff --git a/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/RuleProduct.java b/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/RuleProduct.java index 2033d4e..2c66ada 100644 --- a/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/RuleProduct.java +++ b/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/RuleProduct.java @@ -11,6 +11,8 @@ import lombok.experimental.SuperBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; +import java.math.BigDecimal; + /** * 规格商品中间对象 rule_product * @@ -35,11 +37,12 @@ public class RuleProduct extends BaseEntity /** 规格编号 */ @Excel(name = "规格编号") - private Long ruleId; + private String sku; /** 规格值 */ @Excel(name = "规格值") private String ruleValue; - + private Integer stock; + private BigDecimal price; } diff --git a/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/model/AttrValueModel.java b/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/model/AttrValueModel.java new file mode 100644 index 0000000..139466f --- /dev/null +++ b/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/model/AttrValueModel.java @@ -0,0 +1,21 @@ +package com.muyu.product.domain.model; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @ClassName AttrValueModel + * @Description 描述 + * @Author SaiSai.Liu + * @Date 2024/3/22/0022 20:11 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AttrValueModel { + private Long id; + private String value; +} diff --git a/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/model/ProductAddModel.java b/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/model/ProductAddModel.java new file mode 100644 index 0000000..161fcdd --- /dev/null +++ b/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/model/ProductAddModel.java @@ -0,0 +1,62 @@ +package com.muyu.product.domain.model; + +import com.muyu.common.core.annotation.Excel; +import com.muyu.common.core.web.domain.BaseEntity; +import io.swagger.annotations.ApiModel; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; + +import java.util.Date; + +/** + * @ClassName ProductAddModel + * @Description 描述 + * @Author SaiSai.Liu + * @Date 2024/3/22/0022 20:22 + */ + +@Data +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor +@ApiModel(value = "ProjectInfoSaveReq", description = "商品信息") +public class ProductAddModel extends BaseEntity { + /** 主键 */ + private Long id; + + /** 商品名 */ + @Excel(name = "商品名") + private String name; + + /** 商品信息 */ + @Excel(name = "商品信息") + private String introduction; + + /** 品牌编号 */ + @Excel(name = "品牌编号") + private Long brandId; + + /** 图片 */ + @Excel(name = "图片") + private String images; + + /** 发货地 */ + @Excel(name = "轮播图") + private String slideshow; + + /** 商品状态 */ + @Excel(name = "商品状态") + private String status; + + /** 创建人 */ + private String createdBy; + + /** 创建时间 */ + private Date createdTime; + + /** 更新人 */ + private String updatedBy; + +} diff --git a/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/model/ProductSkuModel.java b/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/model/ProductSkuModel.java new file mode 100644 index 0000000..dae1769 --- /dev/null +++ b/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/model/ProductSkuModel.java @@ -0,0 +1,25 @@ +package com.muyu.product.domain.model; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; + +/** + * @ClassName ProductSkuModel + * @Description 描述 + * @Author SaiSai.Liu + * @Date 2024/3/22/0022 20:12 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ProductSkuModel { + private String sku; + private Long stock; + private BigDecimal price; + private String image; +} diff --git a/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/req/ProductInfoSaveReq.java b/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/req/ProductInfoSaveReq.java new file mode 100644 index 0000000..ca4bbce --- /dev/null +++ b/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/req/ProductInfoSaveReq.java @@ -0,0 +1,34 @@ +package com.muyu.product.domain.req; + +import com.muyu.common.core.web.domain.BaseEntity; +import com.muyu.product.domain.model.AttrValueModel; +import com.muyu.product.domain.model.ProductAddModel; +import com.muyu.product.domain.model.ProductSkuModel; +import io.swagger.annotations.ApiModel; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; + +import java.util.List; + +/** + * @ClassName ProductInfoSaveReq + * @Description 描述 + * @Author SaiSai.Liu + * @Date 2024/3/22/0022 20:17 + */ +@Data +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor +@ApiModel(value = "ProjectInfoSaveReq", description = "商品信息") +public class ProductInfoSaveReq extends BaseEntity { + private static final long serialVersionUID = 1L; + + private ProductAddModel productAddModel; + + private List attrValueList; + + private List productList; +} diff --git a/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/req/ProductSkuInfoEditReq.java b/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/req/ProductSkuInfoEditReq.java new file mode 100644 index 0000000..8fa0ac6 --- /dev/null +++ b/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/req/ProductSkuInfoEditReq.java @@ -0,0 +1,30 @@ +package com.muyu.product.domain.req; + +import com.muyu.common.core.web.domain.BaseEntity; +import io.swagger.annotations.ApiModel; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; + +import java.math.BigDecimal; + +/** + * @ClassName ProductSkuInfoEditReq + * @Description 描述 + * @Author SaiSai.Liu + * @Date 2024/3/22/0022 19:52 + */ +@Data +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor +@ApiModel(value = "ProjectSkuInfoEditReq", description = "商品SKU") +public class ProductSkuInfoEditReq extends BaseEntity { + private static final long serialVersionUID = 1L; + private Long projectId; + private String sku; + private Long stock; + private BigDecimal price; + private String image; +} 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 9aa950f..0b2fd23 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 @@ -1,30 +1,19 @@ package com.muyu.product.controller; -import java.util.List; -import java.io.IOException; -import javax.servlet.http.HttpServletResponse; - -import com.muyu.common.security.utils.SecurityUtils; -import com.muyu.product.domain.model.CategoryInfoSaveModel; -import com.muyu.product.domain.req.CategoryReq; -import com.muyu.product.domain.resp.CategoryResp; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import com.muyu.common.core.domain.Result; +import com.muyu.common.core.utils.poi.ExcelUtil; +import com.muyu.common.core.web.controller.BaseController; import com.muyu.common.log.annotation.Log; import com.muyu.common.log.enums.BusinessType; import com.muyu.common.security.annotation.RequiresPermissions; -import com.muyu.product.domain.CategoryInfo; +import com.muyu.product.domain.req.CategoryReq; +import com.muyu.product.domain.resp.CategoryResp; import com.muyu.product.service.ICategoryInfoService; -import com.muyu.common.core.web.controller.BaseController; -import com.muyu.common.core.domain.Result; -import com.muyu.common.core.utils.poi.ExcelUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; /** * 品类信息Controller @@ -34,8 +23,7 @@ import com.muyu.common.core.utils.poi.ExcelUtil; */ @RestController @RequestMapping("/category_info") -public class CategoryInfoController extends BaseController -{ +public class CategoryInfoController extends BaseController { @Autowired private ICategoryInfoService categoryInfoService; @@ -44,9 +32,8 @@ public class CategoryInfoController extends BaseController */ @RequiresPermissions("product:category_info:list") @GetMapping("/list") - public Result list(CategoryInfoSaveModel categoryInfoSaveModel) - { - List list = categoryInfoService.selectCategoryInfoList(categoryInfoSaveModel); + public Result list(CategoryReq categoryReq) { + List list = categoryInfoService.selectCategoryInfoList(categoryReq); return success(list); } @@ -56,9 +43,8 @@ public class CategoryInfoController extends BaseController @RequiresPermissions("product:category_info:export") @Log(title = "品类信息", businessType = BusinessType.EXPORT) @PostMapping("/export") - public void export(HttpServletResponse response, CategoryInfoSaveModel categoryInfoSaveModel) - { - List list = categoryInfoService.selectCategoryInfoList(categoryInfoSaveModel); + public void export(HttpServletResponse response, CategoryReq categoryReq) { + List list = categoryInfoService.selectCategoryInfoList(categoryReq); ExcelUtil util = new ExcelUtil(CategoryResp.class); util.exportExcel(response, list, "品类信息数据"); } @@ -68,8 +54,7 @@ public class CategoryInfoController extends BaseController */ @RequiresPermissions("product:category_info:query") @GetMapping(value = "/{id}") - public Result getInfo(@PathVariable("id") Long id) - { + public Result getInfo(@PathVariable("id") Long id) { return success(categoryInfoService.selectCategoryInfoById(id)); } @@ -79,9 +64,8 @@ public class CategoryInfoController extends BaseController @RequiresPermissions("product:category_info:add") @Log(title = "品类信息", businessType = BusinessType.INSERT) @PostMapping - public Result add(@RequestBody CategoryReq categoryReq) - { - return toAjax(categoryInfoService.save(CategoryInfoSaveModel.saveBuilder(categoryReq, SecurityUtils::getUsername ))); + public Result add(@RequestBody CategoryReq categoryReq) { + return toAjax(categoryInfoService.save(categoryReq)); } /** @@ -90,9 +74,8 @@ public class CategoryInfoController extends BaseController @RequiresPermissions("product:category_info:edit") @Log(title = "品类信息", businessType = BusinessType.UPDATE) @PutMapping - public Result edit(@RequestBody CategoryInfoSaveModel categoryInfoSaveModel) - { - return toAjax(categoryInfoService.updateCategoryInfo(categoryInfoSaveModel)); + public Result edit(@RequestBody CategoryReq categoryReq) { + return toAjax(categoryInfoService.updateCategoryInfo(categoryReq)); } /** @@ -100,9 +83,8 @@ public class CategoryInfoController extends BaseController */ @RequiresPermissions("product:category_info:remove") @Log(title = "品类信息", businessType = BusinessType.DELETE) - @DeleteMapping("/{ids}") - public Result remove(@PathVariable Long[] ids) - { + @DeleteMapping("/{ids}") + public Result remove(@PathVariable Long[] ids) { return toAjax(categoryInfoService.deleteCategoryInfoByIds(ids)); } } diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/ICategoryInfoService.java b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/ICategoryInfoService.java index 84f2c9d..ae53df1 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/ICategoryInfoService.java +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/ICategoryInfoService.java @@ -1,22 +1,19 @@ package com.muyu.product.service; -import java.util.List; - import com.baomidou.mybatisplus.extension.service.IService; -import com.muyu.product.domain.Address; import com.muyu.product.domain.CategoryInfo; -import com.muyu.product.domain.model.CategoryInfoSaveModel; import com.muyu.product.domain.req.CategoryReq; import com.muyu.product.domain.resp.CategoryResp; +import java.util.List; + /** * 品类信息Service接口 * * @author Saisai * @date 2024-02-29 */ -public interface ICategoryInfoService extends IService -{ +public interface ICategoryInfoService extends IService { /** * 查询品类信息 * @@ -28,26 +25,19 @@ public interface ICategoryInfoService extends IService /** * 查询品类信息列表 * - * @param categoryInfoSaveModel 品类信息 + * @param categoryReq 品类信息 * @return 品类信息集合 */ - List selectCategoryInfoList(CategoryInfoSaveModel categoryInfoSaveModel); + List selectCategoryInfoList(CategoryReq categoryReq); - /** - * 新增品类信息 - * - * @param categoryInfoSaveModel 品类信息 - * @return 结果 - */ - int insertCategoryInfo(CategoryInfoSaveModel categoryInfoSaveModel); /** * 修改品类信息 * - * @param categoryInfoSaveModel 品类信息 + * @param categoryReq 品类信息 * @return 结果 */ - boolean updateCategoryInfo(CategoryInfoSaveModel categoryInfoSaveModel); + boolean updateCategoryInfo(CategoryReq categoryReq); /** * 批量删除品类信息 @@ -65,5 +55,5 @@ public interface ICategoryInfoService extends IService */ int deleteCategoryInfoById(Long id); - boolean save(CategoryInfoSaveModel categoryInfoSaveModel); + boolean save(CategoryReq categoryReq); } diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/CategoryInfoServiceImpl.java b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/CategoryInfoServiceImpl.java index 19d3f4b..1115f32 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/CategoryInfoServiceImpl.java +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/CategoryInfoServiceImpl.java @@ -3,8 +3,12 @@ package com.muyu.product.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.muyu.common.security.utils.SecurityUtils; -import com.muyu.product.domain.*; +import com.muyu.product.domain.BrandCategory; +import com.muyu.product.domain.CategoryAttribute; +import com.muyu.product.domain.CategoryAttributeGroup; +import com.muyu.product.domain.CategoryInfo; import com.muyu.product.domain.model.CategoryInfoSaveModel; +import com.muyu.product.domain.req.CategoryReq; import com.muyu.product.domain.resp.CategoryResp; import com.muyu.product.mapper.CategoryInfoMapper; import com.muyu.product.service.*; @@ -53,19 +57,19 @@ public class CategoryInfoServiceImpl extends ServiceImpl selectCategoryInfoList(CategoryInfoSaveModel categoryInfoSaveModel) { + public List selectCategoryInfoList(CategoryReq categoryReq) { //三大响应结果集 -// List categoryAttributes = CategoryAttribute.saveBuilder(categoryInfoSaveModel, SecurityUtils::getUsername); -// List categoryAttributeGroups = CategoryAttributeGroup.saveBuilderList(categoryInfoSaveModel, SecurityUtils::getUsername); -// List brandCategories = BrandCategory.saveBuilderList(categoryInfoSaveModel, SecurityUtils::getUsername); +// List categoryAttributes = CategoryAttribute.saveBuilder(categoryReq, SecurityUtils::getUsername); +// List categoryAttributeGroups = CategoryAttributeGroup.saveBuilderList(categoryReq, SecurityUtils::getUsername); +// List brandCategories = BrandCategory.saveBuilderList(categoryReq, SecurityUtils::getUsername); // List categoryInfos = null; - List list = categoryInfoMapper.selectCategoryInfoList(CategoryInfo.saveBuilder(categoryInfoSaveModel)).stream().map(categoryInfo -> { + List list = categoryInfoMapper.selectCategoryInfoList(CategoryInfo.saveBuilder(categoryReq)).stream().map(categoryInfo -> { CategoryInfoSaveModel infoSaveModel = new CategoryInfoSaveModel(); infoSaveModel.setId(categoryInfo.getId()); List attrIds = categoryAttributeService.list(new LambdaQueryWrapper().eq(CategoryAttribute::getCategoryId, categoryInfo.getId())).stream().map(CategoryAttribute::getAttributeId).toList(); @@ -87,59 +91,43 @@ public class CategoryInfoServiceImpl extends ServiceImpl().eq(CategoryInfo::getId, categoryInfo.getId())); -// LambdaQueryWrapper attributeWrapper = new LambdaQueryWrapper().eq(CategoryAttribute::getCategoryId,categoryInfoSaveModel.getId()); + public boolean updateCategoryInfo(CategoryReq categoryReq) { + CategoryInfo categoryInfo = CategoryInfo.saveBuilder(categoryReq); +// boolean updated = this.update(new LambdaQueryWrapper().eq(CategoryInfo::getId, categoryInfo.getId())); + boolean b = this.updateById(categoryInfo); +// LambdaQueryWrapper attributeWrapper = new LambdaQueryWrapper().eq(CategoryAttribute::getCategoryId,categoryReq.getId()); //删除中间表数据 categoryAttributeService.remove(new LambdaQueryWrapper() - .eq(CategoryAttribute::getCategoryId, categoryInfoSaveModel.getId()) + .eq(CategoryAttribute::getCategoryId, categoryReq.getId()) ); //添加新数据 - categoryAttributeService.saveBatch(CategoryAttribute.saveBuilder(categoryInfoSaveModel, SecurityUtils::getUsername)); + categoryAttributeService.saveBatch(CategoryAttribute.saveBuilder(categoryReq, SecurityUtils::getUsername)); //修改属性组中间表 // LambdaQueryWrapper groupWrapper = new LambdaQueryWrapper(); categoryAttributeGroupService.remove(new LambdaQueryWrapper() - .eq(CategoryAttributeGroup::getCategoryId, categoryInfoSaveModel.getId()) + .eq(CategoryAttributeGroup::getCategoryId, categoryReq.getId()) ); categoryAttributeGroupService.saveBatch( - CategoryAttributeGroup.saveBuilderList(categoryInfoSaveModel, SecurityUtils::getUsername) + CategoryAttributeGroup.saveBuilderList(categoryReq, SecurityUtils::getUsername) ); // LambdaQueryWrapper brandWrapper = new LambdaQueryWrapper(); brandCategoryService.remove( new LambdaQueryWrapper() - .eq(BrandCategory::getCategoryId, categoryInfoSaveModel.getId()) + .eq(BrandCategory::getCategoryId, categoryReq.getId()) ); brandCategoryService.saveBatch( - BrandCategory.saveBuilderList(categoryInfoSaveModel, SecurityUtils::getUsername) + BrandCategory.saveBuilderList(categoryReq, SecurityUtils::getUsername) ); - return updated; + return b; } /** @@ -170,19 +158,19 @@ public class CategoryInfoServiceImpl extends ServiceImpl checkedAttributeIds = categoryInfoSaveModel.getCheckedAttributeIds(); + List checkedAttributeIds = categoryReq.getCheckedAttributeIds(); //判断已选属性集是否为空 if (checkedAttributeIds != null && !checkedAttributeIds.isEmpty()) { categoryAttributeService.saveBatch( @@ -190,13 +178,20 @@ public class CategoryInfoServiceImpl extends ServiceImpl CategoryAttribute.categoryBuilder(id, attributeId, SecurityUtils::getUsername)).toList() ); } - List attributeGroupIds = categoryInfoSaveModel.getCheckedAttributeGroupIds(); + List attributeGroupIds = categoryReq.getCheckedAttributeGroupIds(); if (attributeGroupIds != null && !attributeGroupIds.isEmpty()) { categoryAttributeGroupService.saveBatch( attributeGroupIds.stream(). map(groupId -> CategoryAttributeGroup.saveBuilder(id, groupId, SecurityUtils::getUsername)).toList() ); } + List brandIds = categoryReq.getCheckedBrandIds(); + if (brandIds != null && !brandIds.isEmpty()) { + brandCategoryService.saveBatch( + brandIds.stream(). + map(brandId -> BrandCategory.saveBrandBuilder(id, brandId, SecurityUtils::getUsername)).toList() + ); + } return save; } } diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/resources/mapper/product/ProductInfoMapper.xml b/muyu-modules/muyu-product/muyu-product-server/src/main/resources/mapper/product/ProductInfoMapper.xml index 97686d0..a6bb35f 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/resources/mapper/product/ProductInfoMapper.xml +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/resources/mapper/product/ProductInfoMapper.xml @@ -10,7 +10,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + @@ -20,7 +20,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select id, name, introduction, brand_id, images, address_send, status, remark, created_by, created_time, updated_by, update_time from product_info + select id, name, introduction, brand_id, images, slideshow, status, remark, created_by, created_time, updated_by, update_time from product_info @@ -47,7 +47,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" introduction, brand_id, images, - address_send, + slideshow, status, remark, created_by, @@ -60,7 +60,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{introduction}, #{brandId}, #{images}, - #{addressSend}, + #{slideshow}, #{status}, #{remark}, #{createdBy}, @@ -77,7 +77,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" introduction = #{introduction}, brand_id = #{brandId}, images = #{images}, - address_send = #{addressSend}, + slideshow = #{slideshow}, status = #{status}, remark = #{remark}, created_by = #{createdBy},