Interface RoleUserRepository

All Superinterfaces:
org.springframework.data.repository.CrudRepository<RoleUser,String>, org.springframework.data.jpa.repository.JpaRepository<RoleUser,String>, org.springframework.data.jpa.repository.JpaSpecificationExecutor<RoleUser>, org.springframework.data.repository.ListCrudRepository<RoleUser,String>, org.springframework.data.repository.ListPagingAndSortingRepository<RoleUser,String>, org.springframework.data.repository.PagingAndSortingRepository<RoleUser,String>, org.springframework.data.repository.query.QueryByExampleExecutor<RoleUser>, org.springframework.data.repository.Repository<RoleUser,String>

@Repository @NullMarked public interface RoleUserRepository extends org.springframework.data.jpa.repository.JpaRepository<RoleUser,String>, org.springframework.data.jpa.repository.JpaSpecificationExecutor<RoleUser>

RoleUserRepository 是角色-用户关联的 JPA 数据仓库接口。

它提供了对 RoleUser 实体的数据库操作,包括按角色ID或用户ID查询、检查是否存在、删除以及按角色ID和用户ID查询。

  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.springframework.data.jpa.repository.JpaSpecificationExecutor

    org.springframework.data.jpa.repository.JpaSpecificationExecutor.SpecificationFluentQuery<T>
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    删除指定角色ID和用户ID的角色-用户关联。
    boolean
    检查指定角色ID和用户ID的关联是否存在。
    根据角色ID查询所有角色-用户关联。
    根据角色ID和用户ID查询单个角色-用户关联。
    根据用户ID查询所有角色-用户关联。

    Methods inherited from interface org.springframework.data.repository.CrudRepository

    count, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, findById, save

    Methods inherited from interface org.springframework.data.jpa.repository.JpaRepository

    deleteAllByIdInBatch, deleteAllInBatch, deleteAllInBatch, deleteInBatch, findAll, findAll, flush, getById, getOne, getReferenceById, saveAllAndFlush, saveAndFlush

    Methods inherited from interface org.springframework.data.jpa.repository.JpaSpecificationExecutor

    count, count, delete, delete, exists, exists, findAll, findAll, findAll, findAll, findAll, findBy, findBy, findOne, findOne, update

    Methods inherited from interface org.springframework.data.repository.ListCrudRepository

    findAll, findAllById, saveAll

    Methods inherited from interface org.springframework.data.repository.ListPagingAndSortingRepository

    findAll

    Methods inherited from interface org.springframework.data.repository.PagingAndSortingRepository

    findAll

    Methods inherited from interface org.springframework.data.repository.query.QueryByExampleExecutor

    count, exists, findAll, findBy, findOne
  • Method Details

    • findByRoleId

      List<RoleUser> findByRoleId(String roleId)
      根据角色ID查询所有角色-用户关联。
      Parameters:
      roleId - 角色ID。
      Returns:
      匹配的角色-用户关联列表。
    • existsByRoleIdAndUserId

      boolean existsByRoleIdAndUserId(String roleId, String userId)
      检查指定角色ID和用户ID的关联是否存在。
      Parameters:
      roleId - 角色ID。
      userId - 用户ID。
      Returns:
      如果存在则为 true,否则为 false
    • deleteByRoleIdAndUserId

      void deleteByRoleIdAndUserId(String roleId, String userId)
      删除指定角色ID和用户ID的角色-用户关联。
      Parameters:
      roleId - 角色ID。
      userId - 用户ID。
    • findByUserId

      List<RoleUser> findByUserId(String userId)
      根据用户ID查询所有角色-用户关联。
      Parameters:
      userId - 用户ID。
      Returns:
      匹配的角色-用户关联列表。
    • findByRoleIdAndUserId

      Optional<RoleUser> findByRoleIdAndUserId(String roleId, String userId)
      根据角色ID和用户ID查询单个角色-用户关联。
      Parameters:
      roleId - 角色ID。
      userId - 用户ID。
      Returns:
      匹配的角色-用户关联的 Optional,如果不存在则为 Optional.empty()