把前几天修改的方法换成了mybatis_puls的方法了

main
wuchang2 2024-11-17 22:03:03 +08:00
parent 64124b2bb2
commit c437b1136a
8 changed files with 42 additions and 21 deletions

View File

@ -145,6 +145,7 @@ public class ProjectInfo extends BaseEntity {
.status(projectInfoEditReq.getStatus()) .status(projectInfoEditReq.getStatus())
.ruleId(projectInfoEditReq.getRuleId()) .ruleId(projectInfoEditReq.getRuleId())
.brandId(projectInfoEditReq.getBrandId()) .brandId(projectInfoEditReq.getBrandId())
.remark(projectInfoEditReq.getRemark())
.build(); .build();
} }

View File

@ -29,5 +29,6 @@ public class RuleInfoUpdRes {
private String status; private String status;
private String remark; private String remark;
private List<RuleAttrAddModel> ruleAttrList; private List<RuleAttrAddModel> ruleAttrList;
} }

View File

@ -56,4 +56,6 @@ public class ProjectAddModel extends BaseEntity {
/** 品牌 */ /** 品牌 */
@ApiModelProperty(name = "品牌", value = "品牌") @ApiModelProperty(name = "品牌", value = "品牌")
private Long brandId; private Long brandId;
private String remark;
} }

View File

@ -63,4 +63,6 @@ public class ProjectInfoEditReq extends BaseEntity {
@ApiModelProperty(name = "品牌", value = "品牌") @ApiModelProperty(name = "品牌", value = "品牌")
private Long brandId; private Long brandId;
private String remark;
} }

View File

@ -74,7 +74,7 @@ public interface CategoryInfoService extends IService<CategoryInfo> {
Boolean updId(Long id, CategoryInfoUpdReq categoryInfoUpdReq); Boolean updId(Long id, CategoryInfoUpdReq categoryInfoUpdReq);
Result del(Long ids); Result del(Long id);
CategoryInfoUpdReq getUpdById(Long id); CategoryInfoUpdReq getUpdById(Long id);

View File

@ -43,6 +43,9 @@ public class AttributeGroupServiceImpl extends ServiceImpl<AttributeGroupMapper,
@Autowired @Autowired
private AttributeInfoService attributeInfoService; private AttributeInfoService attributeInfoService;
@Autowired
private AttributeGroupMapper attributeGroupMapper;
@Autowired @Autowired
private AttributeGroupUpdMapper attributeGroupUpdMapper; private AttributeGroupUpdMapper attributeGroupUpdMapper;
@ -140,10 +143,12 @@ public class AttributeGroupServiceImpl extends ServiceImpl<AttributeGroupMapper,
@Override @Override
public void updAs(Long id, AttributeGroupEditReq attributeGroupEditReq) { public void updAs(Long id, AttributeGroupEditReq attributeGroupEditReq) {
attributeGroupUpdMapper.del(id); attributeGroupService.remove(new LambdaQueryWrapper<AsAttributeGroup>().eq(AsAttributeGroup::getGroupId,id));
List<AttributeInfoSaveReq> attributeList = attributeGroupEditReq.getAttributeList();
for (AttributeInfoSaveReq attributeInfoSaveReq : attributeList) { if (null!=attributeGroupEditReq.getAttributeList()){
attributeGroupEditReq.getAttributeList().stream().forEach(attributeInfoSaveReq -> {
attributeGroupUpdMapper.attriAddGroup(id,attributeInfoSaveReq.getId()); attributeGroupUpdMapper.attriAddGroup(id,attributeInfoSaveReq.getId());
});
} }
} }

View File

@ -291,11 +291,17 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
public Boolean updId(Long id, CategoryInfoUpdReq categoryInfoUpdReq) { public Boolean updId(Long id, CategoryInfoUpdReq categoryInfoUpdReq) {
Boolean b = categoryInfoMapper.updById(id, categoryInfoUpdReq); Boolean b = categoryInfoMapper.updById(id, categoryInfoUpdReq);
asCategoryAttributeGroupService.remove(new LambdaQueryWrapper<AsCategoryAttributeGroup>().eq(AsCategoryAttributeGroup::getCategoryId,id)); LambdaQueryWrapper<AsCategoryAttributeGroup> groupServiceLambdaQueryWrapper = new LambdaQueryWrapper<>();
groupServiceLambdaQueryWrapper.eq(AsCategoryAttributeGroup::getCategoryId,id);
asCategoryAttributeGroupService.remove(groupServiceLambdaQueryWrapper);
asCategoryAttributeService.remove(new LambdaQueryWrapper<AsCategoryAttribute>().eq(AsCategoryAttribute::getCategoryId,id)); LambdaQueryWrapper<AsCategoryBrand> asCategoryBrandLambdaQueryWrapper = new LambdaQueryWrapper<>();
asCategoryBrandLambdaQueryWrapper.eq(AsCategoryBrand::getCategoryId,id);
asCategoryBrandService.remove(asCategoryBrandLambdaQueryWrapper);
asCategoryBrandService.remove(new LambdaQueryWrapper<AsCategoryBrand>().eq(AsCategoryBrand::getCategoryId,id)); LambdaQueryWrapper<AsCategoryAttribute> asCategoryAttributeLambdaQueryWrapper = new LambdaQueryWrapper<>();
asCategoryAttributeLambdaQueryWrapper.eq(AsCategoryAttribute::getCategoryId,id);
asCategoryAttributeService.remove(asCategoryAttributeLambdaQueryWrapper);
if (null!=categoryInfoUpdReq.getBrandIdList()){ if (null!=categoryInfoUpdReq.getBrandIdList()){
categoryInfoUpdReq.getBrandIdList().stream().forEach(brandId->{ categoryInfoUpdReq.getBrandIdList().stream().forEach(brandId->{
@ -324,17 +330,17 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
QueryWrapper<CategoryInfo> queryWrapper = new QueryWrapper<>(); QueryWrapper<CategoryInfo> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("parent_id",ids); queryWrapper.eq("parent_id",ids);
List<CategoryInfo> categoryInfos = categoryInfoMapper.selectList(queryWrapper); List<CategoryInfo> categoryInfos = categoryInfoMapper.selectList(queryWrapper);
if(categoryInfos.size()==0){//长度为0 就是没有子集
if(0 == categoryInfos.size()){//无子级
//是否有商品关联关系 //是否有商品关联关系
List<ProjectInfo> list = categoryInfoMapper.selectProjectInfoById(ids); // 商品信息对象 project_info List<ProjectInfo> list = categoryInfoMapper.selectProjectInfoById(ids); // 商品信息对象 project_info
if(0 == list.size()) {//无商品关联 if(list.size()==0) {//商品的列表长度为0 就是没有集合
categoryInfoMapper.delete(new LambdaQueryWrapper<CategoryInfo>().eq(CategoryInfo::getId, ids)); LambdaQueryWrapper<CategoryInfo> eq = new LambdaQueryWrapper<CategoryInfo>().eq(CategoryInfo::getId, ids);
return Result.success("删除成功"); categoryInfoMapper.delete(eq);
return Result.success("删除...成功了...");
} }
return Result.error("有商品关联关系无法删除...."); return Result.error("不能删除不能删除因为有商品....");
} }
return Result.error("有子级无法删除....."); return Result.error("不能删除不能删除有孩子.....");
} }
@Override @Override
@ -391,6 +397,7 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
return; return;
} }
CategoryInfo categoryInfo = this.getById(cateGoryId); CategoryInfo categoryInfo = this.getById(cateGoryId);
parentIdList.add(categoryInfo.getId()); parentIdList.add(categoryInfo.getId());
getParentIdListByCateGoryId(parentIdList, categoryInfo.getParentId()); getParentIdListByCateGoryId(parentIdList, categoryInfo.getParentId());
} }

View File

@ -149,13 +149,16 @@ public class RuleInfoServiceImpl extends ServiceImpl<RuleInfoMapper, RuleInfo>
@Override @Override
public void updRuleId(Long id, RuleInfoUpdRes ruleInfoUpdRes) { public void updRuleId(Long id, RuleInfoUpdRes ruleInfoUpdRes) {
ruleInfoUpdMapper.del(id); ruleAttrInfoService.remove(new LambdaQueryWrapper<RuleAttrInfo>().eq(RuleAttrInfo::getRuleId,id));
List<RuleAttrAddModel> ruleAttrList = ruleInfoUpdRes.getRuleAttrList();
for (RuleAttrAddModel ruleAttrAddModel : ruleAttrList) { if (null!=ruleInfoUpdRes.getRuleAttrList()){
ruleInfoUpdRes.getRuleAttrList().stream().forEach(ruleAttrAddModel -> {
List<String> valueList = ruleAttrAddModel.getValueList(); List<String> valueList = ruleAttrAddModel.getValueList();
String join = String.join(",", valueList); String join = String.join(",", valueList);
ruleInfoUpdMapper.addRuleInfo(id,ruleAttrAddModel.getName(),join); ruleInfoUpdMapper.addRuleInfo(id,ruleAttrAddModel.getName(),join);
});
} }
} }
} }