package com.crunii.micro.domain.repo.main;

import com.crunii.micro.domain.common.BaseRepo;
import com.crunii.micro.domain.entity.main.YcqDynamicFormConfig;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Optional;

public interface YcqFormRepo extends BaseRepo<YcqDynamicFormConfig, Long> {

    @Query(value = "SELECT * FROM flo_form WHERE id in (?1)", nativeQuery = true)
    List<YcqDynamicFormConfig> findByIds(List<Long> ids);

    @Query(value = "SELECT * FROM ycq_form ff WHERE ff.id = (SELECT max(id) FROM ycq_form ff1 WHERE ff1.CODE = ?1)", nativeQuery = true)
    Optional<YcqDynamicFormConfig> getLastForm(String code);

}
