Files
hose-use/src/cli/commands/assist-platform/search.ts
T
gitea ed9fa979e0 feat(assist-platform): add assist platform automation and tenant onboarding
- Add SSO QR status poller and assist platform HTTP client
- Add assist-platform session store with 0600 secure permissions
- Implement domains/assist-platform (api, services, types) for corporation search, detail, tickets, staff query and passwordless token generation
- Implement cli/commands/assist-platform with aliases assist-center and ap
- Support seamless --save --switch --elevate pipeline to import tenant and extract persistent OpenAPI credentials
- Update embedded skill documentation, reference guide, and test suites
2026-10-21 10:33:27 +08:00

65 lines
2.0 KiB
TypeScript

import { searchCorporations } from "../../../domains/assist-platform/services.js";
import { numberOption, stringOption } from "../../parser.js";
import { printJson, printTable } from "../../printer.js";
import type { CliParsedArgs, CliResult, CliRuntime } from "../../types.js";
import { resolveAssistClient } from "./common.js";
export async function handleSearch(
parsed: CliParsedArgs,
runtime: CliRuntime
): Promise<CliResult> {
const client = resolveAssistClient(parsed, runtime);
const keyword =
parsed.args[0] ||
stringOption(parsed.options, ["keyword", "query", "q", "name", "id"]) ||
"";
const count = numberOption(parsed.options, ["count", "limit", "n"]) || 20;
const start = numberOption(parsed.options, ["start", "offset"]) || 0;
const state = stringOption(parsed.options, ["state", "status"]);
const res = await searchCorporations(client, {
keyword: keyword.trim() || undefined,
state: state?.trim() || undefined,
limit: { start, count },
});
if (runtime.jsonMode) {
return {
stdout: printJson(res, runtime.outputOptions),
stderr: "",
exitCode: 0,
};
}
if (res.items.length === 0) {
return {
stdout: `协助平台企业库中未找到匹配 "${keyword}" 的企业记录。\n`,
stderr: "",
exitCode: 0,
};
}
const rows = res.items.map((c, i) => [
String(start + i + 1),
c.id,
c.name,
c.platformName || "app",
c.state || "-",
c.payType === "TRYOUT" ? "试用" : c.payType === "PAY" ? "付费" : c.payType || "-",
c.sumPeople !== null && c.sumPeople !== undefined ? String(c.sumPeople) : "-",
c.tel || "-",
]);
const table = printTable(
["#", "企业 ID", "企业名称", "集群", "状态", "类型", "授权人数", "联系电话"],
rows
);
return {
stdout: `====== 合思协助平台企业搜索结果 (共匹配 ${res.count} 家,当前显示 ${res.items.length} 条) ======\n${table}\n\n提示: 可使用 hose-use assist-platform tickets <企业ID> 查询协助工单\n`,
stderr: "",
exitCode: 0,
};
}