package com.crm.ucard.dao.repository;

import com.crm.rely.backend.core.pojo.table.ucard.UcardCardTable;
import com.crm.rely.backend.dao.repository.BaseRepository;
import org.springframework.data.jpa.repository.Lock;
import org.springframework.stereotype.Repository;

import javax.persistence.LockModeType;
import java.util.List;

@Repository
public interface UcardCardRepository extends BaseRepository<UcardCardTable> {

    @Lock(LockModeType.PESSIMISTIC_WRITE)
    UcardCardTable findByCardNo(String cardNo);

    UcardCardTable getByCardNo(String cardNo);

    UcardCardTable findByUniqueIdAndCardTypeId(String uniqueId, Integer cardTypeId);

    @Lock(LockModeType.PESSIMISTIC_WRITE)
    UcardCardTable findFirstById(Long id);
    UcardCardTable getFirstById(Long id);

    List<UcardCardTable> findAllByStatus(String status);
    List<UcardCardTable> findAllByStatusAndLogisticsStatusNot(String status, String logisticsStatus);
    UcardCardTable getByCardNumber(String cardNumber);

}
