商品更新bug修改

This commit is contained in:
joylink_zhangsai 2020-12-22 18:19:43 +08:00
parent 6c5713bfda
commit aab1348b33

View File

@ -221,18 +221,13 @@ public class GoodsService implements IGoodsService {
* 如果要更新的商品不存在报DBException数据不存在
*/
public void updateGoods(Long id, GoodsUpdateVO updateVO, UserVO user) {
confirmExist(id);
SaleGoods goods = updateVO.convert2DB();
goods.setId(id);
goods.setUpdateUserId(user.getId());
goods.setUpdateTime(LocalDateTime.now());
saleGoodsDAO.updateByPrimaryKeySelective(goods);
}
private void confirmExist(Long id) {
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotTrue(isExist(id),
String.format("id为[%s]的商品不存在", id));
SaleGoods entity = getEntityById(id);
entity.setName(updateVO.getName());
entity.setPrice((long) (updateVO.getPrice() * 100));
entity.setRemarks(updateVO.getRemarks());
entity.setUpdateUserId(user.getId());
entity.setUpdateTime(LocalDateTime.now());
saleGoodsDAO.updateByPrimaryKeySelective(entity);
}
@Override