package com.izouma.wenlvju.repo;

import com.izouma.wenlvju.domain.PerformanceApply;
import com.izouma.wenlvju.enums.ApplyStatus;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import javax.transaction.Transactional;
import java.util.List;

public interface PerformanceApplyRepo extends JpaRepository<PerformanceApply, Long>, JpaSpecificationExecutor<PerformanceApply> {
    @Query("update PerformanceApply t set t.del = true where t.id = ?1")
    @Modifying
    @Transactional
    void softDelete(Long id);

    @Query("update PerformanceApply t set t.del = true where t.performanceId = ?1")
    @Modifying
    @Transactional
    void softDeleteByPerformanceId(Long performanceId);

    List<PerformanceApply> findAllByStatusAndPerformanceId(ApplyStatus status, Long performanceId);

//    List<PerformanceApply> findAllByShowTimeIsNotNullAndPerformanceId(Long performanceId);
}