商品管理
parent
75b24524ae
commit
d1a7a6d94c
|
@ -109,8 +109,7 @@ public class DataScopeAspect {
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(sqlString.toString())) {
|
if (StringUtils.isNotBlank(sqlString.toString())) {
|
||||||
Object params = joinPoint.getArgs()[0];
|
Object params = joinPoint.getArgs()[0];
|
||||||
if (StringUtils.isNotNull(params) && params instanceof BaseEntity) {
|
if (StringUtils.isNotNull(params) && params instanceof BaseEntity baseEntity) {
|
||||||
BaseEntity baseEntity = (BaseEntity) params;
|
|
||||||
baseEntity.getParams().put(DATA_SCOPE, " AND (" + sqlString.substring(4) + ")");
|
baseEntity.getParams().put(DATA_SCOPE, " AND (" + sqlString.substring(4) + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,4 +45,11 @@ public class AsAttributeGroup extends BaseEntity {
|
||||||
private Long attributeId;
|
private Long attributeId;
|
||||||
|
|
||||||
|
|
||||||
|
public static AsAttributeGroup buildGroup (Long attributeGroupId,
|
||||||
|
Long attributeId) {
|
||||||
|
return AsAttributeGroup.builder()
|
||||||
|
.groupId(attributeGroupId)
|
||||||
|
.attributeId(attributeId)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.product.domain;
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.muyu.product.domain.base.CategoryBase;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
@ -25,7 +26,7 @@ import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
@TableName("as_category_attribute")
|
@TableName("as_category_attribute")
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@ApiModel(value = "AsCategoryAttribute", description = "品类属性中间")
|
@ApiModel(value = "AsCategoryAttribute", description = "品类属性中间")
|
||||||
public class AsCategoryAttribute extends BaseEntity {
|
public class AsCategoryAttribute extends BaseEntity implements CategoryBase {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ -45,4 +46,15 @@ public class AsCategoryAttribute extends BaseEntity {
|
||||||
private Long attributeId;
|
private Long attributeId;
|
||||||
|
|
||||||
|
|
||||||
|
public static AsCategoryAttribute categoryBuild(Long categoryInfoId, Long attributeId) {
|
||||||
|
return AsCategoryAttribute.builder()
|
||||||
|
.categoryId(categoryInfoId)
|
||||||
|
.attributeId(attributeId)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long getBaseId () {
|
||||||
|
return this.attributeId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.product.domain;
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.muyu.product.domain.base.CategoryBase;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
@ -25,7 +26,7 @@ import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
@TableName("as_category_attribute_group")
|
@TableName("as_category_attribute_group")
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@ApiModel(value = "AsCategoryAttributeGroup", description = "品类属性组中间")
|
@ApiModel(value = "AsCategoryAttributeGroup", description = "品类属性组中间")
|
||||||
public class AsCategoryAttributeGroup extends BaseEntity {
|
public class AsCategoryAttributeGroup extends BaseEntity implements CategoryBase {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ -45,4 +46,15 @@ public class AsCategoryAttributeGroup extends BaseEntity {
|
||||||
private Long attributeGroupId;
|
private Long attributeGroupId;
|
||||||
|
|
||||||
|
|
||||||
|
public static AsCategoryAttributeGroup categoryBuild(Long categoryInfoId, Long attributeGroupId) {
|
||||||
|
return AsCategoryAttributeGroup.builder()
|
||||||
|
.attributeGroupId(attributeGroupId)
|
||||||
|
.categoryId(categoryInfoId)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long getBaseId () {
|
||||||
|
return this.attributeGroupId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.product.domain;
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.muyu.product.domain.base.CategoryBase;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
@ -25,7 +26,7 @@ import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
@TableName("as_category_brand")
|
@TableName("as_category_brand")
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@ApiModel(value = "AsCategoryBrand", description = "品类品牌中间")
|
@ApiModel(value = "AsCategoryBrand", description = "品类品牌中间")
|
||||||
public class AsCategoryBrand extends BaseEntity {
|
public class AsCategoryBrand extends BaseEntity implements CategoryBase {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ -44,4 +45,15 @@ public class AsCategoryBrand extends BaseEntity {
|
||||||
@ApiModelProperty(name = "品牌id", value = "品牌id", required = true)
|
@ApiModelProperty(name = "品牌id", value = "品牌id", required = true)
|
||||||
private Long brandId;
|
private Long brandId;
|
||||||
|
|
||||||
|
public static AsCategoryBrand categoryBuild(Long categoryInfoId, Long brandId) {
|
||||||
|
return AsCategoryBrand.builder()
|
||||||
|
.brandId(brandId)
|
||||||
|
.categoryId(categoryInfoId)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long getBaseId () {
|
||||||
|
return this.brandId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.muyu.product.domain.model.TemplateAttributeModel;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
@ -39,18 +40,32 @@ public class AttributeInfo extends BaseEntity {
|
||||||
@ApiModelProperty(name = "属性编号", value = "属性编号")
|
@ApiModelProperty(name = "属性编号", value = "属性编号")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
/** 属性编码 */
|
||||||
|
@Excel(name = "属性编码")
|
||||||
|
@ApiModelProperty(name = "属性编码", value = "属性编码", required = true)
|
||||||
|
private String code;
|
||||||
|
|
||||||
/** 属性名 */
|
/** 属性名 */
|
||||||
@Excel(name = "属性名")
|
@Excel(name = "属性名")
|
||||||
@ApiModelProperty(name = "属性名", value = "属性名", required = true)
|
@ApiModelProperty(name = "属性名", value = "属性名", required = true)
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
|
||||||
|
public TemplateAttributeModel buildTemplateModel(){
|
||||||
|
return TemplateAttributeModel.builder()
|
||||||
|
.id(this.getId())
|
||||||
|
.code(this.getCode())
|
||||||
|
.name(this.getName())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询构造器
|
* 查询构造器
|
||||||
*/
|
*/
|
||||||
public static AttributeInfo queryBuild( AttributeInfoQueryReq attributeInfoQueryReq){
|
public static AttributeInfo queryBuild( AttributeInfoQueryReq attributeInfoQueryReq){
|
||||||
return AttributeInfo.builder()
|
return AttributeInfo.builder()
|
||||||
.name(attributeInfoQueryReq.getName())
|
.name(attributeInfoQueryReq.getName())
|
||||||
|
.code(attributeInfoQueryReq.getCode())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,6 +75,7 @@ public class AttributeInfo extends BaseEntity {
|
||||||
public static AttributeInfo saveBuild(AttributeInfoSaveReq attributeInfoSaveReq){
|
public static AttributeInfo saveBuild(AttributeInfoSaveReq attributeInfoSaveReq){
|
||||||
return AttributeInfo.builder()
|
return AttributeInfo.builder()
|
||||||
.name(attributeInfoSaveReq.getName())
|
.name(attributeInfoSaveReq.getName())
|
||||||
|
.code(attributeInfoSaveReq.getCode())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,6 +86,7 @@ public class AttributeInfo extends BaseEntity {
|
||||||
return AttributeInfo.builder()
|
return AttributeInfo.builder()
|
||||||
.id(id)
|
.id(id)
|
||||||
.name(attributeInfoEditReq.getName())
|
.name(attributeInfoEditReq.getName())
|
||||||
|
.code(attributeInfoEditReq.getCode())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.product.domain;
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.muyu.product.domain.model.CategoryInfoSaveModel;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
@ -15,6 +16,10 @@ import com.muyu.product.domain.req.CategoryInfoSaveReq;
|
||||||
import com.muyu.product.domain.req.CategoryInfoEditReq;
|
import com.muyu.product.domain.req.CategoryInfoEditReq;
|
||||||
import com.muyu.common.core.web.domain.TreeEntity;
|
import com.muyu.common.core.web.domain.TreeEntity;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 品类信息对象 category_info
|
* 品类信息对象 category_info
|
||||||
*
|
*
|
||||||
|
@ -72,12 +77,15 @@ public class CategoryInfo extends TreeEntity {
|
||||||
/**
|
/**
|
||||||
* 添加构造器
|
* 添加构造器
|
||||||
*/
|
*/
|
||||||
public static CategoryInfo saveBuild(CategoryInfoSaveReq categoryInfoSaveReq){
|
public static CategoryInfo saveBuild(CategoryInfoSaveReq categoryInfoSaveReq, Supplier<String> supplier){
|
||||||
return CategoryInfo.builder()
|
return CategoryInfo.builder()
|
||||||
.name(categoryInfoSaveReq.getName())
|
.name(categoryInfoSaveReq.getName())
|
||||||
.image(categoryInfoSaveReq.getImage())
|
.image(categoryInfoSaveReq.getImage())
|
||||||
.start(categoryInfoSaveReq.getStart())
|
.start(categoryInfoSaveReq.getStart())
|
||||||
.introduction(categoryInfoSaveReq.getIntroduction())
|
.introduction(categoryInfoSaveReq.getIntroduction())
|
||||||
|
.parentId(categoryInfoSaveReq.getParentId())
|
||||||
|
.createBy(supplier.get())
|
||||||
|
.createTime(new Date())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,4 +102,15 @@ public class CategoryInfo extends TreeEntity {
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static CategoryInfo saveModelBuild(CategoryInfoSaveModel categoryInfoSaveModel) {
|
||||||
|
return CategoryInfo.builder()
|
||||||
|
.name(categoryInfoSaveModel.getName())
|
||||||
|
.image(categoryInfoSaveModel.getImage())
|
||||||
|
.start(categoryInfoSaveModel.getStart())
|
||||||
|
.introduction(categoryInfoSaveModel.getIntroduction())
|
||||||
|
.parentId(categoryInfoSaveModel.getParentId())
|
||||||
|
.createBy(categoryInfoSaveModel.getCreateBy())
|
||||||
|
.createTime(new Date())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.product.domain;
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.muyu.product.domain.model.RuleAttrAddModel;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
@ -15,6 +16,9 @@ import com.muyu.product.domain.req.RuleAttrInfoSaveReq;
|
||||||
import com.muyu.product.domain.req.RuleAttrInfoEditReq;
|
import com.muyu.product.domain.req.RuleAttrInfoEditReq;
|
||||||
import com.muyu.common.core.web.domain.BaseEntity;
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 规格详情对象 rule_attr_info
|
* 规格详情对象 rule_attr_info
|
||||||
*
|
*
|
||||||
|
@ -86,4 +90,13 @@ public class RuleAttrInfo extends BaseEntity {
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static RuleAttrInfo addModelBuild (RuleAttrAddModel ruleAttrAddModel, Supplier<Long> ruleId, Supplier<String> createBy) {
|
||||||
|
return RuleAttrInfo.builder()
|
||||||
|
.ruleId(ruleId.get())
|
||||||
|
.name(ruleAttrAddModel.getName())
|
||||||
|
.attrValue(String.join(",", ruleAttrAddModel.getValueList()))
|
||||||
|
.createBy(createBy.get())
|
||||||
|
.createTime(new Date())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.product.domain;
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.muyu.product.domain.model.RuleInfoAddModel;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
@ -15,6 +16,9 @@ import com.muyu.product.domain.req.RuleInfoSaveReq;
|
||||||
import com.muyu.product.domain.req.RuleInfoEditReq;
|
import com.muyu.product.domain.req.RuleInfoEditReq;
|
||||||
import com.muyu.common.core.web.domain.BaseEntity;
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品规格对象 rule_info
|
* 商品规格对象 rule_info
|
||||||
*
|
*
|
||||||
|
@ -78,4 +82,18 @@ public class RuleInfo extends BaseEntity {
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param ruleInfoAddModel 添加模型
|
||||||
|
* @param createBy 创建者
|
||||||
|
* @return 规格对象
|
||||||
|
*/
|
||||||
|
public static RuleInfo addModelBuild (RuleInfoAddModel ruleInfoAddModel, Supplier<String> createBy) {
|
||||||
|
return RuleInfo.builder()
|
||||||
|
.name(ruleInfoAddModel.getName())
|
||||||
|
.status(ruleInfoAddModel.getStatus())
|
||||||
|
.createBy(createBy.get())
|
||||||
|
.createTime(new Date())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.muyu.product.domain.base;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author DongZl
|
||||||
|
* @description: attribute基础方法
|
||||||
|
* @Date 2024-3-1 下午 02:28
|
||||||
|
*/
|
||||||
|
public interface CategoryBase {
|
||||||
|
|
||||||
|
public Long getBaseId();
|
||||||
|
}
|
|
@ -0,0 +1,55 @@
|
||||||
|
package com.muyu.product.domain.model;
|
||||||
|
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
import com.muyu.product.domain.AttributeGroup;
|
||||||
|
import com.muyu.product.domain.req.AttributeGroupSaveReq;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author DongZl
|
||||||
|
* @description: 属性组添加模型
|
||||||
|
* @Date 2024-2-28 下午 03:16
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class AttributeGroupSaveModel extends BaseEntity {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 组名称 */
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/** 状态 */
|
||||||
|
private String states;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 属性ID集合
|
||||||
|
*/
|
||||||
|
private List<Long> attributeIdList;
|
||||||
|
|
||||||
|
public static AttributeGroupSaveModel saveReqBuild (AttributeGroupSaveReq req){
|
||||||
|
return AttributeGroupSaveModel.builder()
|
||||||
|
.name(req.getName())
|
||||||
|
.states(req.getStates())
|
||||||
|
.attributeIdList(req.getAttributeIdList())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public AttributeGroup buildAttributeGroup () {
|
||||||
|
return AttributeGroup.builder()
|
||||||
|
.name(this.getName())
|
||||||
|
.states(this.getStates())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,78 @@
|
||||||
|
package com.muyu.product.domain.model;
|
||||||
|
|
||||||
|
import com.muyu.common.core.web.domain.TreeEntity;
|
||||||
|
import com.muyu.product.domain.CategoryInfo;
|
||||||
|
import com.muyu.product.domain.req.CategoryInfoSaveReq;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 品类信息对象 category_info
|
||||||
|
*
|
||||||
|
* @author DongZeLiang
|
||||||
|
* @date 2024-02-27
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class CategoryInfoSaveModel extends TreeEntity {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|
||||||
|
/** 品类名称 */
|
||||||
|
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 CategoryInfoSaveModel saveBuild(CategoryInfoSaveReq categoryInfoSaveReq, Supplier<String> supplier){
|
||||||
|
return CategoryInfoSaveModel.builder()
|
||||||
|
.name(categoryInfoSaveReq.getName())
|
||||||
|
.image(categoryInfoSaveReq.getImage())
|
||||||
|
.start(categoryInfoSaveReq.getStart())
|
||||||
|
.introduction(categoryInfoSaveReq.getIntroduction())
|
||||||
|
.parentId(categoryInfoSaveReq.getParentId())
|
||||||
|
.attributeGroupIdList(categoryInfoSaveReq.getAttributeGroupIdList())
|
||||||
|
.attributeIdList(categoryInfoSaveReq.getAttributeIdList())
|
||||||
|
.brandIdList(categoryInfoSaveReq.getBrandIdList())
|
||||||
|
.createBy(supplier.get())
|
||||||
|
.createTime(new Date())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
package com.muyu.product.domain.model;
|
||||||
|
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
import com.muyu.product.domain.RuleAttrInfo;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author DongZl
|
||||||
|
* @description: 规格属性,添加模型
|
||||||
|
* @Date 2024-3-4 下午 02:28
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class RuleAttrAddModel extends BaseEntity {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 规格属性名称
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 规格属性值集合
|
||||||
|
*/
|
||||||
|
private List<String> valueList;
|
||||||
|
|
||||||
|
public static RuleAttrAddModel infoBuild (RuleAttrInfo ruleAttrInfo) {
|
||||||
|
return RuleAttrAddModel.builder()
|
||||||
|
.name(ruleAttrInfo.getName())
|
||||||
|
.valueList(Arrays.stream(ruleAttrInfo.getAttrValue().split(",")).toList())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
package com.muyu.product.domain.model;
|
||||||
|
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author DongZl
|
||||||
|
* @description: 规格保存模型
|
||||||
|
* @Date 2024-3-4 下午 02:33
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class RuleInfoAddModel extends BaseEntity {
|
||||||
|
|
||||||
|
/** 规格名称 */
|
||||||
|
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.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;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author DongZl
|
||||||
|
* @description: 共有属性组
|
||||||
|
* @Date 2024-3-6 下午 02:29
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class TemplateAttributeGroupModel extends BaseEntity {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组名称
|
||||||
|
*/
|
||||||
|
private String groupName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 属性组下属性集合
|
||||||
|
*/
|
||||||
|
private List<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,36 @@
|
||||||
|
package com.muyu.product.domain.model;
|
||||||
|
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author DongZl
|
||||||
|
* @description: 共有属性
|
||||||
|
* @Date 2024-3-6 下午 02:30
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class TemplateAttributeModel extends BaseEntity {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 属性名称
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编码
|
||||||
|
*/
|
||||||
|
private String code;
|
||||||
|
}
|
|
@ -1,6 +1,8 @@
|
||||||
package com.muyu.product.domain.req;
|
package com.muyu.product.domain.req;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
@ -26,19 +28,21 @@ public class AttributeGroupSaveReq extends BaseEntity {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/** 属性组编号 */
|
/** 属性组编号 */
|
||||||
|
|
||||||
@ApiModelProperty(name = "属性组编号", value = "属性组编号")
|
@ApiModelProperty(name = "属性组编号", value = "属性组编号")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
/** 组名称 */
|
/** 组名称 */
|
||||||
|
|
||||||
@ApiModelProperty(name = "组名称", value = "组名称", required = true)
|
@ApiModelProperty(name = "组名称", value = "组名称", required = true)
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
/** 状态 */
|
/** 状态 */
|
||||||
|
|
||||||
@ApiModelProperty(name = "状态", value = "状态", required = true)
|
@ApiModelProperty(name = "状态", value = "状态", required = true)
|
||||||
private String states;
|
private String states;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 属性ID集合
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(name = "属性ID集合", value = "属性ID集合", required = true)
|
||||||
|
private List<Long> attributeIdList;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,5 +33,8 @@ public class AttributeInfoEditReq extends BaseEntity {
|
||||||
@ApiModelProperty(name = "分组", value = "分组")
|
@ApiModelProperty(name = "分组", value = "分组")
|
||||||
private Long groupId;
|
private Long groupId;
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "属性编码", value = "属性编码")
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,5 +29,8 @@ public class AttributeInfoQueryReq extends BaseEntity {
|
||||||
@ApiModelProperty(name = "属性名", value = "属性名")
|
@ApiModelProperty(name = "属性名", value = "属性名")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "属性编码", value = "属性编码")
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,4 +35,7 @@ public class AttributeInfoSaveReq extends BaseEntity {
|
||||||
@ApiModelProperty(name = "属性名", value = "属性名", required = true)
|
@ApiModelProperty(name = "属性名", value = "属性名", required = true)
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "属性编码", value = "属性编码")
|
||||||
|
private String code;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,8 @@ import lombok.experimental.SuperBuilder;
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import com.muyu.common.core.web.domain.TreeEntity;
|
import com.muyu.common.core.web.domain.TreeEntity;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 品类信息对象 category_info
|
* 品类信息对象 category_info
|
||||||
*
|
*
|
||||||
|
@ -48,4 +50,18 @@ public class CategoryInfoSaveReq extends TreeEntity {
|
||||||
@ApiModelProperty(name = "介绍", value = "介绍")
|
@ApiModelProperty(name = "介绍", value = "介绍")
|
||||||
private String introduction;
|
private String introduction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品属性组关联ID
|
||||||
|
*/
|
||||||
|
private List<Long> attributeGroupIdList;
|
||||||
|
/**
|
||||||
|
* 商品属性关联ID
|
||||||
|
*/
|
||||||
|
private List<Long> attributeIdList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品品牌组关联ID
|
||||||
|
*/
|
||||||
|
private List<Long> brandIdList;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.muyu.product.domain.req;
|
package com.muyu.product.domain.req;
|
||||||
|
|
||||||
|
import com.muyu.product.domain.model.RuleAttrAddModel;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
@ -8,6 +9,8 @@ import lombok.experimental.SuperBuilder;
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import com.muyu.common.core.web.domain.BaseEntity;
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品规格对象 rule_info
|
* 商品规格对象 rule_info
|
||||||
*
|
*
|
||||||
|
@ -23,19 +26,16 @@ public class RuleInfoSaveReq extends BaseEntity {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/** 主键 */
|
|
||||||
|
|
||||||
@ApiModelProperty(name = "主键", value = "主键")
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/** 规格名称 */
|
/** 规格名称 */
|
||||||
|
|
||||||
@ApiModelProperty(name = "规格名称", value = "规格名称")
|
@ApiModelProperty(name = "规格名称", value = "规格名称")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
/** 规格状态 */
|
/** 规格状态 */
|
||||||
|
|
||||||
@ApiModelProperty(name = "规格状态", value = "规格状态")
|
@ApiModelProperty(name = "规格状态", value = "规格状态")
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 规格属性集合
|
||||||
|
*/
|
||||||
|
private List<RuleAttrAddModel> ruleAttrList;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,59 @@
|
||||||
|
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 lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author DongZl
|
||||||
|
* @description: 属性组列表对象
|
||||||
|
* @Date 2024-2-28 下午 04:15
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class AttributeGroupPageResp extends BaseEntity {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 属性组编号 */
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/** 组名称 */
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/** 状态 */
|
||||||
|
private String states;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 属性对象集合
|
||||||
|
*/
|
||||||
|
private List<AttributeInfo> attributeInfoList;
|
||||||
|
|
||||||
|
public static AttributeGroupPageResp groupBuild (AttributeGroup attributeGroup, List<AttributeInfo> attributeInfos) {
|
||||||
|
return AttributeGroupPageResp.builder()
|
||||||
|
.id(attributeGroup.getId())
|
||||||
|
.name(attributeGroup.getName())
|
||||||
|
.states(attributeGroup.getStates())
|
||||||
|
.attributeInfoList(attributeInfos)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
public static AttributeGroupPageResp groupFunBuild (AttributeGroup attributeGroup, Function<Long,List<AttributeInfo> > function) {
|
||||||
|
return AttributeGroupPageResp.builder()
|
||||||
|
.id(attributeGroup.getId())
|
||||||
|
.name(attributeGroup.getName())
|
||||||
|
.states(attributeGroup.getStates())
|
||||||
|
.attributeInfoList(function.apply(attributeGroup.getId()))
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
package com.muyu.product.domain.resp;
|
||||||
|
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
import com.muyu.product.domain.model.TemplateAttributeGroupModel;
|
||||||
|
import com.muyu.product.domain.model.TemplateAttributeModel;
|
||||||
|
import lombok.*;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author DongZl
|
||||||
|
* @description: 商品类别公共元素
|
||||||
|
* @Date 2024-3-6 下午 02:25
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class CategoryCommonElementResp extends BaseEntity {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 共有属性组
|
||||||
|
*/
|
||||||
|
private List<TemplateAttributeGroupModel> templateAttributeGroupList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 共有属性
|
||||||
|
*/
|
||||||
|
private List<TemplateAttributeModel> templateAttributeList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自有属性(所有未包含属性)
|
||||||
|
*/
|
||||||
|
private List<TemplateAttributeModel> attributeList;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
package com.muyu.product.domain.resp;
|
||||||
|
|
||||||
|
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 java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author DongZl
|
||||||
|
* @description: 类别父通用元素
|
||||||
|
* @Date 2024-3-1 上午 11:02
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class CategoryParentCommonElementResp {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 属性集合
|
||||||
|
*/
|
||||||
|
private List<AttributeInfo> attributeInfoList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 属性组集合
|
||||||
|
*/
|
||||||
|
private List<AttributeGroup> attributeGroupList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 品牌集合
|
||||||
|
*/
|
||||||
|
private List<BrandInfo> brandInfoList;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author DongZl
|
||||||
|
* @description: 规格返回结果集
|
||||||
|
* @Date 2024-3-4 下午 04:08
|
||||||
|
*/
|
||||||
|
@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,8 @@ package com.muyu.product.controller;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import com.muyu.product.domain.model.AttributeGroupSaveModel;
|
||||||
|
import com.muyu.product.domain.resp.AttributeGroupPageResp;
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
@ -45,10 +47,11 @@ public class AttributeGroupController extends BaseController {
|
||||||
@ApiOperation("获取属性组列表")
|
@ApiOperation("获取属性组列表")
|
||||||
@RequiresPermissions("product:attributeGroup:list")
|
@RequiresPermissions("product:attributeGroup:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public Result<TableDataInfo<AttributeGroup>> list(AttributeGroupQueryReq attributeGroupQueryReq) {
|
public Result<TableDataInfo<AttributeGroupPageResp>> list(AttributeGroupQueryReq attributeGroupQueryReq) {
|
||||||
startPage();
|
startPage();
|
||||||
List<AttributeGroup> list = attributeGroupService.list(AttributeGroup.queryBuild(attributeGroupQueryReq));
|
TableDataInfo<AttributeGroupPageResp> tableDataInfo =
|
||||||
return getDataTable(list);
|
attributeGroupService.page(AttributeGroup.queryBuild(attributeGroupQueryReq));
|
||||||
|
return Result.success(tableDataInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -83,7 +86,9 @@ public class AttributeGroupController extends BaseController {
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@ApiOperation("新增属性组")
|
@ApiOperation("新增属性组")
|
||||||
public Result<String> add(@RequestBody AttributeGroupSaveReq attributeGroupSaveReq) {
|
public Result<String> add(@RequestBody AttributeGroupSaveReq attributeGroupSaveReq) {
|
||||||
return toAjax(attributeGroupService.save(AttributeGroup.saveBuild(attributeGroupSaveReq)));
|
return toAjax(
|
||||||
|
attributeGroupService.save(AttributeGroupSaveModel.saveReqBuild(attributeGroupSaveReq))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -102,7 +107,7 @@ public class AttributeGroupController extends BaseController {
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("product:attributeGroup:remove")
|
@RequiresPermissions("product:attributeGroup:remove")
|
||||||
@Log(title = "属性组", businessType = BusinessType.DELETE)
|
@Log(title = "属性组", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{ids}")
|
@DeleteMapping("/{ids}")
|
||||||
@ApiOperation("删除属性组")
|
@ApiOperation("删除属性组")
|
||||||
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = String.class, example = "1,2,3,4")
|
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = String.class, example = "1,2,3,4")
|
||||||
public Result<String> remove(@PathVariable List<Long> ids) {
|
public Result<String> remove(@PathVariable List<Long> ids) {
|
||||||
|
|
|
@ -36,6 +36,8 @@ import com.muyu.common.core.web.page.TableDataInfo;
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/attribute")
|
@RequestMapping("/attribute")
|
||||||
public class AttributeInfoController extends BaseController {
|
public class AttributeInfoController extends BaseController {
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private AttributeInfoService attributeInfoService;
|
private AttributeInfoService attributeInfoService;
|
||||||
|
|
||||||
|
@ -83,7 +85,8 @@ public class AttributeInfoController extends BaseController {
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@ApiOperation("新增商品属性")
|
@ApiOperation("新增商品属性")
|
||||||
public Result<String> add(@RequestBody AttributeInfoSaveReq attributeInfoSaveReq) {
|
public Result<String> add(@RequestBody AttributeInfoSaveReq attributeInfoSaveReq) {
|
||||||
return toAjax(attributeInfoService.save(AttributeInfo.saveBuild(attributeInfoSaveReq)));
|
AttributeInfo attributeInfo = AttributeInfo.saveBuild(attributeInfoSaveReq);
|
||||||
|
return attributeInfoService.save(attributeInfo) ? success(attributeInfo.getId()) : error();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.product.controller;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import com.muyu.common.core.text.Convert;
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
@ -45,10 +46,13 @@ public class BrandInfoController extends BaseController {
|
||||||
@ApiOperation("获取品牌信息列表")
|
@ApiOperation("获取品牌信息列表")
|
||||||
@RequiresPermissions("product:brand:list")
|
@RequiresPermissions("product:brand:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public Result<TableDataInfo<BrandInfo>> list(BrandInfoQueryReq brandInfoQueryReq) {
|
public Result list(BrandInfoQueryReq brandInfoQueryReq) {
|
||||||
startPage();
|
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));
|
List<BrandInfo> list = brandInfoService.list(BrandInfo.queryBuild(brandInfoQueryReq));
|
||||||
return getDataTable(list);
|
return isPage ? getDataTable(list) : Result.success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,8 +1,16 @@
|
||||||
package com.muyu.product.controller;
|
package com.muyu.product.controller;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.function.Supplier;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import com.muyu.common.security.utils.SecurityUtils;
|
||||||
|
import com.muyu.product.domain.AttributeGroup;
|
||||||
|
import com.muyu.product.domain.AttributeInfo;
|
||||||
|
import com.muyu.product.domain.BrandInfo;
|
||||||
|
import com.muyu.product.domain.model.CategoryInfoSaveModel;
|
||||||
|
import com.muyu.product.domain.resp.CategoryCommonElementResp;
|
||||||
|
import com.muyu.product.domain.resp.CategoryParentCommonElementResp;
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
@ -73,6 +81,17 @@ public class CategoryInfoController extends BaseController {
|
||||||
return Result.success(categoryInfoService.getById(id));
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增品类信息
|
* 新增品类信息
|
||||||
*/
|
*/
|
||||||
|
@ -81,7 +100,9 @@ public class CategoryInfoController extends BaseController {
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@ApiOperation("新增品类信息")
|
@ApiOperation("新增品类信息")
|
||||||
public Result<String> add(@RequestBody CategoryInfoSaveReq categoryInfoSaveReq) {
|
public Result<String> add(@RequestBody CategoryInfoSaveReq categoryInfoSaveReq) {
|
||||||
return toAjax(categoryInfoService.save(CategoryInfo.saveBuild(categoryInfoSaveReq)));
|
return toAjax(categoryInfoService.save(
|
||||||
|
CategoryInfoSaveModel.saveBuild(categoryInfoSaveReq, SecurityUtils::getUsername)
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -106,4 +127,18 @@ public class CategoryInfoController extends BaseController {
|
||||||
public Result<String> remove(@PathVariable List<Long> ids) {
|
public Result<String> remove(@PathVariable List<Long> ids) {
|
||||||
return toAjax(categoryInfoService.removeBatchByIds(ids));
|
return toAjax(categoryInfoService.removeBatchByIds(ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过品类ID获取父级以上的属性、属性组、品牌集合
|
||||||
|
* @param categoryId 品类ID
|
||||||
|
* @return 父级以上的属性、属性组、品牌集合
|
||||||
|
*/
|
||||||
|
@GetMapping("/parentCommonElement/{categoryId}")
|
||||||
|
@ApiOperation("通过品类ID获取父级以上的属性集合")
|
||||||
|
@ApiImplicitParam(name = "categoryId", value = "categoryId", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class, example = "1")
|
||||||
|
public Result<CategoryParentCommonElementResp> parentCommonElement(
|
||||||
|
@PathVariable(value = "categoryId") Long categoryId
|
||||||
|
) {
|
||||||
|
return Result.success(categoryInfoService.parentCommonElement(categoryId));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,9 @@ package com.muyu.product.controller;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import com.muyu.common.core.text.Convert;
|
||||||
|
import com.muyu.product.domain.model.RuleInfoAddModel;
|
||||||
|
import com.muyu.product.domain.resp.RuleInfoResp;
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
@ -45,10 +48,13 @@ public class RuleInfoController extends BaseController {
|
||||||
@ApiOperation("获取商品规格列表")
|
@ApiOperation("获取商品规格列表")
|
||||||
@RequiresPermissions("product:rule:list")
|
@RequiresPermissions("product:rule:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public Result<TableDataInfo<RuleInfo>> list(RuleInfoQueryReq ruleInfoQueryReq) {
|
public Result list(RuleInfoQueryReq ruleInfoQueryReq) {
|
||||||
startPage();
|
boolean isPage = ruleInfoQueryReq.getParams().get("isPage") == null || Convert.toBool(ruleInfoQueryReq.getParams().get("isPage"), true);
|
||||||
List<RuleInfo> list = ruleInfoService.list(RuleInfo.queryBuild(ruleInfoQueryReq));
|
if (isPage){
|
||||||
return getDataTable(list);
|
startPage();
|
||||||
|
}
|
||||||
|
TableDataInfo<RuleInfoResp> tableDataInfo = ruleInfoService.queryList(ruleInfoQueryReq);
|
||||||
|
return isPage ? Result.success(tableDataInfo) : Result.success(tableDataInfo.getRows());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -83,7 +89,7 @@ public class RuleInfoController extends BaseController {
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@ApiOperation("新增商品规格")
|
@ApiOperation("新增商品规格")
|
||||||
public Result<String> add(@RequestBody RuleInfoSaveReq ruleInfoSaveReq) {
|
public Result<String> add(@RequestBody RuleInfoSaveReq ruleInfoSaveReq) {
|
||||||
return toAjax(ruleInfoService.save(RuleInfo.saveBuild(ruleInfoSaveReq)));
|
return toAjax(ruleInfoService.save(RuleInfoAddModel.saveReqBuild(ruleInfoSaveReq)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,8 +1,13 @@
|
||||||
package com.muyu.product.service;
|
package com.muyu.product.service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.muyu.common.core.web.page.TableDataInfo;
|
||||||
import com.muyu.product.domain.AttributeGroup;
|
import com.muyu.product.domain.AttributeGroup;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
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.resp.AttributeGroupPageResp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 属性组Service接口
|
* 属性组Service接口
|
||||||
|
@ -11,6 +16,14 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
* @date 2024-02-27
|
* @date 2024-02-27
|
||||||
*/
|
*/
|
||||||
public interface AttributeGroupService extends IService<AttributeGroup> {
|
public interface AttributeGroupService extends IService<AttributeGroup> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询
|
||||||
|
* @param attributeGroup 分组对象
|
||||||
|
* @return 返回结果
|
||||||
|
*/
|
||||||
|
public TableDataInfo<AttributeGroupPageResp> page(AttributeGroup attributeGroup);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询属性组列表
|
* 查询属性组列表
|
||||||
*
|
*
|
||||||
|
@ -19,4 +32,11 @@ public interface AttributeGroupService extends IService<AttributeGroup> {
|
||||||
*/
|
*/
|
||||||
public List<AttributeGroup> list(AttributeGroup attributeGroup);
|
public List<AttributeGroup> list(AttributeGroup attributeGroup);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存
|
||||||
|
* @param attributeGroupSaveModel 属性组保存模型
|
||||||
|
* @return 是否成功
|
||||||
|
*/
|
||||||
|
public Boolean save(AttributeGroupSaveModel attributeGroupSaveModel);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,4 +19,10 @@ public interface AttributeInfoService extends IService<AttributeInfo> {
|
||||||
*/
|
*/
|
||||||
public List<AttributeInfo> list(AttributeInfo attributeInfo);
|
public List<AttributeInfo> list(AttributeInfo attributeInfo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过groupId查询属性集合
|
||||||
|
* @param groupId 属性组Id
|
||||||
|
* @return 属性集合
|
||||||
|
*/
|
||||||
|
public List<AttributeInfo> attributeListByGroupId(Long groupId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,15 @@
|
||||||
package com.muyu.product.service;
|
package com.muyu.product.service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
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.muyu.product.domain.CategoryInfo;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.muyu.product.domain.model.CategoryInfoSaveModel;
|
||||||
|
import com.muyu.product.domain.resp.CategoryCommonElementResp;
|
||||||
|
import com.muyu.product.domain.resp.CategoryParentCommonElementResp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 品类信息Service接口
|
* 品类信息Service接口
|
||||||
|
@ -19,4 +26,45 @@ public interface CategoryInfoService extends IService<CategoryInfo> {
|
||||||
*/
|
*/
|
||||||
public List<CategoryInfo> list(CategoryInfo categoryInfo);
|
public List<CategoryInfo> list(CategoryInfo categoryInfo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存
|
||||||
|
* @param categoryInfoSaveModel 保存品类模型
|
||||||
|
* @return 是否成功
|
||||||
|
*/
|
||||||
|
public boolean save(CategoryInfoSaveModel categoryInfoSaveModel);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过品类ID获取父级以上的属性组集合
|
||||||
|
* @param categoryId 品类ID
|
||||||
|
* @return 父级以上的属性组集合
|
||||||
|
*/
|
||||||
|
List<AttributeGroup> getAttributeGroup (Long categoryId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过品类ID获取父级以上的品牌集合
|
||||||
|
* @param categoryId 品类ID
|
||||||
|
* @return 父级以上的品牌集合
|
||||||
|
*/
|
||||||
|
List<BrandInfo> getBrand (Long categoryId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过品类ID获取父级以上的属性集合
|
||||||
|
* @param categoryId 品类ID
|
||||||
|
* @return 父级以上的属性集合
|
||||||
|
*/
|
||||||
|
List<AttributeInfo> getAttribute (Long categoryId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过品类ID获取父级以上的属性、属性组、品牌集合
|
||||||
|
* @param categoryId 品类ID
|
||||||
|
* @return 父级以上的属性、属性组、品牌集合
|
||||||
|
*/
|
||||||
|
CategoryParentCommonElementResp parentCommonElement (Long categoryId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过品类ID获取品类共有属性
|
||||||
|
* @param cateGoryId 品类ID
|
||||||
|
* @return 品类共有属性
|
||||||
|
*/
|
||||||
|
CategoryCommonElementResp getTemplateAttributeByCateGoryId (Long cateGoryId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,13 @@
|
||||||
package com.muyu.product.service;
|
package com.muyu.product.service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.muyu.common.core.web.page.TableDataInfo;
|
||||||
import com.muyu.product.domain.RuleInfo;
|
import com.muyu.product.domain.RuleInfo;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
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接口
|
* 商品规格Service接口
|
||||||
|
@ -19,4 +24,12 @@ public interface RuleInfoService extends IService<RuleInfo> {
|
||||||
*/
|
*/
|
||||||
public List<RuleInfo> list(RuleInfo ruleInfo);
|
public List<RuleInfo> list(RuleInfo ruleInfo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加规格信息
|
||||||
|
* @param ruleInfoAddModel 规格添加模型
|
||||||
|
* @return 时候成功
|
||||||
|
*/
|
||||||
|
public boolean save(RuleInfoAddModel ruleInfoAddModel);
|
||||||
|
|
||||||
|
TableDataInfo<RuleInfoResp> queryList (RuleInfoQueryReq ruleInfoQueryReq);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,10 +40,6 @@ public class AsAttributeGroupServiceImpl extends ServiceImpl<AsAttributeGroupMap
|
||||||
queryWrapper.eq(AsAttributeGroup::getAttributeId, asAttributeGroup.getAttributeId());
|
queryWrapper.eq(AsAttributeGroup::getAttributeId, asAttributeGroup.getAttributeId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return list(queryWrapper);
|
return list(queryWrapper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,27 @@
|
||||||
package com.muyu.product.service.impl;
|
package com.muyu.product.service.impl;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.muyu.common.core.utils.ObjUtils;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import com.muyu.product.mapper.AttributeGroupMapper;
|
|
||||||
import com.muyu.product.domain.AttributeGroup;
|
|
||||||
import com.muyu.product.service.AttributeGroupService;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import com.muyu.common.core.utils.ObjUtils;
|
||||||
|
import com.muyu.common.core.web.page.TableDataInfo;
|
||||||
|
import com.muyu.product.domain.AsAttributeGroup;
|
||||||
|
import com.muyu.product.domain.AttributeGroup;
|
||||||
|
import com.muyu.product.domain.AttributeInfo;
|
||||||
|
import com.muyu.product.domain.model.AttributeGroupSaveModel;
|
||||||
|
import com.muyu.product.domain.resp.AttributeGroupPageResp;
|
||||||
|
import com.muyu.product.mapper.AttributeGroupMapper;
|
||||||
|
import com.muyu.product.service.AsAttributeGroupService;
|
||||||
|
import com.muyu.product.service.AttributeGroupService;
|
||||||
|
import com.muyu.product.service.AttributeInfoService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 属性组Service业务层处理
|
* 属性组Service业务层处理
|
||||||
|
@ -19,27 +31,80 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class AttributeGroupServiceImpl extends ServiceImpl<AttributeGroupMapper, AttributeGroup> implements AttributeGroupService {
|
public class AttributeGroupServiceImpl extends ServiceImpl<AttributeGroupMapper, AttributeGroup> implements AttributeGroupService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AsAttributeGroupService attributeGroupService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AttributeInfoService attributeInfoService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询
|
||||||
|
*
|
||||||
|
* @param attributeGroupQuery 分组对象
|
||||||
|
*
|
||||||
|
* @return 返回结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public TableDataInfo<AttributeGroupPageResp> page (AttributeGroup attributeGroupQuery) {
|
||||||
|
List<AttributeGroup> list = this.list(attributeGroupQuery);
|
||||||
|
List<AttributeGroupPageResp> pageRespList = list.stream()
|
||||||
|
.map(attributeGroup ->
|
||||||
|
AttributeGroupPageResp.groupFunBuild(
|
||||||
|
attributeGroup, groupId -> attributeInfoService.attributeListByGroupId(groupId)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.toList();
|
||||||
|
return TableDataInfo.<AttributeGroupPageResp>builder()
|
||||||
|
.total(new PageInfo(list).getTotal())
|
||||||
|
.rows(pageRespList)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询属性组列表
|
* 查询属性组列表
|
||||||
*
|
*
|
||||||
* @param attributeGroup 属性组
|
* @param attributeGroup 属性组
|
||||||
|
*
|
||||||
* @return 属性组
|
* @return 属性组
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<AttributeGroup> list(AttributeGroup attributeGroup) {
|
public List<AttributeGroup> list (AttributeGroup attributeGroup) {
|
||||||
LambdaQueryWrapper<AttributeGroup> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<AttributeGroup> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
|
||||||
|
if (ObjUtils.notNull(attributeGroup.getName())) {
|
||||||
if (ObjUtils.notNull(attributeGroup.getName())){
|
|
||||||
queryWrapper.like(AttributeGroup::getName, attributeGroup.getName());
|
queryWrapper.like(AttributeGroup::getName, attributeGroup.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ObjUtils.notNull(attributeGroup.getStates())){
|
if (ObjUtils.notNull(attributeGroup.getStates())) {
|
||||||
queryWrapper.eq(AttributeGroup::getStates, attributeGroup.getStates());
|
queryWrapper.eq(AttributeGroup::getStates, attributeGroup.getStates());
|
||||||
}
|
}
|
||||||
|
|
||||||
return list(queryWrapper);
|
return list(queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存
|
||||||
|
*
|
||||||
|
* @param attributeGroupSaveModel 属性组保存模型
|
||||||
|
*
|
||||||
|
* @return 是否成功
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public Boolean save (AttributeGroupSaveModel attributeGroupSaveModel) {
|
||||||
|
AttributeGroup attributeGroup = attributeGroupSaveModel.buildAttributeGroup();
|
||||||
|
boolean save = this.save(attributeGroup);
|
||||||
|
// 处理属性ID
|
||||||
|
Long attributeGroupId = attributeGroup.getId();
|
||||||
|
List<Long> attributeIdList = attributeGroupSaveModel.getAttributeIdList();
|
||||||
|
|
||||||
|
attributeGroupService.saveBatch(
|
||||||
|
attributeIdList.stream()
|
||||||
|
.map(attributeId -> AsAttributeGroup.buildGroup(attributeGroupId, attributeId))
|
||||||
|
.toList()
|
||||||
|
);
|
||||||
|
return save;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,12 @@ package com.muyu.product.service.impl;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.muyu.common.core.exception.ServiceException;
|
||||||
import com.muyu.common.core.utils.ObjUtils;
|
import com.muyu.common.core.utils.ObjUtils;
|
||||||
|
import com.muyu.product.domain.AsAttributeGroup;
|
||||||
|
import com.muyu.product.service.AsAttributeGroupService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.muyu.product.mapper.AttributeInfoMapper;
|
import com.muyu.product.mapper.AttributeInfoMapper;
|
||||||
import com.muyu.product.domain.AttributeInfo;
|
import com.muyu.product.domain.AttributeInfo;
|
||||||
|
@ -21,6 +25,9 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
@Service
|
@Service
|
||||||
public class AttributeInfoServiceImpl extends ServiceImpl<AttributeInfoMapper, AttributeInfo> implements AttributeInfoService {
|
public class AttributeInfoServiceImpl extends ServiceImpl<AttributeInfoMapper, AttributeInfo> implements AttributeInfoService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AsAttributeGroupService asAttributeGroupService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询商品属性列表
|
* 查询商品属性列表
|
||||||
*
|
*
|
||||||
|
@ -36,6 +43,35 @@ public class AttributeInfoServiceImpl extends ServiceImpl<AttributeInfoMapper, A
|
||||||
queryWrapper.like(AttributeInfo::getName, attributeInfo.getName());
|
queryWrapper.like(AttributeInfo::getName, attributeInfo.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ObjUtils.notNull(attributeInfo.getCode())){
|
||||||
|
queryWrapper.like(AttributeInfo::getCode, attributeInfo.getCode());
|
||||||
|
}
|
||||||
|
|
||||||
return list(queryWrapper);
|
return list(queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过groupId查询属性集合
|
||||||
|
*
|
||||||
|
* @param groupId 属性组Id
|
||||||
|
*
|
||||||
|
* @return 属性集合
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<AttributeInfo> attributeListByGroupId (Long groupId) {
|
||||||
|
if (groupId == null){
|
||||||
|
throw new ServiceException("查询商品属性组,属性组ID不可为空");
|
||||||
|
}
|
||||||
|
LambdaQueryWrapper<AsAttributeGroup> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(AsAttributeGroup::getGroupId, groupId);
|
||||||
|
List<Long> list = asAttributeGroupService.list(queryWrapper).stream()
|
||||||
|
.map(AsAttributeGroup::getAttributeId)
|
||||||
|
.toList();
|
||||||
|
if (list == null || list.isEmpty()){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return this.listByIds(
|
||||||
|
list
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class BrandInfoServiceImpl extends ServiceImpl<BrandInfoMapper, BrandInfo
|
||||||
|
|
||||||
|
|
||||||
if (ObjUtils.notNull(brandInfo.getNam())){
|
if (ObjUtils.notNull(brandInfo.getNam())){
|
||||||
queryWrapper.eq(BrandInfo::getNam, brandInfo.getNam());
|
queryWrapper.like(BrandInfo::getNam, brandInfo.getNam());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ObjUtils.notNull(brandInfo.getLogo())){
|
if (ObjUtils.notNull(brandInfo.getLogo())){
|
||||||
|
|
|
@ -1,15 +1,30 @@
|
||||||
package com.muyu.product.service.impl;
|
package com.muyu.product.service.impl;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.muyu.common.core.utils.ObjUtils;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import com.muyu.product.mapper.CategoryInfoMapper;
|
|
||||||
import com.muyu.product.domain.CategoryInfo;
|
|
||||||
import com.muyu.product.service.CategoryInfoService;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
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.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.resp.CategoryCommonElementResp;
|
||||||
|
import com.muyu.product.domain.resp.CategoryParentCommonElementResp;
|
||||||
|
import com.muyu.product.mapper.CategoryInfoMapper;
|
||||||
|
import com.muyu.product.service.*;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 品类信息Service业务层处理
|
* 品类信息Service业务层处理
|
||||||
|
@ -19,43 +34,340 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, CategoryInfo> implements CategoryInfoService {
|
public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, CategoryInfo> implements CategoryInfoService {
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AsCategoryAttributeService asCategoryAttributeService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AsCategoryAttributeGroupService asCategoryAttributeGroupService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AsCategoryBrandService asCategoryBrandService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AsAttributeGroupService asAttributeGroupService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AttributeInfoService attributeInfoService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private BrandInfoService brandInfoService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AttributeGroupService attributeGroupService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询品类信息列表
|
* 查询品类信息列表
|
||||||
*
|
*
|
||||||
* @param categoryInfo 品类信息
|
* @param categoryInfo 品类信息
|
||||||
|
*
|
||||||
* @return 品类信息
|
* @return 品类信息
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<CategoryInfo> list(CategoryInfo categoryInfo) {
|
public List<CategoryInfo> list (CategoryInfo categoryInfo) {
|
||||||
LambdaQueryWrapper<CategoryInfo> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<CategoryInfo> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
|
||||||
|
|
||||||
if (ObjUtils.notNull(categoryInfo.getName())){
|
if (ObjUtils.notNull(categoryInfo.getName())) {
|
||||||
queryWrapper.like(CategoryInfo::getName, categoryInfo.getName());
|
queryWrapper.like(CategoryInfo::getName, categoryInfo.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ObjUtils.notNull(categoryInfo.getImage())){
|
if (ObjUtils.notNull(categoryInfo.getImage())) {
|
||||||
queryWrapper.eq(CategoryInfo::getImage, categoryInfo.getImage());
|
queryWrapper.eq(CategoryInfo::getImage, categoryInfo.getImage());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ObjUtils.notNull(categoryInfo.getParentId())){
|
if (ObjUtils.notNull(categoryInfo.getParentId())) {
|
||||||
queryWrapper.eq(CategoryInfo::getParentId, categoryInfo.getParentId());
|
queryWrapper.eq(CategoryInfo::getParentId, categoryInfo.getParentId());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ObjUtils.notNull(categoryInfo.getStart())){
|
if (ObjUtils.notNull(categoryInfo.getStart())) {
|
||||||
queryWrapper.eq(CategoryInfo::getStart, categoryInfo.getStart());
|
queryWrapper.eq(CategoryInfo::getStart, categoryInfo.getStart());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ObjUtils.notNull(categoryInfo.getIntroduction())){
|
if (ObjUtils.notNull(categoryInfo.getIntroduction())) {
|
||||||
queryWrapper.eq(CategoryInfo::getIntroduction, categoryInfo.getIntroduction());
|
queryWrapper.eq(CategoryInfo::getIntroduction, categoryInfo.getIntroduction());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return list(queryWrapper);
|
return list(queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
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()) {
|
||||||
|
asCategoryAttributeService.saveBatch(
|
||||||
|
attributeIdList.stream()
|
||||||
|
.map(attributeId -> AsCategoryAttribute.categoryBuild(categoryInfoId, attributeId))
|
||||||
|
.toList()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
List<Long> attributeGroupIdList = categoryInfoSaveModel.getAttributeGroupIdList();
|
||||||
|
if (attributeGroupIdList != null && !attributeGroupIdList.isEmpty()) {
|
||||||
|
asCategoryAttributeGroupService.saveBatch(
|
||||||
|
attributeGroupIdList.stream()
|
||||||
|
.map(attributeGroupId -> AsCategoryAttributeGroup.categoryBuild(categoryInfoId, attributeGroupId))
|
||||||
|
.toList()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
List<Long> brandIdList = categoryInfoSaveModel.getBrandIdList();
|
||||||
|
if (brandIdList != null && !brandIdList.isEmpty()) {
|
||||||
|
asCategoryBrandService.saveBatch(
|
||||||
|
brandIdList.stream()
|
||||||
|
.map(brandId -> AsCategoryBrand.categoryBuild(categoryInfoId, brandId))
|
||||||
|
.toList()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return save;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过品类ID获取父级以上的属性组集合
|
||||||
|
*
|
||||||
|
* @param categoryId 品类ID
|
||||||
|
*
|
||||||
|
* @return 父级以上的属性组集合
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<AttributeGroup> getAttributeGroup (Long categoryId) {
|
||||||
|
List<AttributeGroup> attributeGroupList = new ArrayList<>();
|
||||||
|
LambdaQueryWrapper<AsCategoryAttributeGroup> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(AsCategoryAttributeGroup::getCategoryId, categoryId);
|
||||||
|
List<AsCategoryAttributeGroup> asCategoryAttributeGroupList = asCategoryAttributeGroupService.list(queryWrapper);
|
||||||
|
if (asCategoryAttributeGroupList != null && !asCategoryAttributeGroupList.isEmpty()) {
|
||||||
|
List<Long> attributeGroupIdList = asCategoryAttributeGroupList.stream()
|
||||||
|
.map(AsCategoryAttributeGroup::getAttributeGroupId)
|
||||||
|
.toList();
|
||||||
|
attributeGroupList.addAll(attributeGroupService.listByIds(attributeGroupIdList));
|
||||||
|
}
|
||||||
|
CategoryInfo categoryInfo = this.getById(categoryId);
|
||||||
|
if (categoryInfo.getParentId() != 0) {
|
||||||
|
if (attributeGroupList.isEmpty()) {
|
||||||
|
attributeGroupList.addAll(getAttributeGroup(categoryInfo.getParentId()));
|
||||||
|
} else {
|
||||||
|
List<AttributeGroup> attributeGroups = getAttributeGroup(categoryInfo.getParentId());
|
||||||
|
attributeGroups.forEach(attributeGroup -> {
|
||||||
|
if (!attributeGroupList.contains(attributeGroup)) {
|
||||||
|
attributeGroupList.add(attributeGroup);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return attributeGroupList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过品类ID获取父级以上的品牌集合
|
||||||
|
*
|
||||||
|
* @param categoryId 品类ID
|
||||||
|
*
|
||||||
|
* @return 父级以上的品牌集合
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<BrandInfo> getBrand (Long categoryId) {
|
||||||
|
List<BrandInfo> brandInfoList = new ArrayList<>();
|
||||||
|
LambdaQueryWrapper<AsCategoryBrand> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(AsCategoryBrand::getCategoryId, categoryId);
|
||||||
|
List<AsCategoryBrand> asCategoryBrandList = asCategoryBrandService.list(queryWrapper);
|
||||||
|
if (asCategoryBrandList != null && !asCategoryBrandList.isEmpty()) {
|
||||||
|
List<Long> brandIdList = asCategoryBrandList.stream()
|
||||||
|
.map(AsCategoryBrand::getBrandId)
|
||||||
|
.toList();
|
||||||
|
brandInfoList.addAll(brandInfoService.listByIds(brandIdList));
|
||||||
|
}
|
||||||
|
CategoryInfo categoryInfo = this.getById(categoryId);
|
||||||
|
if (categoryInfo.getParentId() != 0) {
|
||||||
|
if (brandInfoList.isEmpty()) {
|
||||||
|
brandInfoList.addAll(getBrand(categoryInfo.getParentId()));
|
||||||
|
} else {
|
||||||
|
List<BrandInfo> brandInfos = getBrand(categoryInfo.getParentId());
|
||||||
|
brandInfos.forEach(brandInfo -> {
|
||||||
|
if (!brandInfoList.contains(brandInfo)) {
|
||||||
|
brandInfoList.add(brandInfo);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return brandInfoList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过品类ID获取父级以上的属性集合
|
||||||
|
*
|
||||||
|
* @param categoryId 品类ID
|
||||||
|
*
|
||||||
|
* @return 父级以上的属性集合
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<AttributeInfo> getAttribute (Long categoryId) {
|
||||||
|
List<AttributeInfo> attributeInfoList = new ArrayList<>();
|
||||||
|
LambdaQueryWrapper<AsCategoryAttribute> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(AsCategoryAttribute::getCategoryId, categoryId);
|
||||||
|
List<AsCategoryAttribute> asCategoryAttributeList = asCategoryAttributeService.list(queryWrapper);
|
||||||
|
if (asCategoryAttributeList != null && !asCategoryAttributeList.isEmpty()) {
|
||||||
|
List<Long> attributeIdList = asCategoryAttributeList.stream()
|
||||||
|
.map(AsCategoryAttribute::getAttributeId)
|
||||||
|
.toList();
|
||||||
|
attributeInfoList.addAll(attributeInfoService.listByIds(attributeIdList));
|
||||||
|
}
|
||||||
|
CategoryInfo categoryInfo = this.getById(categoryId);
|
||||||
|
if (categoryInfo.getParentId() != 0) {
|
||||||
|
if (attributeInfoList.isEmpty()) {
|
||||||
|
attributeInfoList.addAll(getAttribute(categoryInfo.getParentId()));
|
||||||
|
} else {
|
||||||
|
List<AttributeInfo> attributeInfos = getAttribute(categoryInfo.getParentId());
|
||||||
|
attributeInfos.forEach(attributeInfoQuery -> {
|
||||||
|
if (!attributeInfoList.contains(attributeInfoQuery)) {
|
||||||
|
attributeInfoList.add(attributeInfoQuery);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return attributeInfoList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public <T, AS> List<T> getCommon (Long categoryId, IService<AS> iService, IService<T> bsiService) {
|
||||||
|
List<T> list = new ArrayList();
|
||||||
|
QueryWrapper<AS> asQueryWrapper = new QueryWrapper<>();
|
||||||
|
asQueryWrapper.eq("category_id", categoryId);
|
||||||
|
List<AS> asList = iService.list(asQueryWrapper);
|
||||||
|
if (asList != null && !asList.isEmpty()) {
|
||||||
|
List<Long> baseIdList = asList.stream()
|
||||||
|
.map(as -> {
|
||||||
|
if (as instanceof CategoryBase categoryBase) {
|
||||||
|
return categoryBase.getBaseId();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
})
|
||||||
|
.toList();
|
||||||
|
list.addAll(bsiService.listByIds(baseIdList));
|
||||||
|
}
|
||||||
|
CategoryInfo categoryInfo = this.getById(categoryId);
|
||||||
|
if (categoryInfo.getParentId() != 0) {
|
||||||
|
if (list.isEmpty()) {
|
||||||
|
list.addAll(getCommon(categoryInfo.getParentId(), iService, bsiService));
|
||||||
|
} else {
|
||||||
|
List<T> commonList = getCommon(categoryInfo.getParentId(), iService, bsiService);
|
||||||
|
commonList.forEach(common -> {
|
||||||
|
if (!list.contains(common)) {
|
||||||
|
list.add(common);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过品类ID获取父级以上的属性、属性组、品牌集合
|
||||||
|
*
|
||||||
|
* @param categoryId 品类ID
|
||||||
|
*
|
||||||
|
* @return 父级以上的属性、属性组、品牌集合
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public CategoryParentCommonElementResp parentCommonElement (Long categoryId) {
|
||||||
|
return CategoryParentCommonElementResp.builder()
|
||||||
|
.attributeInfoList(getCommon(categoryId, asCategoryAttributeService, attributeInfoService))
|
||||||
|
.attributeGroupList(getCommon(categoryId, asCategoryAttributeGroupService, attributeGroupService))
|
||||||
|
.brandInfoList(getCommon(categoryId, asCategoryBrandService, brandInfoService))
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getParentIdListByCateGoryId(List<Long> parentIdList, Long cateGoryId){
|
||||||
|
if (cateGoryId.equals(0L)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
CategoryInfo categoryInfo = this.getById(cateGoryId);
|
||||||
|
parentIdList.add(categoryInfo.getId());
|
||||||
|
getParentIdListByCateGoryId(parentIdList, categoryInfo.getParentId());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过品类ID获取品类共有属性
|
||||||
|
*
|
||||||
|
* @param cateGoryId 品类ID
|
||||||
|
*
|
||||||
|
* @return 品类共有属性
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public CategoryCommonElementResp getTemplateAttributeByCateGoryId (Long cateGoryId) {
|
||||||
|
List<Long> cateGoryIdList = new ArrayList<>();
|
||||||
|
getParentIdListByCateGoryId(cateGoryIdList, cateGoryId);
|
||||||
|
// 取出和品类相关联的属性组关系 - 中间表
|
||||||
|
LambdaQueryWrapper<AsCategoryAttributeGroup> asCategoryAttributeGroupLambdaQueryWrapper = new LambdaQueryWrapper<>(){{
|
||||||
|
in(AsCategoryAttributeGroup::getCategoryId, cateGoryIdList);
|
||||||
|
}};
|
||||||
|
List<AsCategoryAttributeGroup> categoryAttributeGroupList = asCategoryAttributeGroupService.list(asCategoryAttributeGroupLambdaQueryWrapper);
|
||||||
|
List<TemplateAttributeGroupModel> attributeGroupModelList = categoryAttributeGroupList.stream()
|
||||||
|
.map(asCategoryAttributeGroup -> TemplateAttributeGroupModel.attributeGroupBuild(
|
||||||
|
attributeGroupService.getById(asCategoryAttributeGroup.getAttributeGroupId()),
|
||||||
|
attributeGroupId -> {
|
||||||
|
LambdaQueryWrapper<AsAttributeGroup> asAttributeGroupQueryWrapper = new LambdaQueryWrapper<>() {{
|
||||||
|
eq(AsAttributeGroup::getGroupId, asCategoryAttributeGroup.getAttributeGroupId());
|
||||||
|
}};
|
||||||
|
List<Long> attributeIdList = asAttributeGroupService.list(asAttributeGroupQueryWrapper).stream()
|
||||||
|
.map(AsAttributeGroup::getAttributeId)
|
||||||
|
.toList();
|
||||||
|
if (attributeIdList.isEmpty()){
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
return attributeInfoService.listByIds(attributeIdList).stream()
|
||||||
|
.map(AttributeInfo::buildTemplateModel)
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
))
|
||||||
|
.filter(TemplateAttributeGroupModel::isEffective)
|
||||||
|
.toList();
|
||||||
|
// 查重集合
|
||||||
|
Set<Long> attributeIdSet = new HashSet<>();
|
||||||
|
// 获取组内所有的属性Id
|
||||||
|
if (!attributeGroupModelList.isEmpty()){
|
||||||
|
attributeIdSet.addAll(
|
||||||
|
attributeGroupModelList.stream()
|
||||||
|
.flatMap((Function<TemplateAttributeGroupModel, Stream<TemplateAttributeModel>>) templateAttributeGroupModel -> templateAttributeGroupModel.getAttributeList().stream())
|
||||||
|
.map(TemplateAttributeModel::getId)
|
||||||
|
.toList()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<TemplateAttributeModel> templateAttributeModelList = new ArrayList<>();
|
||||||
|
LambdaQueryWrapper<AsCategoryAttribute> categoryAttributeQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
categoryAttributeQueryWrapper.in(AsCategoryAttribute::getCategoryId, cateGoryIdList);
|
||||||
|
List<AsCategoryAttribute> asCategoryAttributeList = asCategoryAttributeService.list(categoryAttributeQueryWrapper);
|
||||||
|
if (asCategoryAttributeList != null && !asCategoryAttributeList.isEmpty()){
|
||||||
|
List<Long> templateAttributeIdList = asCategoryAttributeList.stream()
|
||||||
|
.map(AsCategoryAttribute::getAttributeId)
|
||||||
|
.filter(templateAttributeId -> !attributeIdSet.contains(templateAttributeId))
|
||||||
|
.toList();
|
||||||
|
templateAttributeModelList = attributeInfoService.listByIds(templateAttributeIdList).stream()
|
||||||
|
.map(AttributeInfo::buildTemplateModel)
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<TemplateAttributeModel> attributeModelList = new ArrayList<>();
|
||||||
|
|
||||||
|
if (!templateAttributeModelList.isEmpty()){
|
||||||
|
attributeIdSet.addAll(
|
||||||
|
templateAttributeModelList.stream().map(TemplateAttributeModel::getId).toList()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
LambdaQueryWrapper<AttributeInfo> attributeInfoLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
attributeInfoLambdaQueryWrapper.notIn(!attributeIdSet.isEmpty(), AttributeInfo::getId, attributeIdSet);
|
||||||
|
attributeModelList = attributeInfoService.list(attributeInfoLambdaQueryWrapper).stream().map(AttributeInfo::buildTemplateModel).toList();
|
||||||
|
|
||||||
|
return CategoryCommonElementResp.builder()
|
||||||
|
.templateAttributeGroupList(attributeGroupModelList)
|
||||||
|
.templateAttributeList(templateAttributeModelList)
|
||||||
|
.attributeList(attributeModelList)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,25 @@
|
||||||
package com.muyu.product.service.impl;
|
package com.muyu.product.service.impl;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import com.muyu.common.core.text.Convert;
|
||||||
import com.muyu.common.core.utils.ObjUtils;
|
import com.muyu.common.core.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 lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.muyu.product.mapper.RuleInfoMapper;
|
import com.muyu.product.mapper.RuleInfoMapper;
|
||||||
import com.muyu.product.domain.RuleInfo;
|
import com.muyu.product.domain.RuleInfo;
|
||||||
|
@ -21,6 +37,9 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
@Service
|
@Service
|
||||||
public class RuleInfoServiceImpl extends ServiceImpl<RuleInfoMapper, RuleInfo> implements RuleInfoService {
|
public class RuleInfoServiceImpl extends ServiceImpl<RuleInfoMapper, RuleInfo> implements RuleInfoService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RuleAttrInfoService ruleAttrInfoService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询商品规格列表
|
* 查询商品规格列表
|
||||||
*
|
*
|
||||||
|
@ -46,4 +65,41 @@ public class RuleInfoServiceImpl extends ServiceImpl<RuleInfoMapper, RuleInfo>
|
||||||
|
|
||||||
return list(queryWrapper);
|
return list(queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加规格信息
|
||||||
|
*
|
||||||
|
* @param ruleInfoAddModel 规格添加模型
|
||||||
|
*
|
||||||
|
* @return 时候成功
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean save (RuleInfoAddModel ruleInfoAddModel) {
|
||||||
|
RuleInfo ruleInfo = RuleInfo.addModelBuild(ruleInfoAddModel, SecurityUtils::getUsername);
|
||||||
|
boolean save = this.save(ruleInfo);
|
||||||
|
ruleAttrInfoService.saveBatch(
|
||||||
|
ruleInfoAddModel.getRuleAttrList().stream()
|
||||||
|
.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