实现工单核心:创建、列表、状态流转与分派

Open
#13 0 comments 0 reactions 0 assignees View on GitHub

@linuxsuren-fs is already working on this.

Since Nov 14, 2026.

  • #22 by @linuxsuren-fs — open

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
15/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Domain
backend

Research direction

Start with the referenced designs in issues #2, #3, and #4, then inspect the validator in #12 and event contract in #7. The issue calls for ticket migrations and repository work, creation, filtering, workflow transitions, assignments, and integration tests. Done means the listed state paths and errors behave as specified, concurrent creation produces unique ticket numbers, and requesters receive 404 for other users’ tickets.

Written by the indexing model from the issue text.

Description

help wanted P0

Background

工单域的核心逻辑。设计见 #2(表)、#3(端点与语义)、#4(workflow 运行时)。本 issue 实现创建、列表、详情、状态流转与分派。

Technical requirement

  • 创建:POST /api/tickets;custom_fields 按该类型 form_schema 校验(调 #12 的校验器)后落库;工单号取租户内递增序号(行锁或等价方案保证并发唯一);初始 state 取 workflow 的 initial;发布 ticket.created 事件;
  • 列表:筛选(type / state / assignee / priority / keyword)+ 分页契约;requester 只见自己创建的;keyword 匹配标题与工单号;
  • 详情:返回工单全量 + 类型摘要(状态名、可用 transitions 预计算,供前端渲染按钮);
  • 状态流转:POST /api/tickets/:id/transitions 按 action 查 workflow,校验角色(#6 矩阵与 creator 相对角色取交集),更新 state,写 timeline state_change(meta 含 from / to / action),维护 closed_at,发布 ticket.state_changed;非法动作返回 STATE_CONFLICT;
  • 分派 / 转交:POST /api/tickets/:id/assignments,仅 agent / tenant_admin;写 timeline assignment,发布 ticket.assigned;
  • 事件发布走 internal/events(#7 契约:事务提交后同步分发,订阅者 panic 隔离)。

Expect

  • 状态机集成测试:合法路径全走通(pending → processing → confirming → closed → reopen)、每类非法流转(错误角色、不存在的 action、final 后无 reopen 的动作)均返回 STATE_CONFLICT 或 FORBIDDEN;
  • 并发创建工单号不重号(并发测试);
  • requester 越权查看他人工单返回 404。

Potential TODO list

  • tickets 迁移与 repository(索引见 #2)
  • 工单号生成(并发安全)
  • 创建 + 校验 + 事件
  • 列表筛选与分页
  • transitions 状态机
  • assignments 分派
  • 集成测试

依赖

#12(类型与校验器)。

Dominant language
No language data
Stars
0
Forks
1
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from LinuxSuRen/tick-flow

All issues in LinuxSuRen/tick-flow

Similar issues

More Backend & API Design issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.