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

import com.crunii.micro.domain.common.BaseRepo;
import com.crunii.micro.domain.entity.main.TsmPostWorker;
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 org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Repository
@Transactional(rollbackFor = Exception.class)
public interface TsmPostWorkerRepo extends BaseRepo<TsmPostWorker, String> {

    @Query(value = "select * from tsm_post_worker where post_id=:postId", nativeQuery = true)
    List<TsmPostWorker> findByPostId(@Param("postId") Long postId);

    @Modifying
    @Query(value = "delete from tsm_post_worker where worker_id=:workerId", nativeQuery = true)
    List<TsmPostWorker> deletePostByWorker(@Param("workerId") Long workerId);
}
