package com.betriebsratkanzlei.legalconsenthub.application_form

import org.springframework.data.domain.Page
import org.springframework.data.domain.Pageable
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.data.jpa.repository.Query
import org.springframework.stereotype.Repository
import java.util.UUID

@Repository
interface ApplicationFormRepository : JpaRepository<ApplicationForm, UUID> {
    fun findAllByIsTemplateTrue(page: Pageable): Page<ApplicationForm>

    @Query("SELECT c FROM ApplicationForm c WHERE (c.isTemplate IS false) AND (:organizationId is null or c.organizationId = :organizationId)")
    fun findAllByIsTemplateFalseAndOrganizationId(organizationId: String?, page: Pageable): Page<ApplicationForm>
}
