Skip to content

Commit babcac6

Browse files
authored
docs(wiki): sync CommonShelf/CAS master data documentation with current implementation (#25)
1 parent ebe7b77 commit babcac6

File tree

5 files changed

+43
-18
lines changed

5 files changed

+43
-18
lines changed

wiki/backend/api-reference.md

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
- `announcements.router` -> `/api`
88
- `cart_sync.router` -> `/api`
99
- `chemical_info.router` -> `/api`
10+
- `chemical_name_map.router` -> `/api`
11+
- `common_shelf.router` -> `/api`
1012
- `consumable_orders.router` -> `/api`
1113
- `error_logs.router` -> `/api`
1214
- `events.router` -> `/api`
@@ -15,7 +17,7 @@
1517
- `user_logs.router` -> `/api`
1618
- `user_sessions.router` -> `/api/users/me`
1719
- `users.router` -> `/api`
18-
- `inventory_extended_routes` `common_shelf` 通过 `register_*` 动态挂到 `inventory.router`,最终前缀为 `/api/inventory`
20+
- `inventory_extended_routes` 通过 `register_*` 动态挂到 `inventory.router`,最终前缀为 `/api/inventory`
1921
- `reagent_orders_workflow` 通过 `register_*` 动态挂到 `reagent_orders.router`,最终前缀为 `/api/reagent-orders`
2022

2123
## 权限判定
@@ -102,12 +104,28 @@
102104

103105
| 方法 | 路径 | 函数 | 权限 | 关键参数(path/query/body/file) | 返回模型 | 状态码 | 代码 |
104106
| --- | --- | --- | --- | --- | --- | --- | --- |
105-
| `GET` | `/api/inventory/common-shelf` | `list_common_shelf` | 已登录用户 | query: `search` | `` | `200` | <InlineCodeRef href="https://github.com/hzb666/LabStorageManager/blob/main/app/api/common_shelf.py#L591" /> |
106-
| `POST` | `/api/inventory/common-shelf/consume-one` | `consume_one_common_shelf_item` | 管理员 | body: `CommonShelfConsumeRequest` | `` | `200` | <InlineCodeRef href="https://github.com/hzb666/LabStorageManager/blob/main/app/api/common_shelf.py#L679" /> |
107-
| `GET` | `/api/inventory/common-shelf/export` | `export_common_shelf` | 已登录用户 || `` | `200` | <InlineCodeRef href="https://github.com/hzb666/LabStorageManager/blob/main/app/api/common_shelf.py#L895" /> |
108-
| `DELETE` | `/api/inventory/common-shelf/group/{sample_inventory_id}` | `delete_common_shelf_group` | 已登录用户 | path: `sample_inventory_id` | `dict` | `200` | <InlineCodeRef href="https://github.com/hzb666/LabStorageManager/blob/main/app/api/common_shelf.py#L862" /> |
109-
| `PUT` | `/api/inventory/common-shelf/group/{sample_inventory_id}` | `update_common_shelf_group` | 已登录用户 | path: `sample_inventory_id`;body: `InventoryUpdate` | `dict` | `200` | <InlineCodeRef href="https://github.com/hzb666/LabStorageManager/blob/main/app/api/common_shelf.py#L783" /> |
110-
| `POST` | `/api/inventory/common-shelf/manual-add` | `manual_add_common_shelf_inventory` | 已登录用户 | body: `ManualInventoryCreate` | `dict` | `200` | <InlineCodeRef href="https://github.com/hzb666/LabStorageManager/blob/main/app/api/common_shelf.py#L757" /> |
107+
| `GET` | `/api/common-shelf/groups` | `list_common_shelf_groups` | 已登录用户 | query: `search``search_field``fuzzy``sort_by``sort_order` | `CommonShelfGroupListResponse` | `200` | <InlineCodeRef href="https://github.com/hzb666/LabStorageManager/blob/main/app/api/common_shelf.py#L131" /> |
108+
| `POST` | `/api/common-shelf/manual-add` | `manual_add_common_shelf` | 已登录用户 | body: `CommonShelfManualCreate` | `dict` | `200` | <InlineCodeRef href="https://github.com/hzb666/LabStorageManager/blob/main/app/api/common_shelf.py#L206" /> |
109+
| `GET` | `/api/common-shelf/groups/{group_key}/locations` | `get_common_shelf_group_locations` | 已登录用户 | path: `group_key` | `list[CommonShelfLocationSummaryResponse]` | `200` | <InlineCodeRef href="https://github.com/hzb666/LabStorageManager/blob/main/app/api/common_shelf.py#L155" /> |
110+
| `GET` | `/api/common-shelf/groups/{group_key}/location-suggestions` | `get_common_shelf_group_location_suggestions` | 已登录用户 | path: `group_key` | `list[str]` | `200` | <InlineCodeRef href="https://github.com/hzb666/LabStorageManager/blob/main/app/api/common_shelf.py#L164" /> |
111+
| `GET` | `/api/common-shelf/location-suggestions` | `get_common_shelf_location_suggestions_by_fields` | 已登录用户 | query: `cas_number``brand``specification` | `list[str]` | `200` | <InlineCodeRef href="https://github.com/hzb666/LabStorageManager/blob/main/app/api/common_shelf.py#L169" /> |
112+
| `GET` | `/api/common-shelf/groups/{group_key}/items` | `get_common_shelf_group_items` | 已登录用户 | path: `group_key` | `list[CommonShelfGroupItemResponse]` | `200` | <InlineCodeRef href="https://github.com/hzb666/LabStorageManager/blob/main/app/api/common_shelf.py#L187" /> |
113+
| `PUT` | `/api/common-shelf/groups/{group_key}` | `update_common_shelf_group` | 已登录用户 | path: `group_key`;body: `CommonShelfGroupEditRequest` | `dict` | `200` | <InlineCodeRef href="https://github.com/hzb666/LabStorageManager/blob/main/app/api/common_shelf.py#L229" /> |
114+
| `PUT` | `/api/common-shelf/groups/{group_key}/items/{item_id}` | `update_common_shelf_item` | 已登录用户 | path: `group_key``item_id`;body: `CommonShelfGroupItemUpdateRequest` | `dict` | `200` | <InlineCodeRef href="https://github.com/hzb666/LabStorageManager/blob/main/app/api/common_shelf.py#L312" /> |
115+
| `POST` | `/api/common-shelf/groups/{group_key}/add-bottles` | `add_common_shelf_bottles` | 已登录用户 | path: `group_key`;body: `CommonShelfAddBottlesRequest` | `dict` | `200` | <InlineCodeRef href="https://github.com/hzb666/LabStorageManager/blob/main/app/api/common_shelf.py#L357" /> |
116+
| `POST` | `/api/common-shelf/groups/{group_key}/remove-one` | `remove_one_common_shelf` | 已登录用户 | path: `group_key`;body: `CommonShelfRemoveOneRequest` | `dict` | `200` | <InlineCodeRef href="https://github.com/hzb666/LabStorageManager/blob/main/app/api/common_shelf.py#L399" /> |
117+
| `DELETE` | `/api/common-shelf/groups/{group_key}/items/{item_id}` | `delete_common_shelf_item` | 已登录用户 | path: `group_key``item_id` | `dict` | `200` | <InlineCodeRef href="https://github.com/hzb666/LabStorageManager/blob/main/app/api/common_shelf.py#L439" /> |
118+
| `DELETE` | `/api/common-shelf/groups/{group_key}` | `delete_common_shelf_group` | 管理员 | path: `group_key` | `dict` | `200` | <InlineCodeRef href="https://github.com/hzb666/LabStorageManager/blob/main/app/api/common_shelf.py#L473" /> |
119+
| `GET` | `/api/common-shelf/export` | `export_common_shelf` | 已登录用户 || `` | `200` | <InlineCodeRef href="https://github.com/hzb666/LabStorageManager/blob/main/app/api/common_shelf.py#L506" /> |
120+
121+
### CAS 主数据接口 (`chemical_name_map`)
122+
123+
| 方法 | 路径 | 函数 | 权限 | 关键参数(path/query/body/file) | 返回模型 | 状态码 | 代码 |
124+
| --- | --- | --- | --- | --- | --- | --- | --- |
125+
| `GET` | `/api/chemical-name-map` | `list_chemical_name_map` | 已登录用户 | query: `search``search_field``fuzzy``skip``limit` | `dict` | `200` | <InlineCodeRef href="https://github.com/hzb666/LabStorageManager/blob/main/app/api/chemical_name_map.py#L85" /> |
126+
| `POST` | `/api/chemical-name-map` | `create_chemical_name_map` | 已登录用户 | body: `ChemicalNameMapCreate` | `ChemicalNameMapResponse` | `200` | <InlineCodeRef href="https://github.com/hzb666/LabStorageManager/blob/main/app/api/chemical_name_map.py#L123" /> |
127+
| `PUT` | `/api/chemical-name-map/{item_id}` | `update_chemical_name_map` | 已登录用户 | path: `item_id`;body: `ChemicalNameMapUpdate` | `ChemicalNameMapResponse` | `200` | <InlineCodeRef href="https://github.com/hzb666/LabStorageManager/blob/main/app/api/chemical_name_map.py#L149" /> |
128+
| `DELETE` | `/api/chemical-name-map/{item_id}` | `delete_chemical_name_map` | 已登录用户 | path: `item_id` | `dict` | `200` | <InlineCodeRef href="https://github.com/hzb666/LabStorageManager/blob/main/app/api/chemical_name_map.py#L173" /> |
111129

112130
### 试剂订单基础接口 (`reagent_orders`)
113131

@@ -211,4 +229,3 @@
211229
- [app/main.py](https://github.com/hzb666/LabStorageManager/blob/main/app/main.py)(行370,382,396)
212230
- [app/services/chemical_info.py](https://github.com/hzb666/LabStorageManager/blob/main/app/services/chemical_info.py)(行442)
213231

214-

wiki/backend/api-workflows.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- [app/api/reagent_orders_workflow.py](https://github.com/hzb666/LabStorageManager/blob/main/app/api/reagent_orders_workflow.py) 负责审批、到货、入库和删除。
1414
- [app/api/consumable_orders.py](https://github.com/hzb666/LabStorageManager/blob/main/app/api/consumable_orders.py) 同时承担耗材订单 CRUD 与状态流转。
1515
- [app/api/announcements.py](https://github.com/hzb666/LabStorageManager/blob/main/app/api/announcements.py)[app/api/error_logs.py](https://github.com/hzb666/LabStorageManager/blob/main/app/api/error_logs.py)[app/api/user_logs.py](https://github.com/hzb666/LabStorageManager/blob/main/app/api/user_logs.py)[app/api/cart_sync.py](https://github.com/hzb666/LabStorageManager/blob/main/app/api/cart_sync.py)[app/api/events.py](https://github.com/hzb666/LabStorageManager/blob/main/app/api/events.py) 则处理外围能力。
16+
- [app/api/common_shelf.py](https://github.com/hzb666/LabStorageManager/blob/main/app/api/common_shelf.py)[app/api/chemical_name_map.py](https://github.com/hzb666/LabStorageManager/blob/main/app/api/chemical_name_map.py) 负责常用货架分组与 CAS 主数据维护。
1617

1718
## 试剂工作流
1819

@@ -45,14 +46,15 @@
4546
- `borrow``return` 会修改状态、写借还历史,并通过 SSE 通知前端。
4647
- `dashboard/my-borrows``dashboard/pending-stockin` 为首页和仪表盘聚合数据。
4748
- `import/template``import` 组成 Excel 导入链路。
48-
- 常用货架不单独建表,而是同 `inventory` 共表,通过 `is_common` 语义和专用路由完成分组维护。
49+
- 常用货架由独立的 `common_shelf` 表(`CommonShelf` 模型)维护,按 `CAS + 品牌 + 规格` 形成分组键 `group_key`,并由 `/api/common-shelf/*` 提供分组级与瓶级操作。
50+
- 手动加瓶前会校验 CAS 主数据;若缺失主数据,需要先走 `/api/chemical-name-map` 完成补录,避免常用货架出现无法稳定展示名称的脏数据。
4951

5052
## 事件驱动补充层
5153

5254
路由不是唯一的更新出口。很多接口在数据库提交后还会广播 SSE:
5355

5456
- 库存创建、编辑、删除、借用、归还
55-
- 常用货架创建、编辑、删除、消耗
57+
- 常用货架创建、编辑、删除、加瓶、扣减 1 瓶
5658
- 试剂订单与耗材订单的创建、更新、删除
5759
- 仪表盘聚合数据更新
5860

wiki/changelog.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
本页按版本概括项目的主要演进,用于帮助开发者快速判断能力边界、理解历史改动背景,并辅助阅读不同阶段的代码与文档。
44

5+
## 0.9.1
6+
7+
- 重构常用货架为“分组 + 瓶级条目”模型,新增分组定位、位置建议、加瓶/扣减与条目级维护接口。
8+
- 分组逻辑:按 `CAS + 品牌(标准化)+ 规格(标准化)` 生成 `group_key`;只要三者之一变化,就会进入新分组或触发分组合并确认。
9+
- 新增 CAS 主数据维护能力(`/api/chemical-name-map`),支持在常用货架补录链路中先补主数据再续写加瓶操作。
10+
- 前端常用货架页新增 CAS 主数据管理入口,手动添加流程与主数据校验联动,减少名称缺失导致的展示不一致。
11+
512
## 0.9.0
613

714
- 引入 SSE 实时推送、常用货架管理和 FTS 全文搜索,补齐库存检索、状态感知与实时刷新能力。

wiki/frontend/page-map.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
| `ReagentOrders` | `reagentOrderAPI` | `reagent_orders` |
4141
| `ConsumableOrders` | `consumableOrderAPI` | `consumable_orders` |
4242
| `Inventory` | `inventoryAPI` | `inventory` |
43-
| `CommonShelf` | `commonShelfAPI` | `common_shelf` |
43+
| `CommonShelf` | `commonShelfAPI``chemicalNameMapAPI` | `common_shelf` |
4444
| `CartImport` | `cartSyncAPI` | 以 HTTP 为主,提交后触发相关房间刷新 |
4545

4646
## 改动入口
@@ -50,6 +50,7 @@
5050
- 表单页优先接入 `BaseForm``validationSchemas`
5151
- 需要实时数据时,优先补齐 `useSSE``useListSSE`
5252
- 页面级导航变化时,同步更新本页和 [应用骨架](/frontend/app-shell)
53+
- 涉及常用货架补录时,同步考虑 CAS 主数据管理入口和 `chemicalNameMapAPI` 的联动
5354

5455
## 验证建议
5556

@@ -64,4 +65,3 @@
6465
- [frontend/src/pages/Layout.tsx](https://github.com/hzb666/LabStorageManager/blob/main/frontend/src/pages/Layout.tsx)
6566
- [frontend/src/pages/ReagentOrders.tsx](https://github.com/hzb666/LabStorageManager/blob/main/frontend/src/pages/ReagentOrders.tsx)
6667

67-

wiki/user-guide/inventory-and-borrowing.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,6 @@
126126

127127
当某组还有可用瓶时,页面可能会出现 **拿一瓶**
128128

129-
### 这个操作有什么限制
130-
131-
这个操作只有管理员可以用。普通用户点了也会提示权限不够。
132-
133129
### 它和借用有什么不同
134130

135131
“拿一瓶”不是借用,它更像是把一瓶常用试剂直接记为消耗掉了。执行后,这瓶会被标记为已耗尽,剩余量清零,也会留下相应记录。
@@ -142,11 +138,12 @@
142138

143139
- 查看常用货架
144140
- 新增常用货架条目
141+
- 补录或维护 CAS 主数据(名称、英文名、别名)
145142
- 编辑分组
146-
- 删除分组
143+
- 删除整组(仅管理员)
147144
- 导出分组
148145

149-
其中“拿一瓶”仍然只有管理员可用
146+
“拿一瓶”(扣减 1 瓶)登录用户即可操作
150147

151148
## 手动补录怎么分
152149

@@ -165,6 +162,8 @@
165162
- 公共试剂补录
166163
- 需要按组展示、按瓶消耗的常用品
167164

165+
如果系统提示“该 CAS 还未录入主数据”,先在常用货架页点 **CAS 主数据管理** 补齐名称信息,再继续本次手动添加。
166+
168167
### 这两种方式的共同点
169168

170169
- 都会检查 CAS 信息。

0 commit comments

Comments
 (0)