| | |
| | | goods.setCreateDate(new Date()); |
| | | goods.setCreator(user.getId()); |
| | | goods.setIsdeleted(Constants.ZERO); |
| | | //处理拼音问题 |
| | | goods.setPinyin(PinYinUtil.getFullSpell(goods.getName())); |
| | | goods.setShortPinyin(PinYinUtil.getFirstSpell(goods.getName())); |
| | | this.validateSubCategory(goods); |
| | | goodsMapper.insert(goods); |
| | | |
| | | List<Multifile> multifileList = goods.getMultifileList(); |
| | |
| | | goods.setEditDate(new Date()); |
| | | goods.setEditor(user.getId()); |
| | | goods.setIsdeleted(Constants.ZERO); |
| | | //处理拼音问题 |
| | | goods.setPinyin(PinYinUtil.getFullSpell(goods.getName())); |
| | | goods.setShortPinyin(PinYinUtil.getFirstSpell(goods.getName())); |
| | | this.validateSubCategory(goods); |
| | | goodsMapper.updateById(goods); |
| | | |
| | | multifileMapper.delete(new QueryWrapper<Multifile>().eq("OBJ_ID",goods.getId()) |
| | |
| | | queryWrapper.eq(Goods::getIsdeleted,Constants.ZERO); |
| | | |
| | | queryWrapper.eq(!Objects.isNull(pageWrap.getModel()) && !Objects.isNull(pageWrap.getModel().getCategoryId()), Goods::getCategoryId, pageWrap.getModel().getCategoryId()) |
| | | .eq(!Objects.isNull(pageWrap.getModel()) && !Objects.isNull(pageWrap.getModel().getSubCategoryId()), Goods::getSubCategoryId, pageWrap.getModel().getSubCategoryId()) |
| | | .eq(!Objects.isNull(pageWrap.getModel()) && !Objects.isNull(pageWrap.getModel().getBrandId()), Goods::getBrandId, pageWrap.getModel().getBrandId()) |
| | | .and(!Objects.isNull(pageWrap.getModel()) && StringUtils.isNotBlank(pageWrap.getModel().getKeyword()), |
| | | i->i.like(Goods::getPinyin,pageWrap.getModel().getKeyword()) |
| | |
| | | this.dealGoodsMsg(goodsIPage.getRecords()); |
| | | } |
| | | return PageData.from(goodsIPage); |
| | | } |
| | | |
| | | private void validateSubCategory(Goods goods) { |
| | | if (goods.getSubCategoryId() == null) { |
| | | return; |
| | | } |
| | | Category sub = categoryMapper.selectById(goods.getSubCategoryId()); |
| | | if (sub == null || sub.getParentId() == null || !sub.getParentId().equals(goods.getCategoryId())) { |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "二级类别必须属于所选一级品类"); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | queryWrapper.eq(Goods::getIsdeleted,Constants.ZERO); |
| | | queryWrapper.eq(Goods::getCompanyId,loginUserInfo.getCompanyId()); |
| | | queryWrapper.eq(!Objects.isNull(goodsRequest) && !Objects.isNull(goodsRequest.getCategoryId()), Goods::getCategoryId, goodsRequest.getCategoryId()) |
| | | .eq(!Objects.isNull(goodsRequest) && !Objects.isNull(goodsRequest.getSubCategoryId()), Goods::getSubCategoryId, goodsRequest.getSubCategoryId()) |
| | | .eq(!Objects.isNull(goodsRequest) && !Objects.isNull(goodsRequest.getBrandId()), Goods::getBrandId, goodsRequest.getBrandId()) |
| | | .and(!Objects.isNull(goodsRequest) && StringUtils.isNotBlank(goodsRequest.getKeyword()), |
| | | i->i.like(Goods::getPinyin,goodsRequest.getKeyword()) |