OneBot: Leantime 改造版源码(BOM/Univer 表格/AI 接管/品牌替换等)
Some checks failed
Security Audit / Composer Security Audit (push) Has been cancelled
Security Audit / NPM Security Audit (push) Has been cancelled
Security Audit / CodeQL Analysis (push) Has been cancelled

This commit is contained in:
wangruiguo
2026-09-03 18:49:20 +08:00
commit d647428529
3501 changed files with 1988906 additions and 0 deletions

View File

@@ -0,0 +1,88 @@
<?php
namespace Leantime\Domain\Goalcanvas\Tools;
use Laravel\Mcp\Server\Tool;
use Laravel\Mcp\Server\Tools\ToolInputSchema;
use Laravel\Mcp\Server\Tools\ToolResult;
use Leantime\Core\Exceptions\AuthorizationException;
use Leantime\Domain\Goalcanvas\Services\Goalcanvas;
/**
* Update an existing goal.
*/
class EditGoalTool extends Tool
{
public function __construct(
private Goalcanvas $goalcanvasService,
) {}
public function schema(ToolInputSchema $schema): ToolInputSchema
{
return $schema
->integer('id')->description('ID of the goal to update.')
->required()
->string('title')->description('Updated title of the goal.')
->string('description')->description('Updated description of what the goal is measuring.')
->number('startValue')->description('Updated starting value for the goal metric.')
->number('currentValue')->description('Updated current value of the goal metric.')
->number('endValue')->description('Updated target value for the goal metric.')
->string('startDate')->description('Updated start date in ISO8601 format.')
->string('endDate')->description('Updated end date in ISO8601 format.')
->integer('milestoneId')->description('Updated ID of a milestone to attach to this goal.')
->string('metricType')->description('Updated type of metric (e.g., "percent", "currency", "number").')
->string('status')->description('Updated status of the goal (e.g., "status_ontrack", "status_atrisk", "status_miss").');
}
public function name(): string
{
return 'editGoal';
}
public function description(): string
{
return 'Updates an existing goal with the specified details.';
}
/**
* Handle the tool request.
*/
public function handle(array $arguments): ToolResult
{
$id = (int) ($arguments['id'] ?? 0);
if ($id <= 0) {
return ToolResult::error('A valid goal id is required.');
}
$optionalFields = [
'title', 'description', 'startValue', 'currentValue', 'endValue',
'startDate', 'endDate', 'milestoneId', 'metricType', 'status',
];
$params = [];
foreach ($optionalFields as $field) {
$value = $arguments[$field] ?? null;
if ($value !== null) {
$params[$field] = $value;
}
}
if ($params === []) {
return ToolResult::error('Provide at least one field to update.');
}
try {
$updated = $this->goalcanvasService->patchGoalItem($id, $params);
} catch (AuthorizationException) {
// Unknown, foreign, or unauthorized goal id — one message for all three, so the
// response does not leak whether a goal id exists in another project.
return ToolResult::error("Goal with ID {$id} not found.");
}
if ($updated) {
return ToolResult::text('Goal updated successfully.');
}
return ToolResult::error('Failed to update goal.');
}
}