From f05d617dca1ed990396f864c936010b236afef30 Mon Sep 17 00:00:00 2001 From: jisyoona <664501563@qq.com> Date: Thu, 7 Sep 2023 10:54:46 +0800 Subject: [PATCH 1/5] update models --- EduSystemServer/API/views.py | 4 +++- EduSystemServer/EduSystemServer/urls.py | 2 +- EduSystemServer/Student/models.py | 16 ++++++++-------- EduSystemServer/Student/urls.py | 3 ++- EduSystemServer/Student/views.py | 25 +++++++++++++++---------- 5 files changed, 29 insertions(+), 21 deletions(-) diff --git a/EduSystemServer/API/views.py b/EduSystemServer/API/views.py index 0d36511..8bda5b8 100644 --- a/EduSystemServer/API/views.py +++ b/EduSystemServer/API/views.py @@ -1,7 +1,9 @@ from django.shortcuts import render from django.http import JsonResponse + + # Create your views here. def student(request): - return JsonResponse({"sid": 1, "sname":"张三"}) + return JsonResponse({"sid": 1, "sname": "张三"}) diff --git a/EduSystemServer/EduSystemServer/urls.py b/EduSystemServer/EduSystemServer/urls.py index 2b2d6da..ef87b34 100644 --- a/EduSystemServer/EduSystemServer/urls.py +++ b/EduSystemServer/EduSystemServer/urls.py @@ -20,5 +20,5 @@ from django.urls import path, include urlpatterns = [ path('Eduadmin/', admin.site.urls), path('api/', include(("API.urls", "api"), namespace="api")), - path('student/', include(("Student.urls", "studnet"), namespace="student")), + path('student/', include(("Student.urls", "student"), namespace="student")), ] diff --git a/EduSystemServer/Student/models.py b/EduSystemServer/Student/models.py index 48c8358..daa5a52 100644 --- a/EduSystemServer/Student/models.py +++ b/EduSystemServer/Student/models.py @@ -4,17 +4,17 @@ from django.db import models # Create your models here. class Student(models.Model): sid = models.AutoField(primary_key=True, verbose_name="学生编号", name="sid") - username = models.CharField(max_length=30, verbose_name="用户名称", name="s_username", blank=True) - password = models.CharField(max_length=100, verbose_name="密码", name="s_password", blank=True) + s_username = models.CharField(max_length=30, verbose_name="用户名称", name="s_username", blank=True) + s_password = models.CharField(max_length=100, verbose_name="密码", name="s_password", blank=True) s_name = models.CharField(max_length=100, verbose_name="姓名", name="s_name", blank=True) - sex = models.CharField(max_length=4, verbose_name="性别", name="s_sex", blank=True) - grade = models.CharField(max_length=20, verbose_name="年级", name="s_grade", blank=True) - class_name = models.CharField(max_length=50, verbose_name="班级", name="s_class_name", blank=True) - major = models.CharField(max_length=50, verbose_name="专业名称", name="s_major", blank=True) + s_sex = models.CharField(max_length=4, verbose_name="性别", name="s_sex", blank=True) + s_grade = models.CharField(max_length=20, verbose_name="年级", name="s_grade", blank=True) + s_class_name = models.CharField(max_length=50, verbose_name="班级", name="s_class_name", blank=True) + s_major = models.CharField(max_length=50, verbose_name="专业名称", name="s_major", blank=True) def to_dict(self): - return {"sid": self.sid, "s_name": self.s_name, "username": self.username, "password": self.password, - "s_sex": self.sex, "s_grade": self.grade, "class_name": self.class_name, "major": self.major} + return {"sid": self.sid, "s_name": self.s_name, "s_username": self.s_username, "s_password": self.s_password, + "s_sex": self.s_sex, "s_grade": self.s_grade, "s_class_name": self.s_class_name, "s_major": self.s_major} class Meta: db_table = "student" diff --git a/EduSystemServer/Student/urls.py b/EduSystemServer/Student/urls.py index 78f4a6b..bbefd5c 100644 --- a/EduSystemServer/Student/urls.py +++ b/EduSystemServer/Student/urls.py @@ -3,5 +3,6 @@ from django.urls import path from Student.views import * urlpatterns = [ - path("", studnets) + path("", studnets), + path("delete", delete_student) ] \ No newline at end of file diff --git a/EduSystemServer/Student/views.py b/EduSystemServer/Student/views.py index d33cf19..fae5fc7 100644 --- a/EduSystemServer/Student/views.py +++ b/EduSystemServer/Student/views.py @@ -4,21 +4,27 @@ from django.shortcuts import render from django.http import JsonResponse from Student.models import Student from django.views.decorators.csrf import csrf_exempt +from django.http import QueryDict + + +def delete_student(request): + sid = request.GET.get("sid") + info = Student.objects.filter(sid=sid).delete() + response = {"code": 200, "message": "删除成功!", "data": info} + return JsonResponse(response) + @csrf_exempt def studnets(request): if request.method == "POST": student = Student() - student.username = request.POST.get("username") - student.password = request.POST.get("password") + student.s_username = request.POST.get("s_username") + student.s_password = request.POST.get("s_password") student.s_name = request.POST.get("s_name") - student.sex = request.POST.get("sex") - student.grade = int(request.POST.get("grade")) - print(student.grade) - student.class_name = request.POST.get("class_name") - student.major = request.POST.get("major") - student.sid = request.POST.get("sid") - print(student.to_dict()) + student.s_sex = request.POST.get("s_sex") + student.s_grade = request.POST.get("s_grade") + student.s_class_name = request.POST.get("s_class_name") + student.s_major = request.POST.get("s_major") student.save() response = {"code": 200, "message": "添加成功!", "data": student.to_dict()} return JsonResponse(response) @@ -29,4 +35,3 @@ def studnets(request): response_json["data"].append(student.to_dict()) return JsonResponse(response_json) - From b022a48923063c91b17785358ff49030eeba2c83 Mon Sep 17 00:00:00 2001 From: jisyoona <664501563@qq.com> Date: Thu, 7 Sep 2023 14:53:32 +0800 Subject: [PATCH 2/5] update student view --- EduSystemServer/Student/urls.py | 1 - EduSystemServer/Student/views.py | 88 +++++++++++++++++++++++++------- 2 files changed, 70 insertions(+), 19 deletions(-) diff --git a/EduSystemServer/Student/urls.py b/EduSystemServer/Student/urls.py index bbefd5c..594bc98 100644 --- a/EduSystemServer/Student/urls.py +++ b/EduSystemServer/Student/urls.py @@ -4,5 +4,4 @@ from Student.views import * urlpatterns = [ path("", studnets), - path("delete", delete_student) ] \ No newline at end of file diff --git a/EduSystemServer/Student/views.py b/EduSystemServer/Student/views.py index fae5fc7..f4d5456 100644 --- a/EduSystemServer/Student/views.py +++ b/EduSystemServer/Student/views.py @@ -4,14 +4,8 @@ from django.shortcuts import render from django.http import JsonResponse from Student.models import Student from django.views.decorators.csrf import csrf_exempt -from django.http import QueryDict - - -def delete_student(request): - sid = request.GET.get("sid") - info = Student.objects.filter(sid=sid).delete() - response = {"code": 200, "message": "删除成功!", "data": info} - return JsonResponse(response) +from io import BytesIO +from django.http.multipartparser import MultiPartParser @csrf_exempt @@ -20,18 +14,76 @@ def studnets(request): student = Student() student.s_username = request.POST.get("s_username") student.s_password = request.POST.get("s_password") - student.s_name = request.POST.get("s_name") - student.s_sex = request.POST.get("s_sex") - student.s_grade = request.POST.get("s_grade") - student.s_class_name = request.POST.get("s_class_name") - student.s_major = request.POST.get("s_major") + student.s_name = request.POST.get("s_name") or '' + student.s_sex = request.POST.get("s_sex") or '' + student.s_grade = request.POST.get("s_grade") or '' + student.s_class_name = request.POST.get("s_class_name") or '' + student.s_major = request.POST.get("s_major") or '' student.save() response = {"code": 200, "message": "添加成功!", "data": student.to_dict()} return JsonResponse(response) elif request.method == "GET": - student_list = Student.objects.all() - response_json = {"code": 200, "message": "success", "data": []} - for student in student_list: - response_json["data"].append(student.to_dict()) - return JsonResponse(response_json) + sid = request.GET.get('sid') + s_name = request.GET.get('s_name') + s_sex = request.GET.get('s_sex') + s_grade = request.GET.get('s_grade') + s_class_name = request.GET.get('s_class_name') + s_major = request.GET.get('s_major') + data = [] + if sid: + filtered = Student.objects.filter(sid=sid) + for student in filtered: + data.append(student.to_dict()) + elif s_name: + filtered = Student.objects.filter(s_name=s_name) + for student in filtered: + data.append(student.to_dict()) + elif s_sex: + filtered = Student.objects.filter(s_sex=s_sex) + for student in filtered: + data.append(student.to_dict()) + elif s_grade: + filtered = Student.objects.filter(s_grade=s_grade) + for student in filtered: + data.append(student.to_dict()) + elif s_class_name: + filtered = Student.objects.filter(s_class_name=s_class_name) + for student in filtered: + data.append(student.to_dict()) + elif s_major: + filtered = Student.objects.filter(s_major=s_major) + for student in filtered: + data.append(student.to_dict()) + else: + all_objects = Student.objects.all() + for studnet in all_objects: + data.append(studnet.to_dict()) + return JsonResponse({'code': 200, 'msg': 'success', 'data': data}, safe=False) + elif request.method == "DELETE": + parser = MultiPartParser(request.META, BytesIO(request.body), request.upload_handlers, request.encoding) + post_dict = parser.parse() + sid = post_dict[0]['sid'] + try: + info = Student.objects.filter(sid=sid).get().to_dict() + Student.objects.filter(sid=sid).delete() + response = {"code": 200, "message": "删除成功!", "data": info} + return JsonResponse(response) + except: + response = {"code": 200, "message": "删除失败,未找到学生信息!"} + return JsonResponse(response) + elif request.method == "PUT": + put = MultiPartParser(request.META, request, request.upload_handlers, request.encoding).parse() + sid = put[0]['sid'] + s_name = put[0]['s_name'] + s_sex = put[0]['s_sex'] + s_grade = put[0]['s_grade'] + s_class_name = put[0]['s_class_name'] + s_major = put[0]['s_major'] + Student.objects.filter(sid=sid).update(s_name=s_name) + Student.objects.filter(sid=sid).update(s_sex=s_sex) + Student.objects.filter(sid=sid).update(s_grade=s_grade) + Student.objects.filter(sid=sid).update(s_class_name=s_class_name) + Student.objects.filter(sid=sid).update(s_major=s_major) + data = Student.objects.filter(sid=sid)[0].to_dict() + return JsonResponse({'code': 200, 'msg': 'success', 'data': data}, safe=False) From 61123816d428f64e92e8338bb6387c271b61e43b Mon Sep 17 00:00:00 2001 From: jisyoona <664501563@qq.com> Date: Thu, 7 Sep 2023 16:52:18 +0800 Subject: [PATCH 3/5] update student view --- EduSystemServer/EduSystemServer/urls.py | 1 + EduSystemServer/Student/views.py | 15 +++--- EduSystemServer/course/models.py | 7 +++ EduSystemServer/course/urls.py | 7 +++ EduSystemServer/course/views.py | 66 +++++++++++++++++++++++++ 5 files changed, 90 insertions(+), 6 deletions(-) create mode 100644 EduSystemServer/course/urls.py diff --git a/EduSystemServer/EduSystemServer/urls.py b/EduSystemServer/EduSystemServer/urls.py index ef87b34..c881251 100644 --- a/EduSystemServer/EduSystemServer/urls.py +++ b/EduSystemServer/EduSystemServer/urls.py @@ -21,4 +21,5 @@ urlpatterns = [ path('Eduadmin/', admin.site.urls), path('api/', include(("API.urls", "api"), namespace="api")), path('student/', include(("Student.urls", "student"), namespace="student")), + path('course/', include(("course.urls", "course"), namespace="course")) ] diff --git a/EduSystemServer/Student/views.py b/EduSystemServer/Student/views.py index f4d5456..e177196 100644 --- a/EduSystemServer/Student/views.py +++ b/EduSystemServer/Student/views.py @@ -74,16 +74,19 @@ def studnets(request): elif request.method == "PUT": put = MultiPartParser(request.META, request, request.upload_handlers, request.encoding).parse() sid = put[0]['sid'] + s_username = put[0]['s_username'] s_name = put[0]['s_name'] s_sex = put[0]['s_sex'] s_grade = put[0]['s_grade'] s_class_name = put[0]['s_class_name'] s_major = put[0]['s_major'] - Student.objects.filter(sid=sid).update(s_name=s_name) - Student.objects.filter(sid=sid).update(s_sex=s_sex) - Student.objects.filter(sid=sid).update(s_grade=s_grade) - Student.objects.filter(sid=sid).update(s_class_name=s_class_name) - Student.objects.filter(sid=sid).update(s_major=s_major) + try: + Student.objects.filter(sid=sid).update(s_username=s_username, s_name=s_name, s_sex=s_sex, s_grade=s_grade, + s_class_name=s_class_name, + s_major=s_major) + except: + Student.objects.create(sid=sid, s_username=s_username, s_name=s_name, s_sex=s_sex, s_grade=s_grade, + s_class_name=s_class_name, + s_major=s_major) data = Student.objects.filter(sid=sid)[0].to_dict() return JsonResponse({'code': 200, 'msg': 'success', 'data': data}, safe=False) - diff --git a/EduSystemServer/course/models.py b/EduSystemServer/course/models.py index b2fda46..c9d7d8d 100644 --- a/EduSystemServer/course/models.py +++ b/EduSystemServer/course/models.py @@ -12,6 +12,10 @@ class Course(models.Model): credit = models.IntegerField(verbose_name="课程学分", name="credit") tid = models.ForeignKey(Teacher, to_field="tid", on_delete=models.CASCADE, name="tid") + def to_dict(self): + return {"cid": self.cid, "c_name": self.c_name, "type": self.type, "credit": self.credit, + "tid": self.tid} + class Meta: db_table = "course" verbose_name = "课程" @@ -24,6 +28,9 @@ class SC(models.Model): middle_grade = models.IntegerField(name="middle_grade") end_grade = models.IntegerField(name="end_grade") + def to_dict(self): + return {"sid": self.sid, "cid": self.cid, "middle_grade": self.middle_grade, "end_grade": self.end_grade} + class Meta: db_table = "sc" verbose_name = "管理员" diff --git a/EduSystemServer/course/urls.py b/EduSystemServer/course/urls.py new file mode 100644 index 0000000..74f5f91 --- /dev/null +++ b/EduSystemServer/course/urls.py @@ -0,0 +1,7 @@ +from django.urls import path + +from course.views import * + +urlpatterns = [ + path("", courses), +] \ No newline at end of file diff --git a/EduSystemServer/course/views.py b/EduSystemServer/course/views.py index 91ea44a..e72d5c1 100644 --- a/EduSystemServer/course/views.py +++ b/EduSystemServer/course/views.py @@ -1,3 +1,69 @@ from django.shortcuts import render # Create your views here. +from django.http import JsonResponse +from course.models import * +from django.views.decorators.csrf import csrf_exempt +from io import BytesIO +from django.http.multipartparser import MultiPartParser + + +@csrf_exempt +def courses(request): + if request.method == "POST": + course = Course() + course.c_name = request.POST.get("c_name") + course.type = request.POST.get('type') + course.credit = request.POST.get("credit") + course.tid = request.POST.get('tid') + course.save() + response = {"code": 200, "message": "添加成功!", "data": course.to_dict()} + return JsonResponse(response) + elif request.method == "GET": + cid = request.GET.get('cid') + c_name = request.GET.get('c_name') + c_type = request.GET.get('type') + tid = request.GET.get('tid') + data = [] + if cid: + filtered = Course.objects.filter(cid=cid) + for item in filtered: + data.append(item.to_dict()) + elif c_name: + filtered = Course.objects.filter(c_name=c_name) + for item in filtered: + data.append(item.to_dict()) + elif c_type: + filtered = Course.objects.filter(type=c_type) + for item in filtered: + data.append(item.to_dict()) + elif tid: + filtered = Course.objects.filter(tid=tid) + for item in filtered: + data.append(item.to_dict()) + else: + all_objects = Course.objects.all() + for item in all_objects: + data.append(item.to_dict()) + return JsonResponse({'code': 200, 'msg': 'success', 'data': data}, safe=False) + elif request.method == "DELETE": + delete = MultiPartParser(request.META, BytesIO(request.body), request.upload_handlers, request.encoding).parse() + cid = delete[0]['cid'] + try: + info = Course.objects.filter(cid=cid).get().to_dict() + Course.objects.filter(cid=cid).delete() + response = {"code": 200, "message": "删除成功!", "data": info} + return JsonResponse(response) + except: + response = {"code": 200, "message": "删除失败,未找到课程信息!"} + return JsonResponse(response) + elif request.method == "PUT": + put = MultiPartParser(request.META, request, request.upload_handlers, request.encoding).parse() + cid = put[0]['cid'] + c_name = put[0]['c_name'] + c_type = put[0]['type'] + credit = put[0]['credit'] + tid = put[0]['tid'] + Course.objects.filter(cid=cid).update(c_name=c_name, type=c_type, credit=credit, tid=tid) + data = Course.objects.filter(cid=cid)[0].to_dict() + return JsonResponse({'code': 200, 'msg': 'success', 'data': data}, safe=False) From e6551c7ddb372eb3402ff6db00f4d142d8eb9a38 Mon Sep 17 00:00:00 2001 From: bettleChen <2207153529@qq.com> Date: Thu, 7 Sep 2023 16:59:36 +0800 Subject: [PATCH 4/5] add login middle .... function --- EduSystemServer/.idea/EduSystemServer.iml | 2 +- EduSystemServer/.idea/misc.xml | 2 +- .../API/__pycache__/apps.cpython-37.pyc | Bin 0 -> 370 bytes .../API/__pycache__/middle.cpython-37.pyc | Bin 0 -> 908 bytes .../API/__pycache__/urls.cpython-37.pyc | Bin 930 -> 893 bytes .../API/__pycache__/views.cpython-37.pyc | Bin 398 -> 1500 bytes EduSystemServer/API/middle.py | 23 +++++++++ EduSystemServer/API/urls.py | 3 +- EduSystemServer/API/views.py | 48 +++++++++++++++++- .../__pycache__/settings.cpython-37.pyc | Bin 2434 -> 2611 bytes .../__pycache__/urls.cpython-37.pyc | Bin 1060 -> 1195 bytes .../__pycache__/utils.cpython-37.pyc | Bin 0 -> 663 bytes EduSystemServer/EduSystemServer/settings.py | 13 ++++- EduSystemServer/EduSystemServer/urls.py | 5 +- EduSystemServer/EduSystemServer/utils.py | 10 ++++ .../Eduadmin/__pycache__/apps.cpython-37.pyc | Bin 0 -> 382 bytes .../__pycache__/models.cpython-37.pyc | Bin 741 -> 757 bytes .../Eduadmin/migrations/0001_initial.py | 6 +-- .../__pycache__/0001_initial.cpython-37.pyc | Bin 0 -> 773 bytes .../__pycache__/__init__.cpython-37.pyc | Bin 0 -> 176 bytes .../Student/__pycache__/apps.cpython-37.pyc | Bin 0 -> 382 bytes .../Student/__pycache__/models.cpython-37.pyc | Bin 445 -> 1280 bytes .../Student/__pycache__/urls.cpython-37.pyc | Bin 0 -> 318 bytes .../Student/__pycache__/views.cpython-37.pyc | Bin 0 -> 1144 bytes .../Student/migrations/0001_initial.py | 18 +++---- .../__pycache__/0001_initial.cpython-37.pyc | Bin 0 -> 1034 bytes .../__pycache__/__init__.cpython-37.pyc | Bin 0 -> 175 bytes EduSystemServer/Student/models.py | 18 +++---- EduSystemServer/Student/urls.py | 1 + EduSystemServer/Student/views.py | 17 +++++++ .../course/__pycache__/apps.cpython-37.pyc | Bin 0 -> 379 bytes .../course/__pycache__/models.cpython-37.pyc | Bin 1541 -> 1578 bytes .../course/__pycache__/views.cpython-37.pyc | Bin 0 -> 207 bytes .../course/migrations/0001_initial.py | 8 +-- .../__pycache__/0001_initial.cpython-37.pyc | Bin 0 -> 1405 bytes .../__pycache__/__init__.cpython-37.pyc | Bin 0 -> 174 bytes EduSystemServer/course/models.py | 4 +- .../teacher/__pycache__/apps.cpython-37.pyc | Bin 0 -> 382 bytes .../teacher/__pycache__/models.cpython-37.pyc | Bin 445 -> 1167 bytes .../teacher/migrations/0001_initial.py | 12 ++--- .../__pycache__/0001_initial.cpython-37.pyc | Bin 0 -> 959 bytes .../__pycache__/__init__.cpython-37.pyc | Bin 0 -> 175 bytes EduSystemServer/teacher/models.py | 14 +++-- 43 files changed, 158 insertions(+), 46 deletions(-) create mode 100644 EduSystemServer/API/__pycache__/apps.cpython-37.pyc create mode 100644 EduSystemServer/API/__pycache__/middle.cpython-37.pyc create mode 100644 EduSystemServer/API/middle.py create mode 100644 EduSystemServer/EduSystemServer/__pycache__/utils.cpython-37.pyc create mode 100644 EduSystemServer/EduSystemServer/utils.py create mode 100644 EduSystemServer/Eduadmin/__pycache__/apps.cpython-37.pyc create mode 100644 EduSystemServer/Eduadmin/migrations/__pycache__/0001_initial.cpython-37.pyc create mode 100644 EduSystemServer/Eduadmin/migrations/__pycache__/__init__.cpython-37.pyc create mode 100644 EduSystemServer/Student/__pycache__/apps.cpython-37.pyc create mode 100644 EduSystemServer/Student/__pycache__/urls.cpython-37.pyc create mode 100644 EduSystemServer/Student/__pycache__/views.cpython-37.pyc create mode 100644 EduSystemServer/Student/migrations/__pycache__/0001_initial.cpython-37.pyc create mode 100644 EduSystemServer/Student/migrations/__pycache__/__init__.cpython-37.pyc create mode 100644 EduSystemServer/course/__pycache__/apps.cpython-37.pyc create mode 100644 EduSystemServer/course/__pycache__/views.cpython-37.pyc create mode 100644 EduSystemServer/course/migrations/__pycache__/0001_initial.cpython-37.pyc create mode 100644 EduSystemServer/course/migrations/__pycache__/__init__.cpython-37.pyc create mode 100644 EduSystemServer/teacher/__pycache__/apps.cpython-37.pyc create mode 100644 EduSystemServer/teacher/migrations/__pycache__/0001_initial.cpython-37.pyc create mode 100644 EduSystemServer/teacher/migrations/__pycache__/__init__.cpython-37.pyc diff --git a/EduSystemServer/.idea/EduSystemServer.iml b/EduSystemServer/.idea/EduSystemServer.iml index 258a1c1..02a9ee7 100644 --- a/EduSystemServer/.idea/EduSystemServer.iml +++ b/EduSystemServer/.idea/EduSystemServer.iml @@ -14,7 +14,7 @@ - + diff --git a/EduSystemServer/.idea/misc.xml b/EduSystemServer/.idea/misc.xml index d56657a..fea17c1 100644 --- a/EduSystemServer/.idea/misc.xml +++ b/EduSystemServer/.idea/misc.xml @@ -1,4 +1,4 @@ - + \ No newline at end of file diff --git a/EduSystemServer/API/__pycache__/apps.cpython-37.pyc b/EduSystemServer/API/__pycache__/apps.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8bb8f3ebe78f0851ae8341a6e94f8d31621b3f02 GIT binary patch literal 370 zcmZ?b<>g`k0+nyyQo?}rV-N=hSbz)%ATCw_5-AKRj5!Rsj8Tk?4DJjmOexGQ3@Oa1 zjLpnZOerkE44SMjfvOlZ8EqM|^xw-~f`bvv_XE0#L;#jzk|);VFm!WqF(j@ literal 0 HcmV?d00001 diff --git a/EduSystemServer/API/__pycache__/middle.cpython-37.pyc b/EduSystemServer/API/__pycache__/middle.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..48cff8c6e86b2931b996bf9950d932af8ccd2324 GIT binary patch literal 908 zcmZuw&1(}u6rb7IY}T|@DFrVg_26MI^)4b-D}I1Q40s5^Vabf?*3E7@GpnR*57Od6 z6k4Q6L9qcnD5wXE2*H13t~QPN13Y-rH?xhl;DdSdX5PoX-|x*{nwY2{kh{?@w&5W3 z-5f?jz_=yN<}kO4g3=ITP=NLL4VfmlxooG2uX zJ=%Mf#+J0v{Ve$IiKJ6G?&+37!jTi@H<>ObiYK6VG|j|ZQ7gWl`<6_!;yQt{S5 ztIEX#F6y(luGd?({h4-0`;9 zMv3+_$wd;jxOP>i&4<51mMclBrmg?9A*zuwu1QNaqYZ55?nxD@Oa>+GwnMdGNz`S@ zrHs-<6Chd`&_PKUOu8)iQpTkc$IQte%|IN7qh-EOW$UH15ymm4V{np_pb+-3Pb%1T zJUoRbapiwh7CG~QXSg?TDAg58TPe$8V~o8L=|z}- v!VE+jr%zmH!`{sYM31q>FlnYU3re*uSnD}Z!4@naoiEzB0OS>~VVwK{x3BM` literal 0 HcmV?d00001 diff --git a/EduSystemServer/API/__pycache__/urls.cpython-37.pyc b/EduSystemServer/API/__pycache__/urls.cpython-37.pyc index fde68bccf12a49fa1be01b922fc5372b90bacedf..d0e5e431f9642de60e2a97c43be0f229b43d5468 100644 GIT binary patch delta 146 zcmZ3){+G?iiIp gdGRgol&r+O^nAV2qMYI)W}wNFHJM9UI2d`D06}mdw*UYD delta 183 zcmey%wun8-iIEHkydSd;MWF_XM=j)XgeCI3ln|f2fp^d}6N6sQxl6}@Nd9Pv95TbTCy-YZ>$OYu{ zfQR2W``+!}cn3MlAOqf9Fnu}8R9T`GHWCsQIYu?MNok_W_>MRpVo$ot_ zWfg}v3Q)&8;^{xI=4X#0uUB&YDE7LLvXbXbpxc4WV?1kR?e`3u!Z3}OS7WXWyIJu) zx53PR(p7eWi4YqWR zPsim>HBh^i)LE^Sbii!lm3dd|na#+YTUpxCbCFeYtShMo_+yedytKEX^Pqt5CRb^1 z^*O9`TW@;$m{~2K1~vS#lD78zcKxOFbB;OD9^`w;81^n%?@&io6U CuYsrl delta 274 zcmcb^-Nzj2#LLUY00c?jzoqN|(vLwL7+?Z29Dul31xTbYq%h_%8Hs$nU7V|0L&?32Z|sO96;_Z4x8Nkl+v73 PJCN1IAm{Ng@~{8^8^|*K diff --git a/EduSystemServer/API/middle.py b/EduSystemServer/API/middle.py new file mode 100644 index 0000000..30bc1b0 --- /dev/null +++ b/EduSystemServer/API/middle.py @@ -0,0 +1,23 @@ +from django.http import JsonResponse + + +class AuthMiddleware: + """ + 验证权限登录中间件 + """ + def __init__(self, get_response): + self.get_response = get_response + + def __call__(self, request): + path = request.path + if path in [ + "/login", + ]: + response = self.get_response(request) + return response + + session = request.session + if not session.get("username") and not session.get("type"): + return JsonResponse({"code": -1, "msg": "not login!"}, status=401) + response = self.get_response(request) + return response diff --git a/EduSystemServer/API/urls.py b/EduSystemServer/API/urls.py index 076f242..1dc6728 100644 --- a/EduSystemServer/API/urls.py +++ b/EduSystemServer/API/urls.py @@ -13,9 +13,8 @@ Including another URLconf 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ -from API import views +from API.views import * from django.urls import path urlpatterns = [ - path("students/", views.student) ] diff --git a/EduSystemServer/API/views.py b/EduSystemServer/API/views.py index 8bda5b8..e00b419 100644 --- a/EduSystemServer/API/views.py +++ b/EduSystemServer/API/views.py @@ -1,9 +1,53 @@ +import json + from django.shortcuts import render from django.http import JsonResponse # Create your views here. +from django.views.decorators.csrf import csrf_exempt +from Student.models import * +from teacher.models import Teacher +from EduSystemServer.utils import ResponseUtil -def student(request): - return JsonResponse({"sid": 1, "sname": "张三"}) +@csrf_exempt +def login(request): + username = json.loads(request.body).get("username") + password = json.loads(request.body).get("password") + _type = json.loads(request.body).get("type") + if _type == "student": + student = Student.objects.filter(username=username, + password=password).first() + if student: + request.session["username"] = student.username + request.session["type"] = "student" + result = {"code": 0, "message": "login success!"} + else: + result = {"code": -1, "message": "username or password error!"} + elif _type == "teacher": + teacher = Teacher.objects.filter(username=username, + password=password).first() + if teacher: + request.session["username"] = teacher.username + request.session["type"] = "teacher" + result = {"code": 0, "message": "login success!"} + else: + result = ResponseUtil.error("username or password error!") + else: + result = ResponseUtil.error("type error!") + return JsonResponse(result) +@csrf_exempt +def get_user_info(request): + _type = request.GET.get("type") + username = request.GET.get("username") + if _type == "student": + student = Student.objects.filter(username=username).first() + result = ResponseUtil.ok(student.to_dict()) + elif _type == "teacher": + teacher = Teacher.objects.filter(username=username).first() + result = ResponseUtil.ok(teacher.to_dict()) + else: + result = ResponseUtil.error("type error") + request.session.clear() + return JsonResponse(result) diff --git a/EduSystemServer/EduSystemServer/__pycache__/settings.cpython-37.pyc b/EduSystemServer/EduSystemServer/__pycache__/settings.cpython-37.pyc index 8ea2b0a7dd10bad8eb8bbfcd91f22bfba018cb46..b8e0d6c45cb1f9c522220ce9659b8579c185b8ad 100644 GIT binary patch delta 519 zcmZvZO=}ZT6o%*Cx$~7|(llR9O|{>xtu~p~Dy6H&7<3>ckOT^6GlaauBoaH4Nh!D~ zxK=mWNf&kR%KQ%hK)3oQ+<8+JyYRf6hkM@ha=CEdXQtW9=e8YFWF36?h3`p4`7s;* zRze<5WJf!!=1uWtoih)TsmMDq)fdUN=u#6R~Vl5B@hV?5UFPy^$rLc)D zY~vwzu!~1{e5DT<&0`NGncGA8md-8r2P_bj#sOvUgtGEsxwJ$chqQpFQ~+-)JI}tc z3M=LMsjYrw#m#?4 zRC+T2hW@9X!=Q{)av4m;duyqo_E8;h>F!_tL;_l_2#M9Y`HJphIjhP?bPaS zyF>Xq%WA9kqSolRm3n*n)i`5?Gx|1{|5iUeMSHP delta 356 zcmYk2IZgvX5JjiD+dZ4d9(%m7n8ju_`*H!`1V|>TWCFf58ia7*0~nDKPKF%78Ri^h zBsfDHf)LskNc^w=R3(*4rOIm$(dZ%wJj>|y;|rI8WqnSYKl!FOGa0@az+wvoaZ5~n zx)IOvA638bLQ}JbWE+Yd6cS<=8a5ob@Zh6}040gg?x&O}4spO0 z9CFnh6`9m<#C05V1EOb%?nxffIc4|al&-Q|JmoAODK8e3EHx)~9Aj`D#}hFa<~`?* hLYPk|;mDS)q!Lz6PV8h|k-eRE}n*bk->D6#ifaO@WOS zbC@JFnQpP>)?@(|88%*^(jwl;Ml7j(AP2E9@-PZ8aWL~R0svll BA^-pY diff --git a/EduSystemServer/EduSystemServer/__pycache__/utils.cpython-37.pyc b/EduSystemServer/EduSystemServer/__pycache__/utils.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..284e6ad2214d4d7894f0073e9d90edaeae4c05cd GIT binary patch literal 663 zcmZuuy-EW?5Z>L(&m~+Cd;>ev=d)&bw=jSNNw$U-iOvXI9fMdPeWy%~13 zT#H(rk*#Cjms(Hx0^5*~r``*w+Cc++kMALabBj3ChWLcuWc(1M$p={MtxJ;uFY<0! zS*RT5RhCSCY@SyTEzUIiSNHvs>*nL>S^wyAaC*m2#h*z0^{ z936R4%MWC<5rQgUp`xFV-ZG`3#v5s3VspVAOYr2CW>faRGGotv&Yq)dJfX4=ZXBF{ literal 0 HcmV?d00001 diff --git a/EduSystemServer/EduSystemServer/settings.py b/EduSystemServer/EduSystemServer/settings.py index e8d1b6c..6bcb726 100644 --- a/EduSystemServer/EduSystemServer/settings.py +++ b/EduSystemServer/EduSystemServer/settings.py @@ -12,6 +12,14 @@ https://docs.djangoproject.com/en/2.2/ref/settings/ import os +CORS_ALLOW_ORIGIN_WHITELIST = [ + "http://localhost:8080", # 允许访问的来源 + "http://localhost:8000", # 允许访问的来源 + # 可以继续添加其他允许的来源 +] + +CORS_ALLOW_CREDENTIALS = True # 允许跨域请求携带凭据(例如Cookies) + # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) @@ -29,7 +37,6 @@ ALLOWED_HOSTS = ["*"] # Application definition - INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', @@ -37,6 +44,7 @@ INSTALLED_APPS = [ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + 'corsheaders', 'API', 'Student', 'teacher', @@ -52,8 +60,11 @@ MIDDLEWARE = [ 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', + 'corsheaders.middleware.CorsMiddleware', + # 'API.middle.AuthMiddleware', ] + ROOT_URLCONF = 'EduSystemServer.urls' TEMPLATES = [ diff --git a/EduSystemServer/EduSystemServer/urls.py b/EduSystemServer/EduSystemServer/urls.py index c881251..6d69d65 100644 --- a/EduSystemServer/EduSystemServer/urls.py +++ b/EduSystemServer/EduSystemServer/urls.py @@ -15,11 +15,14 @@ Including another URLconf """ from django.contrib import admin from django.urls import path, include +from API.views import login, get_user_info urlpatterns = [ path('Eduadmin/', admin.site.urls), path('api/', include(("API.urls", "api"), namespace="api")), path('student/', include(("Student.urls", "student"), namespace="student")), - path('course/', include(("course.urls", "course"), namespace="course")) + path('course/', include(("course.urls", "course"), namespace="course")), + path('login', login), + path('userinfo', get_user_info), ] diff --git a/EduSystemServer/EduSystemServer/utils.py b/EduSystemServer/EduSystemServer/utils.py new file mode 100644 index 0000000..eba0b59 --- /dev/null +++ b/EduSystemServer/EduSystemServer/utils.py @@ -0,0 +1,10 @@ + + +class ResponseUtil: + @staticmethod + def ok(data, message="success!"): + return {"code": 0, "message": message, "data": data} + + @staticmethod + def error(message="error!"): + return {"code": -1, "message": message} \ No newline at end of file diff --git a/EduSystemServer/Eduadmin/__pycache__/apps.cpython-37.pyc b/EduSystemServer/Eduadmin/__pycache__/apps.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..89af00e6976bd3cb320da7ce03916882ab0a7339 GIT binary patch literal 382 zcmZ?b<>g`kf^!eQr^Ev3#~=<2umBkjKwPWv=03(p$0K~-tKq8ePiZO)&sFN{@ zIfV(RoB0;EV@hsj9z^3U4%d{@L=fLkljRmie0*MFZfbn|Ew1?Z-29Z%91xo)KEALt zF$XHc0-{$k6mbF#2NPf2fh-rRn5Rp&Je|BW=GoMlPrDXAU$^l2gtq6KcR$}fKL%(; zaAk2xYA%8moLW?tS_I;QEsseoC@9t|s4QXzngt4tVkRKL!3gI2f!v&um6(^FuLn|B c1d;>GARGZM*AL+8+Vol0P%*&q4&!{5AQp5%{ricSXaDoV~ z$qtMY*n~h#p~=@6Q-wuR?8hW2#RFo3B#R)5;Vj|FjZDJKB8)2k^lhXhA6cF delta 200 zcmey$`jnN|iIB9IwH93X;oascB5HbD?maPl+8 zRAFHt(@&G5h!-Tp2O{_<$1zDtaf6s3$s&kiI7?{qL?&ToAx448%bC;!FeL9XNdN$? CawOXT diff --git a/EduSystemServer/Eduadmin/migrations/0001_initial.py b/EduSystemServer/Eduadmin/migrations/0001_initial.py index ba7ca6f..a3e8f54 100644 --- a/EduSystemServer/Eduadmin/migrations/0001_initial.py +++ b/EduSystemServer/Eduadmin/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 2.1 on 2023-09-06 14:02 +# Generated by Django 2.1 on 2023-09-07 13:49 from django.db import migrations, models @@ -14,8 +14,8 @@ class Migration(migrations.Migration): migrations.CreateModel( name='Admin', fields=[ - ('username', models.CharField(max_length=32, primary_key=True, serialize=False, verbose_name='管理员账号')), - ('password', models.CharField(max_length=128, verbose_name='管理员密码')), + ('username', models.CharField(blank=True, max_length=32, primary_key=True, serialize=False, verbose_name='管理员账号')), + ('password', models.CharField(blank=True, max_length=128, verbose_name='管理员密码')), ], options={ 'verbose_name': '管理员', diff --git a/EduSystemServer/Eduadmin/migrations/__pycache__/0001_initial.cpython-37.pyc b/EduSystemServer/Eduadmin/migrations/__pycache__/0001_initial.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..11aa473ffe2f4703c271653c41832e55b240308d GIT binary patch literal 773 zcmY*XON$dh5bo)oNoMkJBZwyjPr_W5comUdSJ%_-C3_kILuad#o$Nef_e6~+McsoC zR76k^bU_6#dT_zRp8Okql^FL2c<^TRBr#Y}MO9aK)%R8PwR*imP#(h{_)ZD=VSHxyRJtY-xtG!V*Z?QJbE>}Y2lk|@>gPzjmxM4Vi}zMI1pwA0Ur(`N^h=dXSp zeVjb~<~!Qy#5~FPj6374aAUyQVeMIs(Y_k^z97P6Bm5t^df9dM=Y zWD-v9W8wd+Pre*X-#ze|bTK78V`}D-@%};3?hP1n1J$QRTD#B*bKZ%C&$L}MDRm#(TV_#`nG@a5nBM_<*Dtpx?~f)gKD2+nd_8$`IAb#X zdOSUT+eR*}k;+A~^jbpV#7tbUY%jk_yV-1B3g;MC2P0|zUkOz;(74p5wryLKp0&;} pY8BaS-_{=VdD_cXp;Is^z!%9S(3y80t7!MiY&cg9M`frt*kAUb>Tm!6 literal 0 HcmV?d00001 diff --git a/EduSystemServer/Eduadmin/migrations/__pycache__/__init__.cpython-37.pyc b/EduSystemServer/Eduadmin/migrations/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f112daf9b3ab25c8abce7ae1d6a00499c99fe8e3 GIT binary patch literal 176 zcmZ?b<>g`kg12YCr-10kAOZ#$feZ&AE@lA|DGb33nv8xc8Hzx{2;yrPkn3U<^K{9U zr<0e)JexZ6Y1hK%>lQwr(Dr=u?&rJb$GE1H23HoBq~;=6!Kp=MsYM`uVoGjiUQBLg odQoCYW`16AOniK1US>&ryk0@&Ee@O9{FKt1R6CHBpMjVG0EXf?8UO$Q literal 0 HcmV?d00001 diff --git a/EduSystemServer/Student/__pycache__/apps.cpython-37.pyc b/EduSystemServer/Student/__pycache__/apps.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2e1ea02a0660b0bad894552caa05897c76d03b70 GIT binary patch literal 382 zcmZ?b<>g`kf;nfur^Es2#~=<2umBkjKwPWv=03(p$0K~-tKq8ePiZO)&sFN{@ zIfV(RoB0-Ra7k%OYF-IM>n(OD*H4q>7Ds%1USe))eEco0`1suXl+qj!nqY89y#ELcDO2+woX?UFyhgE!xsY-ojEoaOi1o!`#9{N}y4IbAH~8IG;$ANXN2 z_LC;vfpa#FkVlY!ff2I0;TZZK^}Ti#Z8q06jLRql|9f4 zeW{YyNi#w-4h+ zy*pWXyLIn#{BS8*T~}^PazXD)w#wIoIX~o$>FBDUgo!MYaw=iam}vuTCpG?fH+gYe zxwCJ=7KBFB{3%Rpm^J0C@XYS56+Rk({3j zF|4+&z5d!<{Vt;u;A@%r}DBo|n?a$4(hr;o>G=T$ap`cR#U$e|?b%;+-~deent z>Dzxgp0YEJko%Fk9S;V6ET(63+jGFeT-XbRZjehn3cRfB^jW80?_z}LAd!ira;I8R^L&+upsT2IXRZdKGvBTyweD^O6_gGgeuob#m>@I4 zLUIt2itl2Q2Xg`kfC z3!hJDd%k)1^WF1fTvJMeD~n4~a}liI)S|M~q8O+nVnFWFE2zB1VUwGmQks)$#|SjD Om<>qqFmW(*FaiK#Ut*d7 literal 0 HcmV?d00001 diff --git a/EduSystemServer/Student/__pycache__/views.cpython-37.pyc b/EduSystemServer/Student/__pycache__/views.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..da4ae69139d67785160c07c3eee6c6abeba424ef GIT binary patch literal 1144 zcmZ8gziSjh6rS1NciFqd6bVAmXdzsaKR`r86CxH-ynwKrESsJ2a_8>tWo9-%;8I9} zNUDHX2tw{a3mY2+i`XjmcGJow1_Ub$JKxN0RGekLec#)eH}Adq_IjmKMlim#evywB zLSGd*9VQspVDg&)1QDE|6bBe9+enPm3`}jCiIv)ct!*oDQa5lhqAszCvx|0c;1QR2 zyC^7;QXSRGClC$Quyh#h5X!*vZ}F^im-24b;S{)A7dfFF0p?iD*@KX7(zGjLtaie% zi+Kay{5wDowIRKS2I~vFgSIhnqi+&pfO|N!3TA3%7tGSkDVVL9TQEm6uVAibrGj~y zl?ztVY^;a-{s2J(%0$_f0V4hjbK4Nrp0R`Lqx>q6-#3BVWC*5qNO=H2O86}ByqHY&tQnRJY=vq#>fE-5ZkRB@}6ZnNI zOj=w7l~aG%23@^I>^#K%xdM*K!qs7A>RU>4D+c zKFwPW5YwMxuI}hXV-#QiH%^38dEit5cvWn0szh?lJPS_>O&NHQAP4zHaaw=^5(SA2 z3KSDk%19Y{GIC^}^k$?lBS)b>BLf*3gku>Q%E)mzk&%=8(Z(!G{8OIlR% ziD&4h@rcm!1LD;kpJ=vj5h{o1VOHlHhDhSXs~`6kwxZ?5xcv>|&c|<`P>ID$L3;(`V2)(2!wQ|iy~pin;WN!)<$!bs zyEyu>8UJk4;*^PTljJ&Ay1sa6gZXln-gLYq$=&Uh-R;+DlId27dRp+)bE$}FmIH^? zYOWc2x=CfIYk^)j39jnHJ!pQ~ASU><;J8UMO;$=&){-PNjTSWxdn+^v+GS0 z&SSSAnf~5G>(LnRcHYNuT&1gD^eP literal 0 HcmV?d00001 diff --git a/EduSystemServer/Student/migrations/__pycache__/__init__.cpython-37.pyc b/EduSystemServer/Student/migrations/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..eb1c48e32023a5069db338d38e4252337a4671bb GIT binary patch literal 175 zcmZ?b<>g`kf;nfur-10kAOZ#$feZ&AE@lA|DGb33nv8xc8Hzx{2;yrfkn3U<^K{9U zr<0e)JexZ6Y1hK%>lQwr(Dr=u?&rJb$GE1H23HoBq~;=6!Kp=MsYNltC8a5;c_lHq pndwD|C7Jno#WC^mnR%Hd@$q^EmA5!-a`RJ4b5iXg`kg5zhur^Ep1#~=<2umBkjKwPWv=03(p$0K~-tKq8ePiZO)&sFN{@ zIfV(RoB0-xbAD-2aVkXTEw*GZ&rg%(7Ds%1USe))eEco0`1suXl+qj!n6x?GHc*?czLyAbW96ElZ=ZtMPg>9y>iVQJfP} zP=tsqf)EHUph!FqyaW=5Mf?qjyEw8pQGfv~F-D9tM!K1pBa2&Fw-S5gaEBR}46wm@#{fsLL-&@& zD~PyIL8P)oJn%Y3=pUm+BV@`QjX@+CYLzP@?jHzAY9}v1qt z1~-LuXafTiEU;%5cW~~4LoN~ZW;U;A#D^->mWYRl4*}GnF*A7;XEhN(6Tfw6!WQmn zV9=+ag+aG&nY;<7G2m_Gw#S9c#FZjI|9}7R`{J8Bi{Cz;zyGVU`a=jURh!7+D3;Uc zs+g+ax{$qbCZaSR31yQ!{tq{ z-`?E0_~~f=*&Su)(}`F&_}y3YcW*1VF9i(q&|I@)9j`jQp1Ej}6f#b}HRMxhSBrlxp?3b|?)-~i<{y69 z{p+Jo=kMKHe1C6o_x9rFqs7tZ-3w53rdcjV544VuXtrC%*eyA?Gnp!zVsE0sjN675VrgrBKoi<+l%FSlVCIiz(NmX3?gJDlYNmwiEIRY!nJ4Dg5KmBcfm%t&do}vt+~d{ ztY473vg-2>K0&UZr5MQlepq?9a!=5jZYpB5Y8L76S|Or*JP~7*FO`G(Wf>tfcg7nmr6e0a3B37{ovX?aWjcLMWS0)>GBv>*#PI0NYSewC+T2#OeWp$Nk}!p|e|2$Ybxw8i}b zl#z5a@z}%b+FGxMwU+cuoom&eRs$K<;|*nDKV>5vK11lZ2tRiB`yaOZpZ5;lZTnc2 zd}C9y$9dY0Wo>;!Ds9FM@Py`Zq@6gbK5obWbT$gBxN{jxWha8aVpj5+pR*>AS4||l z{6V*XW}E07Ch%2f(OmI{REbi`1fv8TL1!zSI9euRB~pK3qoxLamV6O!K9SnJ6~?kI zj~3_%I=37t*{FxN<)*e5Dys{X#U(|Z)hzW>gZ&&^lVq6)q(qw-99B%<0xNT6CVS@O zwKWV&!)IXl93>Yr(=?kIVChg8aFm}0B&5^KCV$MuaiNB=L=_2!35Z>Zc27GE9h1JcgD{Z# zSnR?{LK0hDK+yJT+yNQJYKlVXCPy)w&{L2Y=Vt3 zm$_U~+_QBSnzgVV&A_8{%zojh>CE7-S64AjXYSAyNT-t4oi;P=%wb8X6UZBk+L0zM Icf?5kFXaKong9R* diff --git a/EduSystemServer/course/__pycache__/views.cpython-37.pyc b/EduSystemServer/course/__pycache__/views.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2244580e248d41298a7b0b19fc043de2d6b213ee GIT binary patch literal 207 zcmZ?b<>g`kg2ggFQk;PFV-N=hn1BoiATAaF5-AKRj5!Rsj8Tk?3@J>(44TX@fuanW zjJMc|Qu9($i~Ka1ZV9AhCFZ5)>lJ6@7nLNJmJ}C(%vi}#!~&$i#8)>U%f%|@>5?r^ zCohe8Hg)FHu7%InEqp$q?fK^2&v(y{aZM==t}HG|%|)<+Q;W({i(-=VON)wAW6Cm9 a%Zv32DsOSv~uUv z?4FQ76{3nLLLiV3uo9mKCy9fo}o$S{dhWe*d;D81IxbMwa|;}X58%M1gJHUp#0fwfKGVD@?2!qUJ7 z3rbiXRDgjEWvGnJ9S#n89P+qO1uys1W}YQjo_SWt`2ajPwg}-NEPw7E7-T(sZ0XDvQO_5s z@W}uC7mlM{gp2U#LbMecJ+{l>@iFh4?NjgsDfpyvuFj>~CLzlbgWfI*<*l!;KkbKc zD8nGq6D^qm#!}d%qOzMwCQ?*pFNCd3i~Hx@-=^Q(p8opb|K{-Nay7?V5W>DNCHMyVSG@eQhN@VXyi+?TsTM^cvD z8{yF#|6Mix@o@6#ZDscaLMRvEzWZwO_N_WA)|xVe{pA_S#&$uL=s8L3)2=~@ipwO^ zBnw7_m{YBr1;E-O0e=)_B8XH4y1op$5z=2Zoua)HVg#uwC!=Ch@>Wyv5EQ?%S+|rI zWHRw7)j%Q$eKtf@cR4+87y?A-(}o6A4#rTJ`?VsI#$5YUQ<;^eG5cl?;Y`0jnBKWH zdG8~|(_Wp63mRKbke#QuoW+XD-js> z<5y^#*f0pkv>CRg>PPGb4~3#&0K0{7JV#7sN2dZ7&oAsYgov3 n_So4dZnDN)3-J`i%h#STEv)BgLRDTU%J!mGKh;UDu!{LFUjMIx literal 0 HcmV?d00001 diff --git a/EduSystemServer/course/migrations/__pycache__/__init__.cpython-37.pyc b/EduSystemServer/course/migrations/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..189cb4f42f592b908a02583906d58ab87e04d244 GIT binary patch literal 174 zcmZ?b<>g`kg5zhur-10kAOZ#$feZ&AE@lA|DGb33nv8xc8Hzx{2;yr9kn3U<^K{9U zr<0e)JexZ6Y1hK%>lQwr(Dr=u?&rJb$GE1H23HoB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Ts*1>3$6 zIi4yB?J}|VALt+r7Aiz-`iicD5Fbi*(-T_4r@bDZm%t|f7EB}1A}cl=s&0xF5R bL{M^gka5>LLwquOpg`kf|X~#r-10kAOZ#$feZ&AE@lA|DGb33nv8xc8Hzx{2;yrfkn3U<^K{9U zr<0e)JexZ6Y1hK%>lQwr(Dr=u?&rJb$GE1H23HoBq~;=6!Kp=MsYNj*sfo!MKsq-w oy(qCHGe565CO$qhFS8^*Uaz3?7Kcr4eoARhsvXG2&p^xo03^IOiU0rr literal 0 HcmV?d00001 diff --git a/EduSystemServer/teacher/models.py b/EduSystemServer/teacher/models.py index d6ce4c4..db9546d 100644 --- a/EduSystemServer/teacher/models.py +++ b/EduSystemServer/teacher/models.py @@ -4,11 +4,15 @@ from django.db import models # Create your models here. class Teacher(models.Model): tid = models.AutoField(primary_key=True, verbose_name="教师编号", name="tid") - t_name = models.CharField(max_length=255, verbose_name="教师名称", name="t_name", blank=True) - sex = models.CharField(max_length=128, verbose_name="教师性别", name="t_sex", blank=True) - title = models.CharField(max_length=128, verbose_name="教师职称", name="t_title", blank=True) - education = models.CharField(max_length=128, verbose_name="教师学历", name="t_education", blank=True) - dept = models.CharField(max_length=128, verbose_name="教师所属院系", name="t_dept", blank=True) + name = models.CharField(max_length=255, verbose_name="教师名称", name="name", blank=True) + sex = models.CharField(max_length=128, verbose_name="教师性别", name="sex", blank=True) + title = models.CharField(max_length=128, verbose_name="教师职称", name="title", blank=True) + education = models.CharField(max_length=128, verbose_name="教师学历", name="education", blank=True) + dept = models.CharField(max_length=128, verbose_name="教师所属院系", name="dept", blank=True) + + def to_dict(self): + return {"tid": self.tid, "name": self.name, "sex": self.sex, + "title": self.title, "education": self.education, "dept": self.dept} class Meta: db_table = "teacher" From 7b09141c358f80dd8877b8665d0d55b629db72aa Mon Sep 17 00:00:00 2001 From: bettleChen <2207153529@qq.com> Date: Thu, 7 Sep 2023 18:00:58 +0800 Subject: [PATCH 5/5] update code --- .../API/__pycache__/urls.cpython-37.pyc | Bin 893 -> 893 bytes .../API/__pycache__/views.cpython-37.pyc | Bin 1500 -> 1540 bytes EduSystemServer/API/views.py | 8 +++--- .../__pycache__/settings.cpython-37.pyc | Bin 2611 -> 2723 bytes .../__pycache__/urls.cpython-37.pyc | Bin 1195 -> 1246 bytes .../__pycache__/utils.cpython-37.pyc | Bin 663 -> 663 bytes EduSystemServer/EduSystemServer/settings.py | 24 +++++++++++++----- .../__pycache__/0001_initial.cpython-37.pyc | Bin 773 -> 773 bytes .../Student/__pycache__/models.cpython-37.pyc | Bin 1280 -> 1280 bytes .../Student/__pycache__/urls.cpython-37.pyc | Bin 318 -> 318 bytes .../Student/__pycache__/views.cpython-37.pyc | Bin 1144 -> 2857 bytes .../__pycache__/0001_initial.cpython-37.pyc | Bin 1034 -> 1034 bytes .../course/__pycache__/models.cpython-37.pyc | Bin 1578 -> 1926 bytes .../course/__pycache__/urls.cpython-37.pyc | Bin 0 -> 266 bytes .../course/__pycache__/views.cpython-37.pyc | Bin 207 -> 1942 bytes .../__pycache__/0001_initial.cpython-37.pyc | Bin 1405 -> 1405 bytes EduSystemServer/course/models.py | 2 +- .../teacher/__pycache__/models.cpython-37.pyc | Bin 1167 -> 1167 bytes .../__pycache__/0001_initial.cpython-37.pyc | Bin 959 -> 959 bytes 19 files changed, 23 insertions(+), 11 deletions(-) create mode 100644 EduSystemServer/course/__pycache__/urls.cpython-37.pyc diff --git a/EduSystemServer/API/__pycache__/urls.cpython-37.pyc b/EduSystemServer/API/__pycache__/urls.cpython-37.pyc index d0e5e431f9642de60e2a97c43be0f229b43d5468..9e8ecab0e70bb2219046b94c2c67998333c4b49b 100644 GIT binary patch delta 19 Zcmey%_Lq&ziIr diff --git a/EduSystemServer/API/__pycache__/views.cpython-37.pyc b/EduSystemServer/API/__pycache__/views.cpython-37.pyc index 67ffb3d2ef05eaddcc2fb5341b1657c4cc531b49..7e6277f33337569d289ea93d519437de98ad5622 100644 GIT binary patch delta 844 zcmZWlL2DC16rP#g+1>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K^dr>qVxUXmKG$M6mJ?V7Yz1Dtvp0^#x9Y>}cI3fJNBi)`whvCGZ+mRmz z^PCd~ksCy2^mgo08bP#>IP3YrT%AqbiD`SBoogqiGo8GM!k2C^FPxZ@f2UmN<{Ljc zB>+fIk~yX{aMaR?(0Iq(Nyew`HNrfSGRip zM|IFh0|TEhV$dNZCk})35gUu|#w|2Q)(>`_WW%JK@;I<0qdC~f!NDBzD8R)$7O;pS zmSmptD4~oBmQlqD?qF5gRKOa!xGOcB8@Px2SjPiAlpL@~@TKslaP~4aGo`Ym z2&A%uX~9&EW~OwuDDD)YU6Rmz1WY=9LtIOsHZ{&Mz%0PSw|Bs^W$) w^-7C!if^$&I7J`_Oy0s=!6pb~6bVi?Vo4Pf0y0?`c^Cy41z5l&kj23W07c#>IsgCw delta 128 zcmcb|xtdemiIe5oAGOzEsq z+$sFQ44MKPH!v{^MX?u`l&0jRmfQj}Qu9hCKV`09698&05}2IKk}3jXvM};63NQ+= JfJsIUMgV9%81(=E diff --git a/EduSystemServer/EduSystemServer/__pycache__/utils.cpython-37.pyc b/EduSystemServer/EduSystemServer/__pycache__/utils.cpython-37.pyc index 284e6ad2214d4d7894f0073e9d90edaeae4c05cd..34c17df191acdd633eb28ccea4221e1a45b82e6c 100644 GIT binary patch delta 19 ZcmbQvI-QlviIp|8@YZn0RSd-1hN1C delta 19 YcmZo=Yh~kd;^pOH0D{((ja;^pOH0D`*{HgbJq0RSc(1g8K1 delta 19 ZcmZqRYT)8>;^pOH0D@81&m(V}s_j z(l}bEhUwd(o#xEX)UFdl+jW~No`tcQ&PK@ z+LhFyr4A)^hIqBBiC|kgNf+SmCL-M{X59#SLSqq+M{((axEO2=n7t4YVAf5IAp&(7 z8>xr2*JWfRhE>;POeBW&)@3v#hLzUcX;hDgCPeyPfM@$=`$LoTF5`OQ@^F|qj?Q;O z?BlBgkvC09u?C)7ItO*-<!FV$YHnoT6F)!Vjd_vuX97q)HBA`BU( za%?|2uwrax7wl;#SViO@_++sgk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Q+~>h5Ie}fuLrzc0Zp5QL$=KrktxH3&Az1vjJ-}Z5L=m2Y2r1v~W(Kzf7E9 z;vX7Dt5v5abC=&^Jl$U|^xj=4+=t{vcMgTeSI?2^%yOF=fE;~!MsOp~Zo~zqpuRR##-?h7qLtJEU0u-7VAEMkkqB1ITa z4c-b9>U@tM47GIaT$sNaiJ?};9gN2&7)+;P!ZY85QfwT}gwpsEdd9^>8!CmG<`X5# zPqYVHobs>*hxEHqE}vLn`f;n w2SGqyMDAp)e8~p4p|3%OVTA%+9D delta 18 XcmeC;=;GjV;^pOH0D^*)g(7*(x5<&R$!Fbf*w(g67ko-T4@r{n$h!>d!rU_ClX@pcFbxY} z#?sdkGIcL4u>|+ayF2@Xy&=c=;JQcya_!|A`7!09E8~XmUw>1a!28>O*PH8=(ZP;= zyE~Es&Oj73XdHJBKCl~ZTswV5pFYl#3erOCmDw7O2J@0DJ%wbjcoo}T+T=yNc}Zm1 zcY>FX7Gx{VLKW$Rr4*MSAagen?W zx4RQ~&b;VM4(O$oA{PYniik|kZU4)(4l^YGBs)N;-Gw=c%P~(t*QX0=sdYz0E|euN zpHO(@W8RkCWL7TT%ma9)PG3W`+@p&iAthK5MLG<4&7YUHTH-I{OsYP+8m4Q9#YV zARz?50Uh%UvJl6P=IMD3&zs#V@7{Jd9jC?Utjl-#C<^zMpA`>-V2jBK>0dJGUl@H) zPVTZO&>Q?!^V&`Gj;Ri{sE)oicGg5M%?BQRXAJ_23oO_OKwSu!($BU11o5xt zip_%62`uu=2H|b)les)F%FH1JtAjBydDhp3*oIV7S|rsXsg7)t)Ruk|F-Z;eOFbSh zQ>{W%5}DrxAv_JhTs1@R)ZvX%Q diff --git a/EduSystemServer/course/__pycache__/urls.cpython-37.pyc b/EduSystemServer/course/__pycache__/urls.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ad266855c3e60fb30930c808475e670693e9b022 GIT binary patch literal 266 zcmZ?b<>g`kf&=|OQ!;?`V-N=hn1KujATCw`5-AKRj5!Rsj8Tk?AU0DDQwT#UV+wOB zb2C#qV-!mYOE7~b>r0?Y22I9WECq=r89lTBbChINkl&r+O^nAV2qMYI)CZL)q zp5*+}qT*D&vdq--;wW|qulN=>Pz6wLNorAE@k)jwcA!!)@zoW`aC3!hJDd%k)1^WF1fTvJMeD~n4~a}liI)S|M~q8NzTF(AA33My}L*yQG? Tl;)(`F#?S&W&sjBOdQMrZ(&f- literal 0 HcmV?d00001 diff --git a/EduSystemServer/course/__pycache__/views.cpython-37.pyc b/EduSystemServer/course/__pycache__/views.cpython-37.pyc index 2244580e248d41298a7b0b19fc043de2d6b213ee..7d87c47276caefcc762d7701e30a860c8b27602f 100644 GIT binary patch literal 1942 zcmZ`)&u<$=6rR~x@2=N&el<-Kh&Um@93tR|q6*q12t?b67!_GTk?WZxPItY|%s3=y zeJDW?0uhlAhf0xZODO_`S`d{uq$(9B{sc4!4uGBJR0)X#H{Oi5O^VW8&CGjm=9~Au z_jYE_wd?+|Vm}Ms|X9=ofvAm_uFaeTdd^F+`MjynX@1-gEUpR;Ei_LKBRavEC7$UT6-qv(QAxLMTQ{ z5W;1PFG{?Q8W?n|NvPGrF`ly%jTkMJXtvRuL`xaXjd9a!AqWhD0Xf}5)Y~BqOZu_3 zj%T`l(wD7m%x?fP13vr~ZjeLhG~Pf!-Zxq+_?)6Q{M$7L;N6?nPAnCAPtnpCD|SHHhyXgZLW|+i?mIrxQeq<_zL} zgBbk3k8QmCG+<_92QWOrIJC!LrXGuV2Qbg+)y>`(YWS<8u@4a(xBCYdk@O*#y|GLC zb_ngK16x*-#S@T4i;v4b$Wgx>fd0g~uG=8Alk0YK2=>mz89F$Es6T=lWNkcQXfoF% zEu?eR$Ub5{l~nI!oPD%%7^-UOIz&(HSces@eg*yz9X4$K=(34*osaU!#koTsiEIHU zJCO;bJMK;w*7q$09H4}OI+QP&5g^V42?v)S3$Zf{<@fBQh41V^=DzCYisZRaPQXj`?o*q?0nn#*8sSElmRMN|<;+(C$+&V#wHjPoij;zYyLyRzZnE$y*Vm4+FGX}s_10@a zRHAc>r78^=7s_K*$Z(~)pi(t`VJU~QfJqqZHOMu~_bQjOoaQt_B@nk7++z0wo7n!rNZ75W3@Hqb`3&j zU(}#OmX96Wle`}8!ye8)d~IyQjE@J+n!|A@(T4!7t%HDg3Yvw7@BoY+%S+2udnVS-JTh3>%Z=Bi)O74{sd&)dO}~p9Gp|8@XCp04G@lSO5S3 delta 19 YcmeC@?C0ci;^pOH00Q^2ja;oP03$8~q5uE@ diff --git a/EduSystemServer/teacher/migrations/__pycache__/0001_initial.cpython-37.pyc b/EduSystemServer/teacher/migrations/__pycache__/0001_initial.cpython-37.pyc index de517afb591d5717746afe2e7e28ed50f3b8d990..d917461c51761d6097ff2bd49d3b450c8bcbb76c 100644 GIT binary patch delta 19 ZcmdnbzMq}TiI