权限查询
This commit is contained in:
parent
060c1a5d1f
commit
4598c11a89
@ -3,6 +3,7 @@ package com.company.agentfoundation.directory;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@ -45,7 +46,14 @@ public class EmployeeDirectoryService {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
List<EmployeeDataPermission> permissions = jdbcTemplate.query("""
|
||||
List<EmployeeDataPermission> permissions = findPermissions(accounts.get(0).id());
|
||||
|
||||
return Optional.of(new EmployeeDirectoryResponse(accounts.get(0), permissions));
|
||||
}
|
||||
|
||||
private List<EmployeeDataPermission> findPermissions(Long employeeId) {
|
||||
try {
|
||||
return jdbcTemplate.query("""
|
||||
SELECT source_system, permission_type, scope_path, scope_name
|
||||
FROM employee_data_permission
|
||||
WHERE employee_id = ?
|
||||
@ -57,9 +65,10 @@ public class EmployeeDirectoryService {
|
||||
rs.getString("scope_path"),
|
||||
rs.getString("scope_name")
|
||||
),
|
||||
accounts.get(0).id()
|
||||
employeeId
|
||||
);
|
||||
|
||||
return Optional.of(new EmployeeDirectoryResponse(accounts.get(0), permissions));
|
||||
} catch (Exception ignored) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user