input('type', ''); $resourceId = (int) $request->input('resourceId', 0); $result = $this->service->link($ticketId, $type, $resourceId); return $result['success'] ? response()->json(['status' => 'success']) : response()->json(['status' => 'error', 'message' => $result['message'] ?? '关联失败'], 400); } /** * 解除一个资源关联:DELETE /tickets/resource-api/{ticketId}/unlink/{type}/{resourceId} */ public function unlink(int $ticketId, string $type, int $resourceId): Response { $result = $this->service->unlink($ticketId, $type, $resourceId); return $result['success'] ? response()->json(['status' => 'success']) : response()->json(['status' => 'error', 'message' => $result['message'] ?? '解除失败'], 400); } /** * 候选资源列表:GET /tickets/resource-api/{projectId}/candidates */ public function candidates(int $projectId): Response { return response()->json(['status' => 'success', 'data' => $this->service->listCandidates($projectId)]); } /** * 已关联资源:GET /tickets/resource-api/{ticketId}/links */ public function links(int $ticketId): Response { return response()->json(['status' => 'success', 'data' => $this->service->getLinkedResources($ticketId)]); } }