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

import com.neusoft.smart.pos.inventory.constants.InventoryConstant;
import com.neusoft.smart.pos.inventory.persistent.domain.InventoryStoreInout;
import com.neusoft.smart.pos.inventory.persistent.domain.InventoryStoreInoutExample;
import com.neusoft.smart.pos.inventory.persistent.mapper.InventoryStoreInoutMapper;
import lombok.val;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author tjm
 * @date 2018-06-20 13：57
 * @description 库存流水Repository
 */
@Component
public class InventoryStoreInoutRepository {
    
    @Autowired
    public InventoryStoreInoutMapper inventoryStoreInoutMapper;
    
    public int insertSelective(InventoryStoreInout inventoryStoreInout) {
        return inventoryStoreInoutMapper.insertSelective(inventoryStoreInout);
    }
    
    public List<InventoryStoreInout> selectSaleRecordByUniqId(InventoryStoreInout inventoryStoreInout) {
        val example = new InventoryStoreInoutExample();
        example.createCriteria()
                .andGoodsIdEqualTo(inventoryStoreInout.getGoodsId())
                .andActionTypeEqualTo(InventoryConstant.GOODS_SALE)
                .andUniqIdEqualTo(inventoryStoreInout.getUniqId());
        return inventoryStoreInoutMapper.selectByExample(example);
    }
    
}
