Merge remote-tracking branch 'origin/coffee_all' into lon_students_merge_code_test
# Conflicts: # stu_jiuye/database.py # stu_jiuye/main.py
This commit is contained in:
@@ -9,6 +9,7 @@ dependencies = [
|
|||||||
"like>=1.7.1",
|
"like>=1.7.1",
|
||||||
"pip>=26.2.1",
|
"pip>=26.2.1",
|
||||||
"pymysql>=1.2.3",
|
"pymysql>=1.2.3",
|
||||||
|
"python-dotenv>=1.2.3",
|
||||||
"sqlalchemy>=2.0.54",
|
"sqlalchemy>=2.0.54",
|
||||||
"uvicorn>=0.53.0",
|
"uvicorn>=0.53.0",
|
||||||
]
|
]
|
||||||
|
|||||||
+16
-12
@@ -1,6 +1,6 @@
|
|||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
from fastapi import APIRouter,Depends,HTTPException
|
from fastapi import APIRouter,Depends,HTTPException,Query
|
||||||
from stu_jiuye.dao import *
|
from stu_jiuye.dao import *
|
||||||
from stu_jiuye.request import PostRequest, EmpResponse, AddRequest,AddResponse,CompRequest,CompResponse
|
from stu_jiuye.request import PostRequest, EmpResponse, AddRequest,AddResponse,CompRequest,CompResponse
|
||||||
from stu_jiuye.database import get_db
|
from stu_jiuye.database import get_db
|
||||||
@@ -9,14 +9,16 @@ CURD=APIRouter()
|
|||||||
|
|
||||||
@CURD.get('/emp',summary='查询就业信息')
|
@CURD.get('/emp',summary='查询就业信息')
|
||||||
def get_stuinfo( #查询学生就业信息
|
def get_stuinfo( #查询学生就业信息
|
||||||
sname:str| None = None
|
sname:str| None = Query(None,description='学生姓名')
|
||||||
,class_num:int| None = None
|
,class_num:int| None = Query(None,description='班级编号')
|
||||||
,employment_company:str|None=None
|
,employment_company:str|None=Query(None,description='公司名称')
|
||||||
,min_salary:int=0
|
,min_salary:int|None=Query(None,description='最小薪资范围')
|
||||||
,max_salary:int|None=None
|
,max_salary:int|None=Query(None,description='最大薪资范围')
|
||||||
,somewhere:str|None=None
|
,somewhere:str|None=Query(None,description='公司地区')
|
||||||
,employment_open_time:datetime.date|None=None
|
,employment_open_start: datetime.date | None = Query(None,description='就业开放起始时间')
|
||||||
,offer_recived_time:datetime.date|None=None
|
,employment_open_end: datetime.date | None = Query(None,description='就业开放结束时间')
|
||||||
|
,offer_recived_start: datetime.date | None = Query(None,description='offer下发起始时间')
|
||||||
|
,offer_recived_end: datetime.date | None = Query(None,description='offer下发结束时间')
|
||||||
,db=Depends(get_db)
|
,db=Depends(get_db)
|
||||||
): #查询条件
|
): #查询条件
|
||||||
r=get_emp_dao( #调用函数
|
r=get_emp_dao( #调用函数
|
||||||
@@ -26,8 +28,10 @@ def get_stuinfo( #查询学生就业信息
|
|||||||
min_salary,
|
min_salary,
|
||||||
max_salary,
|
max_salary,
|
||||||
somewhere,
|
somewhere,
|
||||||
employment_open_time,
|
employment_open_start,
|
||||||
offer_recived_time,
|
employment_open_end,
|
||||||
|
offer_recived_start,
|
||||||
|
offer_recived_end,
|
||||||
db
|
db
|
||||||
)
|
)
|
||||||
if r:
|
if r:
|
||||||
@@ -75,9 +79,9 @@ def updata_stuinfo( #更新数据模块
|
|||||||
d = up.model_dump(exclude_unset=True) #解析
|
d = up.model_dump(exclude_unset=True) #解析
|
||||||
d.pop('create_time', None)
|
d.pop('create_time', None)
|
||||||
d.pop('is_deleted', None)
|
d.pop('is_deleted', None)
|
||||||
r = update_emp_dao(id=id, update_data=d, db=db) #调用更新函数
|
|
||||||
if not d:
|
if not d:
|
||||||
raise HTTPException(status_code=400, detail='没有需要更新的字段')
|
raise HTTPException(status_code=400, detail='没有需要更新的字段')
|
||||||
|
r = update_emp_dao(id=id, update_data=d, db=db) #调用更新函数
|
||||||
if not r:
|
if not r:
|
||||||
raise HTTPException(status_code=404, detail='未找到对应记录') #失败返回错误信息
|
raise HTTPException(status_code=404, detail='未找到对应记录') #失败返回错误信息
|
||||||
return {'code': 200, 'totals': r, 'detail': '更新成功'} #成功返回信息
|
return {'code': 200, 'totals': r, 'detail': '更新成功'} #成功返回信息
|
||||||
|
|||||||
+19
-11
@@ -73,8 +73,10 @@ def get_emp_dao( #获取学生
|
|||||||
,min_salary
|
,min_salary
|
||||||
,max_salary
|
,max_salary
|
||||||
,somewhere
|
,somewhere
|
||||||
,employment_open_time
|
,employment_open_start
|
||||||
,offer_recived_time
|
,employment_open_end
|
||||||
|
,offer_recived_start
|
||||||
|
,offer_recived_end
|
||||||
,db
|
,db
|
||||||
|
|
||||||
# ,page
|
# ,page
|
||||||
@@ -100,10 +102,15 @@ def get_emp_dao( #获取学生
|
|||||||
q = q.filter(Employments.employment_salary >= min_salary)
|
q = q.filter(Employments.employment_salary >= min_salary)
|
||||||
if max_salary is not None: ##根据最大薪资筛选
|
if max_salary is not None: ##根据最大薪资筛选
|
||||||
q = q.filter(Employments.employment_salary <= max_salary)
|
q = q.filter(Employments.employment_salary <= max_salary)
|
||||||
if employment_open_time:
|
if employment_open_start:
|
||||||
q = q.filter(Employments.employment_open_time == employment_open_time)
|
q = q.filter(Employments.employment_open_time >= employment_open_start)
|
||||||
if offer_recived_time:
|
if employment_open_end:
|
||||||
q = q.filter(Employments.offer_recived_time == offer_recived_time)
|
q = q.filter(Employments.employment_open_time <= employment_open_end)
|
||||||
|
if offer_recived_start:
|
||||||
|
q = q.filter(Employments.offer_recived_time >= offer_recived_start)
|
||||||
|
if offer_recived_end:
|
||||||
|
q = q.filter(Employments.offer_recived_time <= offer_recived_end)
|
||||||
|
|
||||||
r= q.all()
|
r= q.all()
|
||||||
if r:
|
if r:
|
||||||
return [ {"id": i.id,
|
return [ {"id": i.id,
|
||||||
@@ -114,11 +121,12 @@ def get_emp_dao( #获取学生
|
|||||||
# "company_id": i.company_id,
|
# "company_id": i.company_id,
|
||||||
"薪资":i.employment_salary or '-',
|
"薪资":i.employment_salary or '-',
|
||||||
# "address_id": i.address_id,
|
# "address_id": i.address_id,
|
||||||
"就业开放时间":i.employment_open_time,
|
"就业开放时间":i.employment_open_time.strftime('%Y-%m-%d') ,
|
||||||
"offer下发时间":i.offer_recived_time or '-',
|
"offer下发时间":i.offer_recived_time.strftime('%Y-%m-%d')
|
||||||
"创建时间": i.create_time,
|
# , "创建时间": i.create_time,
|
||||||
"更新时间": i.update_time,
|
# "更新时间": i.update_time,
|
||||||
"是否删除":i.is_deleted } for i,employment_company,somewhere in r ] #返回信息列表
|
# "是否删除":i.is_deleted
|
||||||
|
} for i,employment_company,somewhere in r ] #返回信息列表
|
||||||
|
|
||||||
|
|
||||||
def delete_emp_dao(id,db): #删除函数
|
def delete_emp_dao(id,db): #删除函数
|
||||||
|
|||||||
@@ -1,3 +1,9 @@
|
|||||||
|
# from sqlalchemy import *
|
||||||
|
# from sqlalchemy.orm import declarative_base,sessionmaker
|
||||||
|
#
|
||||||
|
# db_url = "mysql+pymysql://root:123456@127.0.0.1:3306/ai0824_001?charset=utf8mb4"
|
||||||
|
# # db_url = "mysql+pymysql://root:420821@localhost:3306/student_manage_system?charset=utf8mb4"
|
||||||
|
|
||||||
from sqlalchemy import *
|
from sqlalchemy import *
|
||||||
from sqlalchemy.orm import declarative_base,sessionmaker
|
from sqlalchemy.orm import declarative_base,sessionmaker
|
||||||
|
|
||||||
@@ -12,6 +18,7 @@ DB_PORT = os.getenv("DB_PORT", "3306")
|
|||||||
DB_NAME = os.getenv("DB_NAME", "student_manage_system")
|
DB_NAME = os.getenv("DB_NAME", "student_manage_system")
|
||||||
|
|
||||||
db_url = f"mysql+pymysql://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{DB_PORT}/{DB_NAME}?charset=utf8mb4"
|
db_url = f"mysql+pymysql://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{DB_PORT}/{DB_NAME}?charset=utf8mb4"
|
||||||
|
|
||||||
engine = create_engine(db_url
|
engine = create_engine(db_url
|
||||||
, pool_size=50
|
, pool_size=50
|
||||||
, echo=True
|
, echo=True
|
||||||
|
|||||||
@@ -1,12 +1,15 @@
|
|||||||
from fastapi import FastAPI,APIRouter
|
from fastapi import FastAPI,APIRouter
|
||||||
from stu_jiuye.CURD_api import CURD
|
from stu_jiuye.CURD_api import CURD
|
||||||
from stu_jiuye.database import Base,engine
|
from stu_jiuye.database import Base,engine
|
||||||
|
import stu_jiuye.model
|
||||||
|
|
||||||
# 合并接口
|
# 合并接口
|
||||||
Shtudent_Jiuye = APIRouter()
|
Shtudent_Jiuye = APIRouter()
|
||||||
Shtudent_Jiuye.include_router(CURD)
|
Shtudent_Jiuye.include_router(CURD)
|
||||||
|
|
||||||
# 自测接口
|
# 自测接口
|
||||||
|
|
||||||
|
|
||||||
app=FastAPI()
|
app=FastAPI()
|
||||||
Base.metadata.create_all(engine)
|
Base.metadata.create_all(engine)
|
||||||
app.include_router(CURD,tags=['就业管理系统'])
|
app.include_router(CURD,tags=['就业管理系统'])
|
||||||
|
|||||||
+10
-31
@@ -5,31 +5,6 @@ from stu_jiuye.database import DATETIME,Base,Column,Integer,String,DATE
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
||||||
# class Student(Base):
|
|
||||||
# __tablename__ = 'Student'
|
|
||||||
# id = Column(Integer
|
|
||||||
# , primary_key=True
|
|
||||||
# , autoincrement=True
|
|
||||||
# # 外键
|
|
||||||
# ,comment='自增主键'
|
|
||||||
# )
|
|
||||||
# stuname = Column(String(50)
|
|
||||||
# ,nullable=False
|
|
||||||
# )
|
|
||||||
# stuid=Column(Integer
|
|
||||||
# ,nullable=False
|
|
||||||
# )
|
|
||||||
# stuclass=Column(String(50)
|
|
||||||
# ,nullable=False
|
|
||||||
# )
|
|
||||||
# created_date = Column(DATETIME
|
|
||||||
# ,default=datetime.now
|
|
||||||
# )
|
|
||||||
# updated_date = Column(DATETIME
|
|
||||||
# ,default=datetime.now
|
|
||||||
# ,onupdate=datetime.now
|
|
||||||
# )
|
|
||||||
|
|
||||||
|
|
||||||
class Employments(Base_all): #学生就业信息基类
|
class Employments(Base_all): #学生就业信息基类
|
||||||
__tablename__ = 'Employments' #表名
|
__tablename__ = 'Employments' #表名
|
||||||
@@ -39,8 +14,12 @@ class Employments(Base_all): #学生
|
|||||||
# , ForeignKey('student.id')
|
# , ForeignKey('student.id')
|
||||||
, comment='自增主键'
|
, comment='自增主键'
|
||||||
)
|
)
|
||||||
sname = Column(String(50)) #学生姓名,冗余字段
|
sname = Column(String(50)
|
||||||
class_num = Column(Integer) #学生班级,冗余字段
|
# , ForeignKey='student.name'
|
||||||
|
) #学生姓名,冗余字段
|
||||||
|
class_num = Column(Integer
|
||||||
|
# , ForeignKey='class.id'
|
||||||
|
) #学生班级,冗余字段
|
||||||
|
|
||||||
# compname=Column(String(50)
|
# compname=Column(String(50)
|
||||||
# ,nullable=False
|
# ,nullable=False
|
||||||
@@ -82,10 +61,10 @@ class Company(Base_all): #公司
|
|||||||
, ForeignKey('Address.id') #外键地址表id
|
, ForeignKey('Address.id') #外键地址表id
|
||||||
, nullable=False #非空约束
|
, nullable=False #非空约束
|
||||||
)
|
)
|
||||||
created_date = Column(DATETIME
|
create_time = Column(DATETIME
|
||||||
, default=datetime.now
|
, default=datetime.now
|
||||||
)
|
)
|
||||||
updated_date = Column(DATETIME
|
update_time = Column(DATETIME
|
||||||
, default=datetime.now
|
, default=datetime.now
|
||||||
, onupdate=datetime.now
|
, onupdate=datetime.now
|
||||||
)
|
)
|
||||||
@@ -100,10 +79,10 @@ class Address(Base_all):
|
|||||||
somewhere=Column(String(50) #地址区域
|
somewhere=Column(String(50) #地址区域
|
||||||
, nullable=False
|
, nullable=False
|
||||||
)
|
)
|
||||||
created_date = Column(DATETIME
|
create_time = Column(DATETIME
|
||||||
, default=datetime.now
|
, default=datetime.now
|
||||||
)
|
)
|
||||||
updated_date = Column(DATETIME
|
update_time = Column(DATETIME
|
||||||
, default=datetime.now
|
, default=datetime.now
|
||||||
, onupdate=datetime.now
|
, onupdate=datetime.now
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -851,6 +851,7 @@ dependencies = [
|
|||||||
{ name = "like" },
|
{ name = "like" },
|
||||||
{ name = "pip" },
|
{ name = "pip" },
|
||||||
{ name = "pymysql" },
|
{ name = "pymysql" },
|
||||||
|
{ name = "python-dotenv" },
|
||||||
{ name = "sqlalchemy" },
|
{ name = "sqlalchemy" },
|
||||||
{ name = "uvicorn" },
|
{ name = "uvicorn" },
|
||||||
]
|
]
|
||||||
@@ -861,6 +862,7 @@ requires-dist = [
|
|||||||
{ name = "like", specifier = ">=1.7.1" },
|
{ name = "like", specifier = ">=1.7.1" },
|
||||||
{ name = "pip", specifier = ">=26.2.1" },
|
{ name = "pip", specifier = ">=26.2.1" },
|
||||||
{ name = "pymysql", specifier = ">=1.2.3" },
|
{ name = "pymysql", specifier = ">=1.2.3" },
|
||||||
|
{ name = "python-dotenv", specifier = ">=1.2.3" },
|
||||||
{ name = "sqlalchemy", specifier = ">=2.0.54" },
|
{ name = "sqlalchemy", specifier = ">=2.0.54" },
|
||||||
{ name = "uvicorn", specifier = ">=0.53.0" },
|
{ name = "uvicorn", specifier = ">=0.53.0" },
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user