OneBot: Leantime 改造版源码(BOM/Univer 表格/AI 接管/品牌替换等)

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,55 @@
<?php
namespace Leantime\Domain\Bom\Tools;
use Laravel\Mcp\Server\Tool;
use Laravel\Mcp\Server\Tools\ToolInputSchema;
use Laravel\Mcp\Server\Tools\ToolResult;
use Leantime\Domain\Bom\Services\Bom;
/**
* 给主数据BOM/工艺文件/工具清单)添加一个动态列。
*/
class AddMasterColumnTool extends Tool
{
public function __construct(
private Bom $bomService,
) {}
public function name(): string
{
return 'addMasterColumn';
}
public function description(): string
{
return '给主数据BOM/工艺文件/工具清单添加一个动态列自定义字段。key 为存储标识英文或中文label 为显示名。';
}
public function schema(ToolInputSchema $schema): ToolInputSchema
{
return $schema
->integer('id')->description('主数据 ID。')->required()
->string('key')->description('列标识(英文或中文,用于存储)。')->required()
->string('label')->description('列显示名,默认同 key。');
}
public function handle(array $arguments): ToolResult
{
$id = (int) ($arguments['id'] ?? 0);
$key = (string) ($arguments['key'] ?? '');
$label = (string) ($arguments['label'] ?? $key);
if ($key === '') {
return ToolResult::error('key 不能为空');
}
$columnId = $this->bomService->addColumn($id, $key, $label);
if ($columnId > 0) {
return ToolResult::text("动态列添加成功:{$key}columnId {$columnId})。");
}
return ToolResult::error('添加列失败可能无权限、key 冲突固定列、或主数据不存在)。');
}
}