package com.dbnt.kcscbackend.standardCode.repository;


import com.dbnt.kcscbackend.standardCode.entity.TnDocumentContent;
import com.dbnt.kcscbackend.standardCode.service.StandardCodeContentInterface;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Optional;

public interface TnDocumentContentRepository extends JpaRepository<TnDocumentContent, Integer> {

  @Query(value = "select * from get_recent_full_context_by_content(:docCode, :docPart)", nativeQuery = true)
  List<StandardCodeContentInterface> getRecentFullContextByContent(String docCode, String docPart);

  @Query(value = "select * from get_year_full_context_by_content(:docInfoSeq, :docCode, :docPart, null, null)", nativeQuery = true)
  List<StandardCodeContentInterface> getYearFullContextByContent(Integer docInfoSeq, String docCode, String docPart);

  @Query(value = "select * from sp_get_recent_full_context_by_content(:docCode, :docPart, :ymd)", nativeQuery = true)
  List<StandardCodeContentInterface> spGetRecentFullContextByContent(String docCode, String docPart, String ymd);

  Optional<TnDocumentContent> findByDocContSeq(Integer docContSeq);

}
