parent
65238bdd40
commit
d0cc07b126
|
@ -3,16 +3,12 @@ package com.muyu.product.controller;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.common.core.utils.StringUtils;
|
import com.muyu.common.core.utils.StringUtils;
|
||||||
import com.muyu.product.domain.AsCategoryAttribute;
|
import com.muyu.product.domain.*;
|
||||||
import com.muyu.product.domain.AsCategoryAttributeGroup;
|
|
||||||
import com.muyu.product.domain.AsCategoryBrand;
|
|
||||||
import com.muyu.product.domain.CategoryInfo;
|
|
||||||
import com.muyu.product.domain.req.InsertCategoryReq;
|
import com.muyu.product.domain.req.InsertCategoryReq;
|
||||||
import com.muyu.product.service.AsCategoryAttributeGroupService;
|
import com.muyu.product.service.AsCategoryAttributeGroupService;
|
||||||
import com.muyu.product.service.AsCategoryAttributeService;
|
import com.muyu.product.service.AsCategoryAttributeService;
|
||||||
import com.muyu.product.service.AsCategoryBrandService;
|
import com.muyu.product.service.AsCategoryBrandService;
|
||||||
import com.muyu.product.service.CategoryInfoService;
|
import com.muyu.product.service.CategoryInfoService;
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
@ -78,4 +74,28 @@ public class CategoryController {
|
||||||
}
|
}
|
||||||
return Result.success();
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//使用品类编号来找到所用上级节点获得的属性,属性组,品牌集合
|
||||||
|
//1:获得所用被选中的属性集合
|
||||||
|
@GetMapping("getAllCategoryAttribute")
|
||||||
|
public Result<List<AttributeInfo>> getAllCategoryAttribute(@RequestParam("categoryId") Integer categoryId){
|
||||||
|
List<AttributeInfo> attributeInfos = categoryInfoService.getAttributeList(categoryId);
|
||||||
|
return Result.success(attributeInfos);
|
||||||
|
}
|
||||||
|
//2:获得所用的被选中属性组集合
|
||||||
|
@GetMapping("getAllCategoryAttributeGroup")
|
||||||
|
public Result<List<AttributeGroup>> getAllCategoryAttributeGroup(@RequestParam("categoryId") Integer categoryId){
|
||||||
|
List<AttributeGroup> attributeGroupList = categoryInfoService.getAttributeGroupList(categoryId);
|
||||||
|
return Result.success(attributeGroupList);
|
||||||
|
}
|
||||||
|
//3:获得所用的被选中品牌集合
|
||||||
|
@GetMapping("getAllCategoryBrand")
|
||||||
|
public Result<List<BrandInfo>> getAllCategoryBrand(@RequestParam("categoryId") Integer categoryId){
|
||||||
|
System.out.println("获得的categoryId:"+categoryId);
|
||||||
|
List<BrandInfo> brandList = categoryInfoService.getBrandList(categoryId);
|
||||||
|
return Result.success(brandList);
|
||||||
|
}
|
||||||
|
|
||||||
|
//总,获得every集
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.muyu.common.core.annotation.Excel;
|
import com.muyu.common.core.annotation.Excel;
|
||||||
import com.muyu.common.core.web.domain.BaseEntity;
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
import com.muyu.common.security.utils.SecurityUtils;
|
import com.muyu.common.security.utils.SecurityUtils;
|
||||||
|
import com.muyu.product.domain.base.CategoryBase;
|
||||||
import com.muyu.product.domain.req.AttributeGroupReq;
|
import com.muyu.product.domain.req.AttributeGroupReq;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
@ -30,7 +31,7 @@ import java.util.stream.Collectors;
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@TableName("as_attribute_attribute_group")
|
@TableName("as_attribute_attribute_group")
|
||||||
public class AsAttributeAttributeGroup extends BaseEntity {
|
public class AsAttributeAttributeGroup extends BaseEntity implements CategoryBase {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Excel(name = "属性属性组,中间表编号",cellType = Excel.ColumnType.NUMERIC)
|
@Excel(name = "属性属性组,中间表编号",cellType = Excel.ColumnType.NUMERIC)
|
||||||
|
@ -56,4 +57,8 @@ public class AsAttributeAttributeGroup extends BaseEntity {
|
||||||
).collect(Collectors.toList());
|
).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getBaseId() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.muyu.common.core.annotation.Excel;
|
import com.muyu.common.core.annotation.Excel;
|
||||||
import com.muyu.common.core.web.domain.BaseEntity;
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
import com.muyu.product.domain.base.CategoryBase;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
@ -23,7 +24,7 @@ import lombok.experimental.SuperBuilder;
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@TableName("as_category_attribute")
|
@TableName("as_category_attribute")
|
||||||
public class AsCategoryAttribute extends BaseEntity {
|
public class AsCategoryAttribute extends BaseEntity implements CategoryBase {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
@Excel(name = "参数主键", cellType = Excel.ColumnType.NUMERIC)
|
@Excel(name = "参数主键", cellType = Excel.ColumnType.NUMERIC)
|
||||||
@TableId( type = IdType.AUTO)
|
@TableId( type = IdType.AUTO)
|
||||||
|
@ -32,4 +33,9 @@ public class AsCategoryAttribute extends BaseEntity {
|
||||||
private Integer categoryId;
|
private Integer categoryId;
|
||||||
@Excel(name = "品牌编号")
|
@Excel(name = "品牌编号")
|
||||||
private Integer attributeId;
|
private Integer attributeId;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getBaseId() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.muyu.common.core.annotation.Excel;
|
import com.muyu.common.core.annotation.Excel;
|
||||||
import com.muyu.common.core.web.domain.BaseEntity;
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
import com.muyu.product.domain.base.CategoryBase;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
@ -23,7 +24,7 @@ import lombok.experimental.SuperBuilder;
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@TableName("as_category_attribute_group")
|
@TableName("as_category_attribute_group")
|
||||||
public class AsCategoryAttributeGroup extends BaseEntity {
|
public class AsCategoryAttributeGroup extends BaseEntity implements CategoryBase {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
@Excel(name = "参数主键", cellType = Excel.ColumnType.NUMERIC)
|
@Excel(name = "参数主键", cellType = Excel.ColumnType.NUMERIC)
|
||||||
@TableId( type = IdType.AUTO)
|
@TableId( type = IdType.AUTO)
|
||||||
|
@ -32,4 +33,9 @@ public class AsCategoryAttributeGroup extends BaseEntity {
|
||||||
private Integer categoryId;
|
private Integer categoryId;
|
||||||
@Excel(name = "品牌编号")
|
@Excel(name = "品牌编号")
|
||||||
private Integer attributeGroupId;
|
private Integer attributeGroupId;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getBaseId() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.muyu.common.core.annotation.Excel;
|
import com.muyu.common.core.annotation.Excel;
|
||||||
import com.muyu.common.core.web.domain.BaseEntity;
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
import com.muyu.product.domain.base.CategoryBase;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
@ -23,7 +24,7 @@ import lombok.experimental.SuperBuilder;
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@TableName("as_category_brand")
|
@TableName("as_category_brand")
|
||||||
public class AsCategoryBrand extends BaseEntity {
|
public class AsCategoryBrand extends BaseEntity implements CategoryBase {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
@Excel(name = "参数主键", cellType = Excel.ColumnType.NUMERIC)
|
@Excel(name = "参数主键", cellType = Excel.ColumnType.NUMERIC)
|
||||||
@TableId( type = IdType.AUTO)
|
@TableId( type = IdType.AUTO)
|
||||||
|
@ -32,4 +33,9 @@ public class AsCategoryBrand extends BaseEntity {
|
||||||
private Integer categoryId;
|
private Integer categoryId;
|
||||||
@Excel(name = "品牌编号")
|
@Excel(name = "品牌编号")
|
||||||
private Integer brandId;
|
private Integer brandId;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getBaseId() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.muyu.product.domain.base;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName CategoryBase
|
||||||
|
* @Description 描述
|
||||||
|
* @Author ZHIHAO.DAI
|
||||||
|
* @Date 2024/3/10 15:24
|
||||||
|
*/
|
||||||
|
public interface CategoryBase {
|
||||||
|
public Integer getBaseId();
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
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.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName updateCategoryResp
|
||||||
|
* @Description 描述
|
||||||
|
* @Author ZHIHAO.DAI
|
||||||
|
* @Date 2024/3/10 15:40
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class updateCategoryResp {
|
||||||
|
private List<AttributeGroup> attributeGroupList;
|
||||||
|
private List<AttributeInfo> attributeList;
|
||||||
|
private List<BrandInfo> brandList;
|
||||||
|
}
|
|
@ -1,9 +1,13 @@
|
||||||
package com.muyu.product.service;
|
package com.muyu.product.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.muyu.product.domain.AttributeGroup;
|
||||||
|
import com.muyu.product.domain.AttributeInfo;
|
||||||
import com.muyu.product.domain.BrandInfo;
|
import com.muyu.product.domain.BrandInfo;
|
||||||
import com.muyu.product.domain.CategoryInfo;
|
import com.muyu.product.domain.CategoryInfo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ClassName BrandInfoService
|
* @ClassName BrandInfoService
|
||||||
* @Description 描述
|
* @Description 描述
|
||||||
|
@ -11,4 +15,10 @@ import com.muyu.product.domain.CategoryInfo;
|
||||||
* @Date 2024/3/6 21:13
|
* @Date 2024/3/6 21:13
|
||||||
*/
|
*/
|
||||||
public interface CategoryInfoService extends IService<CategoryInfo> {
|
public interface CategoryInfoService extends IService<CategoryInfo> {
|
||||||
|
List<AttributeInfo> getAttributeList(Integer categoryId);
|
||||||
|
|
||||||
|
List<AttributeGroup> getAttributeGroupList(Integer categoryId);
|
||||||
|
|
||||||
|
List<BrandInfo> getBrandList(Integer categoryId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,22 @@
|
||||||
package com.muyu.product.service.impl;
|
package com.muyu.product.service.impl;
|
||||||
|
|
||||||
|
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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
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.muyu.product.domain.base.CategoryBase;
|
||||||
import com.muyu.product.mapper.CategoryInfoMapper;
|
import com.muyu.product.mapper.CategoryInfoMapper;
|
||||||
import com.muyu.product.service.CategoryInfoService;
|
import com.muyu.product.service.*;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ClassName BrandInfoServiceImpl
|
* @ClassName BrandInfoServiceImpl
|
||||||
* @Description 描述
|
* @Description 描述
|
||||||
|
@ -15,4 +26,73 @@ import org.springframework.stereotype.Service;
|
||||||
@Service
|
@Service
|
||||||
public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, CategoryInfo>
|
public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, CategoryInfo>
|
||||||
implements CategoryInfoService {
|
implements CategoryInfoService {
|
||||||
|
@Autowired
|
||||||
|
private AsCategoryAttributeService asCategoryAttributeService;
|
||||||
|
@Autowired
|
||||||
|
private AsCategoryBrandService asCategoryBrandService;
|
||||||
|
@Autowired
|
||||||
|
private AsCategoryAttributeGroupService asCategoryAttributeGroupService;
|
||||||
|
@Autowired
|
||||||
|
private AttributeInfoService attributeInfoService;
|
||||||
|
@Autowired
|
||||||
|
private AttributeGroupService attributeGroupService;
|
||||||
|
@Autowired
|
||||||
|
private BrandInfoService brandInfoService;
|
||||||
|
@Override
|
||||||
|
public List<AttributeInfo> getAttributeList(Integer categoryId) {
|
||||||
|
if (categoryId == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return getCommon(categoryId,attributeInfoService,asCategoryAttributeService);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AttributeGroup> getAttributeGroupList(Integer categoryId) {
|
||||||
|
if (categoryId == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
List<AttributeGroup> attributeGroupList = getCommon(categoryId,attributeGroupService,asCategoryAttributeGroupService);
|
||||||
|
return attributeGroupList;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<BrandInfo> getBrandList(Integer categoryId) {
|
||||||
|
if (categoryId == 0) {
|
||||||
|
System.out.println("等于0?");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
List<BrandInfo> brandList = getCommon(categoryId, brandInfoService, asCategoryBrandService);
|
||||||
|
return brandList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T, AS> List<T> getCommon(Integer categoryId, IService<T> iService, IService<AS> asiService){
|
||||||
|
ArrayList<T> list = new ArrayList<>();
|
||||||
|
QueryWrapper<AS> asQueryWrapper = new QueryWrapper<>();
|
||||||
|
asQueryWrapper.eq("category_id",categoryId);
|
||||||
|
List<AS> aslist = asiService.list(asQueryWrapper);
|
||||||
|
if (aslist !=null){
|
||||||
|
list.addAll(
|
||||||
|
iService.listByIds(
|
||||||
|
aslist.stream().map(
|
||||||
|
as -> {
|
||||||
|
if (as instanceof CategoryBase categoryBase) {
|
||||||
|
return categoryBase.getBaseId();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
).toList()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
//获得品类属性,由品类属性跟踪到父级品类
|
||||||
|
CategoryInfo categoryInfo = this.getById(categoryId);
|
||||||
|
if (categoryInfo.getParentId() != 0){
|
||||||
|
list.addAll(this.getCommon(categoryInfo.getParentId(),iService,asiService));
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getCategoryIds(Integer category){
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue