package com.crm.custom.dao.repository;

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

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

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


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

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

    CustomLoginTable getFirstByLogin(Long login);

    Integer countByCustomId(Long customId);
}
