amend! 添加注释

更新字段
This commit is contained in:
2026-09-21 21:33:17 +08:00
parent 77de323412
commit 3dcfaa5500
6 changed files with 72 additions and 59 deletions
+28 -28
View File
@@ -33,7 +33,7 @@ def add_address_dao(o,db): #添加地址区域信息函数
try:
o.pop('id', None) #摘除id字段,自增字段无需手动添加
o1 = Address( **o) #实例化参数
db.add(o1) #添加数据进入表
db.add(o1) #添加数据进入表
except Exception as e: #失败返回
print(f'添加失败,{e}')
db.rollback() #回滚数据
@@ -58,58 +58,58 @@ def update_emp_dao(id,update_data,db): #更新数据函数
def get_emp_dao( #获取学生就业信息函数
# stuid,
stuname
,stuclass
,compname
sname
,class_num
,employment_company
,min_salary
,max_salary
,somewhere
,employment_open_date
,offer_date
,employment_open_time
,offer_recived_time
,db
# ,page
# ,page_size
): #根据选择条件获取信息
q = db.query(Employments,Company.compname,Address.somewhere)\
q = db.query(Employments,Company.employment_company,Address.somewhere)\
.join(Company,Employments.company_id==Company.id)\
.join(Address,Company.address_id==Address.id)\
.filter(Employments.is_deleted == 0) #连接公司表和地址表,筛选未被删除信息
# if stuid:
# q = q.filter( Employments.id == stuid )
if stuname: #根据学生姓名筛选
q = q.filter( Employments.stuname == stuname )
if stuclass:
q = q.filter(Employments.stuclass == stuclass)
if sname: #根据学生姓名筛选
q = q.filter( Employments.sname == sname )
if class_num:
q = q.filter(Employments.class_num == class_num)
if somewhere:
q = q.filter(Address.somewhere.like(f'%{somewhere}%'))
if compname: #根据公司姓名筛选
q=q.filter(Company.compname.like(f'%{compname}%'))
if employment_company: #根据公司姓名筛选
q=q.filter(Company.employment_company.like(f'%{employment_company}%'))
# r = q.offset( (page-1)*page_size ).limit( page_size ).all()
if min_salary is not None: #根据最小薪资筛选
q = q.filter(Employments.salary >= min_salary)
q = q.filter(Employments.employment_salary >= min_salary)
if max_salary is not None: ##根据最大薪资筛选
q = q.filter(Employments.salary <= max_salary)
if employment_open_date:
q = q.filter(Employments.employment_open_date == employment_open_date)
if offer_date:
q = q.filter(Employments.offer_date == offer_date)
q = q.filter(Employments.employment_salary <= max_salary)
if employment_open_time:
q = q.filter(Employments.employment_open_time == employment_open_time)
if offer_recived_time:
q = q.filter(Employments.offer_recived_time == offer_recived_time)
r= q.all()
if r:
return [ {"id": i.id,
'学生姓名':i.stuname,
'学生班级':i.stuclass,
"公司": compname,
'学生姓名':i.sname,
'学生班级编号':i.class_num,
"公司": employment_company,
"公司区域":somewhere,
# "company_id": i.company_id,
"薪资":i.salary,
"薪资":i.employment_salary,
# "address_id": i.address_id,
"就业开放时间":i.employment_open_date,
"offer下发时间":i.offer_date,
"created_date": i.created_date,
"updated_date": i.updated_date,
"is_deleted":i.is_deleted } for i,compname,somewhere in r ] #返回信息列表
"就业开放时间":i.employment_open_time,
"offer下发时间":i.offer_recived_time,
"created_date": i.create_time,
"updated_date": i.update_time,
"is_deleted":i.is_deleted } for i,employment_company,somewhere in r ] #返回信息列表
def delete_emp_dao(id,db): #删除函数