package com.crm.manager.dao.repository;

import com.crm.rely.backend.dao.repository.BaseRepository;
import com.crm.rely.backend.model.pojo.table.CustomInfoTable;
import org.springframework.data.jpa.repository.Lock;
import org.springframework.stereotype.Repository;

import javax.persistence.LockModeType;
import java.util.List;

/**
 * Created by max on 2020/6/17.
 */
@Repository
public interface CustomInfoRepository extends BaseRepository<CustomInfoTable> {

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

    CustomInfoTable getFirstByCId(Long cId);

    @Lock(LockModeType.PESSIMISTIC_WRITE)
    List<CustomInfoTable> findAllByAgentId(Long agentId);

    CustomInfoTable getFirstBySno(String sno);

    CustomInfoTable getFirstBySnoAndIdNotAndStatusNot(String sno, Long id, Integer status);


    CustomInfoTable getFirstByEmail(String email);

    boolean existsByIdentity(String identity);
}
