@Override public List<MainProduct> allEnabledMainProduct() { return mainProductRepository.findByEnableTrue(); }
@GetMapping("/manageProductEdit") public String indexForEdit(String code, Model model) { model.addAttribute("currentData", mainProductRepository.getOne(code)); return "_productOperate.html"; }
private void products() throws IOException { if (mainProductRepository.count() > 0) { mainProductRepository.findByProductTypeNull().forEach(product -> { log.info(product + "需要设置货品属性"); mainProductRepository.save(product); }); return; final String productName = value[0]; MainProduct mainProduct = mainProductRepository.findOne(type); ProductType productType = productTypeRepository.findTop1ByName(productName); if (mainProduct == null) { mainProduct = mainProductRepository.save(mainProduct);
if (StringUtils.isEmpty(productName)) throw new IllegalArgumentException(""); if (mainProductRepository.findOne(code) != null) throw new IllegalArgumentException(""); if (productTypeRepository.findOne(productType) == null) product.setCode(code); } else { product = mainProductRepository.getOne(code); product = mainProductRepository.saveAndFlush(product); mainProductRepository.save(product); if(isCleanProductStock){ marketStockService.cleanProductStock(product);
@GetMapping("/manageProductDetail") public String detail(String code, Model model) { model.addAttribute("currentData", mainProductRepository.getOne(code)); return "_productDetail.html"; }
@PostMapping("/products") @ResponseStatus(HttpStatus.NO_CONTENT) @Transactional public void disable(String code) { mainProductRepository.getOne(code).setEnable(false); }
@PutMapping("/products") @ResponseStatus(HttpStatus.NO_CONTENT) @Transactional public void enable(String code) { mainProductRepository.getOne(code).setEnable(true); }
@DeleteMapping("/products") @ResponseStatus(HttpStatus.NO_CONTENT) @Transactional public void delete(String code) { final MainProduct one = mainProductRepository.getOne(code); one.setEnable(false); one.setDeleted(true); }
@PutMapping("/productsHaier") @ResponseStatus(HttpStatus.NO_CONTENT) public void pushHaier(String code) { MainProduct product = mainProductRepository.getOne(code); // 信息校验下先 if (StringUtils.isEmpty(product.getBrand())) throw new IllegalArgumentException(""); if (StringUtils.isEmpty(product.getUnit())) throw new IllegalArgumentException(""); if (StringUtils.isEmpty(product.getSKU())) throw new IllegalArgumentException(""); if (StringUtils.isEmpty(product.getMainCategory())) throw new IllegalArgumentException(""); if (product.getVolumeHeight() == null) throw new IllegalArgumentException(""); if (product.getVolumeHeight() == null) throw new IllegalArgumentException(""); if (product.getVolumeWidth() == null) throw new IllegalArgumentException(""); if (product.getWeight() == null) throw new IllegalArgumentException(""); haierSupplier.updateProduct(product); }
good.setProduct(mainProductRepository.getOne(product));