ddd
parent
17eee84e43
commit
a516b738ca
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<trees>
|
||||
<tree path="/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/model/AttributeGroupSaveModel.java"
|
||||
title="属性组添加模型" extension="" presentableText="" tooltipTitle="" icon="" textColor=""
|
||||
backgroundColor=""/>
|
||||
</trees>
|
|
@ -19,6 +19,7 @@ import lombok.experimental.SuperBuilder;
|
|||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
|
@ -52,4 +53,15 @@ public class AsCategoryAttribute extends BaseEntity {
|
|||
.attributeId(attributeId)
|
||||
.build();
|
||||
}
|
||||
public static AsCategoryAttribute buildCategoryAttribute(Long categoryInfoId,Long attributeId){
|
||||
return AsCategoryAttribute.builder ()
|
||||
.categoryId(categoryInfoId)
|
||||
.attributeId(attributeId)
|
||||
.build ();
|
||||
}
|
||||
public static AsCategoryAttribute buildCategoryAttribute(Long categoryInfoId){
|
||||
return AsCategoryAttribute.builder ()
|
||||
.categoryId(categoryInfoId)
|
||||
.build ();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,4 +52,11 @@ public class AsCategoryAttributeGroup extends BaseEntity {
|
|||
.attributeGroupId(attributeGroupId)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
public static AsCategoryAttributeGroup categoryAttributeGroup(Long categoryId){
|
||||
return AsCategoryAttributeGroup.builder()
|
||||
.categoryId(categoryId)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,11 +7,9 @@ import com.muyu.common.core.annotation.Excel;
|
|||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.*;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* 品类品牌中间对象 as_category_brand
|
||||
|
@ -30,11 +28,11 @@ public class AsCategoryBrand extends BaseEntity {
|
|||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
/** 主键 */
|
||||
@TableId(value = "id",type = IdType.AUTO)
|
||||
@ApiModelProperty(name = "主键", value = "主键")
|
||||
private Long id;
|
||||
|
||||
/** 品类id */
|
||||
@Excel(name = "品类id")
|
||||
@ApiModelProperty(name = "品类id", value = "品类id", required = true)
|
||||
|
@ -51,4 +49,10 @@ public class AsCategoryBrand extends BaseEntity {
|
|||
.brandId(brandId)
|
||||
.build();
|
||||
}
|
||||
public static AsCategoryBrand categoryBrand(Long categoryId){
|
||||
return AsCategoryBrand.builder ()
|
||||
.categoryId(categoryId)
|
||||
.build ();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
|||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.product.domain.model.TemplateAttributeModel;
|
||||
import com.muyu.product.domain.req.AttributeInfoEditReq;
|
||||
import com.muyu.product.domain.req.AttributeInfoQueryReq;
|
||||
import com.muyu.product.domain.req.AttributeInfoSaveReq;
|
||||
|
@ -49,6 +50,15 @@ public class AttributeInfo extends BaseEntity {
|
|||
private String name;
|
||||
|
||||
|
||||
|
||||
public TemplateAttributeModel buildTemplateModel(){
|
||||
return TemplateAttributeModel.builder()
|
||||
.id(this.getId())
|
||||
.code(this.getCode())
|
||||
.name(this.getName())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询构造器
|
||||
*/
|
||||
|
|
|
@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
|||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.product.domain.model.RuleAttrAddModel;
|
||||
import com.muyu.product.domain.model.RuleInfoAddModel;
|
||||
import com.muyu.product.domain.req.RuleAttrInfoEditReq;
|
||||
import com.muyu.product.domain.req.RuleAttrInfoQueryReq;
|
||||
import com.muyu.product.domain.req.RuleAttrInfoSaveReq;
|
||||
|
@ -16,6 +18,9 @@ import lombok.EqualsAndHashCode;
|
|||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* 规格详情对象 rule_attr_info
|
||||
*
|
||||
|
@ -75,6 +80,7 @@ public class RuleAttrInfo extends BaseEntity {
|
|||
.build();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改构造器
|
||||
*/
|
||||
|
@ -87,4 +93,13 @@ public class RuleAttrInfo extends BaseEntity {
|
|||
.build();
|
||||
}
|
||||
|
||||
public static RuleAttrInfo addModelBuild(RuleAttrAddModel ruleAttrAddModel, Long ruleId, Supplier<String> createBy) {
|
||||
return RuleAttrInfo.builder()
|
||||
.ruleId(ruleId)
|
||||
.name(ruleAttrAddModel.getName())
|
||||
.attrValue(String.join ( ",", ruleAttrAddModel.getValueList ()))
|
||||
.createBy ( createBy.get ( ) )
|
||||
.createTime ( new Date () )
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
|||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
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.RuleInfoSaveReq;
|
||||
|
@ -16,6 +17,9 @@ import lombok.EqualsAndHashCode;
|
|||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* 商品规格对象 rule_info
|
||||
*
|
||||
|
@ -79,4 +83,18 @@ public class RuleInfo extends BaseEntity {
|
|||
.build();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ruleInfoAddModel 添加模型
|
||||
* @param supplier 创建者
|
||||
* @return 规格对象
|
||||
*/
|
||||
public static RuleInfo addModelBuild(RuleInfoAddModel ruleInfoAddModel, Supplier<String> supplier){
|
||||
return RuleInfo.builder ()
|
||||
.name( ruleInfoAddModel.getName ( ) )
|
||||
.status( ruleInfoAddModel.getStatus ( ) )
|
||||
.createBy ( supplier.get () )
|
||||
.createTime ( new Date () )
|
||||
.build ();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package com.muyu.product.domain.demo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @ClassName Attribute
|
||||
* @Description 描述
|
||||
* @Author YunFei.Du
|
||||
* @Date 2024/3/6 14:20
|
||||
*/
|
||||
@Data
|
||||
public class Attribute {
|
||||
private Long id;
|
||||
private String code;
|
||||
private String attributeName;
|
||||
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.muyu.product.domain.demo;
|
||||
|
||||
import com.muyu.product.domain.AttributeInfo;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName Group
|
||||
* @Description 描述
|
||||
* @Author YunFei.Du
|
||||
* @Date 2024/3/6 14:19
|
||||
*/
|
||||
@Data
|
||||
public class Group {
|
||||
private String groupName;
|
||||
private List< AttributeInfo > list;
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package com.muyu.product.domain.demo;
|
||||
|
||||
import com.muyu.common.core.web.domain.TreeEntity;
|
||||
import com.muyu.product.domain.AttributeGroup;
|
||||
import com.muyu.product.domain.AttributeInfo;
|
||||
import com.muyu.product.domain.ProjectInfo;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName AttributeGroup
|
||||
* @Description 描述
|
||||
* @Author YunFei.Du
|
||||
* @Date 2024/3/6 14:13
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Project extends TreeEntity {
|
||||
/**
|
||||
* 商品属性组
|
||||
*/
|
||||
private List< AttributeGroup > attributeGroupList;
|
||||
/**
|
||||
* 商品属性
|
||||
*/
|
||||
private List< ProjectInfo > projectInfoList;
|
||||
/**
|
||||
* 自有属性
|
||||
*/
|
||||
private Long id;
|
||||
private String code;
|
||||
private String attributeGroupName;
|
||||
private List< AttributeInfo > attributeList;
|
||||
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
package com.muyu.product.domain.model;
|
||||
|
||||
import com.muyu.common.core.web.domain.TreeEntity;
|
||||
import com.muyu.product.domain.req.CategoryInfoEditReq;
|
||||
import com.muyu.product.domain.req.CategoryInfoSaveReq;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* @ClassName CategoryInfoSaveModel
|
||||
* @Description 描述
|
||||
* @Author Xin.Yao
|
||||
* @Date 2024/3/3 8:52
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class CategoryInfoEditModel extends TreeEntity {
|
||||
private Long id;
|
||||
private String name;
|
||||
private String image;
|
||||
private String start;
|
||||
private String introduction;
|
||||
|
||||
/**
|
||||
* 商品属性组关联ID
|
||||
*/
|
||||
private List<Long> attributeGroupIdList;
|
||||
/**
|
||||
* 商品属性关联ID
|
||||
*/
|
||||
private List<Long> attributeIdList;
|
||||
|
||||
/**
|
||||
* 商品品牌组关联ID
|
||||
*/
|
||||
private List<Long> brandIdList;
|
||||
|
||||
/**
|
||||
* 修改构造器
|
||||
*/
|
||||
public static CategoryInfoEditModel editBuild(Long id,CategoryInfoEditReq categoryInfoEditReq, Supplier<String> supplier){
|
||||
return CategoryInfoEditModel.builder()
|
||||
.id ( id )
|
||||
.name(categoryInfoEditReq.getName())
|
||||
.image(categoryInfoEditReq.getImage())
|
||||
.start(categoryInfoEditReq.getStart())
|
||||
.introduction(categoryInfoEditReq.getIntroduction())
|
||||
.parentId(categoryInfoEditReq.getParentId())
|
||||
.attributeGroupIdList(categoryInfoEditReq.getAttributeGroupIdList())
|
||||
.attributeIdList(categoryInfoEditReq.getAttributeIdList())
|
||||
.brandIdList(categoryInfoEditReq.getBrandIdList())
|
||||
.createBy(supplier.get())
|
||||
.createTime(new Date())
|
||||
.build();
|
||||
}
|
||||
public static CategoryInfoEditReq editBuild1(CategoryInfoEditReq categoryInfoEditReq,Supplier<String> supplier){
|
||||
return CategoryInfoEditReq.builder ()
|
||||
.name ( categoryInfoEditReq.getName () )
|
||||
.image ( categoryInfoEditReq.getImage ( ) )
|
||||
.start ( categoryInfoEditReq.getStart () )
|
||||
.introduction ( categoryInfoEditReq.getIntroduction () )
|
||||
.parentId ( categoryInfoEditReq.getParentId () )
|
||||
.createBy ( supplier.get () )
|
||||
.createTime ( new Date () )
|
||||
.build ();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package com.muyu.product.domain.model;
|
||||
|
||||
import com.muyu.common.core.web.domain.TreeEntity;
|
||||
import com.muyu.product.domain.RuleAttrInfo;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName RuleAttrAddModel
|
||||
* @Description 规格属性,添加模型
|
||||
* @Author YunFei.Du
|
||||
* @Date 2024/3/4 14:41
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class RuleAttrAddModel extends TreeEntity {
|
||||
|
||||
/**
|
||||
* 规格属性名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
private Long ruleId;
|
||||
/**
|
||||
* 规格属性值集合
|
||||
*/
|
||||
|
||||
private List<String> valueList;
|
||||
|
||||
public static RuleAttrAddModel infoBuild (RuleAttrInfo ruleAttrInfo) {
|
||||
return RuleAttrAddModel.builder()
|
||||
.name(ruleAttrInfo.getName())
|
||||
.ruleId( ruleAttrInfo.getRuleId ( ) )
|
||||
.valueList( Arrays.stream(ruleAttrInfo.getAttrValue().split(",")).toList())
|
||||
.build();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package com.muyu.product.domain.model;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.common.core.web.domain.TreeEntity;
|
||||
import com.muyu.product.domain.RuleAttrInfo;
|
||||
import com.muyu.product.domain.req.RuleInfoSaveReq;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName RuleInfoAddModel
|
||||
* @Description 规格保存模块
|
||||
* @Author YunFei.Du
|
||||
* @Date 2024/3/4 16:29
|
||||
*/
|
||||
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("rule_info")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class RuleInfoAddModel extends TreeEntity {
|
||||
|
||||
/** 规格名称 */
|
||||
private String name;
|
||||
|
||||
/** 规格状态 */
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 规格属性集合
|
||||
*/
|
||||
private List< RuleAttrAddModel > ruleAttrList;
|
||||
|
||||
public static RuleInfoAddModel saveReqBuild(RuleInfoSaveReq req){
|
||||
return RuleInfoAddModel.builder ()
|
||||
.name ( req.getName ( ) )
|
||||
.status( req.getStatus ( ) )
|
||||
.ruleAttrList(req.getRuleAttrList ())
|
||||
.build ();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package com.muyu.product.domain.model;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.product.domain.AttributeGroup;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* @ClassName
|
||||
* @Description 共有属性组
|
||||
* @Author YunFei.Du
|
||||
* @Date 2024/3/6 14:31
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class TemplateAttributeGroupModel extends BaseEntity {
|
||||
/**
|
||||
* 组名称
|
||||
*/
|
||||
private String groupName;
|
||||
/**
|
||||
* 属性值下属性集合
|
||||
*/
|
||||
|
||||
private List<TemplateAttributeModel> attributeList;
|
||||
/**
|
||||
* 是否有效
|
||||
* @return
|
||||
*/
|
||||
public boolean isEffective(){
|
||||
return StringUtils.isNotEmpty(groupName) && attributeList != null && !attributeList.isEmpty();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param attributeGroup
|
||||
* @param attributeList
|
||||
* @return
|
||||
*/
|
||||
public static TemplateAttributeGroupModel attributeGroupBuild(AttributeGroup attributeGroup,
|
||||
Function<Long, List<TemplateAttributeModel>> attributeList){
|
||||
return TemplateAttributeGroupModel.builder()
|
||||
.groupName(attributeGroup.getName())
|
||||
.attributeList(attributeList.apply(attributeGroup.getId()))
|
||||
.build();
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package com.muyu.product.domain.model;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* @ClassName
|
||||
* @Description 共有属性
|
||||
* @Author YunFei.Du
|
||||
* @Date 2024/3/6 14:31
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class TemplateAttributeModel extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 属性名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 编码
|
||||
*/
|
||||
private String code;
|
||||
}
|
|
@ -8,6 +8,8 @@ import lombok.Data;
|
|||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 品类信息对象 category_info
|
||||
*
|
||||
|
@ -39,4 +41,8 @@ public class CategoryInfoEditReq extends TreeEntity {
|
|||
@ApiModelProperty(name = "介绍", value = "介绍")
|
||||
private String introduction;
|
||||
|
||||
private List<Long> attributeGroupIdList;
|
||||
private List<Long> attributeIdList;
|
||||
private List<Long> brandIdList;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.muyu.product.domain.req;
|
||||
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.product.domain.model.RuleAttrAddModel;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
@ -8,6 +9,8 @@ import lombok.Data;
|
|||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品规格对象 rule_info
|
||||
*
|
||||
|
@ -38,4 +41,8 @@ public class RuleInfoSaveReq extends BaseEntity {
|
|||
@ApiModelProperty(name = "规格状态", value = "规格状态")
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 规格属性集合
|
||||
*/
|
||||
private List< RuleAttrAddModel > ruleAttrList;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
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.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName CategoryCommonElementReq
|
||||
* @Description 商品类别公共元素
|
||||
* @Author YunFei.Du
|
||||
* @Date 2024/3/6 14:26
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class CategoryCommonElementResp extends BaseEntity {
|
||||
/**
|
||||
* 商品属性组
|
||||
*/
|
||||
private List< TemplateAttributeGroupModel > templateAttributeGroupList;
|
||||
/**
|
||||
* 商品属性
|
||||
*/
|
||||
private List< TemplateAttributeModel > templateAttributeList;
|
||||
/**
|
||||
* 自有属性
|
||||
*/
|
||||
private List<TemplateAttributeModel> attributeList;
|
||||
}
|
|
@ -1,12 +1,10 @@
|
|||
package com.muyu.product.domain.resp;
|
||||
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.product.domain.AttributeGroup;
|
||||
import com.muyu.product.domain.AttributeInfo;
|
||||
import com.muyu.product.domain.BrandInfo;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -20,7 +18,8 @@ import java.util.List;
|
|||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class CategoryParentCommonElementResp {
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class CategoryParentCommonElementResp extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 属性集合
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
package com.muyu.product.domain.resp;
|
||||
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.product.domain.RuleInfo;
|
||||
import com.muyu.product.domain.model.RuleAttrAddModel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* @ClassName RuleInfoResp
|
||||
* @Description 描述
|
||||
* @Author YunFei.Du
|
||||
* @Date 2024/3/4 18:02
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class RuleInfoResp extends BaseEntity {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String status;
|
||||
|
||||
private List< RuleAttrAddModel > ruleAttrList;
|
||||
|
||||
public static RuleInfoResp infoBuild(RuleInfo ruleInfo, Function<Long,List<RuleAttrAddModel>> ruleAttrList){
|
||||
return RuleInfoResp.builder ()
|
||||
.id( ruleInfo.getId ( ) )
|
||||
.name( ruleInfo.getName ( ) )
|
||||
.status ( ruleInfo.getStatus ( ) )
|
||||
.ruleAttrList( ruleAttrList.apply ( ruleInfo.getId ( ) ) )
|
||||
.build ();
|
||||
}
|
||||
}
|
|
@ -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<TableDataInfo<BrandInfo>> 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<BrandInfo> list = brandInfoService.list(BrandInfo.queryBuild(brandInfoQueryReq));
|
||||
return getDataTable(list);
|
||||
return isPage ? getDataTable ( list ) : Result.success ( list );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,7 +4,9 @@ import java.util.List;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
|
||||
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;
|
||||
|
@ -76,6 +78,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< CategoryCommonElementResp > getTemplateAttributeByCateGoryId(@PathVariable("cateGoryId") Long cateGoryId) {
|
||||
return Result.success(categoryInfoService.getTemplateAttributeByCateGoryId(cateGoryId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增品类信息
|
||||
*/
|
||||
|
@ -95,6 +108,7 @@ public class CategoryInfoController extends BaseController {
|
|||
@PutMapping("/{id}")
|
||||
@ApiOperation("修改品类信息")
|
||||
public Result<String> edit(@PathVariable Long id, @RequestBody CategoryInfoEditReq categoryInfoEditReq) {
|
||||
categoryInfoService.updateCategory(id,categoryInfoEditReq);
|
||||
return toAjax(categoryInfoService.updateById( CategoryInfo.editBuild(id,categoryInfoEditReq)));
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,10 @@ 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.RuleAttrAddModel;
|
||||
import com.muyu.product.domain.model.RuleInfoAddModel;
|
||||
import com.muyu.product.domain.resp.RuleInfoResp;
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
@ -45,10 +49,14 @@ public class RuleInfoController extends BaseController {
|
|||
@ApiOperation("获取商品规格列表")
|
||||
@RequiresPermissions("product:rule:list")
|
||||
@GetMapping("/list")
|
||||
public Result<TableDataInfo<RuleInfo>> list(RuleInfoQueryReq ruleInfoQueryReq) {
|
||||
public Result<TableDataInfo<RuleInfoResp>> list(RuleInfoQueryReq ruleInfoQueryReq) {
|
||||
|
||||
boolean isPage = ruleInfoQueryReq.getParams ( ).get ( "isPage" )==null || Convert.toBool ( ruleInfoQueryReq.getParams ().get ( "isPage" ),true );
|
||||
if (isPage){
|
||||
startPage();
|
||||
List<RuleInfo> list = ruleInfoService.list(RuleInfo.queryBuild(ruleInfoQueryReq));
|
||||
return getDataTable(list);
|
||||
}
|
||||
TableDataInfo< RuleInfoResp > tableDataInfo = ruleInfoService.queryList(ruleInfoQueryReq);
|
||||
return Result.success ( tableDataInfo );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -59,6 +67,7 @@ public class RuleInfoController extends BaseController {
|
|||
@Log(title = "商品规格", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, RuleInfo ruleInfo) {
|
||||
|
||||
List<RuleInfo> list = ruleInfoService.list(ruleInfo);
|
||||
ExcelUtil<RuleInfo> util = new ExcelUtil<RuleInfo>(RuleInfo.class);
|
||||
util.exportExcel(response, list, "商品规格数据");
|
||||
|
@ -72,6 +81,7 @@ public class RuleInfoController extends BaseController {
|
|||
@GetMapping(value = "/{id}")
|
||||
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
|
||||
public Result<RuleInfo> getInfo(@PathVariable("id") Long id) {
|
||||
|
||||
return Result.success(ruleInfoService.getById(id));
|
||||
}
|
||||
|
||||
|
@ -83,7 +93,8 @@ public class RuleInfoController extends BaseController {
|
|||
@PostMapping
|
||||
@ApiOperation("新增商品规格")
|
||||
public Result<String> add(@RequestBody RuleInfoSaveReq ruleInfoSaveReq) {
|
||||
return toAjax(ruleInfoService.save(RuleInfo.saveBuild(ruleInfoSaveReq)));
|
||||
return toAjax(ruleInfoService.save(RuleInfoAddModel.saveReqBuild(ruleInfoSaveReq)));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -8,6 +8,8 @@ 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.CategoryInfoEditReq;
|
||||
import com.muyu.product.domain.resp.CategoryCommonElementResp;
|
||||
import com.muyu.product.domain.resp.CategoryParentCommonElementResp;
|
||||
|
||||
/**
|
||||
|
@ -60,4 +62,22 @@ public interface CategoryInfoService extends IService<CategoryInfo> {
|
|||
* @return 父级以上的属性,属性组,品牌集合
|
||||
*/
|
||||
CategoryParentCommonElementResp parentCommonElement(Long categoryId);
|
||||
|
||||
/**
|
||||
* 修改 品类
|
||||
* @param id
|
||||
* @param categoryInfoEditReq
|
||||
*/
|
||||
void updateCategory(Long id, CategoryInfoEditReq categoryInfoEditReq);
|
||||
|
||||
/**
|
||||
* 通过品类ID获取品类共有属性
|
||||
*
|
||||
* @param cateGoryId 品类ID
|
||||
*
|
||||
* @return 品类共有属性
|
||||
*/
|
||||
|
||||
CategoryCommonElementResp getTemplateAttributeByCateGoryId(Long cateGoryId);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
package com.muyu.product.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
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.RuleInfoQueryReq;
|
||||
import com.muyu.product.domain.resp.RuleInfoResp;
|
||||
|
||||
/**
|
||||
* 商品规格Service接口
|
||||
|
@ -19,4 +24,10 @@ public interface RuleInfoService extends IService<RuleInfo> {
|
|||
*/
|
||||
public List<RuleInfo> list(RuleInfo ruleInfo);
|
||||
|
||||
public boolean save(RuleInfoAddModel ruleInfoAddModel);
|
||||
|
||||
TableDataInfo< RuleInfoResp > queryList (RuleInfoQueryReq ruleInfoQueryReq);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -47,7 +47,6 @@ public class AsAttributeGroupServiceImpl extends ServiceImpl<AsAttributeGroupMap
|
|||
return list(queryWrapper);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void deleteAsAttributeGroupByIds(List< Long > ids) {
|
||||
asAttributeGroupMapper.deleteAsAttributeGroupByIds ( ids );
|
||||
|
|
|
@ -39,11 +39,6 @@ public class AsBrandProjectServiceImpl extends ServiceImpl<AsBrandProjectMapper,
|
|||
if (ObjUtils.notNull(asBrandProject.getProjectId())){
|
||||
queryWrapper.eq(AsBrandProject::getProjectId, asBrandProject.getProjectId());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return list(queryWrapper);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,10 +40,6 @@ public class AsCategoryAttributeGroupServiceImpl extends ServiceImpl<AsCategoryA
|
|||
queryWrapper.eq(AsCategoryAttributeGroup::getAttributeGroupId, asCategoryAttributeGroup.getAttributeGroupId());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return list(queryWrapper);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,9 +41,6 @@ public class AsCategoryAttributeServiceImpl extends ServiceImpl<AsCategoryAttrib
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return list(queryWrapper);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ public class BrandInfoServiceImpl extends ServiceImpl<BrandInfoMapper, BrandInfo
|
|||
|
||||
|
||||
if (ObjUtils.notNull(brandInfo.getNam())){
|
||||
queryWrapper.eq(BrandInfo::getNam, brandInfo.getNam());
|
||||
queryWrapper.like (BrandInfo::getNam, brandInfo.getNam());
|
||||
}
|
||||
|
||||
if (ObjUtils.notNull(brandInfo.getLogo())){
|
||||
|
|
|
@ -10,6 +10,10 @@ 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.CategoryInfoEditReq;
|
||||
import com.muyu.product.domain.resp.CategoryCommonElementResp;
|
||||
import com.muyu.product.domain.resp.CategoryParentCommonElementResp;
|
||||
import com.muyu.product.service.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
@ -43,6 +47,10 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
|
|||
private BrandInfoService brandInfoService;
|
||||
@Autowired
|
||||
private AttributeInfoService attributeInfoService;
|
||||
|
||||
@Autowired
|
||||
private AsAttributeGroupService asAttributeGroupService;
|
||||
|
||||
/**
|
||||
* 查询品类信息列表
|
||||
*
|
||||
|
@ -91,51 +99,123 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
|
|||
.build ();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改品类
|
||||
* @param id
|
||||
* @param categoryInfoEditReq
|
||||
*/
|
||||
@Override
|
||||
public boolean save(CategoryInfoSaveModel categoryInfoSaveModel) {
|
||||
CategoryInfo categoryInfo = CategoryInfo.saveModelBuild(categoryInfoSaveModel);
|
||||
boolean save = this.save(categoryInfo);
|
||||
Long categoryInfoId = categoryInfo.getId();
|
||||
List<Long> attributeIdList = categoryInfoSaveModel.getAttributeIdList();
|
||||
if (attributeIdList != null && !attributeIdList.isEmpty()){
|
||||
public void updateCategory(Long id, CategoryInfoEditReq categoryInfoEditReq) {
|
||||
// 查询符合条件的列表 AsCategoryAttribute
|
||||
AsCategoryAttribute asCategoryAttribute = AsCategoryAttribute.buildCategoryAttribute ( id );
|
||||
|
||||
List< AsCategoryAttribute > list = asCategoryAttributeService.list ( asCategoryAttribute );
|
||||
|
||||
ArrayList< Long > asCategoryIds = new ArrayList<> ( );
|
||||
for (AsCategoryAttribute categoryAttribute : list) {
|
||||
asCategoryIds.add ( categoryAttribute.getId () );
|
||||
}
|
||||
// 批量删除
|
||||
asCategoryAttributeService.removeBatchByIds ( asCategoryIds );
|
||||
List< Long > attributeIdList = categoryInfoEditReq.getAttributeIdList ( );
|
||||
asCategoryAttributeService.saveBatch (
|
||||
attributeIdList.stream( )
|
||||
.map ( attributeId-> AsCategoryAttribute.buildCategoryAttribute ( id, attributeId ) )
|
||||
.toList ()
|
||||
);
|
||||
|
||||
|
||||
AsCategoryAttributeGroup asCategoryAttributeGroup = AsCategoryAttributeGroup.categoryAttributeGroup ( id );
|
||||
List< AsCategoryAttributeGroup > list1 = asCategoryAttributeGroupService.list ( asCategoryAttributeGroup );
|
||||
ArrayList< Long > asCategoryIds1 = new ArrayList<> ( );
|
||||
for (AsCategoryAttributeGroup categoryAttributeGroup : list1) {
|
||||
asCategoryIds1.add ( categoryAttributeGroup.getId () );
|
||||
}
|
||||
// 批量删除
|
||||
asCategoryAttributeGroupService.removeBatchByIds ( asCategoryIds1 );
|
||||
List< Long > attributeGroupIdList = categoryInfoEditReq.getAttributeGroupIdList ();
|
||||
asCategoryAttributeGroupService.saveBatch (
|
||||
attributeGroupIdList.stream ()
|
||||
.map ( attributeGroupId->AsCategoryAttributeGroup.categoryAttributeGroup ( id,attributeGroupId ) )
|
||||
.toList ()
|
||||
);
|
||||
|
||||
|
||||
AsCategoryBrand asCategoryBrand = AsCategoryBrand.categoryBrand ( id );
|
||||
List< AsCategoryBrand > list2 = asCategoryBrandService.list ( asCategoryBrand );
|
||||
ArrayList< Long > asCategoryIds2 = new ArrayList<> ( );
|
||||
for (AsCategoryBrand categoryBrand : list2) {
|
||||
asCategoryIds2.add ( categoryBrand.getId () );
|
||||
}
|
||||
asCategoryBrandService.removeBatchByIds ( asCategoryIds2 );
|
||||
List< Long > brandIdList = categoryInfoEditReq.getBrandIdList ( );
|
||||
asCategoryBrandService.saveBatch (
|
||||
brandIdList.stream ()
|
||||
.map ( brandId->AsCategoryBrand.categoryBrand ( id,brandId ) )
|
||||
.toList ()
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean save(CategoryInfoSaveModel categoryInfoSaveModel) {
|
||||
// 根据 CategoryInfoSaveModel 构建 categoryInfo 对象
|
||||
CategoryInfo categoryInfo = CategoryInfo.saveModelBuild(categoryInfoSaveModel);
|
||||
// 保存 CateGoryInfo,对象到数据库中
|
||||
boolean save = this.save(categoryInfo);
|
||||
// 获取保存后的CateGoryINfo 对象 的 Id
|
||||
Long categoryInfoId = categoryInfo.getId();
|
||||
|
||||
// 处理属性列表
|
||||
List<Long> attributeIdList = categoryInfoSaveModel.getAttributeIdList();
|
||||
|
||||
// 批量保存属性关联关系
|
||||
// 是否为 null 是否为空
|
||||
if (attributeIdList != null && !attributeIdList.isEmpty()){
|
||||
asCategoryAttributeService.saveBatch(
|
||||
// 将 attributeIdList 转换为流,以便后续进行流式操作。
|
||||
attributeIdList.stream()
|
||||
// 使用 map 操作将流中的每个 attributeId 转换为相应的 AsCategoryAttribute 对象,这些对象表示类别和属性之间的关联关系。
|
||||
.map(attributeId -> AsCategoryAttribute.categoryBuild(categoryInfoId, attributeId))
|
||||
// 将流中的元素收集到一个新的列表中。
|
||||
.toList()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// 处理属性分组列表
|
||||
List<Long> attributeGroupIdList = categoryInfoSaveModel.getAttributeGroupIdList();
|
||||
if (attributeGroupIdList != null && !attributeGroupIdList.isEmpty()){
|
||||
// 批量保存属性分组关联关系
|
||||
asCategoryAttributeGroupService.saveBatch(
|
||||
attributeGroupIdList.stream()
|
||||
.map(attributeGroupId -> AsCategoryAttributeGroup.categoryAttributeGroup(categoryInfoId, attributeGroupId))
|
||||
.toList()
|
||||
);
|
||||
}
|
||||
// 处理品牌列表
|
||||
List<Long> brandIdList = categoryInfoSaveModel.getBrandIdList();
|
||||
if (brandIdList != null && !brandIdList.isEmpty()){
|
||||
// 批量保存品牌关联关系
|
||||
asCategoryBrandService.saveBatch(
|
||||
brandIdList.stream()
|
||||
.map(brandId -> AsCategoryBrand.categoryBrand (categoryInfoId, brandId))
|
||||
.toList()
|
||||
);
|
||||
}
|
||||
// 返回保存结果
|
||||
return save;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 通过品类获取 父级以上的属性组集合
|
||||
* @param categoryId
|
||||
* @return
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
public <T,AS> List<T> getCommon(Long categoryId, IService<AS> iService, IService<T> bsiService){
|
||||
List<T> list = new ArrayList();
|
||||
QueryWrapper<AS> asQueryWrapper = new QueryWrapper<> ();
|
||||
|
@ -192,6 +272,52 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
|
|||
}
|
||||
return attributeGroupList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过品类ID获取品类共有属性
|
||||
*
|
||||
* @param cateGoryId 品类ID
|
||||
*
|
||||
* @return 品类共有属性
|
||||
*/
|
||||
@Override
|
||||
public CategoryCommonElementResp getTemplateAttributeByCateGoryId(Long cateGoryId) {
|
||||
|
||||
|
||||
// 取出和品类相关联的属性组关系 - 中间表
|
||||
LambdaQueryWrapper<AsCategoryAttributeGroup> asCategoryAttributeGroupLambdaQueryWrapper = new LambdaQueryWrapper<>(){{
|
||||
eq(AsCategoryAttributeGroup::getCategoryId, cateGoryId);
|
||||
}};
|
||||
List<AsCategoryAttributeGroup> categoryAttributeGroupList = asCategoryAttributeGroupService.list(asCategoryAttributeGroupLambdaQueryWrapper);
|
||||
List<TemplateAttributeGroupModel> attributeGroupModelList = categoryAttributeGroupList.stream()
|
||||
.map(asCategoryAttributeGroup -> TemplateAttributeGroupModel.attributeGroupBuild(
|
||||
attributeGroupService.getById(asCategoryAttributeGroup.getAttributeGroupId()),
|
||||
attributeGroupId -> attributeInfoService.listByIds(
|
||||
asAttributeGroupService.list(
|
||||
new LambdaQueryWrapper<>(){{
|
||||
eq(AsAttributeGroup::getGroupId, asCategoryAttributeGroup.getAttributeGroupId());
|
||||
}}
|
||||
).stream().map(AsAttributeGroup::getAttributeId).toList()
|
||||
).stream()
|
||||
.map(AttributeInfo::buildTemplateModel)
|
||||
.toList()
|
||||
))
|
||||
.filter(TemplateAttributeGroupModel::isEffective)
|
||||
.toList();
|
||||
|
||||
List< TemplateAttributeModel > templateAttributeModelList = new ArrayList<>();
|
||||
|
||||
List<TemplateAttributeModel> attributeModelList = new ArrayList<>();
|
||||
|
||||
|
||||
return CategoryCommonElementResp.builder()
|
||||
.templateAttributeGroupList(attributeGroupModelList)
|
||||
.templateAttributeList(templateAttributeModelList)
|
||||
.attributeList(attributeModelList)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List< BrandInfo > getBrand(Long categoryId) {
|
||||
return null;
|
||||
|
|
|
@ -2,8 +2,19 @@ package com.muyu.product.service.impl;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
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;
|
||||
import com.muyu.product.domain.RuleAttrInfo;
|
||||
import com.muyu.product.domain.model.RuleAttrAddModel;
|
||||
import com.muyu.product.domain.model.RuleInfoAddModel;
|
||||
import com.muyu.product.domain.req.RuleInfoQueryReq;
|
||||
import com.muyu.product.domain.resp.RuleInfoResp;
|
||||
import com.muyu.product.service.RuleAttrInfoService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.muyu.product.mapper.RuleInfoMapper;
|
||||
import com.muyu.product.domain.RuleInfo;
|
||||
|
@ -21,6 +32,9 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||
@Service
|
||||
public class RuleInfoServiceImpl extends ServiceImpl<RuleInfoMapper, RuleInfo> implements RuleInfoService {
|
||||
|
||||
|
||||
@Autowired
|
||||
private RuleAttrInfoService ruleAttrInfoService;
|
||||
/**
|
||||
* 查询商品规格列表
|
||||
*
|
||||
|
@ -46,4 +60,41 @@ public class RuleInfoServiceImpl extends ServiceImpl<RuleInfoMapper, RuleInfo>
|
|||
|
||||
return list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean save(RuleInfoAddModel ruleInfoAddModel) {
|
||||
// 调用添加模型构建
|
||||
RuleInfo ruleInfo = RuleInfo.addModelBuild(ruleInfoAddModel, SecurityUtils::getUsername);
|
||||
// 调用当前对象的save 方法保存 ruleInfo 对象,并获取保存的结果
|
||||
boolean save = this.save(ruleInfo);
|
||||
// if 保存成功 则继续 保存规则属性消息
|
||||
if (save){
|
||||
// 批量保存规则消息
|
||||
ruleAttrInfoService.saveBatch(
|
||||
ruleInfoAddModel.getRuleAttrList().stream()
|
||||
// 将每个规则添加转换为 RuleAttrInfo 对象 并保存到列表中
|
||||
.map(ruleAttrAddModel -> RuleAttrInfo.addModelBuild(ruleAttrAddModel, ruleInfo.getId (), SecurityUtils::getUsername))
|
||||
.toList()
|
||||
);
|
||||
}
|
||||
return save;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TableDataInfo< RuleInfoResp > queryList (RuleInfoQueryReq ruleInfoQueryReq) {
|
||||
List<RuleInfo> list = this.list(RuleInfo.queryBuild(ruleInfoQueryReq));
|
||||
List<RuleInfoResp> ruleInfoRespList = list.stream()
|
||||
.map(ruleInfo -> RuleInfoResp.infoBuild(ruleInfo, ruleId -> {
|
||||
LambdaQueryWrapper<RuleAttrInfo> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(RuleAttrInfo::getRuleId, ruleId);
|
||||
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.<RuleInfoResp>builder()
|
||||
.rows(ruleInfoRespList)
|
||||
.total(isPage ? new PageInfo<> ( list ).getTotal ():0)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue