From a8b7f5550a65cb2243d3813c34241ea5c6758e67 Mon Sep 17 00:00:00 2001 From: konard Date: Wed, 29 Oct 2025 16:35:19 +0100 Subject: [PATCH 1/3] Initial commit with task details for issue #22 Adding CLAUDE.md with task information for AI processing. This file will be removed when the task is complete. Issue: undefined --- CLAUDE.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/CLAUDE.md b/CLAUDE.md index da28d4d..df0e67f 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -324,4 +324,14 @@ Copyright: © 2023-2025 谢榕川 All rights reserved - [README_WORKERS.md](README_WORKERS.md) - Подробная информация о воркерах - [swagger.yaml](swagger.yaml) - OpenAPI спецификация - [docs/](docs/) - Дополнительная документация -- [check-scheduler.md](check-scheduler.md) - Проверка планировщика задач \ No newline at end of file +- [check-scheduler.md](check-scheduler.md) - Проверка планировщика задач + +--- + +Issue to solve: undefined +Your prepared branch: issue-22-1327abdd +Your prepared working directory: /tmp/gh-issue-solver-1761752111660 +Your forked repository: konard/TaskMateTelegramBot +Original repository (upstream): xierongchuan/TaskMateTelegramBot + +Proceed. \ No newline at end of file From 8791907911cef378dfe4578564d7257e04c867d5 Mon Sep 17 00:00:00 2001 From: konard Date: Wed, 29 Oct 2025 16:40:54 +0100 Subject: [PATCH 2/3] feat: add missing shift endpoints /shifts/my and /shifts/my/current MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added two new endpoints to support user-specific shift operations: - GET /shifts/my - Returns paginated list of shifts for authenticated user with optional filters: status, date_from, date_to - GET /shifts/my/current - Returns current active shift for authenticated user or null if no active shift exists These endpoints were missing from the API but are expected by TaskMateFrontend and documented in the frontend's swagger specification. Changes: - Added ShiftController::my() method for user's shift history - Added ShiftController::myCurrent() method for user's current active shift - Updated routes/api.php to register the new endpoints - Updated swagger.yaml with complete API documentation for both endpoints Fixes issue where frontend received 404 error when accessing /shifts/my/current 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../Controllers/Api/V1/ShiftController.php | 59 ++++++++++ routes/api.php | 2 + swagger.yaml | 102 ++++++++++++++++++ 3 files changed, 163 insertions(+) diff --git a/app/Http/Controllers/Api/V1/ShiftController.php b/app/Http/Controllers/Api/V1/ShiftController.php index 48b4631..307f8b1 100644 --- a/app/Http/Controllers/Api/V1/ShiftController.php +++ b/app/Http/Controllers/Api/V1/ShiftController.php @@ -103,4 +103,63 @@ public function statistics(Request $request) ] ]); } + + /** + * Get shifts for the authenticated user + */ + public function my(Request $request) + { + $user = $request->user(); + $perPage = (int) $request->query('per_page', '15'); + $status = $request->query('status'); + $dateFrom = $request->query('date_from'); + $dateTo = $request->query('date_to'); + + $query = Shift::with(['user', 'dealership', 'replacement']) + ->where('user_id', $user->id); + + if ($status) { + $query->where('status', $status); + } + + if ($dateFrom) { + $query->where('shift_start', '>=', Carbon::parse($dateFrom)->startOfDay()); + } + + if ($dateTo) { + $query->where('shift_start', '<=', Carbon::parse($dateTo)->endOfDay()); + } + + $shifts = $query->orderByDesc('shift_start')->paginate($perPage); + + return response()->json($shifts); + } + + /** + * Get the current active shift for the authenticated user + */ + public function myCurrent(Request $request) + { + $user = $request->user(); + + $shift = Shift::with(['user', 'dealership', 'replacement']) + ->where('user_id', $user->id) + ->where('status', 'open') + ->whereNull('shift_end') + ->orderByDesc('shift_start') + ->first(); + + if (!$shift) { + return response()->json([ + 'success' => true, + 'data' => null, + 'message' => 'No active shift found' + ], 200); + } + + return response()->json([ + 'success' => true, + 'data' => $shift + ]); + } } diff --git a/routes/api.php b/routes/api.php index 0a399a5..d2c0f1c 100644 --- a/routes/api.php +++ b/routes/api.php @@ -75,6 +75,8 @@ Route::get('/shifts', [ShiftController::class, 'index']); Route::get('/shifts/current', [ShiftController::class, 'current']); Route::get('/shifts/statistics', [ShiftController::class, 'statistics']); + Route::get('/shifts/my', [ShiftController::class, 'my']); + Route::get('/shifts/my/current', [ShiftController::class, 'myCurrent']); Route::get('/shifts/{id}', [ShiftController::class, 'show']); // Tasks diff --git a/swagger.yaml b/swagger.yaml index f2b4ae4..30686ee 100644 --- a/swagger.yaml +++ b/swagger.yaml @@ -1909,6 +1909,108 @@ paths: schema: $ref: '#/components/schemas/Error' + /shifts/my: + get: + tags: + - Shifts + summary: Получить смены текущего пользователя + description: Получение списка смен для аутентифицированного пользователя с пагинацией и фильтрацией + operationId: getMyShifts + security: + - bearerAuth: [] + parameters: + - name: per_page + in: query + description: Количество элементов на странице + schema: + type: integer + default: 15 + example: 20 + - name: page + in: query + description: Номер страницы + schema: + type: integer + default: 1 + example: 1 + - name: status + in: query + description: Фильтр по статусу + schema: + type: string + enum: [open, closed] + example: open + - name: date_from + in: query + description: Фильтр по начальной дате + schema: + type: string + format: date + example: "2025-10-01" + - name: date_to + in: query + description: Фильтр по конечной дате + schema: + type: string + format: date + example: "2025-10-31" + responses: + '200': + description: Список смен пользователя + content: + application/json: + schema: + allOf: + - $ref: '#/components/schemas/PaginatedResponse' + - type: object + properties: + data: + type: array + items: + $ref: '#/components/schemas/Shift' + '401': + description: Неавторизован + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + + /shifts/my/current: + get: + tags: + - Shifts + summary: Получить текущую открытую смену пользователя + description: Получение текущей активной смены аутентифицированного пользователя + operationId: getMyCurrentShift + security: + - bearerAuth: [] + responses: + '200': + description: Текущая смена пользователя + content: + application/json: + schema: + type: object + properties: + success: + type: boolean + example: true + data: + oneOf: + - $ref: '#/components/schemas/Shift' + - type: 'null' + nullable: true + message: + type: string + nullable: true + example: No active shift found + '401': + description: Неавторизован + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + /tasks: get: tags: From adfb3430f33a40f3d2d7c5d6d09edf1a3c6d9911 Mon Sep 17 00:00:00 2001 From: konard Date: Wed, 29 Oct 2025 16:44:54 +0100 Subject: [PATCH 3/3] Revert "Initial commit with task details for issue #22" This reverts commit a8b7f5550a65cb2243d3813c34241ea5c6758e67. --- CLAUDE.md | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index df0e67f..da28d4d 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -324,14 +324,4 @@ Copyright: © 2023-2025 谢榕川 All rights reserved - [README_WORKERS.md](README_WORKERS.md) - Подробная информация о воркерах - [swagger.yaml](swagger.yaml) - OpenAPI спецификация - [docs/](docs/) - Дополнительная документация -- [check-scheduler.md](check-scheduler.md) - Проверка планировщика задач - ---- - -Issue to solve: undefined -Your prepared branch: issue-22-1327abdd -Your prepared working directory: /tmp/gh-issue-solver-1761752111660 -Your forked repository: konard/TaskMateTelegramBot -Original repository (upstream): xierongchuan/TaskMateTelegramBot - -Proceed. \ No newline at end of file +- [check-scheduler.md](check-scheduler.md) - Проверка планировщика задач \ No newline at end of file