|
|
@@ -25,6 +25,9 @@ public class ProductServiceImpl implements ProductService {
|
|
|
|
|
|
@Override
|
|
|
public Boolean create(ProductVO productVO) {
|
|
|
+ if (productRepository.findByStoreIdAndName(productVO.getStoreId(),productVO.getName())==null){
|
|
|
+ throw BlueWhaleException.nameAlreadyExists();
|
|
|
+ }
|
|
|
Product product=productVO.toPO();
|
|
|
product.setSalesAmount(0);
|
|
|
product.setStock(0);
|
|
|
@@ -35,12 +38,12 @@ public class ProductServiceImpl implements ProductService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Boolean addStock(Integer id) {
|
|
|
+ public Boolean addStock(Integer id, Integer number) {
|
|
|
Product product=productRepository.findById(id).orElse(null);
|
|
|
if(product==null){
|
|
|
throw BlueWhaleException.productNotExists();
|
|
|
}
|
|
|
- product.setStock(product.getStock()+1);
|
|
|
+ product.setStock(product.getStock()+number);
|
|
|
productRepository.save(product);
|
|
|
return true;
|
|
|
}
|