package com.ym.dao;

import com.ym.pojo.Whiteboard;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by weiqinxiao on 2019/2/25.
 */
@Repository
public interface WhiteboardDao extends JpaRepository<Whiteboard, Long> {
    List<Whiteboard> findByRid(String rid);

    List<Whiteboard> findByRidAndCreator(String rid, String creator);

    List<Whiteboard> findByRidAndWbid(String rid, String wbid);

    int deleteByRid(String rid);

    @Modifying
    int deleteByWbid(String wbid);

    @Modifying
    @Query(value = "delete from rongyun_whiteboard where rid=?1 and creator=?2", nativeQuery = true)
    int deleteByRidAndCreator(String rid, String creator);

    @Modifying
    @Query(value = "update rongyun_whiteboard set cur_pg=?3 where wbid=?2 and rid=?1", nativeQuery = true)
    int updatePageByRidAndWbid(String rid, String wbid, int page);
}