gitlink-cli/skills/gitlink-user/examples/user-workflow.md

86 lines
2.0 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 示例:用户信息查询(真实数据)
> 本示例基于 `chroe/gitlink-cli` 项目于 2026-06-13 在 Claude Code 中实际执行。
> 展示用户信息查询的完整流程:认证验证 → 查看自己 → 查看他人 → 搜索用户 ID。
---
## 场景:项目维护者确认身份并查询团队成员信息
### Step 1确认当前登录状态
```bash
gitlink-cli user +me --format json
```
**真实输出:**
```json
{
"ok": true,
"data": {
"user_id": 141645,
"login": "caoweiqiong",
"username": "CWQ",
"email": "caoweiqiong@example.org",
"phone": "18627370661",
"admin": false,
"image_url": "system/lets/letter_avatars/2/C/223_176_135/120.png"
}
}
```
**确认:** 当前以 `caoweiqiong`CWQ登录user_id 为 141645。
### Step 2查询项目维护者详情
```bash
gitlink-cli user +info --login chroe --format json
```
**真实输出:**
```json
{
"ok": true,
"data": {
"user_id": 149027,
"login": "chroe",
"name": "chroe",
"real_name": "chroe",
"user_identity": "专业人士",
"created_time": "2026-04-30 11:41",
"common_projects_count": 5,
"user_projects_count": 5,
"mirror_projects_count": 0,
"user_org_count": 0,
"watched_count": 0,
"watching_count": 0,
"description": null,
"image_url": "system/lets/letter_avatars/2/C/142_140_188/120.png"
}
}
```
**分析:** chroe 的 user_id 为 149027拥有 5 个项目,注册于 2026-04-30。
### Step 3搜索用户获取 user_id 用于批量操作)
在执行 `member +add` 等需要 user_id 的操作前,先搜索获取:
```bash
gitlink-cli api GET /users/list --query 'search=chroe'
```
返回匹配用户的列表,从中提取 `id` 字段即可用于其他命令。
---
## 典型用途
| 场景 | 命令 |
|------|------|
| 验证认证是否生效 | `user +me` |
| 查看团队成员信息 | `user +info --login <login>` |
| 获取 user_id 用于 member/batch 操作 | `api GET /users/list --query 'search=<login>'` |