商品公共属性
parent
59f3687b47
commit
842fa2d667
|
@ -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) + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -81,4 +82,12 @@ public class AttributeInfo extends BaseEntity {
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TemplateAttributeModel buildTemplateModel(){
|
||||||
|
return TemplateAttributeModel.builder()
|
||||||
|
.id(this.getId())
|
||||||
|
.code(this.getCode())
|
||||||
|
.name(this.getName())
|
||||||
|
.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,10 @@ 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.List;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 规格详情对象 rule_attr_info
|
* 规格详情对象 rule_attr_info
|
||||||
*
|
*
|
||||||
|
@ -86,4 +91,15 @@ public class RuleAttrInfo extends BaseEntity {
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static RuleAttrInfo addModelBuild(RuleAttrAddModel ruleAttrAddModel, Supplier<Long> ruleId, Supplier<String> create){
|
||||||
|
return RuleAttrInfo.builder()
|
||||||
|
.ruleId(ruleId.get())
|
||||||
|
.name(ruleAttrAddModel.getName())
|
||||||
|
.attrValue(String.join(",",ruleAttrAddModel.getValueList()))
|
||||||
|
.createBy(create.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,29 @@
|
||||||
|
package com.muyu.product.domain.demo;
|
||||||
|
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName DemoAttribute
|
||||||
|
* @Description 描述
|
||||||
|
* @Author Xin.Yao
|
||||||
|
* @Date 2024/3/6 14:19
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class DemoAttribute extends BaseEntity {
|
||||||
|
/**
|
||||||
|
* 属性id
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 属性编号
|
||||||
|
*/
|
||||||
|
private String code;
|
||||||
|
private String attributeName;
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.muyu.product.domain.demo;
|
||||||
|
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName DemoAttributeGroup
|
||||||
|
* @Description 描述
|
||||||
|
* @Author Xin.Yao
|
||||||
|
* @Date 2024/3/6 14:20
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class DemoAttributeGroup extends BaseEntity {
|
||||||
|
private String attributeGroupName;
|
||||||
|
private List<DemoAttribute> attributeList;
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
package com.muyu.product.domain.demo;
|
||||||
|
|
||||||
|
import com.alibaba.ttl.threadpool.agent.internal.javassist.bytecode.AttributeInfo;
|
||||||
|
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 java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName Project
|
||||||
|
* @Description 描述
|
||||||
|
* @Author Xin.Yao
|
||||||
|
* @Date 2024/3/6 14:13
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class Project extends BaseEntity {
|
||||||
|
/**
|
||||||
|
* 商品属性组集合
|
||||||
|
*/
|
||||||
|
private List<DemoAttributeGroup> attributeGroupList;
|
||||||
|
/**
|
||||||
|
* 商品属性集合
|
||||||
|
*/
|
||||||
|
private List<DemoAttribute> attributeList;
|
||||||
|
/**
|
||||||
|
* 自由属性集合
|
||||||
|
*/
|
||||||
|
private List<DemoAttribute> selfOwnedAttributeList;
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
package com.muyu.product.domain.model;
|
||||||
|
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
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 Xin.Yao
|
||||||
|
* @Date 2024/3/5 21:13
|
||||||
|
*/
|
||||||
|
@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,37 @@
|
||||||
|
package com.muyu.product.domain.model;
|
||||||
|
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
import com.muyu.product.domain.req.RuleInfoSaveReq;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName RuleInfoAddModel
|
||||||
|
* @Description 描述
|
||||||
|
* @Author Xin.Yao
|
||||||
|
* @Date 2024/3/5 21:14
|
||||||
|
*/
|
||||||
|
@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,42 @@
|
||||||
|
package com.muyu.product.domain.model;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ser.Serializers;
|
||||||
|
import com.muyu.common.core.utils.StringUtils;
|
||||||
|
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 TemplateAttributeGroupModel
|
||||||
|
* @Description 描述
|
||||||
|
* @Author Xin.Yao
|
||||||
|
* @Date 2024/3/7 17:26
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class TemplateAttributeGroupModel extends Serializers.Base {
|
||||||
|
private String groupName;
|
||||||
|
|
||||||
|
private List<TemplateAttributeModel> attributeList;
|
||||||
|
|
||||||
|
public boolean isEffective(){
|
||||||
|
return StringUtils.isNotEmpty(groupName) && attributeList != null && attributeList.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
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,25 @@
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName TemplateAttributeModel
|
||||||
|
* @Description 描述
|
||||||
|
* @Author Xin.Yao
|
||||||
|
* @Date 2024/3/7 17:27
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class TemplateAttributeModel extends BaseEntity {
|
||||||
|
private Long id;
|
||||||
|
private String name;
|
||||||
|
private String code;
|
||||||
|
}
|
|
@ -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
|
||||||
*
|
*
|
||||||
|
@ -38,4 +41,5 @@ public class RuleInfoSaveReq extends BaseEntity {
|
||||||
@ApiModelProperty(name = "规格状态", value = "规格状态")
|
@ApiModelProperty(name = "规格状态", value = "规格状态")
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
|
private List<RuleAttrAddModel> ruleAttrList;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
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 CategoryCommonElementResp
|
||||||
|
* @Description 描述
|
||||||
|
* @Author Xin.Yao
|
||||||
|
* @Date 2024/3/7 18:58
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class CategoryCommonElementResp extends BaseEntity {
|
||||||
|
private List<TemplateAttributeGroupModel> templateAttributeGroupList;
|
||||||
|
|
||||||
|
private List<TemplateAttributeModel> templateAttributeList;
|
||||||
|
|
||||||
|
private List<TemplateAttributeModel> attributeList;
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
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 Xin.Yao
|
||||||
|
* @Date 2024/3/7 8:30
|
||||||
|
*/
|
||||||
|
@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 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -5,6 +5,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import com.muyu.common.security.utils.SecurityUtils;
|
import com.muyu.common.security.utils.SecurityUtils;
|
||||||
import com.muyu.product.domain.model.CategoryInfoSaveModel;
|
import com.muyu.product.domain.model.CategoryInfoSaveModel;
|
||||||
|
import com.muyu.product.domain.resp.CategoryCommonElementResp;
|
||||||
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;
|
||||||
|
@ -120,4 +121,12 @@ public class CategoryInfoController extends BaseController {
|
||||||
return categoryInfoService.parentCommonElement(categoryId);
|
return categoryInfoService.parentCommonElement(categoryId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
||||||
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)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -9,6 +9,7 @@ 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.model.CategoryInfoSaveModel;
|
||||||
|
import com.muyu.product.domain.resp.CategoryCommonElementResp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 品类信息Service接口
|
* 品类信息Service接口
|
||||||
|
@ -52,4 +53,6 @@ public interface CategoryInfoService extends IService<CategoryInfo> {
|
||||||
List<BrandInfo> getBrandInfoList(Long categoryId);
|
List<BrandInfo> getBrandInfoList(Long categoryId);
|
||||||
|
|
||||||
public boolean save(CategoryInfoSaveModel categoryInfoSaveModel);
|
public boolean save(CategoryInfoSaveModel categoryInfoSaveModel);
|
||||||
|
|
||||||
|
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,8 @@ public interface RuleInfoService extends IService<RuleInfo> {
|
||||||
*/
|
*/
|
||||||
public List<RuleInfo> list(RuleInfo ruleInfo);
|
public List<RuleInfo> list(RuleInfo ruleInfo);
|
||||||
|
|
||||||
|
public boolean save(RuleInfoAddModel ruleInfoAddModel);
|
||||||
|
|
||||||
|
TableDataInfo<RuleInfoResp> queryList (RuleInfoQueryReq ruleInfoQueryReq);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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())){
|
||||||
|
|
|
@ -2,11 +2,16 @@ package com.muyu.product.service.impl;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.common.core.utils.ObjUtils;
|
import com.muyu.common.core.utils.ObjUtils;
|
||||||
import com.muyu.product.domain.*;
|
import com.muyu.product.domain.*;
|
||||||
import com.muyu.product.domain.model.CategoryInfoSaveModel;
|
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.domain.resp.CategoryParentCommonElementResp;
|
||||||
import com.muyu.product.service.*;
|
import com.muyu.product.service.*;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
@ -222,4 +227,85 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
|
||||||
}
|
}
|
||||||
return save;
|
return save;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void getParentIdListByCateGoryId(List<Long> parentIdList,Long cateGoryId){
|
||||||
|
if (cateGoryId.equals(0)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
CategoryInfo categoryInfo = this.getById(cateGoryId);
|
||||||
|
parentIdList.add(categoryInfo.getId());
|
||||||
|
getParentIdListByCateGoryId(parentIdList,categoryInfo.getParentId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AsAttributeGroupService asAttributeGroupService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CategoryCommonElementResp getTemplateAttributeByCateGoryId(Long cateGoryId) {
|
||||||
|
List<Long> cateGroupIdList = new ArrayList<>();
|
||||||
|
getParentIdListByCateGoryId(cateGroupIdList,cateGoryId);
|
||||||
|
LambdaQueryWrapper<AsCategoryAttributeGroup> asCategoryAttributeGroupLambdaQueryWrapper = new LambdaQueryWrapper<>() {{
|
||||||
|
in(AsCategoryAttributeGroup::getCategoryId, cateGroupIdList);
|
||||||
|
}};
|
||||||
|
List<AsCategoryAttributeGroup> categoryAttributeGroupList = asCategoryAttributeGroupService.list(asCategoryAttributeGroupLambdaQueryWrapper);
|
||||||
|
List<TemplateAttributeGroupModel> attributeGroupModelList = categoryAttributeGroupList.stream()
|
||||||
|
.map(asCategoryAttributeGroup -> TemplateAttributeGroupModel.attributeGroupBuild(
|
||||||
|
attributeGroupService.getById(asCategoryAttributeGroup.getAttributeGroupId()),
|
||||||
|
attributeGroupId -> {
|
||||||
|
LambdaQueryWrapper<AsAttributeGroup> asAttributeGroupLambdaQueryWrapper = new LambdaQueryWrapper<>() {{
|
||||||
|
eq(AsAttributeGroup::getGroupId, asCategoryAttributeGroup.getAttributeGroupId());
|
||||||
|
}};
|
||||||
|
List<Long> attributeIdList = asAttributeGroupService.list(asAttributeGroupLambdaQueryWrapper).stream()
|
||||||
|
.map(AsAttributeGroup::getAttributeId)
|
||||||
|
.toList();
|
||||||
|
if (attributeIdList.isEmpty()) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
return attributeInfoService.listByIds(attributeIdList).stream()
|
||||||
|
.map(AttributeInfo::buildTemplateModel)
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
))
|
||||||
|
.filter(TemplateAttributeGroupModel::isEffective)
|
||||||
|
.toList();
|
||||||
|
List<TemplateAttributeModel> templateAttributeModelList = new ArrayList<>();
|
||||||
|
LambdaQueryWrapper<AsCategoryAttribute> categoryAttributeQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
categoryAttributeQueryWrapper.in(AsCategoryAttribute::getCategoryId,cateGroupIdList);
|
||||||
|
List<AsCategoryAttribute> asCategoryAttributeList = asCategoryAttributeService.list(categoryAttributeQueryWrapper);
|
||||||
|
if (asCategoryAttributeList != null && !asCategoryAttributeList.isEmpty()){
|
||||||
|
templateAttributeModelList = attributeInfoService.listByIds(
|
||||||
|
asCategoryAttributeList.stream()
|
||||||
|
.map(AsCategoryAttribute::getAttributeId)
|
||||||
|
.toList()
|
||||||
|
).stream()
|
||||||
|
.map(AttributeInfo::buildTemplateModel)
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
List<TemplateAttributeModel> attributeModelList = new ArrayList<>();
|
||||||
|
List<Long> attributeIdList = new ArrayList<>();
|
||||||
|
if (!templateAttributeModelList.isEmpty()){
|
||||||
|
attributeIdList.addAll(
|
||||||
|
templateAttributeModelList.stream().map(TemplateAttributeModel::getId).toList()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (!attributeGroupModelList.isEmpty()){
|
||||||
|
attributeIdList.addAll(
|
||||||
|
attributeGroupModelList.stream()
|
||||||
|
.flatMap((Function<TemplateAttributeGroupModel, Stream<TemplateAttributeModel>>) templateAttributeGroupModel -> templateAttributeGroupModel.getAttributeList().stream())
|
||||||
|
.map(TemplateAttributeModel::getId)
|
||||||
|
.toList()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
LambdaQueryWrapper<AttributeInfo> attributeInfoLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
attributeInfoLambdaQueryWrapper.notIn(!attributeIdList.isEmpty(),AttributeInfo::getId,attributeIdList);
|
||||||
|
attributeModelList=attributeInfoService.list(attributeInfoLambdaQueryWrapper).stream().map(AttributeInfo::buildTemplateModel).toList();
|
||||||
|
return CategoryCommonElementResp.builder()
|
||||||
|
.templateAttributeGroupList(attributeGroupModelList)
|
||||||
|
.templateAttributeList(templateAttributeModelList)
|
||||||
|
.attributeList(attributeModelList)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,19 @@ package com.muyu.product.service.impl;
|
||||||
|
|
||||||
import java.util.List;
|
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.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 +32,8 @@ 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 +59,33 @@ public class RuleInfoServiceImpl extends ServiceImpl<RuleInfoMapper, RuleInfo>
|
||||||
|
|
||||||
return list(queryWrapper);
|
return list(queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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> ruleInfoResps = 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(ruleInfoResps)
|
||||||
|
.total(isPage ? new PageInfo<>(list).getTotal() : 0)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue