|
|
|
@ -40,29 +40,20 @@ def teacher(request):
|
|
|
|
|
dept = request.GET.get('dept')
|
|
|
|
|
data = []
|
|
|
|
|
if name:
|
|
|
|
|
filtered = Teacher.objects.filter(name=name)
|
|
|
|
|
for teacher_x in filtered:
|
|
|
|
|
data.append(teacher_x.to_dict())
|
|
|
|
|
data.append(Teacher.objects.filter(name=name))
|
|
|
|
|
elif sex:
|
|
|
|
|
filtered = Teacher.objects.filter(sex=sex)
|
|
|
|
|
for teacher_x in filtered:
|
|
|
|
|
data.append(teacher_x.to_dict())
|
|
|
|
|
data.append(Teacher.objects.filter(sex=sex))
|
|
|
|
|
elif title:
|
|
|
|
|
filtered = Teacher.objects.filter(title=title)
|
|
|
|
|
for teacher_x in filtered:
|
|
|
|
|
data.append(teacher_x.to_dict())
|
|
|
|
|
data.append(Teacher.objects.filter(title=title))
|
|
|
|
|
elif education:
|
|
|
|
|
filtered = Teacher.objects.filter(education=education)
|
|
|
|
|
for teacher_x in filtered:
|
|
|
|
|
data.append(teacher_x.to_dict())
|
|
|
|
|
data.append(Teacher.objects.filter(education=education))
|
|
|
|
|
elif dept:
|
|
|
|
|
filtered = Teacher.objects.filter(dept=dept)
|
|
|
|
|
for teacher_x in filtered:
|
|
|
|
|
data.append(teacher_x.to_dict())
|
|
|
|
|
data.append(Teacher.objects.filter(dept=dept))
|
|
|
|
|
else:
|
|
|
|
|
all_objects = Teacher.objects.all()
|
|
|
|
|
for teacher_x in all_objects:
|
|
|
|
|
data.append(teacher_x.to_dict())
|
|
|
|
|
data.append(Teacher.objects.all())
|
|
|
|
|
data_x = []
|
|
|
|
|
for teacher_x in data[0]:
|
|
|
|
|
data_x.append(teacher_x.to_dict())
|
|
|
|
|
response = ResponseUtil.ok(data, "老师信息查询成功")
|
|
|
|
|
return JsonResponse(response)
|
|
|
|
|
|
|
|
|
@ -90,16 +81,11 @@ def teacher(request):
|
|
|
|
|
title = put[0]['title']
|
|
|
|
|
education = put[0]['education']
|
|
|
|
|
dept = put[0]['dept']
|
|
|
|
|
Teacher.objects.filter(tid=tid).update(name=name)
|
|
|
|
|
Teacher.objects.filter(tid=tid).update(sex=sex)
|
|
|
|
|
Teacher.objects.filter(tid=tid).update(title=title)
|
|
|
|
|
Teacher.objects.filter(tid=tid).update(education=education)
|
|
|
|
|
Teacher.objects.filter(tid=tid).update(dept=dept)
|
|
|
|
|
Teacher.objects.filter(tid=tid).update(name=name,sex=sex,title=title)
|
|
|
|
|
Teacher.objects.filter(tid=tid).update(education=education,dept=dept)
|
|
|
|
|
data = Teacher.objects.filter(tid=tid)[0].to_dict()
|
|
|
|
|
return JsonResponse({'code': 200, 'msg': 'success','data':data}, safe=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def delete(request):
|
|
|
|
|
tid = request.GET.get('tid')
|
|
|
|
|
try:
|
|
|
|
@ -110,7 +96,77 @@ def delete(request):
|
|
|
|
|
|
|
|
|
|
@csrf_exempt
|
|
|
|
|
def teaching_resources(request):
|
|
|
|
|
pass
|
|
|
|
|
if request.method == 'POST':
|
|
|
|
|
cid = request.POST.get('cid')
|
|
|
|
|
name = request.POST.get('name')
|
|
|
|
|
type = request.POST.get('type')
|
|
|
|
|
credit = request.POST.get('credit')
|
|
|
|
|
tid = request.POST.get('tid')
|
|
|
|
|
t_name = request.POST.get('t_name')
|
|
|
|
|
# 定义空查询条件
|
|
|
|
|
conditions = Q()
|
|
|
|
|
t_conditions = Q()
|
|
|
|
|
if cid:
|
|
|
|
|
conditions &= Q(cid=cid)
|
|
|
|
|
if name:
|
|
|
|
|
conditions &= Q(name=name)
|
|
|
|
|
if type:
|
|
|
|
|
conditions &= Q(type=type)
|
|
|
|
|
if credit:
|
|
|
|
|
conditions &= Q(credit=credit)
|
|
|
|
|
if tid:
|
|
|
|
|
t_conditions &= Q(tid=tid)
|
|
|
|
|
if t_name:
|
|
|
|
|
t_conditions &= Q(t_name=t_name)
|
|
|
|
|
# 添加非空查询条件至基本查询集
|
|
|
|
|
query1 = Course.objects.filter(conditions)
|
|
|
|
|
query2 = Teacher.objects.filter(t_conditions)
|
|
|
|
|
combined_data = []
|
|
|
|
|
for item in query2:
|
|
|
|
|
matching_items = query1.filter(tid=item.tid).values()
|
|
|
|
|
combined_data.extend(matching_items)
|
|
|
|
|
print(combined_data)
|
|
|
|
|
response = ResponseUtil.ok("课程信息查询成功")
|
|
|
|
|
return JsonResponse(response)
|
|
|
|
|
elif request.method == "GET":
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
@csrf_exempt
|
|
|
|
|
def query_student_information(request):
|
|
|
|
|
if request.method == 'POST':
|
|
|
|
|
name = request.POST.get('name')
|
|
|
|
|
sid = request.POST.get('sid')
|
|
|
|
|
sex = request.POST.get('sex')
|
|
|
|
|
grade = request.POST.get('grade')
|
|
|
|
|
class_name = request.POST.get('class_name')
|
|
|
|
|
major = request.POST.get('major')
|
|
|
|
|
# 定义空查询条件
|
|
|
|
|
conditions = Q()
|
|
|
|
|
if name:
|
|
|
|
|
conditions &= Q(name=name)
|
|
|
|
|
if sid:
|
|
|
|
|
conditions &= Q(sid=sid)
|
|
|
|
|
if sex:
|
|
|
|
|
conditions &= Q(sex=sex)
|
|
|
|
|
if grade:
|
|
|
|
|
conditions &= Q(grade=grade)
|
|
|
|
|
if class_name:
|
|
|
|
|
conditions &= Q(class_name=class_name)
|
|
|
|
|
if major:
|
|
|
|
|
conditions &= Q(major=major)
|
|
|
|
|
# 添加非空查询条件至基本查询集
|
|
|
|
|
query = Student.objects.filter(conditions)
|
|
|
|
|
data = query.values() # 将 QuerySet 对象转换为字典列表
|
|
|
|
|
data = list(data) # 转换为列表以便序列化为 JSON
|
|
|
|
|
print(query)
|
|
|
|
|
response = ResponseUtil.ok(data, "学生信息查询成功")
|
|
|
|
|
return JsonResponse(response)
|
|
|
|
|
elif request.method == "GET":
|
|
|
|
|
query = Student.objects.all()
|
|
|
|
|
data = query.values() # 将 QuerySet 对象转换为字典列表
|
|
|
|
|
data = list(data) # 转换为列表以便序列化为 JSON
|
|
|
|
|
response = ResponseUtil.ok(data, "学生信息查询成功")
|
|
|
|
|
return JsonResponse(response)
|
|
|
|
|
@csrf_exempt
|
|
|
|
|
def student_performance_management(request): # 学生成绩管理
|
|
|
|
|
if request.method == "POST": # 学生成绩录入
|
|
|
|
|