```php
<?php

require_once '../../core/api_bootstrap.php';
require_once '../../core/employee_auth.php';

EmployeeAuth::check('manage_roles');

$data = Request::post();

try{

Validator::required($data,['role_id','permissions']);

$db = new Database();
$conn = $db->connect();

$conn->prepare("

DELETE FROM role_permissions
WHERE role_id=:role

")->execute([
':role'=>$data['role_id']
]);

$stmt = $conn->prepare("

INSERT INTO role_permissions
(role_id,permission_id)
VALUES (:role,:permission)

");

foreach($data['permissions'] as $permission){

$stmt->execute([
':role'=>$data['role_id'],
':permission'=>$permission
]);

}

Response::success([],"Permissions assigned");

}
catch(Exception $e){

Logger::log("system.log",$e->getMessage());

Response::error("Server error",500);

}