package com.crm.custom.dao.repository;

import com.crm.rely.backend.core.pojo.table.CustomFileTable;
import com.crm.rely.backend.dao.repository.BaseRepository;
import org.springframework.data.jpa.repository.Lock;

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


public interface CustomFileRepository extends BaseRepository<CustomFileTable> {

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

    @Lock(LockModeType.PESSIMISTIC_WRITE)
    CustomFileTable findFirstByCustomIdAndType(Long customId, Integer type);

    @Lock(LockModeType.PESSIMISTIC_WRITE)
    List<CustomFileTable> findAllByIdInAndCustomId(List<Long> ids, Long customId);

    List<CustomFileTable> getAllByCustomIdOrderByType(Long customId);

    Integer countByCustomId(Long customId);

    CustomFileTable findFirstByCustomIdAndId(Long customId, Long id);
}
