这里到完全的属性组
parent
2f4bb745de
commit
6207ce4ba6
|
@ -58,13 +58,46 @@ 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);
|
||||
if (b){
|
||||
return Result.success();
|
||||
}
|
||||
return Result.error();
|
||||
}
|
||||
//修改属性组
|
||||
AttributeGroup attributeGroup = AttributeGroup.BuildAttributeGroupByReq(attributeGroupReq);
|
||||
boolean save = attributeGroupService.save(attributeGroup);
|
||||
System.out.println("添加属性组之后返回的主键:"+attributeGroup.getId());
|
||||
attributeGroupReq.setAttributeGroupId(attributeGroup.getId());
|
||||
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 b = asAttributeAttributeGroupService.saveBatch(asAttributeAttributeGroupList);
|
||||
if (b){
|
||||
//添加
|
||||
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();
|
||||
|
|
|
@ -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())
|
||||
|
|
Loading…
Reference in New Issue