package com.ffii.fpsms.modules.productProcess.entity

import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.data.jpa.repository.JpaSpecificationExecutor
import org.springframework.stereotype.Repository
import java.util.*
import java.time.LocalDate

@Repository
interface ProductProcessRepository : JpaRepository<ProductProcess, Long>, JpaSpecificationExecutor<ProductProcess> {
    fun findByProductProcessCode(code: String): Optional<ProductProcess>
    fun findByJobOrder_Id(jobOrderId: Long): List<ProductProcess>
    fun findByProductProcessCodeStartingWith(prefix: String): List<ProductProcess>
    fun findTopByProductProcessCodeStartingWithOrderByProductProcessCodeDesc(prefix: String): ProductProcess?
    fun findByIdAndDeletedIsFalse(id: Long): Optional<ProductProcess>
    fun findAllByDeletedIsFalse(): List<ProductProcess>
    fun findByBom_Id(bomId: Long): List<ProductProcess>
    fun findAllByDeletedIsFalseAndDate(date: LocalDate): List<ProductProcess>
    fun findByJobOrder_IdInAndDeletedIsFalse(jobOrderIds: List<Long>): List<ProductProcess>
}