package com.dbnt.kcscopensearch.opensearch.documentGroup.service;

import com.dbnt.kcscopensearch.opensearch.documentGroup.model.DocumentGroup;
import com.dbnt.kcscopensearch.opensearch.documentGroup.repository.DocumentGroupRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@RequiredArgsConstructor
public class DocumentGroupService {

  private final DocumentGroupRepository documentGroupRepository;

  public List<DocumentGroup> search(String groupNm){
    return documentGroupRepository.findByGroupNmLike(groupNm);
  }

  @Transactional
  public void save(List<DocumentGroup> documentGroupList) {
    documentGroupRepository.saveAll(documentGroupList);
  }
}
