package com.eactive.eai.rms.data.entity.onl.apim.portalinquiry;

import com.eactive.apim.portal.qna.entity.InquiryComment;
import com.eactive.eai.data.jpa.BaseRepository;
import com.eactive.eai.rms.data.EMSDataSource;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;

@EMSDataSource
public interface PortalInquiryCommentRepository extends BaseRepository<InquiryComment, String> {

    long countByInquiry_Id(String inquiryId);

    long countByInquiry_IdAndDelYn(String inquiryId, String delYn);

    List<InquiryComment> findByInquiry_IdAndDelYnOrderByCreatedDateAsc(String inquiryId, String delYn);

    Optional<InquiryComment> findTopByInquiry_IdAndDelYnOrderByCreatedDateDesc(
            String inquiryId, String delYn);

    Optional<InquiryComment> findTopByInquiry_IdAndAdminYnAndDelYnOrderByCreatedDateDesc(
            String inquiryId, String adminYn, String delYn);

    boolean existsByInquiry_IdAndAdminYnAndDelYnAndCreatedDateAfter(
            String inquiryId, String adminYn, String delYn, LocalDateTime after);
}
