Files
brapi-java/docs/dev/01-core/05-trial.md
2026-05-28 11:56:17 +08:00

79 lines
3.3 KiB
Markdown
Raw 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.

# 01 Core - trial 表录入说明
来源:`docs/requirements/01-core-data-entry-requirements.md`
## 录入目标
`trial` 表示某一批试验、区域试验或年度试验,位于 program 与 study 之间。创建 trial 时选择 program并自动带出或校验 crop。
## 前置依赖和下游引用
| 类型 | 内容 |
| --- | --- |
| 表 | `trial` |
| 前置依赖 | `program``crop` |
| 下游引用 | `study``observation_unit``observation``plate``sample` |
## 页面入口
| 页面 | 录入要求 |
| --- | --- |
| Trial 列表页 | 支持 crop、program、active、起止日期、关键词筛选新增、编辑、查看详情、停用 |
| Trial 新增/编辑页 | 包含基本信息、项目作物、联系人、出版物四个区域 |
| Trial 详情页 | 展示 study 列表和 phenotyping/genotyping 入口 |
列表页表格字段:`trial_name`、program、crop、`start_date``end_date`、active。
## 字段录入
| 字段 | 类型 | 控件 | 录入说明 | 校验/来源 |
| --- | --- | --- | --- | --- |
| `id` | varchar(255) | 隐藏/只读 | 试验主键 | 必填、唯一 |
| `auth_user_id` | varchar(255) | 隐藏 | 数据所属用户 | 登录上下文自动写入 |
| `active` | boolean | 开关 | 是否启用 | 默认启用 |
| `documentationurl` | varchar(255) | URL 输入框 | 试验文档链接 | URL 格式校验 |
| `end_date` | timestamp | 日期选择器 | 结束日期 | 不早于 `start_date` |
| `start_date` | timestamp | 日期选择器 | 开始日期 | 可选 |
| `trial_description` | varchar(255) | 多行文本 | 试验描述 | 可选 |
| `trial_name` | varchar(255) | 文本框 | 试验名称 | 必填 |
| `trialpui` | varchar(255) | 文本框 | 试验永久标识 | 可选,建议唯一 |
| `crop_id` | varchar(255) | 作物选择器 | 所属作物 | 必选,来源 `crop.id` |
| `program_id` | varchar(255) | 项目选择器 | 所属项目 | 必选,来源 `program.id` |
## 校验规则
1. `trial_name` 必填。
2. `program_id` 必选且必须存在。
3. `crop_id` 必选且必须与 `program.crop_id` 一致。
4. `end_date` 不能早于 `start_date`
5. `documentationurl` 需要做 URL 格式校验。
## 接口能力
| 接口 | 用途 |
| --- | --- |
| `GET /trials` | trial 分页查询 |
| `POST /trials` | 新增 trial |
| `GET /trials/{id}` | trial 详情 |
| `PUT /trials/{id}` | 编辑 trial |
| `DELETE /trials/{id}` | 删除或停用 trial需检查 study 引用 |
| `GET /trials/{id}/studies` | 查询 trial 下 study |
| `GET /selectors/trials` | trial 搜索下拉,参数 `keyword``programId``cropId``active` |
## 导入导出
1. 支持通过 Core 导入流程导入 `trial`
2. 外键列支持填写 ID可额外支持名称匹配但名称重复时必须报错。
3. 导入时必须校验 trial 的 crop 与 program 的 crop 一致。
4. 列表页支持导出当前筛选结果,导出文件应包含 ID 和展示名称。
## 删除/停用
`trial` 已被 `study``observation_unit``observation``plate``sample` 引用时,不允许物理删除。后端需要返回引用对象类型和数量,前端展示后引导用户停用。
## 验收点
1. 创建 trial 时,选择 program 后自动带出 crop。
2. Trial 列表页支持按 crop、program、active、日期筛选。
3. 已被 study 引用的 trial 不能直接删除。