|
|
@ -18,9 +18,11 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.Collection;
|
|
|
|
import java.util.Collection;
|
|
|
|
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
@ -77,9 +79,9 @@ public class AttrServiceImpl extends ServiceImpl<AttrDao, AttrEntity> implements
|
|
|
|
//后台管理,查询基本内容和关联分组和关联属性
|
|
|
|
//后台管理,查询基本内容和关联分组和关联属性
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public PageUtils queryBasePage(Map<String, Object> params, Long cateLogId, String attrType) {
|
|
|
|
public PageUtils queryBasePage(Map<String, Object> params, Long cateLogId, String attrType) {
|
|
|
|
QueryWrapper<AttrEntity> wrapper = new QueryWrapper<AttrEntity>();
|
|
|
|
QueryWrapper<AttrEntity> wrapper = new QueryWrapper<AttrEntity>().eq("attr_type", "base".equalsIgnoreCase(attrType)?1:0);
|
|
|
|
if (cateLogId != 0) {
|
|
|
|
if (cateLogId != 0) {
|
|
|
|
wrapper.eq("catelog_id", cateLogId).eq("attr_name", "base".equalsIgnoreCase(attrType)?1:0);
|
|
|
|
wrapper.eq("catelog_id", cateLogId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String key = (String)params.get("key");
|
|
|
|
String key = (String)params.get("key");
|
|
|
|
if (!StringUtils.isNullOrEmpty(key)) {
|
|
|
|
if (!StringUtils.isNullOrEmpty(key)) {
|
|
|
@ -127,15 +129,14 @@ public class AttrServiceImpl extends ServiceImpl<AttrDao, AttrEntity> implements
|
|
|
|
// log.info("查询属性,attrId: {}", attrId);
|
|
|
|
// log.info("查询属性,attrId: {}", attrId);
|
|
|
|
AttrRespVo respVo = new AttrRespVo();
|
|
|
|
AttrRespVo respVo = new AttrRespVo();
|
|
|
|
AttrEntity attrEntity = this.getById(attrId);
|
|
|
|
AttrEntity attrEntity = this.getById(attrId);
|
|
|
|
|
|
|
|
BeanUtils.copyProperties(attrEntity, respVo);
|
|
|
|
|
|
|
|
|
|
|
|
//如果是base
|
|
|
|
//如果是base
|
|
|
|
if (attrEntity.getAttrType() == ProductConstant.AttrEnum.ATTR_TYPE_BASE.getCode()) {
|
|
|
|
if (attrEntity.getAttrType() == ProductConstant.AttrEnum.ATTR_TYPE_BASE.getCode()) {
|
|
|
|
//设置分组id
|
|
|
|
//设置分组id
|
|
|
|
BeanUtils.copyProperties(attrEntity, respVo);
|
|
|
|
|
|
|
|
// log.info("beanutilzhengchang");
|
|
|
|
// log.info("beanutilzhengchang");
|
|
|
|
AttrAttrgroupRelationEntity RelationEntity = RelationDao.selectOne(
|
|
|
|
AttrAttrgroupRelationEntity RelationEntity = RelationDao.selectOne(
|
|
|
|
new QueryWrapper<AttrAttrgroupRelationEntity>().eq("attr_id",attrId));
|
|
|
|
new QueryWrapper<AttrAttrgroupRelationEntity>().eq("attr_id",attrId));
|
|
|
|
|
|
|
|
|
|
|
|
if (RelationEntity!=null) {
|
|
|
|
if (RelationEntity!=null) {
|
|
|
|
// log.info("查询属性,relation正常");
|
|
|
|
// log.info("查询属性,relation正常");
|
|
|
|
respVo.setAttrGroupId(RelationEntity.getAttrGroupId());
|
|
|
|
respVo.setAttrGroupId(RelationEntity.getAttrGroupId());
|
|
|
@ -234,7 +235,11 @@ public class AttrServiceImpl extends ServiceImpl<AttrDao, AttrEntity> implements
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
//这些分组的属性
|
|
|
|
//这些分组的属性
|
|
|
|
List<AttrAttrgroupRelationEntity> relationEntities = RelationDao.selectList(
|
|
|
|
List<AttrAttrgroupRelationEntity> relationEntities = RelationDao.selectList(
|
|
|
|
new QueryWrapper<AttrAttrgroupRelationEntity>().in("attr_group_id", collect));
|
|
|
|
new QueryWrapper<AttrAttrgroupRelationEntity>()
|
|
|
|
|
|
|
|
.in("attr_group_id", collect.isEmpty() ?
|
|
|
|
|
|
|
|
Collections.singletonList(attrgroupId) :
|
|
|
|
|
|
|
|
Stream.concat(collect.stream(), Stream.of(attrgroupId)).collect(Collectors.toList())));
|
|
|
|
|
|
|
|
|
|
|
|
List<Long> attrIds = relationEntities.stream().map((entity) -> {
|
|
|
|
List<Long> attrIds = relationEntities.stream().map((entity) -> {
|
|
|
|
return entity.getAttrId();
|
|
|
|
return entity.getAttrId();
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
}).collect(Collectors.toList());
|
|
|
@ -243,6 +248,9 @@ public class AttrServiceImpl extends ServiceImpl<AttrDao, AttrEntity> implements
|
|
|
|
//条件
|
|
|
|
//条件
|
|
|
|
QueryWrapper<AttrEntity> queryWrapper = new QueryWrapper<AttrEntity>().eq("catelog_id", catelogId).eq(
|
|
|
|
QueryWrapper<AttrEntity> queryWrapper = new QueryWrapper<AttrEntity>().eq("catelog_id", catelogId).eq(
|
|
|
|
"attr_type",ProductConstant.AttrEnum.ATTR_TYPE_BASE.getCode() );
|
|
|
|
"attr_type",ProductConstant.AttrEnum.ATTR_TYPE_BASE.getCode() );
|
|
|
|
|
|
|
|
if (attrIds !=null && attrIds.size() > 0) {
|
|
|
|
|
|
|
|
queryWrapper.notIn("attr_id", attrIds);
|
|
|
|
|
|
|
|
}
|
|
|
|
//关键字查找
|
|
|
|
//关键字查找
|
|
|
|
String key = (String) params.get("key");
|
|
|
|
String key = (String) params.get("key");
|
|
|
|
if (!StringUtils.isNullOrEmpty(key)) {
|
|
|
|
if (!StringUtils.isNullOrEmpty(key)) {
|
|
|
@ -250,9 +258,7 @@ public class AttrServiceImpl extends ServiceImpl<AttrDao, AttrEntity> implements
|
|
|
|
wrapper.eq("attr_id", key).or().like("attr_name", key);
|
|
|
|
wrapper.eq("attr_id", key).or().like("attr_name", key);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (attrIds !=null && attrIds.size() > 0) {
|
|
|
|
|
|
|
|
queryWrapper.notIn("attr_id", attrIds);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//分页查询
|
|
|
|
//分页查询
|
|
|
|
IPage<AttrEntity> page = this.page(new Query<AttrEntity>().getPage(params), queryWrapper);
|
|
|
|
IPage<AttrEntity> page = this.page(new Query<AttrEntity>().getPage(params), queryWrapper);
|
|
|
|