Важный фикс
Забыл добавить управление отделами :)
This commit is contained in:
@@ -133,6 +133,63 @@ if ($method === 'POST') {
|
||||
RestApi::response($result, $result['success'] ? 200 : 403);
|
||||
}
|
||||
|
||||
// ==================== CRUD ОТДЕЛОВ ====================
|
||||
|
||||
// Добавление отдела
|
||||
if ($action === 'add_department') {
|
||||
$project_id = $data['project_id'] ?? null;
|
||||
$name = trim($data['name'] ?? '');
|
||||
$color = $data['color'] ?? '#6366f1';
|
||||
if (!$project_id || !$name) {
|
||||
RestApi::response(['success' => false, 'errors' => ['data' => 'Укажите project_id и name']], 400);
|
||||
}
|
||||
$result = Project::addDepartment($project_id, $name, $color, $user_id);
|
||||
RestApi::response($result, $result['success'] ? 200 : 403);
|
||||
}
|
||||
|
||||
// Обновление отдела
|
||||
if ($action === 'update_department') {
|
||||
$id = $data['id'] ?? null;
|
||||
$name = isset($data['name']) ? trim($data['name']) : null;
|
||||
$color = $data['color'] ?? null;
|
||||
if (!$id) {
|
||||
RestApi::response(['success' => false, 'errors' => ['id' => 'Укажите ID отдела']], 400);
|
||||
}
|
||||
$result = Project::updateDepartment($id, $name, $color, $user_id);
|
||||
RestApi::response($result, $result['success'] ? 200 : 403);
|
||||
}
|
||||
|
||||
// Получение количества задач в отделе (для подтверждения удаления)
|
||||
if ($action === 'get_department_tasks_count') {
|
||||
$id = $data['id'] ?? null;
|
||||
if (!$id) {
|
||||
RestApi::response(['success' => false, 'errors' => ['id' => 'Укажите ID отдела']], 400);
|
||||
}
|
||||
$count = Project::getDepartmentTasksCount($id);
|
||||
RestApi::response(['success' => true, 'count' => $count]);
|
||||
}
|
||||
|
||||
// Удаление отдела
|
||||
if ($action === 'delete_department') {
|
||||
$id = $data['id'] ?? null;
|
||||
if (!$id) {
|
||||
RestApi::response(['success' => false, 'errors' => ['id' => 'Укажите ID отдела']], 400);
|
||||
}
|
||||
$result = Project::deleteDepartment($id, $user_id);
|
||||
RestApi::response($result, $result['success'] ? 200 : 403);
|
||||
}
|
||||
|
||||
// Обновление порядка отделов
|
||||
if ($action === 'update_departments_order') {
|
||||
$project_id = $data['project_id'] ?? null;
|
||||
$ids = $data['ids'] ?? [];
|
||||
if (!$project_id || empty($ids)) {
|
||||
RestApi::response(['success' => false, 'errors' => ['data' => 'Укажите project_id и ids']], 400);
|
||||
}
|
||||
$result = Project::updateDepartmentsOrder($project_id, $ids, $user_id);
|
||||
RestApi::response($result, $result['success'] ? 200 : 403);
|
||||
}
|
||||
|
||||
// Метод не указан
|
||||
if (!$action) {
|
||||
RestApi::response(['success' => false, 'error' => 'Укажите метод'], 400);
|
||||
|
||||
Reference in New Issue
Block a user