OneBot: Leantime 改造版源码(BOM/Univer 表格/AI 接管/品牌替换等)
This commit is contained in:
60
app/Domain/Tickets/Controllers/TicketResourceApi.php
Normal file
60
app/Domain/Tickets/Controllers/TicketResourceApi.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace Leantime\Domain\Tickets\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Leantime\Domain\Tickets\Services\TicketResource as TicketResourceService;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
* 待办事项 ↔ 资源关联(BOM/工艺文件/工具清单/文件/wiki)JSON API。
|
||||
* 每个动作都在 Service 层按 ticket 所属项目自鉴权。
|
||||
*/
|
||||
class TicketResourceApi
|
||||
{
|
||||
public function __construct(
|
||||
private TicketResourceService $service,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* 关联一个资源:POST /tickets/resource-api/{ticketId}/link
|
||||
*/
|
||||
public function link(int $ticketId, Request $request): Response
|
||||
{
|
||||
$type = (string) $request->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)]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user