RoomMemberDao.java 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package com.ym.dao;
  2. import com.ym.pojo.RoomMember;
  3. import org.springframework.data.jpa.repository.JpaRepository;
  4. import org.springframework.data.jpa.repository.Lock;
  5. import org.springframework.data.jpa.repository.Modifying;
  6. import org.springframework.data.jpa.repository.Query;
  7. import org.springframework.stereotype.Repository;
  8. import org.springframework.transaction.annotation.Transactional;
  9. import javax.persistence.LockModeType;
  10. import java.util.List;
  11. /**
  12. * Created by weiqinxiao on 2019/2/25.
  13. */
  14. @Repository
  15. public interface RoomMemberDao extends JpaRepository<RoomMember, Long> {
  16. public List<RoomMember> findByRid(String rid);
  17. @Lock(value = LockModeType.PESSIMISTIC_WRITE)
  18. public List<RoomMember> findByRidAndUid(String rid, String uid);
  19. public List<RoomMember> findByRidAndRole(String rid, int role);
  20. public List<RoomMember> findByUid(String uid);
  21. public int countByRidAndRole(String rid, int role);
  22. @Modifying
  23. @Transactional
  24. public int deleteByRid(String roomId);
  25. @Query(value = "select count(*) from rongyun_room_member where rid=?1", nativeQuery = true)
  26. public int countByRid(String roomId);
  27. @Query(value = "select count(*) from rongyun_room_member where rid=?1 and role!=?2", nativeQuery = true)
  28. public int countByRidAndExcludeRole(String roomId, int excludeRole);
  29. @Transactional
  30. @Modifying
  31. @Query(value = "delete from rongyun_room_member where rid=?1 and uid=?2", nativeQuery = true)
  32. public int deleteUserByRidAndUid(String rid, String uid);
  33. @Transactional
  34. @Modifying
  35. @Query(value = "update rongyun_room_member set role=?3 where rid=?1 and uid=?2", nativeQuery = true)
  36. public int updateRoleByRidAndUid(String rid, String uid, int role);
  37. @Transactional
  38. @Modifying
  39. @Query(value = "update rongyun_room_member set role=?3 where rid=?1 and role=?2", nativeQuery = true)
  40. public int updateRoleByRidAndRole(String rid, int role);
  41. @Transactional
  42. @Modifying
  43. @Query(value = "update rongyun_room_member set camera=?3 where rid=?1 and uid=?2", nativeQuery = true)
  44. public int updateCameraByRidAndUid(String rid, String uid, boolean camera);
  45. @Transactional
  46. @Modifying
  47. @Query(value = "update rongyun_room_member set mic=?3 where rid=?1 and uid=?2", nativeQuery = true)
  48. public int updateMicByRidAndUid(String rid, String uid, boolean mic);
  49. @Transactional
  50. @Modifying
  51. @Query(value = "update rongyun_room_member set music_mode=?3 where rid=?1 and uid=?2", nativeQuery = true)
  52. public int updateMusicByRidAndUid(String rid, String uid, boolean musicMode);
  53. public boolean existsByRidAndUid(String rid, String uid);
  54. public boolean existsByRidAndRole(String rid, int role);
  55. }