package com.crm.custom.dao.repository;

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

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

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

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

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

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

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

    CustomLoginAssetManagementTable getFirstByLogin(Long login);

    boolean existsByLogin(Long login);
}
