package com.lanyuanxiaoyao.leopard.core.repository;

import com.lanyuanxiaoyao.leopard.core.entity.Stock;
import com.lanyuanxiaoyao.service.template.repository.SimpleRepository;
import jakarta.transaction.Transactional;
import java.util.Collection;
import java.util.Set;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

/**
 * @author lanyuanxiaoyao
 * @version 20250828
 */
@Repository
public interface StockRepository extends SimpleRepository<Stock> {
  @Query("select distinct stock.industry from Stock stock where stock.industry is not null")
  Set<String> findDistinctIndustries();

  @Query("select distinct stock.code from Stock stock")
  Set<String> findDistinctCodes();

  @Transactional(rollbackOn = Throwable.class)
  @Modifying
  void deleteAllByCodeIn(Collection<String> code);
}
