package de.votian.services.repository;

import de.votian.services.entity.JobPrice;
import de.votian.services.entity.JobPriceId;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import java.util.List;

public interface JobPriceRepository extends JpaRepository<JobPrice, JobPriceId> {

    List<JobPrice> findByJobIdOrderByMetaSortAsc(Long jobId);

    @Modifying
    @Query("DELETE FROM JobPrice jp WHERE jp.jobId = :jobId")
    void deleteByJobId(@Param("jobId") Long jobId);

    @Modifying
    @Query("DELETE FROM JobPrice jp WHERE jp.jobId = :jobId AND jp.metaSort = :metaSort")
    void deleteByJobIdAndMetaSort(@Param("jobId") Long jobId, @Param("metaSort") Integer metaSort);
}
