package com.crm.manager.dao.repository;

import com.crm.rely.backend.core.pojo.table.UserHireTable;
import com.crm.rely.backend.core.pojo.table.UserReferralTable;
import com.crm.rely.backend.dao.repository.BaseRepository;
import org.springframework.data.jpa.repository.Lock;
import org.springframework.stereotype.Repository;

import javax.persistence.LockModeType;

@Repository
public interface UserReferralRepository extends BaseRepository<UserReferralTable> {

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

    UserReferralTable getFirstByReferralUserId(Long referralUserId);

    @Lock(LockModeType.PESSIMISTIC_WRITE)
    UserReferralTable findFirstByReferralCode(String referralCode);

    UserReferralTable getFirstByReferralCode(String referralCode);
}
