品类添加及查询父类属性,属性组,品牌
parent
e8392009d0
commit
59f3687b47
|
@ -112,7 +112,7 @@ public class AttributeGroupController extends BaseController {
|
|||
@ApiOperation("删除属性组")
|
||||
@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) {
|
||||
System.out.println();
|
||||
attributeGroupService.deleteAsAttributeGroup(ids);
|
||||
return toAjax(attributeGroupService.removeBatchByIds(ids));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,6 @@ public interface AsAttributeGroupService extends IService<AsAttributeGroup> {
|
|||
*/
|
||||
public List<AsAttributeGroup> list(AsAttributeGroup asAttributeGroup);
|
||||
|
||||
void deleteAsAttributeGroup(List<Long> attributeId);
|
||||
void deleteAsAttributeGroup(List<Long> groupId);
|
||||
|
||||
}
|
||||
|
|
|
@ -41,4 +41,6 @@ public interface AttributeGroupService extends IService<AttributeGroup> {
|
|||
public Boolean save(AttributeGroupSaveModel attributeGroupSaveModel);
|
||||
|
||||
void updateAsAttributeGrop(AttributeGroupEditReq attributeGroupEditReq,Long groupId);
|
||||
|
||||
void deleteAsAttributeGroup(List<Long> ids);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.muyu.product.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.muyu.common.core.utils.ObjUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
@ -44,15 +45,18 @@ public class AsAttributeGroupServiceImpl extends ServiceImpl<AsAttributeGroupMap
|
|||
queryWrapper.eq(AsAttributeGroup::getAttributeId, asAttributeGroup.getAttributeId());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAsAttributeGroup(List<Long> attributeId) {
|
||||
asAttributeGroupMapper.deleteAsAttributeGroup(attributeId);
|
||||
public void deleteAsAttributeGroup(List<Long> groupId) {
|
||||
List<List<AsAttributeGroup>> lists = groupId.stream()
|
||||
.map(id -> this.list(new AsAttributeGroup(null, id, null)))
|
||||
.toList();
|
||||
List<AsAttributeGroup> collect = lists.stream().flatMap(List::stream).collect(Collectors.toList());
|
||||
List<Long> longs = collect.stream()
|
||||
.map(asAttributeGroup -> asAttributeGroup.getId())
|
||||
.toList();
|
||||
this.removeBatchByIds(longs);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.product.service.impl;
|
|||
import java.util.List;
|
||||
|
||||
import com.muyu.common.core.utils.ObjUtils;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.muyu.product.mapper.AsBrandProjectMapper;
|
||||
|
@ -19,6 +20,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@Log4j2
|
||||
public class AsBrandProjectServiceImpl extends ServiceImpl<AsBrandProjectMapper, AsBrandProject> implements AsBrandProjectService {
|
||||
|
||||
/**
|
||||
|
@ -40,10 +42,6 @@ public class AsBrandProjectServiceImpl extends ServiceImpl<AsBrandProjectMapper,
|
|||
queryWrapper.eq(AsBrandProject::getProjectId, asBrandProject.getProjectId());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return list(queryWrapper);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
|
@ -129,4 +130,9 @@ public class AttributeGroupServiceImpl extends ServiceImpl<AttributeGroupMapper,
|
|||
.toList()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAsAttributeGroup(List<Long> ids) {
|
||||
asAttributeGroupService.deleteAsAttributeGroup(ids);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
|
|||
private AttributeInfoService attributeInfoService;
|
||||
|
||||
@Autowired
|
||||
private AsAttributeGroupService asAttributeGroupService;
|
||||
private AttributeGroupService attributeGroupService;
|
||||
|
||||
@Autowired
|
||||
private BrandInfoService brandInfoService;
|
||||
|
@ -99,7 +99,30 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
|
|||
*/
|
||||
@Override
|
||||
public List<AttributeGroup> getAttributeGroupList(Long categoryId) {
|
||||
return null;
|
||||
ArrayList<AttributeGroup> attributeGroups = new ArrayList<>();
|
||||
LambdaQueryWrapper<AsCategoryAttributeGroup> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(AsCategoryAttributeGroup::getCategoryId,categoryId);
|
||||
List<AsCategoryAttributeGroup> asCategoryAttributeGroups = asCategoryAttributeGroupService.list(queryWrapper);
|
||||
if (asCategoryAttributeGroups != null && !asCategoryAttributeGroups.isEmpty()){
|
||||
List<Long> attributeGroupIdList = asCategoryAttributeGroups.stream()
|
||||
.map(AsCategoryAttributeGroup::getAttributeGroupId)
|
||||
.toList();
|
||||
attributeGroups.addAll(attributeGroupService.listByIds(attributeGroupIdList));
|
||||
}
|
||||
CategoryInfo categoryInfo = this.getById(categoryId);
|
||||
if (categoryInfo.getParentId() !=0){
|
||||
if (attributeGroups.isEmpty()){
|
||||
attributeGroups.addAll(getAttributeGroupList(categoryInfo.getParentId()));
|
||||
}else{
|
||||
List<AttributeGroup> attributeGroupList = getAttributeGroupList(categoryInfo.getParentId());
|
||||
for (AttributeGroup attributeGroup : attributeGroupList) {
|
||||
if (!attributeGroups.contains(attributeGroup)){
|
||||
attributeGroups.add(attributeGroup);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return attributeGroups;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -113,7 +136,7 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
|
|||
LambdaQueryWrapper<AsCategoryAttribute> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(AsCategoryAttribute::getCategoryId,categoryId);
|
||||
List<AsCategoryAttribute> asCategoryAttributeList = asCategoryAttributeService.list(queryWrapper);
|
||||
if (asCategoryAttributeList != null && asCategoryAttributeList.isEmpty()){
|
||||
if (asCategoryAttributeList != null && !asCategoryAttributeList.isEmpty()){
|
||||
List<Long> attributeIdList = asCategoryAttributeList.stream()
|
||||
.map(AsCategoryAttribute::getAttributeId)
|
||||
.toList();
|
||||
|
@ -122,10 +145,17 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
|
|||
CategoryInfo categoryInfo = this.getById(categoryId);
|
||||
if (categoryInfo.getParentId() !=0){
|
||||
if (attributeInfoList.isEmpty()){
|
||||
|
||||
attributeInfoList.addAll(getAttributeInfoList(categoryInfo.getParentId()));
|
||||
}else{
|
||||
List<AttributeInfo> attributeList = getAttributeInfoList(categoryInfo.getParentId());
|
||||
for (AttributeInfo attribute : attributeList) {
|
||||
if (!attributeInfoList.contains(attribute)){
|
||||
attributeInfoList.add(attribute);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return attributeInfoList;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -135,7 +165,30 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
|
|||
*/
|
||||
@Override
|
||||
public List<BrandInfo> getBrandInfoList(Long categoryId) {
|
||||
return null;
|
||||
ArrayList<BrandInfo> brandInfos = new ArrayList<>();
|
||||
LambdaQueryWrapper<AsCategoryBrand> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(AsCategoryBrand::getCategoryId,categoryId);
|
||||
List<AsCategoryBrand> asCategoryBrands = asCategoryBrandService.list(queryWrapper);
|
||||
if (asCategoryBrands != null && !asCategoryBrands.isEmpty()){
|
||||
List<Long> brandIdList = asCategoryBrands.stream()
|
||||
.map(AsCategoryBrand::getBrandId)
|
||||
.toList();
|
||||
brandInfos.addAll(brandInfoService.listByIds(brandIdList));
|
||||
}
|
||||
CategoryInfo categoryInfo = this.getById(categoryId);
|
||||
if (categoryInfo.getParentId() !=0){
|
||||
if (brandInfos.isEmpty()){
|
||||
brandInfos.addAll(getBrandInfoList(categoryInfo.getParentId()));
|
||||
}else{
|
||||
List<BrandInfo> brandInfoList = getBrandInfoList(categoryInfo.getParentId());
|
||||
for (BrandInfo brandInfo : brandInfoList) {
|
||||
if (!brandInfos.contains(brandInfo)){
|
||||
brandInfos.add(brandInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return brandInfos;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue