这里到完全的属性组

master
20300 2024-03-06 21:03:55 +08:00
parent 2f4bb745de
commit 6207ce4ba6
2 changed files with 39 additions and 5 deletions

View File

@ -58,9 +58,11 @@ public class AttributeGroupController {
}
@PostMapping("/insertAttributeGroup")
public Result insertAttributeGroup(@RequestBody AttributeGroupReq attributeGroupReq){
if (attributeGroupReq.getAttributeGroupId()==null || "".equals(attributeGroupReq.getAttributeGroupId())){
AttributeGroup attributeGroup = AttributeGroup.BuildAttributeGroupByReq(attributeGroupReq);
boolean save = attributeGroupService.save(attributeGroup);
System.out.println("添加属性组之后返回的主键:"+attributeGroup.getId());
attributeGroupReq.setAttributeGroupId(attributeGroup.getId());
List<AsAttributeAttributeGroup> asAttributeAttributeGroupList = AsAttributeAttributeGroup.buildAttributeMiddle(attributeGroupReq);
boolean b = asAttributeAttributeGroupService.saveBatch(asAttributeAttributeGroupList);
@ -69,5 +71,36 @@ public class AttributeGroupController {
}
return Result.error();
}
//修改属性组
AttributeGroup attributeGroup = AttributeGroup.BuildAttributeGroupByReq(attributeGroupReq);
System.out.println(attributeGroup);
boolean b = attributeGroupService.updateById(attributeGroup);
//删除中间表
attributeGroupReq.setAttributeGroupId(attributeGroupReq.getAttributeGroupId());
QueryWrapper<AsAttributeAttributeGroup> queryWrapper = new QueryWrapper<>();
queryWrapper.in("attribute_group_id",attributeGroupReq.getAttributeGroupId());
asAttributeAttributeGroupService.remove(queryWrapper);
//重新得到添加中间表的数据
List<AsAttributeAttributeGroup> asAttributeAttributeGroupList = AsAttributeAttributeGroup.buildAttributeMiddle(attributeGroupReq);
//添加
boolean boo = asAttributeAttributeGroupService.saveBatch(asAttributeAttributeGroupList);
if (boo){
return Result.success();
}
return Result.error();
}
//删除属性组,与属性中间表
@GetMapping("/deleteAttributeById")
public Result deleteAttributeById(@RequestParam("groupId") Integer groupId){
boolean b = attributeGroupService.removeById(groupId);
QueryWrapper<AsAttributeAttributeGroup> groupQueryWrapper = new QueryWrapper<>();
groupQueryWrapper.eq("attribute_group_id",groupId);
boolean remove = asAttributeAttributeGroupService.remove(groupQueryWrapper);
if (remove){
return Result.success();
}
return Result.error();
}
}

View File

@ -41,6 +41,7 @@ public class AttributeGroup extends BaseEntity {
public static AttributeGroup BuildAttributeGroupByReq(AttributeGroupReq attributeGroupReq){
return AttributeGroup.builder()
.id(attributeGroupReq.getAttributeGroupId())
.name(attributeGroupReq.getName())
.remark(attributeGroupReq.getRemark())
.createBy(SecurityUtils.getUsername())