springboot编辑调用save方法

/**
* 编辑商品
* @param productInfo
* @return
* @throws BreezeeException
*/
@PostMapping(“/editProductInfo”)
Response editProductInfo(@RequestBody ProductInfo productInfo) throws BreezeeException;

/**
* 商品的编辑
* @param productInfo
* @return
*/
@Override
public Response editProductInfo(ProductInfo productInfo) throws BreezeeException {
productInfo.setOperType( OperTypeEnum.WRITE);
//1、用id查询相应的数据–》进行相应的set
//2、获取get 到info(传入)的每个值做判断。
ProductInfo p= new ProductEntity().buildId(productInfo.getId()).buildCode(productInfo.getId()).findOne();
ProductInfo result=null;
if (p!=null){
if (productInfo.getName()!=null){
p.setName(productInfo.getName());
}
if (productInfo.getCategory()!=null){
p.setCategory(productInfo.getCategory());
}
if (productInfo.getCatalogId()!=null){
p.setCatalogId(productInfo.getCatalogId());
}
if (productInfo.getDescription()!=null){
p.setDescription(productInfo.getDescription());
}
if (productInfo.getRemark()!=null){
p.setRemark(productInfo.getRemark());
}
if (productInfo.getExpired()!=null){
p.setExpired(productInfo.getExpired());
}
if (productInfo.getGrossWeight()!=null){
p.setGrossWeight(productInfo.getGrossWeight());
}
if (productInfo.getHeight()!=null){
p.setHeight(productInfo.getHeight());
}
if (productInfo.getLength()!=null){
p.setLength(productInfo.getLength());
}
if (productInfo.getNetWeight()!=null){
p.setNetWeight(productInfo.getNetWeight());
}
if (productInfo.getSalePrice()!=null){
p.setSalePrice(productInfo.getSalePrice());
}
if (productInfo.getStandard()!=null){
p.setStandard(productInfo.getStandard());
}
if (productInfo.getStoreId()!=null){
p.setStoreId(productInfo.getStoreId());
}
if (productInfo.getTemperature()!=null){
p.setTemperature(productInfo.getTemperature());
}
if (productInfo.getImages()!=null){
p.setImages(productInfo.getImages());
}
if (productInfo.getTotalQuantity()!=null){
p.setTotalQuantity(productInfo.getTotalQuantity());
}
if (productInfo.getUc()!=null){
p.setUc(productInfo.getUc());
}
if (productInfo.getVolume()!=null){
p.setVolume(productInfo.getVolume());
}
result = (ProductInfo) new ProductEntity().createWithInfo(p).save();

    }


    return JsonResponse.buildSingle(result);
}

你可能感兴趣的:(java后端,spring,boot,updat,save)