将 native/api/ 改名为 native/wndb/,避免与 Web API 层命名冲突

This commit is contained in:
2026-03-09 12:13:27 +08:00
parent 6b85cfc666
commit 20ab08e206
87 changed files with 33 additions and 33 deletions
+7 -7
View File
@@ -276,7 +276,7 @@ TJWater integrates compiled C/Go binaries for water network simulation:
```
Python (FastAPI)
app/native/api/
app/native/wndb/
├── project.py (list, create, delete, open projects)
├── s2_junctions.py (CRUD for junctions)
├── s5_pipes.py (CRUD for pipes)
@@ -290,7 +290,7 @@ app/native/api_encap/ (Low-level binary wrappers)
#### 1. Native API Initialization
```python
# app/native/api/__init__.py
# app/native/wndb/__init__.py
from app.native.api_encap.api import (
ChangeSet, # Change tracking
API_ADD, API_UPDATE, API_DELETE, # Operations
@@ -302,7 +302,7 @@ from app.native.api_encap.api import (
#### 2. Example: Project Management
```python
# app/services/tjnetwork.py
from app.native.api import list_project, open_project, close_project
from app.native.wndb import list_project, open_project, close_project
def list_project() -> list[str]:
"""List all project databases"""
@@ -334,7 +334,7 @@ def update_junction(name: str, demand: float):
#### 4. Network CRUD Operations
```python
# All operations follow this pattern:
from app.native.api import get_all_junctions, add_junction, set_junction
from app.native.wndb import get_all_junctions, add_junction, set_junction
# Read
junctions = get_all_junctions() # Returns list of dicts
@@ -357,7 +357,7 @@ app/api/v1/endpoints/simulation.py
app/services/simulation.py (business logic)
app/native/api/ (calls binary functions)
app/native/wndb/ (calls binary functions)
├── open_project("szh")
├── set_option("QUALITY", "CHEMICAL")
├── run_simulation()
@@ -372,7 +372,7 @@ Response to client
Native module exports constants for enumerations:
```python
from app.native.api import (
from app.native.wndb import (
OPTION_UNITS_LPS, # Flow units
OPTION_PRESSURE_KPA, # Pressure units
OPTION_QUALITY_CHEMICAL, # Quality type
@@ -1004,7 +1004,7 @@ services:
| **Repository** | `app/infra/repositories/` | Data access layer | psycopg cursor |
| **Domain** | `app/domain/` | Models & schemas | Pydantic, Enum |
| **Services** | `app/services/` | Business logic | Python, native APIs |
| **Native API** | `app/native/api/` | Binary integration | ctypes/cffi, .so/.dll |
| **Native API** | `app/native/wndb/` | Binary integration | ctypes/cffi, .so/.dll |
| **Config** | `app/core/config.py` | Settings management | Pydantic Settings |
| **Security** | `app/core/security.py` | Encryption, hashing | cryptography, passlib |
| **Audit** | `app/infra/audit/` | Operation logging | Middleware, Repository |