package com.crm.custom.dao.repository;

import com.crm.rely.backend.dao.repository.BaseRepository;
import com.crm.rely.backend.model.pojo.table.CustomLoginDemoTable;
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 CustomLoginDemoRepository extends BaseRepository<CustomLoginDemoTable> {

    List<CustomLoginDemoTable> getAllByCustomId(Long customId);

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


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

    @Lock(LockModeType.PESSIMISTIC_WRITE)
    List<CustomLoginDemoTable> findAllByCustomIdAndIdIn(Long customId, List<Long> ids);


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


    @Lock(LockModeType.PESSIMISTIC_WRITE)
    List<CustomLoginDemoTable> findAllByCustomIdAndStatusInAndLoginNot(Long customId, List<Integer> status,Long login);

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

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

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

    boolean existsByCustomIdAndStatus(Long customId, Integer status);

    CustomLoginDemoTable getFirstByLogin(Long login);
}
