package com.neusoft.smart.pos.inventory.repository;


import com.neusoft.smart.pos.framework.exception.BusinessCommonException;
import com.neusoft.smart.pos.inventory.constants.GoodsErrorCode;
import com.neusoft.smart.pos.inventory.persistent.domain.InventoryGoodsLockInfo;
import com.neusoft.smart.pos.inventory.persistent.mapper.InventoryGoodsLockInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class InventoryGoodsLockInfoRepository {
    
    @Autowired
    private InventoryGoodsLockInfoMapper inventoryGoodsLockInfoMapper;
    
    public Integer updateWithVersion(InventoryGoodsLockInfo inventoryGoodsLockInfo) {
        Integer result = inventoryGoodsLockInfoMapper.updateByPrimaryKey(inventoryGoodsLockInfo);
        if (result == 0) {
            throw new BusinessCommonException(GoodsErrorCode.DATA_UPDATE_ERROR);
        }
        return result;
    }
    
    public Integer updateSelectiveWithVersion(InventoryGoodsLockInfo inventoryGoodsLockInfo) {
        Integer result = inventoryGoodsLockInfoMapper.updateByPrimaryKeySelective(inventoryGoodsLockInfo);
        if (result == 0) {
            throw new BusinessCommonException(GoodsErrorCode.DATA_UPDATE_ERROR);
        }
        return result;
    }
}
