谷粒商城-商品管理

1.SPU检索(复杂条件查询)

来到spuinfocontroller找到list,来重新写一个分页查询方法

来到实现类写方法体(brandId和catelogId记得要排除掉0再拼装查询条件)下图未排除

2.SKU检索(价格区间功能)

来到skuinfocontroller类里

写方法体

    @Override
    public PageUtils queryPageByCondition(Map<String, Object> params) {
        QueryWrapper<SkuInfoEntity> wrapper = new QueryWrapper<>();
        String key = (String) params.get("key");
        if (StringUtils.hasLength(key)){//如果有key 拼装查skuId 和模糊查询skuName
            wrapper.and(w->{
                w.eq("sku_id",key).or().like("sku_name",key);
            });
        }
        String catelogId = (String) params.get("catelogId");
        if (StringUtils.hasLength(catelogId)&& !"0".equalsIgnoreCase(catelogId)){//如果传了catelogId,拼装条件查询
            wrapper.eq("catalog_id",catelogId);
        }
        String brandId = (String) params.get("brandId");
        if (StringUtils.hasLength(brandId)&&!"0".equalsIgnoreCase(brandId)){//如果传了brandId,拼装条件查询
            wrapper.eq("brand_id",brandId);
        }
        String min = (String) params.get("min");
        if (StringUtils.hasLength(min)){//拼装最小值min,价格price要大于等于 min
            wrapper.ge("price",min);
        }
        String max = (String) params.get("max");
        if (StringUtils.hasLength(max) ){//拼装最大值 max 
            try {//放try是怕前端传来别的类型的值
                BigDecimal bigDecimal = new BigDecimal(max);//把max转成BigDecimal类型,来排除当max==0时,我们不拼装小于max这个条件
                if (bigDecimal.compareTo(new BigDecimal("0"))==1){
                    wrapper.le("price",max);
                }
            }catch (Exception e){
            }
        }
        IPage<SkuInfoEntity> page = this.page(
                new Query<SkuInfoEntity>().getPage(params),wrapper
        );
        return new PageUtils(page);
    }

P100SPU规格维护

找不到页面的可以先来前端的/src/router/index.js 在mainRoutes->children【】里面加上:{ path: '/product-attrupdate', component: _import('modules/product/attrupdate'), name: 'attr-update', meta: { title: '规格维护', isTab: true } },

然后来到数据库:gulimall_admin执行以下sql再刷新页面即可:【INSERT INTO sys_menu (menu_id, parent_id, name, url, perms, type, icon, order_num) VALUES (76, 37, '规格维护', 'product/attrupdate', '', 2, 'log', 0);】

解决后来看API文档,业务逻辑就是点击规格按钮让事务进行回显

controller

方法体:

    @Override
    public List<ProductAttrValueEntity> baseAttrListForSpu(Long spuId) {
        List<ProductAttrValueEntity> entities = this.baseMapper.selectList(new QueryWrapper<ProductAttrValueEntity>().eq("spu_id", spuId));
        return entities;
    }

2.修改商品规格

Tips:修改时间戳

来到配置文件

spring/Jackson/date-format: 格式

时区不对的话加time-zone

  • 14
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值