package com.crm.ucard.dao.repository;

import com.crm.rely.backend.core.pojo.table.CustomLoginTable;
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;

/**
 * @description:
 * @author: houn
 * @create: 2020-05-05 16:25
 */
@Repository
public interface CustomLoginRepository extends BaseRepository<CustomLoginTable> {

    /**
     * 根据用户id拉取用户所有的交易账户
     *
     * @param customId
     * @return
     */
    List<CustomLoginTable> getAllByCustomId(Long customId);

    CustomLoginTable getFirstByCustomIdAndLogin(Long customId, Long login);

    CustomLoginTable getFirstByLogin(Long login);

    List<CustomLoginTable> getByCustomIdAndLoginIn(Long customId, List<Long> logins);

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

    @Lock(LockModeType.PESSIMISTIC_WRITE)
    List<CustomLoginTable> findAllByCustomIdAndAgentId(Long customId, Long agentId);

}
