implement find permissions by role's ID method
This commit is contained in:
parent
5aa2ff89c0
commit
e168925d5c
@ -1,12 +1,14 @@
|
||||
package com.example.springdemo.service;
|
||||
package com.example.springdemo.serviceImpl;
|
||||
|
||||
import com.example.springdemo.dao.PermissionsRepository;
|
||||
import com.example.springdemo.dao.RolesPermissionsRepository;
|
||||
import com.example.springdemo.entities.RBAC.Permissions;
|
||||
import com.example.springdemo.service.PermissionsService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@ -54,4 +56,15 @@ public class PermissionsServiceImpl implements PermissionsService {
|
||||
public List<Permissions> findAllPermissions() {
|
||||
return permissionsRepository.findAll();
|
||||
}
|
||||
|
||||
//根据角色id查询权限
|
||||
@Override
|
||||
public List<Permissions> findPermissionsByRoleId(Long roleId) {
|
||||
List<Long> permissionsId = rolesPermissionsRepository.findPermissionsIdByRolesId(roleId);
|
||||
List<Permissions> permissions = new ArrayList<>();
|
||||
for (Long permissionId : permissionsId) {
|
||||
permissions.add(permissionsRepository.findById(permissionId).orElseThrow());
|
||||
}
|
||||
return permissions;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user