业务层修改,属性组前台数据获取

day-06
Saisai Liu 2024-03-03 16:01:13 +08:00
parent 7b0ea31558
commit bdbfc8ed3a
2 changed files with 15 additions and 2 deletions

View File

@ -38,6 +38,7 @@ public class AttributeGroup extends BaseEntity
private String name; private String name;
private List<Attribute> attributeList; private List<Attribute> attributeList;
private List<Long> checkedAttributeIds;
/** 状态 */ /** 状态 */
@Excel(name = "状态") @Excel(name = "状态")
@ -74,4 +75,11 @@ public class AttributeGroup extends BaseEntity
.build(); .build();
} }
public void setCheckedAttributeIds(List<Long> checkedAttributeIds) {
this.checkedAttributeIds = checkedAttributeIds;
}
public List<Long> getCheckedAttributeIds() {
return checkedAttributeIds;
}
} }

View File

@ -53,11 +53,16 @@ public class AttributeGroupServiceImpl extends ServiceImpl<AttributeGroupMapper,
*/ */
private void setAttributeList(AttributeGroup group) { private void setAttributeList(AttributeGroup group) {
List<Attribute> attributeLongs = new ArrayList<>(); List<Attribute> attributeLongs = new ArrayList<>();
List<Long> longs = new ArrayList<>();
List<AsAttributeGroup> asAttributeGroups = asAttributeGroupService.selectAsAttributeGroupList(AsAttributeGroup.builder() List<AsAttributeGroup> asAttributeGroups = asAttributeGroupService.selectAsAttributeGroupList(AsAttributeGroup.builder()
.groupId(group.getId()) .groupId(group.getId())
.build()); .build());
asAttributeGroups.forEach(asAttributeGroup -> attributeLongs.add(attributeService.selectAttributeById(asAttributeGroup.getAttributeId()))); asAttributeGroups.forEach(asAttributeGroup -> attributeLongs.add(attributeService.selectAttributeById(asAttributeGroup.getAttributeId())));
asAttributeGroups.forEach(asAttributeGroup -> longs.add(attributeService.selectAttributeById(asAttributeGroup.getAttributeId()).getId()));
group.setAttributeList(attributeLongs); group.setAttributeList(attributeLongs);
group.setCheckedAttributeIds(longs);
} }
/** /**
@ -109,8 +114,8 @@ public class AttributeGroupServiceImpl extends ServiceImpl<AttributeGroupMapper,
.map(attributeId -> AsAttributeGroup .map(attributeId -> AsAttributeGroup
.saveBuilder(attributeGroup.getId(), attributeId)) .saveBuilder(attributeGroup.getId(), attributeId))
.toList(); .toList();
// asAttributeGroupService.saveBatch(asAttributeGroups); asAttributeGroupService.saveBatch(asAttributeGroups);
asAttributeGroups.forEach(asAttributeGroup -> asAttributeGroupService.updateAsAttributeGroup(asAttributeGroup)); // asAttributeGroups.forEach(asAttributeGroup -> asAttributeGroupService.updateAsAttributeGroup(asAttributeGroup));
return asAttributeGroups.size(); return asAttributeGroups.size();
} }