统计分析模块更新,待测试,成绩模块更新。
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
# .env(放项目根目录,每个人自己建,不提交 Git)
|
# .env(放项目根目录,每个人自己建,不提交 Git)
|
||||||
# 用来修改数据库账户密码
|
# 用来修改数据库账户密码
|
||||||
DB_USER=root
|
DB_USER=root
|
||||||
DB_PASSWORD=123456
|
DB_PASSWORD=420821
|
||||||
DB_HOST=localhost
|
DB_HOST=localhost
|
||||||
DB_PORT=3306
|
DB_PORT=3306
|
||||||
DB_NAME=student_manage_system
|
DB_NAME=student_manage_system
|
||||||
@@ -12,11 +12,8 @@ statcalc_api = APIRouter()
|
|||||||
,summary='人员信息查询'
|
,summary='人员信息查询'
|
||||||
,description=f'查询所有超过30岁的学员的信息。'
|
,description=f'查询所有超过30岁的学员的信息。'
|
||||||
)
|
)
|
||||||
def get_students( stu:StudentsQuery = Depends()
|
def get_students(db=Depends(get_db)):
|
||||||
, db=Depends(get_db)
|
result = get_age_30( db=db )
|
||||||
):
|
|
||||||
s_dict = stu.model_dump(exclude_unset=True) # 没值的不要
|
|
||||||
result = get_student_dao( s=s_dict , db=db )
|
|
||||||
if result:
|
if result:
|
||||||
return result
|
return result
|
||||||
raise HTTPException(status_code=404, detail="没有找到符合条件的学生")
|
raise HTTPException(status_code=404, detail="没有找到符合条件的学生")
|
||||||
@@ -25,9 +22,7 @@ def get_students( stu:StudentsQuery = Depends()
|
|||||||
,summary='人数统计'
|
,summary='人数统计'
|
||||||
,description=f'统计每个班级的人数以及男生女生的人数。'
|
,description=f'统计每个班级的人数以及男生女生的人数。'
|
||||||
)
|
)
|
||||||
def get_students( stu:StudentsQuery = Depends()
|
def get_students(db=Depends(get_db)):
|
||||||
, db=Depends(get_db)
|
|
||||||
):
|
|
||||||
s_dict = stu.model_dump(exclude_unset=True) # 没值的不要
|
s_dict = stu.model_dump(exclude_unset=True) # 没值的不要
|
||||||
result = get_student_dao( s=s_dict , db=db )
|
result = get_student_dao( s=s_dict , db=db )
|
||||||
if result:
|
if result:
|
||||||
|
|||||||
@@ -1,6 +1,18 @@
|
|||||||
# from StatCalc.model.statcalc_model import
|
|
||||||
from StatCalc.schema.statcalc_request import *
|
from StatCalc.schema.statcalc_request import *
|
||||||
from fastapi import HTTPException
|
from fastapi import HTTPException
|
||||||
|
|
||||||
|
from students.model.students_model import Students
|
||||||
|
|
||||||
|
def get_age_30(db):
|
||||||
|
q = db.query(Students).filter(Students.age>=30).all()
|
||||||
|
return q
|
||||||
|
|
||||||
|
from class_management.model.class_management_model import ClassInfo
|
||||||
|
|
||||||
|
def get_class_count(db):
|
||||||
|
q = (db.query(ClassInfo.id)
|
||||||
|
.join(Students,Students.class_id==ClassInfo.id)
|
||||||
|
.filter()
|
||||||
|
.group_by(ClassInfo.id,Students.sex,)
|
||||||
|
.all())
|
||||||
|
return q
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
from fastapi import FastAPI,APIRouter
|
from fastapi import FastAPI,APIRouter
|
||||||
from Teachers.model.tea_model import *
|
from Teachers.model.tea_model import *
|
||||||
from Teachers.api.tea_api import tea_api
|
from Teachers.api.tea_api import tea_api
|
||||||
|
from Teachers.database import *
|
||||||
|
|
||||||
# 合并接口
|
# 合并接口
|
||||||
Teachers_API = APIRouter()
|
Teachers_API = APIRouter()
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
from databases import engine_all,Base_all,Session
|
from databases import engine_all,Base_all,Session
|
||||||
from Teachers.database import *
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from sqlalchemy import *
|
from sqlalchemy import *
|
||||||
import enum
|
import enum
|
||||||
@@ -47,7 +46,7 @@ class Tea(Base_all):
|
|||||||
is_delete = Column(Boolean,default=False,comment='是否删除')
|
is_delete = Column(Boolean,default=False,comment='是否删除')
|
||||||
delete_time = Column(DateTime)
|
delete_time = Column(DateTime)
|
||||||
#科目表
|
#科目表
|
||||||
class Sub(Base):
|
class Sub(Base_all):
|
||||||
__tablename__ = 'subject'
|
__tablename__ = 'subject'
|
||||||
id = Column(Integer
|
id = Column(Integer
|
||||||
, primary_key=True
|
, primary_key=True
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ def get_one_class(id:int,db=Depends(get_db)):
|
|||||||
res = get_class_dao(c={'id':id},db=db)
|
res = get_class_dao(c={'id':id},db=db)
|
||||||
if not res:
|
if not res:
|
||||||
raise HTTPException(status_code=404, detail="该班级不存在或已删除")
|
raise HTTPException(status_code=404, detail="该班级不存在或已删除")
|
||||||
return ClassResponse(total=1,data=res[0])
|
return ClassResponse(totals=1,data=res[0])
|
||||||
|
|
||||||
@class_api.get('',summary='多字段查询班级')
|
@class_api.get('',summary='多字段查询班级')
|
||||||
def get_some_classes( num:str|None = Query(None,description='班级编号')
|
def get_some_classes( num:str|None = Query(None,description='班级编号')
|
||||||
|
|||||||
@@ -4,21 +4,21 @@ from scores.main import Scores_API
|
|||||||
from stu_jiuye.main import Shtudent_Jiuye
|
from stu_jiuye.main import Shtudent_Jiuye
|
||||||
from students.main import Students_API
|
from students.main import Students_API
|
||||||
from Teachers.main import Teachers_API
|
from Teachers.main import Teachers_API
|
||||||
from StatCalc.main import StatCalc_API
|
# from StatCalc.main import StatCalc_API
|
||||||
from databases import *
|
from databases import *
|
||||||
app = FastAPI(title="学生管理系统")
|
app = FastAPI(title="学生管理系统")
|
||||||
|
|
||||||
Base_all.metadata.create_all(bind=engine_all)
|
|
||||||
|
|
||||||
|
|
||||||
app.include_router(Classes_API,tags=["classes"])
|
app.include_router(Classes_API,tags=["classes"])
|
||||||
app.include_router(Scores_API,tags=["scores"])
|
app.include_router(Scores_API,tags=["scores"])
|
||||||
app.include_router(Shtudent_Jiuye,tags=["Employments"])
|
app.include_router(Shtudent_Jiuye,tags=["Employments"])
|
||||||
app.include_router(Students_API,tags=["students"])
|
app.include_router(Students_API,tags=["students"])
|
||||||
app.include_router(Teachers_API,tags=["teachers"])
|
app.include_router(Teachers_API,tags=["teachers"])
|
||||||
app.include_router(StatCalc_API,tags=["StatCalc"])
|
# app.include_router(StatCalc_API,tags=["StatCalc"])
|
||||||
|
|
||||||
|
|
||||||
|
Base_all.metadata.create_all(bind=engine_all)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
def main():
|
def main():
|
||||||
print("Hello from student-manage-system!")
|
print("Hello from student-manage-system!")
|
||||||
|
|||||||
@@ -3,10 +3,6 @@ from scores.database import Base
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from sqlalchemy import DateTime,Column,Integer,String,Float,ForeignKey
|
from sqlalchemy import DateTime,Column,Integer,String,Float,ForeignKey
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Score(Base):
|
|
||||||
from sqlalchemy import DateTime,Column,Integer,String,Float
|
|
||||||
class Score(Base_all):
|
class Score(Base_all):
|
||||||
__tablename__='scores'
|
__tablename__='scores'
|
||||||
id = Column(Integer
|
id = Column(Integer
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
from databases import engine_all,Base_all,Session
|
from databases import engine_all,Base_all,Session
|
||||||
from sqlalchemy import ForeignKey
|
from sqlalchemy import ForeignKey
|
||||||
from student_manage_system import students,classes
|
|
||||||
from stu_jiuye.database import DATETIME,Base,Column,Integer,String,DATE
|
from stu_jiuye.database import DATETIME,Base,Column,Integer,String,DATE
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Employments(Base_all): #学生就业信息基类
|
class Employments(Base_all): #学生就业信息基类
|
||||||
__tablename__ = 'Employments' #表名
|
__tablename__ = 'Employments' #表名
|
||||||
id = Column(Integer #主键,自增主键
|
id = Column(Integer #主键,自增主键
|
||||||
|
|||||||
@@ -14,3 +14,12 @@ select * from students limit 50;
|
|||||||
|
|
||||||
desc students;
|
desc students;
|
||||||
|
|
||||||
|
|
||||||
|
select *
|
||||||
|
from cast(student_manage_system as BINARY)
|
||||||
|
where age >30
|
||||||
|
join on
|
||||||
|
group by
|
||||||
|
having
|
||||||
|
order by
|
||||||
|
limit
|
||||||
Reference in New Issue
Block a user