package com.crm.custom.dao.repository;

import com.crm.rely.backend.dao.repository.BaseRepository;
import com.crm.rely.backend.model.pojo.table.CustomLoginFirmOfferTable;
import org.springframework.data.jpa.repository.Lock;
import org.springframework.stereotype.Repository;

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

/**
 * @author: houn
 */
@Repository
public interface CustomLoginFirmOfferRepository extends BaseRepository<CustomLoginFirmOfferTable> {

    @Lock(LockModeType.PESSIMISTIC_WRITE)
    CustomLoginFirmOfferTable findFirstById(Long id);

    CustomLoginFirmOfferTable getFirstByLogin(Long login);

    @Lock(LockModeType.PESSIMISTIC_WRITE)
    CustomLoginFirmOfferTable findFirstByLoginAndCustomId(Long login, Long customId);


    @Lock(LockModeType.PESSIMISTIC_WRITE)
    CustomLoginFirmOfferTable findFirstByLogin(Long login);

    boolean existsByCustomIdAndStatusIn(Long customId, List<Integer> status);

    @Lock(LockModeType.PESSIMISTIC_WRITE)
    List<CustomLoginFirmOfferTable> findAllByCustomId(Long customId);

    @Lock(LockModeType.PESSIMISTIC_WRITE)
    List<CustomLoginFirmOfferTable> findAllByCustomIdAndStatus(Long customId, Integer status);

}
