package com.crm.ucard.dao.repository;

import com.crm.rely.backend.core.pojo.table.CustomInfoTable;
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 CustomInfoRepository extends BaseRepository<CustomInfoTable> {

    /**
     * 邮箱密码查询用户
     *
     * @param email
     * @param password
     * @return
     */
    CustomInfoTable findFirstByEmailAndPassword(String email, String password);

    /**
     * id密码查询用户
     *
     * @param id
     * @param password
     * @return
     */
    CustomInfoTable findFirstByIdAndPassword(Long id, String password);

    CustomInfoTable getFirstByEmailNotNullAndEmail(String email);

    /**
     * 根据id查询用户信息
     *
     * @param id
     * @return
     */
    @Lock(LockModeType.PESSIMISTIC_WRITE)
    CustomInfoTable findFirstById(Long id);

    CustomInfoTable getFirstById(Long id);

    @Lock(LockModeType.PESSIMISTIC_WRITE)
    CustomInfoTable findFirstByCId(Long cId);
}
