|
|
@ -1,11 +1,15 @@
|
|
|
|
package com.xjs.mall.product.service.impl;
|
|
|
|
package com.xjs.mall.product.service.impl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
|
|
|
import com.xjs.exception.MallException;
|
|
|
|
import com.xjs.mall.product.dao.AttrGroupDao;
|
|
|
|
import com.xjs.mall.product.dao.AttrGroupDao;
|
|
|
|
|
|
|
|
import com.xjs.mall.product.entity.AttrAttrgroupRelationEntity;
|
|
|
|
import com.xjs.mall.product.entity.AttrGroupEntity;
|
|
|
|
import com.xjs.mall.product.entity.AttrGroupEntity;
|
|
|
|
import com.xjs.mall.product.entity.CategoryEntity;
|
|
|
|
import com.xjs.mall.product.entity.CategoryEntity;
|
|
|
|
|
|
|
|
import com.xjs.mall.product.service.AttrAttrgroupRelationService;
|
|
|
|
import com.xjs.mall.product.service.AttrGroupService;
|
|
|
|
import com.xjs.mall.product.service.AttrGroupService;
|
|
|
|
import com.xjs.mall.product.service.CategoryService;
|
|
|
|
import com.xjs.mall.product.service.CategoryService;
|
|
|
|
import com.xjs.mall.product.vo.AttrGroupResponseVo;
|
|
|
|
import com.xjs.mall.product.vo.AttrGroupResponseVo;
|
|
|
@ -29,6 +33,9 @@ public class AttrGroupServiceImpl extends ServiceImpl<AttrGroupDao, AttrGroupEnt
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private CategoryService categoryService;
|
|
|
|
private CategoryService categoryService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private AttrAttrgroupRelationService attrAttrgroupRelationService;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public PageUtils queryPage(Map<String, Object> params, Long categoryId) {
|
|
|
|
public PageUtils queryPage(Map<String, Object> params, Long categoryId) {
|
|
|
|
String key = (String) params.get(Query.KEY_NAME);
|
|
|
|
String key = (String) params.get(Query.KEY_NAME);
|
|
|
@ -63,6 +70,22 @@ public class AttrGroupServiceImpl extends ServiceImpl<AttrGroupDao, AttrGroupEnt
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void removeAttrGroup(List<Long> ids) {
|
|
|
|
|
|
|
|
for (Long id : ids) {
|
|
|
|
|
|
|
|
//先查询中间表是否有数据,有数据代表该数据被引用,则不能删除
|
|
|
|
|
|
|
|
List<AttrAttrgroupRelationEntity> relationEntityList = attrAttrgroupRelationService
|
|
|
|
|
|
|
|
.list(new LambdaQueryWrapper<AttrAttrgroupRelationEntity>()
|
|
|
|
|
|
|
|
.eq(AttrAttrgroupRelationEntity::getAttrGroupId, id));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (CollUtil.isEmpty(relationEntityList)) {
|
|
|
|
|
|
|
|
super.removeById(id);
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
throw new MallException("含有被引用的规格参数未删除,请先删除规格参数");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private List<AttrGroupResponseVo> setList(List<AttrGroupEntity> records) {
|
|
|
|
private List<AttrGroupResponseVo> setList(List<AttrGroupEntity> records) {
|
|
|
|
return records.stream().map(attrGroupEntity -> {
|
|
|
|
return records.stream().map(attrGroupEntity -> {
|
|
|
|