package com.kospo.talk.repository;

import com.kospo.talk.model.Question;
import com.kospo.talk.model.QuestionId;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface QuestionRepository extends JpaRepository<Question, QuestionId> {
    @Query(value = "select * from question\n" +
            "where work_id in (\n" +
            "    select work_id from sm_user where sabun = :sabun\n" +
            "    )", nativeQuery = true)
    List<Question> findBySabun(@Param("sabun") String sabun);

    List<Question> findByIdWorkIdOrderByIdSortAsc(String workId);

    Question findByIdWorkIdAndContentLike(String workId, String content);
}