package com.crm.web.dao.repository;

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

    WebNoticeRecordTable getFirstById(Long id);

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

    @Lock(LockModeType.PESSIMISTIC_WRITE)
    List<WebNoticeRecordTable> findFirstByIdIn(List<Long> ids);

    @Lock(LockModeType.PESSIMISTIC_WRITE)
    List<WebNoticeRecordTable> findFirstByIdInAndCustomIdAndRead(List<Long> ids, Long customId, Integer read);

    @Lock(LockModeType.PESSIMISTIC_WRITE)
    List<WebNoticeRecordTable> findFirstByCustomIdAndRead(Long customId, Integer read);
}
