新增启动时插入数据模块,新增前端页面接口,students模块更新README_students.md模块解释说明,主程序main.py更新数据模块接口。
This commit is contained in:
@@ -96,7 +96,6 @@ ORM:sqlalchemy
|
||||
`is_deleted`
|
||||
`deleted_date`
|
||||
|
||||
|
||||
## schema.students_request:请求体、数据过滤
|
||||
请求体根据业务要求有不同调整,方便后续维护和更改需求
|
||||
1. 查询:StudentsQuery
|
||||
@@ -114,8 +113,19 @@ ORM:sqlalchemy
|
||||
3. 不可全字段为空
|
||||
|
||||
## StatCalc:统计分析模块
|
||||
除了没有model以外没有什么太大的区别
|
||||
|
||||
- 除了没有model以外没有什么太大的区别
|
||||
- 因为接口都有具体需求,所以直接一键呼出,不用填写筛选内容
|
||||
1. 请求体
|
||||
1. 搞清楚业务需求,需要用到哪些字段
|
||||
2. 增删改查的具体逻辑
|
||||
2. api
|
||||
1. 写好接收变量
|
||||
2. 装饰器设定
|
||||
3. 输出规则
|
||||
4. 一次写好基本上就不会再改了
|
||||
3. dao
|
||||
1. 工作量最大的层,所有的业务逻辑都写在这里面
|
||||
2. 所有的业务逻辑都在这个层里
|
||||
|
||||
## 学生管理系统修改报错记录
|
||||
### 1. 合并修改记录:
|
||||
@@ -208,3 +218,20 @@ ORM:sqlalchemy
|
||||
|
||||
启动后端后直接浏览器打开 frontend/index.html 即可使用。
|
||||
|
||||
### 移植
|
||||
只动两个文件,都不需要改代码:
|
||||
|
||||
移动的文件:
|
||||
|
||||
init_test_data.py → 新项目的根目录
|
||||
frontend/ → 新项目的根目录(整个文件夹)
|
||||
要改的唯一参数: frontend/index.html 第 306 行
|
||||
|
||||
const API_BASE = 'http://localhost:59000';
|
||||
改成新项目实际运行的端口即可。
|
||||
|
||||
其他都不用动:
|
||||
|
||||
init_test_data.py 完全独立,连接的是 databases.py 里的 .env 配置,新项目只要 DB 信息对就能直接跑
|
||||
frontend/index.html 纯静态页面,不依赖任何项目代码
|
||||
如果新项目用了不同的端口(比如 8000),改那一行就行
|
||||
@@ -30,7 +30,7 @@ class Students(Base_all):
|
||||
, comment='年龄'
|
||||
, nullable=False)
|
||||
|
||||
sex = Column(Enum(SexEnum)
|
||||
sex = Column(Enum(SexEnum, values_callable=lambda e: [i.value for i in e])
|
||||
, comment='性别'
|
||||
, nullable=False)
|
||||
|
||||
@@ -49,7 +49,7 @@ class Students(Base_all):
|
||||
graduate_time = Column(DATETIME
|
||||
, comment='毕业时间')
|
||||
|
||||
education = Column(Enum(EducationEnum)
|
||||
education = Column(Enum(EducationEnum, values_callable=lambda e: [i.value for i in e])
|
||||
, comment='学历'
|
||||
, nullable=True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user