谷粒商城day52 -商品服务-API-属性分组-分组修改&级联选择器回显

1.添加catelogIds字段

因为我们分组修改页面,实际分类ID显示是一个分类数组  

在实体类中添加字段

2.后端实现

controller层

    @RequestMapping("/info/{attrGroupId}")
    public R info(@PathVariable("attrGroupId") Long attrGroupId){
		AttrGroupEntity attrGroup = attrGroupService.getById(attrGroupId);

        //根据当前分类获取其分类父分类组合
        attrGroup.setCatelogIds(categoryService.getCatelogIds(attrGroup.getCatelogId()));

        return R.ok().put("attrGroup", attrGroup);
    }

service层

CategoryServiceImpl
    @Override
    public Long[] getCatelogIds(Long catelogId) {
        ArrayList<Long> arrayList = new ArrayList<>();

       return getCategoryArray(catelogId,arrayList);
    }

   public Long[] getCategoryArray(Long catelogId,ArrayList<Long> arr){
        arr.add(catelogId);
       CategoryEntity categoryEntity = this.getById(catelogId);
       if(categoryEntity.getParentCid() != 0 )
       {
           getCategoryArray(categoryEntity.getParentCid(),arr);
       }

       Collections.reverse(arr);

       return arr.toArray(new Long[]{});
    }

3.测试成功

修改时分类成功带出来了

 4.弹窗关闭时分类置为空

如下

添加监听 

 

方法,将分类数组置为空

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

我才是真的封不觉

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值