refactor: 移除提示词模板页面及相关接口,精简岗位/标签/用户提示词模型
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
838e986670
commit
e6662cf673
19 files changed
+55
-729
No files matched your search
@@ -333,9 +333,12 @@ Each agent/skill carries a single `square_id` column (`AgentRow` / `SkillRow`, `
|
||||
### 岗位 (Position) Subscription System
|
||||
|
||||
An admin-managed aggregation layer that decides, per user, which agents / skills
|
||||
/ scheduled tasks / custom prompts / recommended questions they are subscribed
|
||||
to or can see. **A user has at most one position** (`users.position_id`, 1:1);
|
||||
unassigned users inherit the single `is_default` position.
|
||||
/ scheduled tasks / recommended questions they are subscribed to or can see.
|
||||
**A user has at most one position** (`users.position_id`, 1:1); unassigned users
|
||||
inherit the single `is_default` position. Note: the admin-configured prompts
|
||||
shown to users ARE the **recommended questions** (`recommended_questions` table)
|
||||
— there is no separate prompt-template store; the per-user `user_custom_prompts`
|
||||
(personal 常用提示词 bar) is untouched by this system.
|
||||
|
||||
**Persistence** (`deerflow/persistence/positions/`, wired as
|
||||
`app.state.position_store`; tables auto-created by `create_all`, migration
|
||||
@@ -345,27 +348,24 @@ unassigned users inherit the single `is_default` position.
|
||||
- `position_tag_bindings` (`PositionTagBindingRow`): one row per
|
||||
`(position, resource_type, tag)`. **No binding for a resource_type = "use the
|
||||
default set".** `POSITION_RESOURCE_TYPES = (agent, skill, scheduled_task,
|
||||
user_prompt, recommended_question)` — the same set drives the tag types
|
||||
(`TAG_TYPES` was extended with `user_prompt` + `recommended_question`).
|
||||
recommended_question)` — the same set drives the tag types (`TAG_TYPES` was
|
||||
extended with `recommended_question`).
|
||||
|
||||
**Sync engine** (`deerflow/services/position_sync.py`, wired as
|
||||
`app.state.position_sync`). `PositionSyncService.resolve_visible(user, type)`
|
||||
returns `set | None` (None = unrestricted) for the **query-time** visibility
|
||||
types (`skill`, `recommended_question`). `sync_user(user)` **materializes** the
|
||||
other three into the existing "我的" tables, idempotently:
|
||||
other two into the existing "我的" tables, idempotently:
|
||||
- agents → `agent_favorites` rows with `origin='position'`
|
||||
- scheduled tasks → `scheduled_task_subscriptions` rows with `origin='position'`
|
||||
- prompts → clones of admin **templates** into `user_custom_prompts`
|
||||
(`origin='position'`, `template_id` set)
|
||||
|
||||
Sync only ever adds/removes `origin='position'` rows, so a user's own
|
||||
favorites/subscriptions/prompts are never clobbered. Default sets: agents =
|
||||
built-ins (`user_id IS NULL`); scheduled tasks = empty; prompts = untagged
|
||||
templates; skills/questions = unrestricted. `origin`/`position_id` columns were
|
||||
added to `agent_favorites`, `scheduled_task_subscriptions`, and
|
||||
`user_custom_prompts` (+ `is_template`/`template_id`) — see migration
|
||||
`20260616_01` + `scripts/sql/column_additions_mysql.sql`. The running app also
|
||||
auto-adds these via `_ensure_orm_columns_sync` on startup.
|
||||
favorites/subscriptions are never clobbered. Default sets: agents = built-ins
|
||||
(`user_id IS NULL`); scheduled tasks = empty; skills/questions = unrestricted.
|
||||
`origin`/`position_id` columns were added to `agent_favorites` and
|
||||
`scheduled_task_subscriptions` — see migration `20260616_01` +
|
||||
`scripts/sql/column_additions_mysql.sql`. The running app also auto-adds these
|
||||
via `_ensure_orm_columns_sync` on startup.
|
||||
|
||||
**Triggers**: assigning/removing members, changing tag bindings (re-syncs all
|
||||
members), becoming the default position (`sync_default_members`), and login
|
||||
@@ -376,13 +376,13 @@ default gets their grants materialized).
|
||||
position CRUD; `GET/PUT /{id}/tag-bindings`; `GET/POST/DELETE /{id}/members`
|
||||
(batch assign/unassign → triggers sync); `POST /{id}/resync`;
|
||||
`GET /users` (all users + their position); `PUT /users/{user_id}` (set one
|
||||
user's position). Related changes: prompt **templates** CRUD under
|
||||
`/api/user-prompts/templates` (admin; `is_template` rows excluded from a user's
|
||||
own `GET /api/user-prompts`); `GET /api/recommended-questions` is now filtered
|
||||
by the caller's position (`?all=1` bypasses for admin management);
|
||||
user's position). Related changes: `GET /api/recommended-questions` is now
|
||||
filtered by the caller's position (`?all=1` bypasses for admin management) and
|
||||
admin can tag questions via `/api/tags/assignments/recommended_question/{id}`;
|
||||
`GET /api/skills?scope=mine` applies skill visibility. Frontend: `core/positions`
|
||||
+ admin `PositionManagementPage` / `PromptTemplatesPage` (侧边栏「综合管理」),
|
||||
recommended-questions moved to a bottom-right Popover in the chat input. Tests:
|
||||
+ admin `PositionManagementPage` (侧边栏「综合管理 → 岗位管理」 + 右下角设置菜单).
|
||||
Recommended questions stay rendered **above** the chat input (their original
|
||||
position), just filtered by the caller's position. Tests:
|
||||
`tests/test_positions.py`.
|
||||
|
||||
### Portable Column Types (`deerflow/persistence/types.py`)
|
||||
|
||||
Reference in new issue
Block a user