Большое обновление
1. Создание личных проектов 2. Управление командой 3. Приглашение участников 4. Уведомления и многое другое...
This commit is contained in:
@@ -6,13 +6,6 @@ if ($method === 'POST') {
|
||||
$data = RestApi::getInput();
|
||||
$action = $data['action'] ?? null;
|
||||
|
||||
// Получение конфигурации приложения
|
||||
if ($action === 'get_config') {
|
||||
RestApi::response(['success' => true, 'data' => [
|
||||
'COLUMN_DONE_ID' => COLUMN_DONE_ID
|
||||
]]);
|
||||
}
|
||||
|
||||
// Авторизация
|
||||
if ($action === 'auth_login') {
|
||||
$account = new Account();
|
||||
@@ -53,6 +46,27 @@ if ($method === 'POST') {
|
||||
RestApi::response($result);
|
||||
}
|
||||
|
||||
// Поиск пользователя по логину
|
||||
if ($action === 'search') {
|
||||
$current_user_id = RestApi::getCurrentUserId();
|
||||
$username = trim($data['username'] ?? '');
|
||||
|
||||
if (!$username) {
|
||||
RestApi::response(['success' => false, 'errors' => ['username' => 'Введите логин']], 400);
|
||||
}
|
||||
|
||||
// Ищем пользователя по username
|
||||
$user = Database::get('accounts', ['id', 'name', 'username', 'avatar_url'], [
|
||||
'username' => $username
|
||||
]);
|
||||
|
||||
if (!$user) {
|
||||
RestApi::response(['success' => false, 'errors' => ['username' => 'Пользователь не найден']]);
|
||||
}
|
||||
|
||||
RestApi::response(['success' => true, 'data' => $user]);
|
||||
}
|
||||
|
||||
// Проверяем, что метод не пустой
|
||||
if (!$action) {
|
||||
RestApi::response(['success' => false, 'error' => 'Укажите метод'], 400);
|
||||
@@ -60,11 +74,22 @@ if ($method === 'POST') {
|
||||
}
|
||||
|
||||
if ($method === 'GET') {
|
||||
// Получение всех пользователей
|
||||
$account = new Account();
|
||||
$users = $account->getAll();
|
||||
// Получение участников проекта
|
||||
// ?id_project=X (обязательный)
|
||||
$current_user_id = RestApi::getCurrentUserId();
|
||||
$id_project = $_GET['id_project'] ?? null;
|
||||
|
||||
RestApi::response(['success' => true, 'data' => $users]);
|
||||
if (!$id_project) {
|
||||
RestApi::response(['success' => false, 'errors' => ['id_project' => 'Проект не указан']], 400);
|
||||
}
|
||||
|
||||
// Проверяем доступ к проекту
|
||||
ProjectAccess::requireAccess((int)$id_project, $current_user_id);
|
||||
|
||||
// Получаем участников проекта
|
||||
$members = ProjectAccess::getMembers((int)$id_project);
|
||||
|
||||
RestApi::response(['success' => true, 'data' => $members]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user