add some methods for 'findBy'
This commit is contained in:
parent
d2187c4913
commit
cc0c1359bd
@ -2,29 +2,30 @@ package com.example.springdemo.dao;
|
||||
|
||||
import com.example.springdemo.entities.RBAC.RolesPermissions;
|
||||
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 java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface RolesPermissionsRepository
|
||||
extends JpaRepository<RolesPermissions, Long> {
|
||||
@Modifying
|
||||
@Query(value = "delete from roles_permissions " +
|
||||
"where rolesId = ?1 and permissionsId = ?2", nativeQuery = true)
|
||||
int RemovePermissionsFromRole(Long roleId, Long permissionId);
|
||||
|
||||
@Modifying
|
||||
@Query(value = "update roles_permissions set rolesId = ?1, permissionsId = ?2 " +
|
||||
"where rolesId = ?1 and permissionsId = ?2", nativeQuery = true)
|
||||
int updateRolePermissions(Long roleId, Long permissionId);
|
||||
|
||||
Optional<RolesPermissions> findByRolesId(Long roleId);
|
||||
List<RolesPermissions> findByRolesId(Long roleId);
|
||||
|
||||
Optional<RolesPermissions> findByPermissionsId(Long permissionId);
|
||||
|
||||
@Query(value = "select permissionsId from roles_permissions where rolesId = ?1", nativeQuery = true)
|
||||
List<Long> findPermissionsIdByRolesId(Long roleId);
|
||||
|
||||
void deleteByRolesId(Long roleId);
|
||||
|
||||
void deleteByPermissionsId(Long permissionId);
|
||||
|
@ -2,17 +2,23 @@ package com.example.springdemo.dao;
|
||||
|
||||
import com.example.springdemo.entities.password.UsersPassword;
|
||||
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;
|
||||
|
||||
@Repository
|
||||
public interface UsersPasswordRepository
|
||||
extends JpaRepository<UsersPassword, Long> {
|
||||
@Modifying
|
||||
|
||||
//修改密码
|
||||
@Query("update UsersPassword UsersPwd set UsersPwd.password = ?1 where UsersPwd.users.id = ?2")
|
||||
int updatePassword(String password, Long userID);
|
||||
|
||||
//删除账户时删除密码
|
||||
void deleteByUsersId(Long userID);
|
||||
|
||||
//根据用户ID查找密码
|
||||
UsersPassword findByUsersId(Long userID);
|
||||
|
||||
//根据用户名查找密码
|
||||
UsersPassword findByUsersName(String userName);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user