package com.ffii.fpsms.modules.jobOrder.entity

import com.ffii.core.support.AbstractRepository
import com.ffii.fpsms.modules.jobOrder.entity.projections.JobOrderInfo
import org.springframework.data.domain.Page
import org.springframework.data.domain.Pageable
import org.springframework.data.jpa.repository.Query
import org.springframework.stereotype.Repository

@Repository
interface JobOrderRepository : AbstractRepository<JobOrder, Long> {
    @Query("""
        select jo.code from JobOrder jo where jo.code like :prefix% order by jo.code desc limit 1
    """)
    fun findLatestCodeByPrefix(prefix: String): String?

    fun findJobOrderInfoByCodeContainsAndBomNameContainsAndDeletedIsFalseOrderByIdDesc(code: String, bomName: String, pageable: Pageable): Page<JobOrderInfo>
}