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

import com.crunii.micro.domain.common.BaseRepo;
import com.crunii.micro.domain.entity.main.YcqArticleDetail;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author baoxy
 * @date 2023-06-27
 */
@Repository
public interface YcqArticleDetailRepo extends BaseRepo<YcqArticleDetail, Long> {

    List<YcqArticleDetail> findByMatchId(Long matchId);

    @Modifying(flushAutomatically = true)
    @Query("update YcqArticleDetail u set u.matchId = :matchId where u.articleId = :articleId")
    void updateMatchId(@Param("articleId") Long articleId, @Param("matchId") Long matchId);
}
