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 918b02c..7336550 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 @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.muyu.product.domain.model.CategoryInfoSaveModel; +import com.muyu.product.domain.req.CategoryInfoUpdReq; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; @@ -13,11 +14,9 @@ import io.swagger.annotations.*; import com.muyu.common.core.annotation.Excel; import com.muyu.product.domain.req.CategoryInfoQueryReq; import com.muyu.product.domain.req.CategoryInfoSaveReq; -import com.muyu.product.domain.req.CategoryInfoEditReq; import com.muyu.common.core.web.domain.TreeEntity; import java.util.Date; -import java.util.function.Function; import java.util.function.Supplier; /** @@ -92,7 +91,7 @@ public class CategoryInfo extends TreeEntity { /** * 修改构造器 */ - public static CategoryInfo editBuild(Long id, CategoryInfoEditReq categoryInfoEditReq){ + public static CategoryInfo editBuild(Long id, CategoryInfoUpdReq categoryInfoEditReq){ return CategoryInfo.builder() .id(id) .name(categoryInfoEditReq.getName()) diff --git a/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/RuleInfo.java b/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/RuleInfo.java index 454cbad..0c89541 100644 --- a/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/RuleInfo.java +++ b/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/RuleInfo.java @@ -50,6 +50,9 @@ public class RuleInfo extends BaseEntity { @Excel(name = "规格状态") @ApiModelProperty(name = "规格状态", value = "规格状态") private String status; + @Excel(name = "规格详情") + @ApiModelProperty(name = "规格详情", value = "规格详情") + private String remark; /** * 查询构造器 diff --git a/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/req/AttributeUpdReq.java b/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/req/AttributeUpdReq.java new file mode 100644 index 0000000..a0bd959 --- /dev/null +++ b/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/req/AttributeUpdReq.java @@ -0,0 +1,22 @@ +package com.muyu.product.domain.req; +import com.muyu.product.domain.AttributeInfo; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import java.util.List; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class AttributeUpdReq { + /** 组名称 */ + private String name; + + /** 状态 */ + private String states; + + /**修改属性的信息**/ + private List attributeList; +} diff --git a/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/req/CategoryInfoUpdReq.java b/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/req/CategoryInfoUpdReq.java new file mode 100644 index 0000000..ebdec15 --- /dev/null +++ b/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/req/CategoryInfoUpdReq.java @@ -0,0 +1,38 @@ +package com.muyu.product.domain.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class CategoryInfoUpdReq { + /** 品类名称 */ + @ApiModelProperty(name = "品类名称", value = "品类名称", required = true) + private String name; + + /** 图片 */ + @ApiModelProperty(name = "图片", value = "图片", required = true) + private String image; + + /** 是否启用 */ + @ApiModelProperty(name = "是否启用", value = "是否启用", required = true) + private String start; + + /** 介绍 */ + @ApiModelProperty(name = "介绍", value = "介绍") + private String introduction; + /**商品属性组关联ID**/ + private List attributeGroupIdList; + /**商品属性关联ID**/ + private List attributeIdList; + /**商品品牌组关联ID**/ + private List brandGroupIdList; + +} diff --git a/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/req/RuleInfoEditReq.java b/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/req/RuleInfoEditReq.java index bc9d602..2a888ea 100644 --- a/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/req/RuleInfoEditReq.java +++ b/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/req/RuleInfoEditReq.java @@ -1,5 +1,7 @@ package com.muyu.product.domain.req; +import com.muyu.common.core.annotation.Excel; +import com.muyu.product.domain.model.RuleAttrAddModel; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; @@ -8,6 +10,8 @@ import lombok.experimental.SuperBuilder; import io.swagger.annotations.*; import com.muyu.common.core.web.domain.BaseEntity; +import java.util.List; + /** * 商品规格对象 rule_info * @@ -30,5 +34,12 @@ public class RuleInfoEditReq extends BaseEntity { /** 规格状态 */ @ApiModelProperty(name = "规格状态", value = "规格状态") private String status; + @Excel(name = "规格详情") + @ApiModelProperty(name = "规格详情", value = "规格详情") + private String remark; + /** + * 规格属性集合 + */ + private List ruleAttrList; } diff --git a/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/req/RuleInfoUpdReq.java b/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/req/RuleInfoUpdReq.java new file mode 100644 index 0000000..3fda33b --- /dev/null +++ b/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/req/RuleInfoUpdReq.java @@ -0,0 +1,33 @@ +package com.muyu.product.domain.req; + +import com.muyu.product.domain.RuleAttrInfo; +import com.muyu.product.domain.model.RuleAttrAddModel; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class RuleInfoUpdReq { + /** + * 规则名称 + */ + private String name; + /** + * 规格备注 + */ + private String states; + /** + * 规格备注 + */ + private String remark; + /** + * 规格属性集合 + */ + private List ruleAttrList; +} diff --git a/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/resp/AttributeGroupUpdResp.java b/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/resp/AttributeGroupUpdResp.java new file mode 100644 index 0000000..7237e1e --- /dev/null +++ b/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/resp/AttributeGroupUpdResp.java @@ -0,0 +1,41 @@ +package com.muyu.product.domain.resp; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.muyu.common.core.annotation.Excel; +import com.muyu.product.domain.AttributeInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 修改回显详细信息 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class AttributeGroupUpdResp { + /** 属性组编号 */ + @TableId(value = "id",type = IdType.AUTO) + @ApiModelProperty(name = "属性组编号", value = "属性组编号") + private Long id; + + /** 组名称 */ + @Excel(name = "组名称") + @ApiModelProperty(name = "组名称", value = "组名称", required = true) + private String name; + + /** 状态 */ + @Excel(name = "状态") + @ApiModelProperty(name = "状态", value = "状态", required = true) + private String states; + + /**属性id集合**/ + private List attributeList; + +} diff --git a/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/resp/RuleInfoUpdResp.java b/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/resp/RuleInfoUpdResp.java new file mode 100644 index 0000000..2592667 --- /dev/null +++ b/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/resp/RuleInfoUpdResp.java @@ -0,0 +1,35 @@ +package com.muyu.product.domain.resp; + +import com.muyu.product.domain.model.RuleAttrAddModel; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import java.util.List; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class RuleInfoUpdResp { + /** + *规则id + */ + private Long id; + /** + * 规则名称 + */ + private String name; + /** + * 规格备注 + */ + private String states; + /** + * 规格备注 + */ + private String remark; + /** + * 规格属性集合 + */ + private List ruleAttrList; +} diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/controller/AttributeGroupController.java b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/controller/AttributeGroupController.java index bd489a0..e094e78 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/controller/AttributeGroupController.java +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/controller/AttributeGroupController.java @@ -4,7 +4,9 @@ import java.util.List; import javax.servlet.http.HttpServletResponse; import com.muyu.product.domain.model.AttributeGroupSaveModel; +import com.muyu.product.domain.req.AttributeUpdReq; import com.muyu.product.domain.resp.AttributeGroupPageResp; +import com.muyu.product.domain.resp.AttributeGroupUpdResp; import io.swagger.annotations.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; @@ -74,8 +76,8 @@ public class AttributeGroupController extends BaseController { @RequiresPermissions("product:attributeGroup:query") @GetMapping(value = "/{id}") @ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class) - public Result getInfo(@PathVariable("id") Long id) { - return Result.success(attributeGroupService.getById(id)); + public Result getInfo(@PathVariable("id") Long id) { + return Result.success(attributeGroupService.getUpdById(id)); } /** @@ -98,8 +100,8 @@ public class AttributeGroupController extends BaseController { @Log(title = "属性组", businessType = BusinessType.UPDATE) @PutMapping("/{id}") @ApiOperation("修改属性组") - public Result edit(@PathVariable Long id, @RequestBody AttributeGroupEditReq attributeGroupEditReq) { - return toAjax(attributeGroupService.updateById(AttributeGroup.editBuild(id,attributeGroupEditReq))); + public Result edit(@PathVariable Long id, @RequestBody AttributeUpdReq attributeUpdReq) { + return toAjax(attributeGroupService.updateByattr(id,attributeUpdReq)); } /** 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 55dbaef..75794fa 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.req.CategoryInfoUpdReq; import com.muyu.product.domain.resp.CategoryCommonElementResp; import com.muyu.product.domain.resp.CategoryParentCommonElementResp; import io.swagger.annotations.*; @@ -112,8 +113,8 @@ public class CategoryInfoController extends BaseController { @Log(title = "品类信息", businessType = BusinessType.UPDATE) @PutMapping("/{id}") @ApiOperation("修改品类信息") - public Result edit(@PathVariable Long id, @RequestBody CategoryInfoEditReq categoryInfoEditReq) { - return toAjax(categoryInfoService.updateById(CategoryInfo.editBuild(id,categoryInfoEditReq))); + public Result edit(@PathVariable Long id, @RequestBody CategoryInfoUpdReq categoryInfoUpdReq) { + return toAjax(categoryInfoService.updateById(id,categoryInfoUpdReq)); } /** @@ -124,8 +125,9 @@ public class CategoryInfoController extends BaseController { @DeleteMapping("/{ids}") @ApiOperation("删除品类信息") @ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = String.class, example = "1,2,3,4") - public Result remove(@PathVariable List ids) { - return toAjax(categoryInfoService.removeBatchByIds(ids)); + public Result remove(@PathVariable Long ids) { + Result i = categoryInfoService.removeBatchById(ids); + return i; } /** 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 b6a9c73..2979bf4 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 @@ -6,6 +6,7 @@ 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 com.muyu.product.domain.resp.RuleInfoUpdResp; import io.swagger.annotations.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; @@ -77,8 +78,8 @@ public class RuleInfoController extends BaseController { @RequiresPermissions("product:rule:query") @GetMapping(value = "/{id}") @ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class) - public Result getInfo(@PathVariable("id") Long id) { - return Result.success(ruleInfoService.getById(id)); + public Result getInfo(@PathVariable("id") Long id) { + return Result.success(ruleInfoService.selectById(id)); } /** @@ -100,7 +101,9 @@ public class RuleInfoController extends BaseController { @PutMapping("/{id}") @ApiOperation("修改商品规格") public Result edit(@PathVariable Long id, @RequestBody RuleInfoEditReq ruleInfoEditReq) { - return toAjax(ruleInfoService.updateById(RuleInfo.editBuild(id,ruleInfoEditReq))); +// return toAjax(ruleInfoService.updateById(RuleInfo.editBuild(id,ruleInfoEditReq))); + boolean result = ruleInfoService.updateById(id, ruleInfoEditReq); + return result ? Result.success() : Result.error(); } /** diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/mapper/AsAttributeGroupMapper.java b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/mapper/AsAttributeGroupMapper.java index 1b420df..76c1afd 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/mapper/AsAttributeGroupMapper.java +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/mapper/AsAttributeGroupMapper.java @@ -3,6 +3,7 @@ package com.muyu.product.mapper; import java.util.List; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.muyu.product.domain.AsAttributeGroup; +import org.apache.ibatis.annotations.Param; /** * 属性与组中间Mapper接口 @@ -12,4 +13,9 @@ import com.muyu.product.domain.AsAttributeGroup; */ public interface AsAttributeGroupMapper extends BaseMapper { + void deleteAsAttributeGroup(Long id); + + void updateAttributeById(@Param("id") Long id, @Param("name") String name, @Param("states") String states); + + void addByGroup(@Param("id") Long id, @Param("id1") Long id1); } diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/mapper/AsCategoryAttributeGroupMapper.java b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/mapper/AsCategoryAttributeGroupMapper.java index b09e788..c51f896 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/mapper/AsCategoryAttributeGroupMapper.java +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/mapper/AsCategoryAttributeGroupMapper.java @@ -12,4 +12,5 @@ import com.muyu.product.domain.AsCategoryAttributeGroup; */ public interface AsCategoryAttributeGroupMapper extends BaseMapper { + void add(Long attributeGroupId, Long id); } diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/mapper/AsCategoryAttributeMapper.java b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/mapper/AsCategoryAttributeMapper.java index 66c2e87..c23bb57 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/mapper/AsCategoryAttributeMapper.java +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/mapper/AsCategoryAttributeMapper.java @@ -3,6 +3,7 @@ package com.muyu.product.mapper; import java.util.List; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.muyu.product.domain.AsCategoryAttribute; +import org.apache.ibatis.annotations.Param; /** * 品类属性中间Mapper接口 @@ -12,4 +13,5 @@ import com.muyu.product.domain.AsCategoryAttribute; */ public interface AsCategoryAttributeMapper extends BaseMapper { + void add(@Param("attributeId") Long attributeId, @Param("id") Long id); } diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/mapper/AsCategoryBrandMapper.java b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/mapper/AsCategoryBrandMapper.java index 3e8c164..bd07e0b 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/mapper/AsCategoryBrandMapper.java +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/mapper/AsCategoryBrandMapper.java @@ -12,4 +12,5 @@ import com.muyu.product.domain.AsCategoryBrand; */ public interface AsCategoryBrandMapper extends BaseMapper { + void add(Long brandGroupId, Long id); } diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/mapper/CategoryInfoMapper.java b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/mapper/CategoryInfoMapper.java index 6ed8f75..84dc9b5 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/mapper/CategoryInfoMapper.java +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/mapper/CategoryInfoMapper.java @@ -1,8 +1,12 @@ package com.muyu.product.mapper; -import java.util.List; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.muyu.product.domain.CategoryInfo; +import com.muyu.product.domain.ProjectInfo; +import com.muyu.product.domain.req.CategoryInfoUpdReq; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * 品类信息Mapper接口 @@ -12,4 +16,7 @@ import com.muyu.product.domain.CategoryInfo; */ public interface CategoryInfoMapper extends BaseMapper { + Boolean updateById(@Param("id") Long id, @Param("categoryInfoUpdReq") CategoryInfoUpdReq categoryInfoUpdReq); + + List selectProjectInfoById(@Param("id") Long id); } diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/AsAttributeGroupService.java b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/AsAttributeGroupService.java index db672c4..b1d17c7 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/AsAttributeGroupService.java +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/AsAttributeGroupService.java @@ -3,6 +3,7 @@ package com.muyu.product.service; import java.util.List; import com.muyu.product.domain.AsAttributeGroup; import com.baomidou.mybatisplus.extension.service.IService; +import io.lettuce.core.dynamic.annotation.Param; /** * 属性与组中间Service接口 @@ -19,4 +20,6 @@ public interface AsAttributeGroupService extends IService { */ public List list(AsAttributeGroup asAttributeGroup); + void addByGroup(@Param("id") Long id, @Param("id1") Long id1); + } diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/AsCategoryAttributeGroupService.java b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/AsCategoryAttributeGroupService.java index fb3b15f..b0bc4a9 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/AsCategoryAttributeGroupService.java +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/AsCategoryAttributeGroupService.java @@ -19,4 +19,5 @@ public interface AsCategoryAttributeGroupService extends IService list(AsCategoryAttributeGroup asCategoryAttributeGroup); + void addByGroup(Long attributeGroupId, Long id); } diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/AsCategoryAttributeService.java b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/AsCategoryAttributeService.java index 365d74b..33e7d7f 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/AsCategoryAttributeService.java +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/AsCategoryAttributeService.java @@ -3,6 +3,7 @@ package com.muyu.product.service; import java.util.List; import com.muyu.product.domain.AsCategoryAttribute; import com.baomidou.mybatisplus.extension.service.IService; +import org.apache.ibatis.annotations.Param; /** * 品类属性中间Service接口 @@ -19,4 +20,5 @@ public interface AsCategoryAttributeService extends IService list(AsCategoryAttribute asCategoryAttribute); + void addByGroup(@Param("attributeId") Long attributeId, @Param("id") Long id); } diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/AsCategoryBrandService.java b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/AsCategoryBrandService.java index a1ccaa9..19d8db5 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/AsCategoryBrandService.java +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/AsCategoryBrandService.java @@ -19,4 +19,5 @@ public interface AsCategoryBrandService extends IService { */ public List list(AsCategoryBrand asCategoryBrand); + void addByGroup(Long brandGroupId, Long id); } diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/AttributeGroupService.java b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/AttributeGroupService.java index 9527f88..0670458 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/AttributeGroupService.java +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/AttributeGroupService.java @@ -5,25 +5,21 @@ import java.util.List; import com.muyu.common.core.web.page.TableDataInfo; import com.muyu.product.domain.AttributeGroup; import com.baomidou.mybatisplus.extension.service.IService; -import com.muyu.product.domain.AttributeInfo; import com.muyu.product.domain.model.AttributeGroupSaveModel; +import com.muyu.product.domain.req.AttributeUpdReq; import com.muyu.product.domain.resp.AttributeGroupPageResp; +import com.muyu.product.domain.resp.AttributeGroupUpdResp; /** * 属性组Service接口 - * - * @author DongZeLiang - * @date 2024-02-27 */ public interface AttributeGroupService extends IService { - /** * 分页查询 * @param attributeGroup 分组对象 * @return 返回结果 */ public TableDataInfo page(AttributeGroup attributeGroup); - /** * 查询属性组列表 * @@ -31,12 +27,18 @@ public interface AttributeGroupService extends IService { * @return 属性组集合 */ public List list(AttributeGroup attributeGroup); - /** * 保存 * @param attributeGroupSaveModel 属性组保存模型 * @return 是否成功 */ public Boolean save(AttributeGroupSaveModel attributeGroupSaveModel); - + /** + * 根据id查询属性组的详情 + */ + AttributeGroupUpdResp getUpdById(Long id); + /** + * 修改属性 + */ + boolean updateByattr(Long id, AttributeUpdReq attributeUpdReq); } 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 9b99d9d..4f35107 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 @@ -2,12 +2,14 @@ package com.muyu.product.service; import java.util.List; +import com.muyu.common.core.domain.Result; import com.muyu.product.domain.AttributeGroup; import com.muyu.product.domain.AttributeInfo; 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.req.CategoryInfoUpdReq; import com.muyu.product.domain.resp.CategoryCommonElementResp; import com.muyu.product.domain.resp.CategoryParentCommonElementResp; @@ -69,4 +71,9 @@ public interface CategoryInfoService extends IService { CategoryCommonElementResp getTemplateAttributeByCateGoryId (Long cateGoryId); public List getCommon (Long categoryId, IService iService, IService bsiService); + + boolean updateById(Long id,CategoryInfoUpdReq categoryInfoUpdReq); + + Result removeBatchById(Long ids); + } diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/RuleInfoService.java b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/RuleInfoService.java index 54c5b08..1cd773e 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/RuleInfoService.java +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/RuleInfoService.java @@ -6,8 +6,11 @@ import com.muyu.common.core.web.page.TableDataInfo; import com.muyu.product.domain.RuleInfo; import com.baomidou.mybatisplus.extension.service.IService; import com.muyu.product.domain.model.RuleInfoAddModel; +import com.muyu.product.domain.req.RuleInfoEditReq; import com.muyu.product.domain.req.RuleInfoQueryReq; +import com.muyu.product.domain.req.RuleInfoUpdReq; import com.muyu.product.domain.resp.RuleInfoResp; +import com.muyu.product.domain.resp.RuleInfoUpdResp; /** * 商品规格Service接口 @@ -32,4 +35,14 @@ public interface RuleInfoService extends IService { public boolean save(RuleInfoAddModel ruleInfoAddModel); TableDataInfo queryList (RuleInfoQueryReq ruleInfoQueryReq); + /** + * 规格id查询根据id + */ + RuleInfoUpdResp selectById(Long id); + + /** + * 通过id修改规格属性 + */ + boolean updateById(Long id, RuleInfoEditReq ruleInfoEditReq); + } diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/AsAttributeGroupServiceImpl.java b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/AsAttributeGroupServiceImpl.java index 7e2e186..8749bcb 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/AsAttributeGroupServiceImpl.java +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/AsAttributeGroupServiceImpl.java @@ -4,6 +4,7 @@ import java.util.List; import com.muyu.common.core.utils.ObjUtils; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.muyu.product.mapper.AsAttributeGroupMapper; import com.muyu.product.domain.AsAttributeGroup; @@ -11,6 +12,8 @@ import com.muyu.product.service.AsAttributeGroupService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import javax.annotation.Resource; + /** * 属性与组中间Service业务层处理 * @@ -20,6 +23,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @Slf4j @Service public class AsAttributeGroupServiceImpl extends ServiceImpl implements AsAttributeGroupService { + @Resource + private AsAttributeGroupMapper asAttributeGroupMapper; /** * 查询属性与组中间列表 @@ -42,4 +47,9 @@ public class AsAttributeGroupServiceImpl extends ServiceImpl implements AsCategoryAttributeGroupService { + @Resource + private AsCategoryAttributeGroupMapper asCategoryAttributeGroupMapper; /** * 查询品类属性组中间列表 * @@ -40,10 +45,11 @@ public class AsCategoryAttributeGroupServiceImpl extends ServiceImpl implements AsCategoryAttributeService { + @Resource + private AsCategoryAttributeMapper asCategoryAttributeMapper; /** * 查询品类属性中间列表 * @@ -40,10 +45,11 @@ public class AsCategoryAttributeServiceImpl extends ServiceImpl implements AsCategoryBrandService { + @Resource + private AsCategoryBrandMapper asCategoryBrandMapper; /** * 查询品类品牌中间列表 * @@ -40,10 +44,11 @@ public class AsCategoryBrandServiceImpl extends ServiceImpl implements AttributeGroupService { @Autowired - private AsAttributeGroupService attributeGroupService; + private AsAttributeGroupService asAttributeGroupService; @Autowired private AttributeInfoService attributeInfoService; + @Resource + private AsAttributeGroupMapper asAttributeGroupMapper; /** * 分页查询 @@ -86,9 +90,7 @@ public class AttributeGroupServiceImpl extends ServiceImpl attributeIdList = attributeGroupSaveModel.getAttributeIdList(); - attributeGroupService.saveBatch( + asAttributeGroupService.saveBatch( attributeIdList.stream() .map(attributeId -> AsAttributeGroup.buildGroup(attributeGroupId, attributeId)) .toList() ); return save; } + + @Override + public AttributeGroupUpdResp getUpdById(Long id) { + //获取id + AttributeGroup attributeGroup = this.getById(id); + + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(AsAttributeGroup::getGroupId,id); + + List asAttributeGroupList = asAttributeGroupService.list(queryWrapper); + List attributeIdList = asAttributeGroupList.stream() + .map(AsAttributeGroup::getAttributeId) + .toList(); + List attributeInfoList = attributeInfoService.listByIds(attributeIdList); + //转型 + return AttributeGroupUpdResp.builder() + .id(attributeGroup.getId()) + .name(attributeGroup.getName()) + .states(attributeGroup.getStates()) + .attributeList(attributeInfoList) + .build(); + } + @Override + @Transactional + public boolean updateByattr(Long id, AttributeUpdReq attributeUpdReq) { + //修改属性组信息 + asAttributeGroupMapper.updateAttributeById(id,attributeUpdReq.getName(),attributeUpdReq.getStates()); + //删除中间表根据属性组id删除 + asAttributeGroupMapper.deleteAsAttributeGroup(id); + //添加中间表 + attributeUpdReq.getAttributeList().stream().forEach(attributeList->{ + asAttributeGroupService.addByGroup(id,attributeList.getId()); + }); + return true; + } } + + + + + + + + + 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 2d6b4d5..a4f477d 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 @@ -4,12 +4,14 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.muyu.common.core.domain.Result; import com.muyu.common.core.utils.ObjUtils; import com.muyu.product.domain.*; import com.muyu.product.domain.base.CategoryBase; import com.muyu.product.domain.model.CategoryInfoSaveModel; import com.muyu.product.domain.model.TemplateAttributeGroupModel; import com.muyu.product.domain.model.TemplateAttributeModel; +import com.muyu.product.domain.req.CategoryInfoUpdReq; import com.muyu.product.domain.resp.CategoryCommonElementResp; import com.muyu.product.domain.resp.CategoryParentCommonElementResp; import com.muyu.product.mapper.CategoryInfoMapper; @@ -19,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import javax.annotation.Resource; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -57,6 +60,8 @@ public class CategoryInfoServiceImpl extends ServiceImpl().eq(AsCategoryAttribute::getCategoryId,id)); + asCategoryAttributeGroupService.remove(new LambdaQueryWrapper().eq(AsCategoryAttributeGroup::getCategoryId,id)); + asCategoryBrandService.remove(new LambdaQueryWrapper().eq(AsCategoryBrand::getCategoryId,id)); + //添加新的关联数据(属性表) + if(null!=categoryInfoUpdReq.getAttributeIdList()){ + categoryInfoUpdReq.getAttributeIdList().stream().forEach(attributeId -> { + asCategoryAttributeService.addByGroup(attributeId,id); + }); + } + //添加新的关联数据(属性组表) + if(null!=categoryInfoUpdReq.getAttributeGroupIdList()){ + categoryInfoUpdReq.getAttributeGroupIdList().stream().forEach(attributeGroupId -> { + asCategoryAttributeGroupService.addByGroup(attributeGroupId,id); + }); + } + //添加新的关联数据(品类组表) + if(null!=categoryInfoUpdReq.getBrandGroupIdList()){ + categoryInfoUpdReq.getBrandGroupIdList().stream().forEach(brandGroupId -> { + asCategoryBrandService.addByGroup(brandGroupId,id); + }); + } + return b; + } + + @Override + public Result removeBatchById(Long ids) { + //查询是否有子级 + //qw是plus的条件构造器,lqw是lambda表达式 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("parent_id",ids); + List list = categoryInfoMapper.selectList(queryWrapper); + if(0==list.size()){ + //是否有商品关联关系 + List list1= categoryInfoMapper.selectProjectInfoById(ids); + if(0==list1.size()){ + //删除 + categoryInfoMapper.delete(new LambdaQueryWrapper().eq(CategoryInfo::getId,ids)); + return Result.success("删除成功"); + } + return Result.error("有商品关联关系,不能删除"); + } + return Result.error("有子集,不能删除"); + } + /** * 通过品类ID获取父级以上的属性、属性组、品牌集合 * diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/RuleAttrInfoServiceImpl.java b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/RuleAttrInfoServiceImpl.java index 4b7b712..1c44cc5 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/RuleAttrInfoServiceImpl.java +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/RuleAttrInfoServiceImpl.java @@ -64,4 +64,5 @@ public class RuleAttrInfoServiceImpl extends ServiceImpl @Autowired private RuleAttrInfoService ruleAttrInfoService; + @Resource + private RuleInfoMapper ruleInfoMapper; /** * 查询商品规格列表 @@ -107,4 +116,51 @@ public class RuleInfoServiceImpl extends ServiceImpl .total(isPage ? new PageInfo<>(list).getTotal() : 0) .build(); } + /** + * 规格id查询根据id + */ + @Override + public RuleInfoUpdResp selectById(Long id) { + //获取id + RuleInfo ruleInfo = this.getById(id); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(RuleAttrInfo::getRuleId,id); + + List ruleAttrInfoList = ruleAttrInfoService.list(queryWrapper); + + return RuleInfoUpdResp.builder() + .id(ruleInfo.getId()) + .name(ruleInfo.getName()) + .remark(ruleInfo.getRemark()) + .ruleAttrList(ruleAttrInfoList.stream().map(RuleAttrAddModel::infoBuild).toList()) + .build(); + } + + @Override + public boolean updateById(Long id, RuleInfoEditReq ruleInfoEditReq) { + //获取id + boolean update = this.updateById(RuleInfo.editBuild(id,ruleInfoEditReq)); + //进行修改 + //判断是否修改 是则删除否则不删除 + if(update){ + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(RuleAttrInfo::getRuleId,id); + //根据id删除 + this.ruleAttrInfoService.remove(queryWrapper); + //删除后再添加 + ruleAttrInfoService.saveBatch( + ruleInfoEditReq.getRuleAttrList().stream() + .map(ruleAttrAddModel -> RuleAttrInfo.addModelBuild(ruleAttrAddModel, + () -> id, SecurityUtils::getUsername)) + .toList() + ); + } + return update; + } } + + + + + + diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/resources/mapper/product/AsAttributeGroupMapper.xml b/muyu-modules/muyu-product/muyu-product-server/src/main/resources/mapper/product/AsAttributeGroupMapper.xml index 05c468d..1be30ea 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/resources/mapper/product/AsAttributeGroupMapper.xml +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/resources/mapper/product/AsAttributeGroupMapper.xml @@ -18,4 +18,23 @@ select id, group_id, attribute_id, remark, create_by, create_time, update_by, update_time from as_attribute_group + + insert into as_attribute_group(group_id, attribute_id) + values (#{id}, #{id1}) + + + update attribute_group + + + name = #{name}, + + + states = #{states}, + + + where id = #{id} + + + delete from as_attribute_group where group_id = #{id} + diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/resources/mapper/product/AsCategoryAttributeGroupMapper.xml b/muyu-modules/muyu-product/muyu-product-server/src/main/resources/mapper/product/AsCategoryAttributeGroupMapper.xml index 7196d03..ac08e9a 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/resources/mapper/product/AsCategoryAttributeGroupMapper.xml +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/resources/mapper/product/AsCategoryAttributeGroupMapper.xml @@ -18,4 +18,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select id, category_id, attribute_group_id, remark, create_by, create_time, update_by, update_time from as_category_attribute_group + + insert into as_category_attribute_group(category_id, attribute_group_id) + values(#{categoryId},#{attributeGroupId}) + diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/resources/mapper/product/AsCategoryAttributeMapper.xml b/muyu-modules/muyu-product/muyu-product-server/src/main/resources/mapper/product/AsCategoryAttributeMapper.xml index d5544af..bd4dbb8 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/resources/mapper/product/AsCategoryAttributeMapper.xml +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/resources/mapper/product/AsCategoryAttributeMapper.xml @@ -18,4 +18,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select id, category_id, attribute_id, remark, create_by, create_time, update_by, update_time from as_category_attribute + + insert into as_category_attribute(category_id, attribute_id) + values(#{id},#{attributeId}) + diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/resources/mapper/product/AsCategoryBrandMapper.xml b/muyu-modules/muyu-product/muyu-product-server/src/main/resources/mapper/product/AsCategoryBrandMapper.xml index 048317d..c35aeb6 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/resources/mapper/product/AsCategoryBrandMapper.xml +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/resources/mapper/product/AsCategoryBrandMapper.xml @@ -18,4 +18,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select id, category_id, brand_id, remark, create_by, create_time, update_by, update_time from as_category_brand + + insert into as_category_brand(category_id, brand_id, create_by, create_time, update_by, update_time) + values(#{categoryId}, #{brandId}, #{createBy}, #{createTime}, #{updateBy}, #{updateTime}) + diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/resources/mapper/product/CategoryInfoMapper.xml b/muyu-modules/muyu-product/muyu-product-server/src/main/resources/mapper/product/CategoryInfoMapper.xml index 99be65b..131a621 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/resources/mapper/product/CategoryInfoMapper.xml +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/resources/mapper/product/CategoryInfoMapper.xml @@ -21,4 +21,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select id, name, image, parent_id, start, introduction, remark, create_by, create_time, update_by, update_time from category_info + + update category_info set name = #{categoryInfoUpdReq.name},image = #{categoryInfoUpdReq.image},start = #{categoryInfoUpdReq.start},introduction = #{categoryInfoUpdReq.introduction} + where id = #{id} + +