签入版本
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
# 行政区划管理
|
||||
|
||||
:::tip 说明
|
||||
行政区划管理模块提供省市区三级行政区划数据的查询和管理能力,支持树形结构展示和下拉选择。模块位于 `src/modules/city/`。
|
||||
:::
|
||||
|
||||
## 模块结构
|
||||
|
||||
```
|
||||
src/modules/city/
|
||||
├── models.py # 行政区划模型
|
||||
├── schemas.py # 参数验证
|
||||
├── repository.py # 数据访问层
|
||||
├── service.py # 业务逻辑层
|
||||
└── handlers.py # 请求处理器
|
||||
```
|
||||
|
||||
## 数据模型
|
||||
|
||||
```python
|
||||
class City(BaseModel):
|
||||
"""行政区划模型"""
|
||||
__tablename__ = "city"
|
||||
|
||||
name = Column(String(100), nullable=False, comment="名称")
|
||||
code = Column(String(20), default="", comment="行政区划代码")
|
||||
parent_id = Column(Integer, default=0, comment="父级ID(0=顶级)")
|
||||
level = Column(Integer, default=0, comment="层级:1=省 2=市 3=区")
|
||||
sort = Column(Integer, default=0, comment="排序")
|
||||
```
|
||||
|
||||
## API 接口
|
||||
|
||||
| 接口 | 方法 | 权限 | 说明 |
|
||||
|:-----|:-----|:-----|:-----|
|
||||
| `/api/v1/city/page` | GET | `sys:city:list` | 分页查询 |
|
||||
| `/api/v1/city/detail/(\d+)` | GET | `sys:city:detail` | 详情查询 |
|
||||
| `/api/v1/city/add` | POST | `sys:city:add` | 新增 |
|
||||
| `/api/v1/city/update` | PUT | `sys:city:update` | 更新 |
|
||||
| `/api/v1/city/delete/(\d+)` | DELETE | `sys:city:delete` | 删除 |
|
||||
| `/api/v1/city/getCityList` | GET | `sys:city:list` | 获取下拉树形列表 |
|
||||
|
||||
## 树形结构
|
||||
|
||||
行政区划按省→市→区三级组织,通过 `parent_id` 字段形成树形结构。下拉选择接口返回嵌套的树形数据。
|
||||
|
||||
## 总结
|
||||
|
||||
行政区划管理模块提供省市区三级数据的 CRUD 和树形查询能力,支持下拉选择组件的数据源。
|
||||
Reference in New Issue
Block a user