diff --git a/EduSystemServer/.idea/EduSystemServer.iml b/EduSystemServer/.idea/EduSystemServer.iml
index a29dcc1..892ceb8 100644
--- a/EduSystemServer/.idea/EduSystemServer.iml
+++ b/EduSystemServer/.idea/EduSystemServer.iml
@@ -14,7 +14,11 @@
+<<<<<<< HEAD
+=======
+
+>>>>>>> 7b09141c358f80dd8877b8665d0d55b629db72aa
diff --git a/EduSystemServer/.idea/deployment.xml b/EduSystemServer/.idea/deployment.xml
new file mode 100644
index 0000000..6300278
--- /dev/null
+++ b/EduSystemServer/.idea/deployment.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/EduSystemServer/.idea/misc.xml b/EduSystemServer/.idea/misc.xml
index 2d83d70..0d04900 100644
--- a/EduSystemServer/.idea/misc.xml
+++ b/EduSystemServer/.idea/misc.xml
@@ -1,4 +1,8 @@
+<<<<<<< HEAD
+=======
+
+>>>>>>> 7b09141c358f80dd8877b8665d0d55b629db72aa
\ No newline at end of file
diff --git a/EduSystemServer/API/__pycache__/__init__.cpython-36.pyc b/EduSystemServer/API/__pycache__/__init__.cpython-36.pyc
new file mode 100644
index 0000000..b56f4bb
Binary files /dev/null and b/EduSystemServer/API/__pycache__/__init__.cpython-36.pyc differ
diff --git a/EduSystemServer/API/__pycache__/admin.cpython-36.pyc b/EduSystemServer/API/__pycache__/admin.cpython-36.pyc
new file mode 100644
index 0000000..c91b932
Binary files /dev/null and b/EduSystemServer/API/__pycache__/admin.cpython-36.pyc differ
diff --git a/EduSystemServer/API/__pycache__/apps.cpython-36.pyc b/EduSystemServer/API/__pycache__/apps.cpython-36.pyc
new file mode 100644
index 0000000..188bc42
Binary files /dev/null and b/EduSystemServer/API/__pycache__/apps.cpython-36.pyc differ
diff --git a/EduSystemServer/API/__pycache__/apps.cpython-37.pyc b/EduSystemServer/API/__pycache__/apps.cpython-37.pyc
new file mode 100644
index 0000000..8bb8f3e
Binary files /dev/null and b/EduSystemServer/API/__pycache__/apps.cpython-37.pyc differ
diff --git a/EduSystemServer/API/__pycache__/middle.cpython-37.pyc b/EduSystemServer/API/__pycache__/middle.cpython-37.pyc
new file mode 100644
index 0000000..48cff8c
Binary files /dev/null and b/EduSystemServer/API/__pycache__/middle.cpython-37.pyc differ
diff --git a/EduSystemServer/API/__pycache__/models.cpython-36.pyc b/EduSystemServer/API/__pycache__/models.cpython-36.pyc
new file mode 100644
index 0000000..869a6d7
Binary files /dev/null and b/EduSystemServer/API/__pycache__/models.cpython-36.pyc differ
diff --git a/EduSystemServer/API/__pycache__/urls.cpython-36.pyc b/EduSystemServer/API/__pycache__/urls.cpython-36.pyc
new file mode 100644
index 0000000..f201a2d
Binary files /dev/null and b/EduSystemServer/API/__pycache__/urls.cpython-36.pyc differ
diff --git a/EduSystemServer/API/__pycache__/urls.cpython-37.pyc b/EduSystemServer/API/__pycache__/urls.cpython-37.pyc
index fde68bc..9e8ecab 100644
Binary files a/EduSystemServer/API/__pycache__/urls.cpython-37.pyc and b/EduSystemServer/API/__pycache__/urls.cpython-37.pyc differ
diff --git a/EduSystemServer/API/__pycache__/views.cpython-36.pyc b/EduSystemServer/API/__pycache__/views.cpython-36.pyc
new file mode 100644
index 0000000..c6dff3e
Binary files /dev/null and b/EduSystemServer/API/__pycache__/views.cpython-36.pyc differ
diff --git a/EduSystemServer/API/__pycache__/views.cpython-37.pyc b/EduSystemServer/API/__pycache__/views.cpython-37.pyc
index 815b487..7e6277f 100644
Binary files a/EduSystemServer/API/__pycache__/views.cpython-37.pyc and b/EduSystemServer/API/__pycache__/views.cpython-37.pyc differ
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/migrations/__pycache__/__init__.cpython-36.pyc b/EduSystemServer/API/migrations/__pycache__/__init__.cpython-36.pyc
new file mode 100644
index 0000000..865e2e3
Binary files /dev/null and b/EduSystemServer/API/migrations/__pycache__/__init__.cpython-36.pyc differ
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 0d36511..1ef3a82 100644
--- a/EduSystemServer/API/views.py
+++ b/EduSystemServer/API/views.py
@@ -1,7 +1,53 @@
+import json
+
from django.shortcuts import render
-from django.http import JsonResponse
+from django.http import JsonResponse, HttpResponse
+
# 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
+
+@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 = ResponseUtil.ok(student.to_dict(), "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 = ResponseUtil.ok(teacher.to_dict(), "login success!")
+ else:
+ result = ResponseUtil.error("username or password error!")
+ else:
+ result = ResponseUtil.error("type error!")
+ return JsonResponse(result)
-def student(request):
- return JsonResponse({"sid": 1, "sname":"张三"})
+@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__/__init__.cpython-36.pyc b/EduSystemServer/EduSystemServer/__pycache__/__init__.cpython-36.pyc
new file mode 100644
index 0000000..9685251
Binary files /dev/null and b/EduSystemServer/EduSystemServer/__pycache__/__init__.cpython-36.pyc differ
diff --git a/EduSystemServer/EduSystemServer/__pycache__/settings.cpython-36.pyc b/EduSystemServer/EduSystemServer/__pycache__/settings.cpython-36.pyc
new file mode 100644
index 0000000..b4f55f2
Binary files /dev/null and b/EduSystemServer/EduSystemServer/__pycache__/settings.cpython-36.pyc differ
diff --git a/EduSystemServer/EduSystemServer/__pycache__/settings.cpython-37.pyc b/EduSystemServer/EduSystemServer/__pycache__/settings.cpython-37.pyc
index 8ea2b0a..026cc4f 100644
Binary files a/EduSystemServer/EduSystemServer/__pycache__/settings.cpython-37.pyc and b/EduSystemServer/EduSystemServer/__pycache__/settings.cpython-37.pyc differ
diff --git a/EduSystemServer/EduSystemServer/__pycache__/urls.cpython-36.pyc b/EduSystemServer/EduSystemServer/__pycache__/urls.cpython-36.pyc
new file mode 100644
index 0000000..ace669c
Binary files /dev/null and b/EduSystemServer/EduSystemServer/__pycache__/urls.cpython-36.pyc differ
diff --git a/EduSystemServer/EduSystemServer/__pycache__/urls.cpython-37.pyc b/EduSystemServer/EduSystemServer/__pycache__/urls.cpython-37.pyc
index 9930cea..7bf7f1a 100644
Binary files a/EduSystemServer/EduSystemServer/__pycache__/urls.cpython-37.pyc and b/EduSystemServer/EduSystemServer/__pycache__/urls.cpython-37.pyc differ
diff --git a/EduSystemServer/EduSystemServer/__pycache__/utils.cpython-37.pyc b/EduSystemServer/EduSystemServer/__pycache__/utils.cpython-37.pyc
new file mode 100644
index 0000000..34c17df
Binary files /dev/null and b/EduSystemServer/EduSystemServer/__pycache__/utils.cpython-37.pyc differ
diff --git a/EduSystemServer/EduSystemServer/__pycache__/wsgi.cpython-36.pyc b/EduSystemServer/EduSystemServer/__pycache__/wsgi.cpython-36.pyc
new file mode 100644
index 0000000..f431aeb
Binary files /dev/null and b/EduSystemServer/EduSystemServer/__pycache__/wsgi.cpython-36.pyc differ
diff --git a/EduSystemServer/EduSystemServer/settings.py b/EduSystemServer/EduSystemServer/settings.py
index e8d1b6c..4d62834 100644
--- a/EduSystemServer/EduSystemServer/settings.py
+++ b/EduSystemServer/EduSystemServer/settings.py
@@ -12,6 +12,8 @@ https://docs.djangoproject.com/en/2.2/ref/settings/
import os
+
+
# 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 +31,6 @@ ALLOWED_HOSTS = ["*"]
# Application definition
-
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
@@ -37,6 +38,7 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
+ 'corsheaders',
'API',
'Student',
'teacher',
@@ -52,8 +54,29 @@ MIDDLEWARE = [
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
+ 'corsheaders.middleware.CorsMiddleware',
+ 'django.middleware.common.CommonMiddleware',
+ # 'API.middle.AuthMiddleware',
]
+CORS_ALLOW_CREDENTIALS = True
+CORS_ORIGIN_ALLOW_ALL = True
+CORS_ALLOW_HEADERS = (
+ 'XMLHttpRequest',
+ 'X_FILENAME',
+ 'accept-encoding',
+ 'authorization',
+ 'content-type',
+ 'dnt',
+ 'origin',
+ 'user-agent',
+ 'x-csrftoken',
+ 'x-requested-with',
+ 'Pragma',
+)
+
+
+
ROOT_URLCONF = 'EduSystemServer.urls'
TEMPLATES = [
diff --git a/EduSystemServer/EduSystemServer/urls.py b/EduSystemServer/EduSystemServer/urls.py
index 7f7d64d..51e7063 100644
--- a/EduSystemServer/EduSystemServer/urls.py
+++ b/EduSystemServer/EduSystemServer/urls.py
@@ -15,12 +15,16 @@ 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", "studnet"), namespace="student")),
path('teacher/', include(("teacher.urls", "teacher"), namespace="teacher")),
+ path('student/', include(("Student.urls", "student"), namespace="student")),
+ 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__/__init__.cpython-36.pyc b/EduSystemServer/Eduadmin/__pycache__/__init__.cpython-36.pyc
new file mode 100644
index 0000000..582a262
Binary files /dev/null and b/EduSystemServer/Eduadmin/__pycache__/__init__.cpython-36.pyc differ
diff --git a/EduSystemServer/Eduadmin/__pycache__/admin.cpython-36.pyc b/EduSystemServer/Eduadmin/__pycache__/admin.cpython-36.pyc
new file mode 100644
index 0000000..3264091
Binary files /dev/null and b/EduSystemServer/Eduadmin/__pycache__/admin.cpython-36.pyc differ
diff --git a/EduSystemServer/Eduadmin/__pycache__/apps.cpython-36.pyc b/EduSystemServer/Eduadmin/__pycache__/apps.cpython-36.pyc
new file mode 100644
index 0000000..d1c72bb
Binary files /dev/null and b/EduSystemServer/Eduadmin/__pycache__/apps.cpython-36.pyc differ
diff --git a/EduSystemServer/Eduadmin/__pycache__/apps.cpython-37.pyc b/EduSystemServer/Eduadmin/__pycache__/apps.cpython-37.pyc
new file mode 100644
index 0000000..89af00e
Binary files /dev/null and b/EduSystemServer/Eduadmin/__pycache__/apps.cpython-37.pyc differ
diff --git a/EduSystemServer/Eduadmin/__pycache__/models.cpython-36.pyc b/EduSystemServer/Eduadmin/__pycache__/models.cpython-36.pyc
new file mode 100644
index 0000000..6f72cda
Binary files /dev/null and b/EduSystemServer/Eduadmin/__pycache__/models.cpython-36.pyc differ
diff --git a/EduSystemServer/Eduadmin/__pycache__/models.cpython-37.pyc b/EduSystemServer/Eduadmin/__pycache__/models.cpython-37.pyc
index f096496..35f66ee 100644
Binary files a/EduSystemServer/Eduadmin/__pycache__/models.cpython-37.pyc and b/EduSystemServer/Eduadmin/__pycache__/models.cpython-37.pyc differ
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/0002_auto_20230907_0859.py b/EduSystemServer/Eduadmin/migrations/0002_auto_20230907_0859.py
new file mode 100644
index 0000000..ba41cf4
--- /dev/null
+++ b/EduSystemServer/Eduadmin/migrations/0002_auto_20230907_0859.py
@@ -0,0 +1,23 @@
+# Generated by Django 3.2.13 on 2023-09-07 08:59
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('Eduadmin', '0001_initial'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='admin',
+ name='password',
+ field=models.CharField(blank=True, max_length=128, verbose_name='管理员密码'),
+ ),
+ migrations.AlterField(
+ model_name='admin',
+ name='username',
+ field=models.CharField(blank=True, max_length=32, primary_key=True, serialize=False, verbose_name='管理员账号'),
+ ),
+ ]
diff --git a/EduSystemServer/Eduadmin/migrations/__pycache__/0001_initial.cpython-36.pyc b/EduSystemServer/Eduadmin/migrations/__pycache__/0001_initial.cpython-36.pyc
new file mode 100644
index 0000000..d741676
Binary files /dev/null and b/EduSystemServer/Eduadmin/migrations/__pycache__/0001_initial.cpython-36.pyc differ
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 0000000..70799ff
Binary files /dev/null and b/EduSystemServer/Eduadmin/migrations/__pycache__/0001_initial.cpython-37.pyc differ
diff --git a/EduSystemServer/Eduadmin/migrations/__pycache__/0002_auto_20230907_0859.cpython-36.pyc b/EduSystemServer/Eduadmin/migrations/__pycache__/0002_auto_20230907_0859.cpython-36.pyc
new file mode 100644
index 0000000..7e70c2d
Binary files /dev/null and b/EduSystemServer/Eduadmin/migrations/__pycache__/0002_auto_20230907_0859.cpython-36.pyc differ
diff --git a/EduSystemServer/Eduadmin/migrations/__pycache__/__init__.cpython-36.pyc b/EduSystemServer/Eduadmin/migrations/__pycache__/__init__.cpython-36.pyc
new file mode 100644
index 0000000..81b91e2
Binary files /dev/null and b/EduSystemServer/Eduadmin/migrations/__pycache__/__init__.cpython-36.pyc differ
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 0000000..f112daf
Binary files /dev/null and b/EduSystemServer/Eduadmin/migrations/__pycache__/__init__.cpython-37.pyc differ
diff --git a/EduSystemServer/Student/__pycache__/__init__.cpython-36.pyc b/EduSystemServer/Student/__pycache__/__init__.cpython-36.pyc
new file mode 100644
index 0000000..5c27da3
Binary files /dev/null and b/EduSystemServer/Student/__pycache__/__init__.cpython-36.pyc differ
diff --git a/EduSystemServer/Student/__pycache__/admin.cpython-36.pyc b/EduSystemServer/Student/__pycache__/admin.cpython-36.pyc
new file mode 100644
index 0000000..6135010
Binary files /dev/null and b/EduSystemServer/Student/__pycache__/admin.cpython-36.pyc differ
diff --git a/EduSystemServer/Student/__pycache__/apps.cpython-36.pyc b/EduSystemServer/Student/__pycache__/apps.cpython-36.pyc
new file mode 100644
index 0000000..0a6f45e
Binary files /dev/null and b/EduSystemServer/Student/__pycache__/apps.cpython-36.pyc differ
diff --git a/EduSystemServer/Student/__pycache__/apps.cpython-37.pyc b/EduSystemServer/Student/__pycache__/apps.cpython-37.pyc
new file mode 100644
index 0000000..2e1ea02
Binary files /dev/null and b/EduSystemServer/Student/__pycache__/apps.cpython-37.pyc differ
diff --git a/EduSystemServer/Student/__pycache__/models.cpython-36.pyc b/EduSystemServer/Student/__pycache__/models.cpython-36.pyc
new file mode 100644
index 0000000..9e60348
Binary files /dev/null and b/EduSystemServer/Student/__pycache__/models.cpython-36.pyc differ
diff --git a/EduSystemServer/Student/__pycache__/models.cpython-37.pyc b/EduSystemServer/Student/__pycache__/models.cpython-37.pyc
index cd68912..a06cb52 100644
Binary files a/EduSystemServer/Student/__pycache__/models.cpython-37.pyc and b/EduSystemServer/Student/__pycache__/models.cpython-37.pyc differ
diff --git a/EduSystemServer/Student/__pycache__/urls.cpython-36.pyc b/EduSystemServer/Student/__pycache__/urls.cpython-36.pyc
new file mode 100644
index 0000000..5669db4
Binary files /dev/null and b/EduSystemServer/Student/__pycache__/urls.cpython-36.pyc differ
diff --git a/EduSystemServer/Student/__pycache__/urls.cpython-37.pyc b/EduSystemServer/Student/__pycache__/urls.cpython-37.pyc
new file mode 100644
index 0000000..bfa6066
Binary files /dev/null and b/EduSystemServer/Student/__pycache__/urls.cpython-37.pyc differ
diff --git a/EduSystemServer/Student/__pycache__/views.cpython-36.pyc b/EduSystemServer/Student/__pycache__/views.cpython-36.pyc
new file mode 100644
index 0000000..85f7cb6
Binary files /dev/null and b/EduSystemServer/Student/__pycache__/views.cpython-36.pyc differ
diff --git a/EduSystemServer/Student/__pycache__/views.cpython-37.pyc b/EduSystemServer/Student/__pycache__/views.cpython-37.pyc
new file mode 100644
index 0000000..c3da84c
Binary files /dev/null and b/EduSystemServer/Student/__pycache__/views.cpython-37.pyc differ
diff --git a/EduSystemServer/Student/migrations/0001_initial.py b/EduSystemServer/Student/migrations/0001_initial.py
index 8f2dab4..67aa19a 100644
--- a/EduSystemServer/Student/migrations/0001_initial.py
+++ b/EduSystemServer/Student/migrations/0001_initial.py
@@ -1,4 +1,4 @@
-# Generated by Django 2.1 on 2023-09-06 14:01
+# Generated by Django 2.1 on 2023-09-07 13:49
from django.db import migrations, models
@@ -14,14 +14,14 @@ class Migration(migrations.Migration):
migrations.CreateModel(
name='Student',
fields=[
- ('sid', models.IntegerField(primary_key=True, serialize=False, verbose_name='学生编号')),
- ('s_username', models.CharField(max_length=30, verbose_name='用户名称')),
- ('s_password', models.CharField(max_length=100, verbose_name='密码')),
- ('s_name', models.CharField(max_length=100, verbose_name='姓名')),
- ('s_sex', models.CharField(max_length=4, verbose_name='性别')),
- ('s_grade', models.IntegerField(verbose_name='年级')),
- ('s_class_name', models.CharField(max_length=50, verbose_name='班级')),
- ('s_major', models.CharField(max_length=50, verbose_name='专业名称')),
+ ('sid', models.AutoField(primary_key=True, serialize=False, verbose_name='学生编号')),
+ ('username', models.CharField(blank=True, max_length=30, verbose_name='用户名称')),
+ ('password', models.CharField(blank=True, max_length=100, verbose_name='密码')),
+ ('name', models.CharField(blank=True, max_length=100, verbose_name='姓名')),
+ ('sex', models.CharField(blank=True, max_length=4, verbose_name='性别')),
+ ('grade', models.CharField(blank=True, max_length=20, verbose_name='年级')),
+ ('class_name', models.CharField(blank=True, max_length=50, verbose_name='班级')),
+ ('major', models.CharField(blank=True, max_length=50, verbose_name='专业名称')),
],
options={
'verbose_name': '学生',
diff --git a/EduSystemServer/Student/migrations/0002_auto_20230907_0916.py b/EduSystemServer/Student/migrations/0002_auto_20230907_0916.py
new file mode 100644
index 0000000..f8f5cfc
--- /dev/null
+++ b/EduSystemServer/Student/migrations/0002_auto_20230907_0916.py
@@ -0,0 +1,53 @@
+# Generated by Django 3.2.13 on 2023-09-07 09:16
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('Student', '0001_initial'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='student',
+ name='s_class_name',
+ field=models.CharField(blank=True, max_length=50, verbose_name='班级'),
+ ),
+ migrations.AlterField(
+ model_name='student',
+ name='s_grade',
+ field=models.CharField(blank=True, max_length=20, verbose_name='年级'),
+ ),
+ migrations.AlterField(
+ model_name='student',
+ name='s_major',
+ field=models.CharField(blank=True, max_length=50, verbose_name='专业名称'),
+ ),
+ migrations.AlterField(
+ model_name='student',
+ name='s_name',
+ field=models.CharField(blank=True, max_length=100, verbose_name='姓名'),
+ ),
+ migrations.AlterField(
+ model_name='student',
+ name='s_password',
+ field=models.CharField(blank=True, max_length=100, verbose_name='密码'),
+ ),
+ migrations.AlterField(
+ model_name='student',
+ name='s_sex',
+ field=models.CharField(blank=True, max_length=4, verbose_name='性别'),
+ ),
+ migrations.AlterField(
+ model_name='student',
+ name='s_username',
+ field=models.CharField(blank=True, max_length=30, verbose_name='用户名称'),
+ ),
+ migrations.AlterField(
+ model_name='student',
+ name='sid',
+ field=models.AutoField(primary_key=True, serialize=False, verbose_name='学生编号'),
+ ),
+ ]
diff --git a/EduSystemServer/Student/migrations/__pycache__/0001_initial.cpython-36.pyc b/EduSystemServer/Student/migrations/__pycache__/0001_initial.cpython-36.pyc
new file mode 100644
index 0000000..2feafc9
Binary files /dev/null and b/EduSystemServer/Student/migrations/__pycache__/0001_initial.cpython-36.pyc differ
diff --git a/EduSystemServer/Student/migrations/__pycache__/0001_initial.cpython-37.pyc b/EduSystemServer/Student/migrations/__pycache__/0001_initial.cpython-37.pyc
new file mode 100644
index 0000000..266d761
Binary files /dev/null and b/EduSystemServer/Student/migrations/__pycache__/0001_initial.cpython-37.pyc differ
diff --git a/EduSystemServer/Student/migrations/__pycache__/0002_auto_20230907_0916.cpython-36.pyc b/EduSystemServer/Student/migrations/__pycache__/0002_auto_20230907_0916.cpython-36.pyc
new file mode 100644
index 0000000..4fbf441
Binary files /dev/null and b/EduSystemServer/Student/migrations/__pycache__/0002_auto_20230907_0916.cpython-36.pyc differ
diff --git a/EduSystemServer/Student/migrations/__pycache__/__init__.cpython-36.pyc b/EduSystemServer/Student/migrations/__pycache__/__init__.cpython-36.pyc
new file mode 100644
index 0000000..06d318e
Binary files /dev/null and b/EduSystemServer/Student/migrations/__pycache__/__init__.cpython-36.pyc differ
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 0000000..eb1c48e
Binary files /dev/null and b/EduSystemServer/Student/migrations/__pycache__/__init__.cpython-37.pyc differ
diff --git a/EduSystemServer/Student/models.py b/EduSystemServer/Student/models.py
index 0b690ff..7a60250 100644
--- a/EduSystemServer/Student/models.py
+++ b/EduSystemServer/Student/models.py
@@ -4,6 +4,7 @@ from django.db import models
# Create your models here.
class Student(models.Model):
sid = models.AutoField(primary_key=True, verbose_name="学生编号", name="sid")
+<<<<<<< HEAD
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)
@@ -15,6 +16,19 @@ class Student(models.Model):
def to_dict(self):
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, "class_name": self.s_class_name, "s_major": self.s_major}
+=======
+ username = models.CharField(max_length=30, verbose_name="用户名称", name="username", blank=True)
+ password = models.CharField(max_length=100, verbose_name="密码", name="password", blank=True)
+ name = models.CharField(max_length=100, verbose_name="姓名", name="name", blank=True)
+ sex = models.CharField(max_length=4, verbose_name="性别", name="sex", blank=True)
+ grade = models.CharField(max_length=20, verbose_name="年级", name="grade", blank=True)
+ class_name = models.CharField(max_length=50, verbose_name="班级", name="class_name", blank=True)
+ major = models.CharField(max_length=50, verbose_name="专业名称", name="major", blank=True)
+
+ def to_dict(self):
+ return {"sid": self.sid, "name": self.name, "username": self.username, "password": self.password,
+ "sex": self.sex, "grade": self.grade, "class_name": self.class_name, "major": self.major}
+>>>>>>> 7b09141c358f80dd8877b8665d0d55b629db72aa
class Meta:
db_table = "student"
diff --git a/EduSystemServer/Student/urls.py b/EduSystemServer/Student/urls.py
index df57970..56d8191 100644
--- a/EduSystemServer/Student/urls.py
+++ b/EduSystemServer/Student/urls.py
@@ -3,5 +3,6 @@ from django.urls import path
from .views import *
urlpatterns = [
- path("", studnets)
+ path("", studnets),
+ path("selectCourse", get_select_course_by_id)
]
\ No newline at end of file
diff --git a/EduSystemServer/Student/views.py b/EduSystemServer/Student/views.py
index 7642c73..1b6ac00 100644
--- a/EduSystemServer/Student/views.py
+++ b/EduSystemServer/Student/views.py
@@ -5,6 +5,10 @@ from django.http import JsonResponse
from .models import Student
from django.views.decorators.csrf import csrf_exempt
from django.http import QueryDict
+from io import BytesIO
+from django.http.multipartparser import MultiPartParser
+
+
@csrf_exempt
def studnets(request):
if request.method == "POST":
@@ -20,10 +24,90 @@ def studnets(request):
print(student.sid)
print(student.to_dict())
+ 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.username = request.POST.get("username")
+ student.password = request.POST.get("password")
+ student.name = request.POST.get("name")
+ student.sex = request.POST.get("sex")
+ student.grade = request.POST.get("grade")
+ student.class_name = request.POST.get("class_name")
+ student.major = request.POST.get("major")
+ student.sid = request.POST.get("sid")
student.save()
response = {"code": 200, "message": "添加成功!", "data": student.to_dict()}
return JsonResponse(response)
elif request.method == "GET":
+ 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_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']
+ 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)
student_list = Student.objects.all()
response_json = {"code": 200, "message": "success", "data": []}
for student in student_list:
@@ -37,3 +121,5 @@ def studnets(request):
print(xx.split('\r\n'))
return JsonResponse({'code': 200, 'msg': 'success'}, safe=False)
+def get_select_course_by_id(request):
+ pass
diff --git a/EduSystemServer/course/__pycache__/__init__.cpython-36.pyc b/EduSystemServer/course/__pycache__/__init__.cpython-36.pyc
new file mode 100644
index 0000000..633a731
Binary files /dev/null and b/EduSystemServer/course/__pycache__/__init__.cpython-36.pyc differ
diff --git a/EduSystemServer/course/__pycache__/admin.cpython-36.pyc b/EduSystemServer/course/__pycache__/admin.cpython-36.pyc
new file mode 100644
index 0000000..15e2b53
Binary files /dev/null and b/EduSystemServer/course/__pycache__/admin.cpython-36.pyc differ
diff --git a/EduSystemServer/course/__pycache__/apps.cpython-36.pyc b/EduSystemServer/course/__pycache__/apps.cpython-36.pyc
new file mode 100644
index 0000000..d3bb9b5
Binary files /dev/null and b/EduSystemServer/course/__pycache__/apps.cpython-36.pyc differ
diff --git a/EduSystemServer/course/__pycache__/apps.cpython-37.pyc b/EduSystemServer/course/__pycache__/apps.cpython-37.pyc
new file mode 100644
index 0000000..bc3c105
Binary files /dev/null and b/EduSystemServer/course/__pycache__/apps.cpython-37.pyc differ
diff --git a/EduSystemServer/course/__pycache__/models.cpython-36.pyc b/EduSystemServer/course/__pycache__/models.cpython-36.pyc
new file mode 100644
index 0000000..26644a0
Binary files /dev/null and b/EduSystemServer/course/__pycache__/models.cpython-36.pyc differ
diff --git a/EduSystemServer/course/__pycache__/models.cpython-37.pyc b/EduSystemServer/course/__pycache__/models.cpython-37.pyc
index 144b12c..2eb682e 100644
Binary files a/EduSystemServer/course/__pycache__/models.cpython-37.pyc and b/EduSystemServer/course/__pycache__/models.cpython-37.pyc differ
diff --git a/EduSystemServer/course/__pycache__/urls.cpython-37.pyc b/EduSystemServer/course/__pycache__/urls.cpython-37.pyc
new file mode 100644
index 0000000..ad26685
Binary files /dev/null and b/EduSystemServer/course/__pycache__/urls.cpython-37.pyc differ
diff --git a/EduSystemServer/course/__pycache__/views.cpython-37.pyc b/EduSystemServer/course/__pycache__/views.cpython-37.pyc
new file mode 100644
index 0000000..7d87c47
Binary files /dev/null and b/EduSystemServer/course/__pycache__/views.cpython-37.pyc differ
diff --git a/EduSystemServer/course/migrations/0001_initial.py b/EduSystemServer/course/migrations/0001_initial.py
index 7155d7a..0a7d710 100644
--- a/EduSystemServer/course/migrations/0001_initial.py
+++ b/EduSystemServer/course/migrations/0001_initial.py
@@ -1,4 +1,4 @@
-# Generated by Django 2.1 on 2023-09-06 14:01
+# Generated by Django 2.1 on 2023-09-07 13:49
from django.db import migrations, models
import django.db.models.deletion
@@ -9,8 +9,8 @@ class Migration(migrations.Migration):
initial = True
dependencies = [
- ('Student', '0001_initial'),
('teacher', '0001_initial'),
+ ('Student', '0001_initial'),
]
operations = [
@@ -18,8 +18,8 @@ class Migration(migrations.Migration):
name='Course',
fields=[
('cid', models.AutoField(primary_key=True, serialize=False, verbose_name='课程编号')),
- ('c_name', models.CharField(max_length=255, verbose_name='课程名称')),
- ('c_type', models.CharField(max_length=128, verbose_name='课程类型')),
+ ('name', models.CharField(blank=True, max_length=255, verbose_name='课程名称')),
+ ('type', models.CharField(blank=True, max_length=128, verbose_name='课程类型')),
('credit', models.IntegerField(verbose_name='课程学分')),
('tid', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='teacher.Teacher')),
],
diff --git a/EduSystemServer/course/migrations/0002_auto_20230907_0859.py b/EduSystemServer/course/migrations/0002_auto_20230907_0859.py
new file mode 100644
index 0000000..32adfc7
--- /dev/null
+++ b/EduSystemServer/course/migrations/0002_auto_20230907_0859.py
@@ -0,0 +1,23 @@
+# Generated by Django 3.2.13 on 2023-09-07 08:59
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('course', '0001_initial'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='course',
+ name='c_name',
+ field=models.CharField(blank=True, max_length=255, verbose_name='课程名称'),
+ ),
+ migrations.AlterField(
+ model_name='course',
+ name='c_type',
+ field=models.CharField(blank=True, max_length=128, verbose_name='课程类型'),
+ ),
+ ]
diff --git a/EduSystemServer/course/migrations/__pycache__/0001_initial.cpython-36.pyc b/EduSystemServer/course/migrations/__pycache__/0001_initial.cpython-36.pyc
new file mode 100644
index 0000000..261ad55
Binary files /dev/null and b/EduSystemServer/course/migrations/__pycache__/0001_initial.cpython-36.pyc differ
diff --git a/EduSystemServer/course/migrations/__pycache__/0001_initial.cpython-37.pyc b/EduSystemServer/course/migrations/__pycache__/0001_initial.cpython-37.pyc
new file mode 100644
index 0000000..67c8a87
Binary files /dev/null and b/EduSystemServer/course/migrations/__pycache__/0001_initial.cpython-37.pyc differ
diff --git a/EduSystemServer/course/migrations/__pycache__/0002_auto_20230907_0859.cpython-36.pyc b/EduSystemServer/course/migrations/__pycache__/0002_auto_20230907_0859.cpython-36.pyc
new file mode 100644
index 0000000..cd2e6e5
Binary files /dev/null and b/EduSystemServer/course/migrations/__pycache__/0002_auto_20230907_0859.cpython-36.pyc differ
diff --git a/EduSystemServer/course/migrations/__pycache__/__init__.cpython-36.pyc b/EduSystemServer/course/migrations/__pycache__/__init__.cpython-36.pyc
new file mode 100644
index 0000000..0226b62
Binary files /dev/null and b/EduSystemServer/course/migrations/__pycache__/__init__.cpython-36.pyc differ
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 0000000..189cb4f
Binary files /dev/null and b/EduSystemServer/course/migrations/__pycache__/__init__.cpython-37.pyc differ
diff --git a/EduSystemServer/course/models.py b/EduSystemServer/course/models.py
index b501f2a..fc7381f 100644
--- a/EduSystemServer/course/models.py
+++ b/EduSystemServer/course/models.py
@@ -7,11 +7,15 @@ from Student.models import Student
# Create your models here.
class Course(models.Model):
cid = models.AutoField(primary_key=True, verbose_name="课程编号", name="cid")
- c_name = models.CharField(max_length=255, verbose_name="课程名称", name="c_name", blank=True)
- type = models.CharField(max_length=128, verbose_name="课程类型", name="c_type", blank=True)
+ name = models.CharField(max_length=255, verbose_name="课程名称", name="name", blank=True)
+ type = models.CharField(max_length=128, verbose_name="课程类型", name="type", blank=True)
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.name, "type": self.type, "credit": self.credit,
+ "tid": self.tid}
+
class Meta:
db_table = "course"
verbose_name = "课程"
@@ -25,7 +29,8 @@ class SC(models.Model):
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}
+ 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)
diff --git a/EduSystemServer/teacher/__pycache__/__init__.cpython-36.pyc b/EduSystemServer/teacher/__pycache__/__init__.cpython-36.pyc
new file mode 100644
index 0000000..54d34ea
Binary files /dev/null and b/EduSystemServer/teacher/__pycache__/__init__.cpython-36.pyc differ
diff --git a/EduSystemServer/teacher/__pycache__/admin.cpython-36.pyc b/EduSystemServer/teacher/__pycache__/admin.cpython-36.pyc
new file mode 100644
index 0000000..03aee0c
Binary files /dev/null and b/EduSystemServer/teacher/__pycache__/admin.cpython-36.pyc differ
diff --git a/EduSystemServer/teacher/__pycache__/apps.cpython-36.pyc b/EduSystemServer/teacher/__pycache__/apps.cpython-36.pyc
new file mode 100644
index 0000000..ba3e038
Binary files /dev/null and b/EduSystemServer/teacher/__pycache__/apps.cpython-36.pyc differ
diff --git a/EduSystemServer/teacher/__pycache__/apps.cpython-37.pyc b/EduSystemServer/teacher/__pycache__/apps.cpython-37.pyc
new file mode 100644
index 0000000..f479f47
Binary files /dev/null and b/EduSystemServer/teacher/__pycache__/apps.cpython-37.pyc differ
diff --git a/EduSystemServer/teacher/__pycache__/models.cpython-36.pyc b/EduSystemServer/teacher/__pycache__/models.cpython-36.pyc
new file mode 100644
index 0000000..e71729d
Binary files /dev/null and b/EduSystemServer/teacher/__pycache__/models.cpython-36.pyc differ
diff --git a/EduSystemServer/teacher/__pycache__/models.cpython-37.pyc b/EduSystemServer/teacher/__pycache__/models.cpython-37.pyc
index 495ea71..a6bd9eb 100644
Binary files a/EduSystemServer/teacher/__pycache__/models.cpython-37.pyc and b/EduSystemServer/teacher/__pycache__/models.cpython-37.pyc differ
diff --git a/EduSystemServer/teacher/__pycache__/urls.cpython-36.pyc b/EduSystemServer/teacher/__pycache__/urls.cpython-36.pyc
new file mode 100644
index 0000000..5ccba58
Binary files /dev/null and b/EduSystemServer/teacher/__pycache__/urls.cpython-36.pyc differ
diff --git a/EduSystemServer/teacher/__pycache__/views.cpython-36.pyc b/EduSystemServer/teacher/__pycache__/views.cpython-36.pyc
new file mode 100644
index 0000000..fa1a25b
Binary files /dev/null and b/EduSystemServer/teacher/__pycache__/views.cpython-36.pyc differ
diff --git a/EduSystemServer/teacher/migrations/0001_initial.py b/EduSystemServer/teacher/migrations/0001_initial.py
index b8454b3..0148b23 100644
--- a/EduSystemServer/teacher/migrations/0001_initial.py
+++ b/EduSystemServer/teacher/migrations/0001_initial.py
@@ -1,4 +1,4 @@
-# Generated by Django 2.1 on 2023-09-06 14:01
+# Generated by Django 2.1 on 2023-09-07 13:49
from django.db import migrations, models
@@ -15,11 +15,11 @@ class Migration(migrations.Migration):
name='Teacher',
fields=[
('tid', models.AutoField(primary_key=True, serialize=False, verbose_name='教师编号')),
- ('t_name', models.CharField(max_length=255, verbose_name='教师名称')),
- ('t_sex', models.CharField(max_length=128, verbose_name='教师性别')),
- ('t_title', models.CharField(max_length=128, verbose_name='教师职称')),
- ('t_education', models.CharField(max_length=128, verbose_name='教师学历')),
- ('t_dept', models.CharField(max_length=128, verbose_name='教师所属院系')),
+ ('name', models.CharField(blank=True, max_length=255, verbose_name='教师名称')),
+ ('sex', models.CharField(blank=True, max_length=128, verbose_name='教师性别')),
+ ('title', models.CharField(blank=True, max_length=128, verbose_name='教师职称')),
+ ('education', models.CharField(blank=True, max_length=128, verbose_name='教师学历')),
+ ('dept', models.CharField(blank=True, max_length=128, verbose_name='教师所属院系')),
],
options={
'verbose_name': '教师',
diff --git a/EduSystemServer/teacher/migrations/0002_auto_20230907_0859.py b/EduSystemServer/teacher/migrations/0002_auto_20230907_0859.py
new file mode 100644
index 0000000..496b1c5
--- /dev/null
+++ b/EduSystemServer/teacher/migrations/0002_auto_20230907_0859.py
@@ -0,0 +1,38 @@
+# Generated by Django 3.2.13 on 2023-09-07 08:59
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('teacher', '0001_initial'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='teacher',
+ name='t_dept',
+ field=models.CharField(blank=True, max_length=128, verbose_name='教师所属院系'),
+ ),
+ migrations.AlterField(
+ model_name='teacher',
+ name='t_education',
+ field=models.CharField(blank=True, max_length=128, verbose_name='教师学历'),
+ ),
+ migrations.AlterField(
+ model_name='teacher',
+ name='t_name',
+ field=models.CharField(blank=True, max_length=255, verbose_name='教师名称'),
+ ),
+ migrations.AlterField(
+ model_name='teacher',
+ name='t_sex',
+ field=models.CharField(blank=True, max_length=128, verbose_name='教师性别'),
+ ),
+ migrations.AlterField(
+ model_name='teacher',
+ name='t_title',
+ field=models.CharField(blank=True, max_length=128, verbose_name='教师职称'),
+ ),
+ ]
diff --git a/EduSystemServer/teacher/migrations/__pycache__/0001_initial.cpython-36.pyc b/EduSystemServer/teacher/migrations/__pycache__/0001_initial.cpython-36.pyc
new file mode 100644
index 0000000..ee58bd3
Binary files /dev/null and b/EduSystemServer/teacher/migrations/__pycache__/0001_initial.cpython-36.pyc differ
diff --git a/EduSystemServer/teacher/migrations/__pycache__/0001_initial.cpython-37.pyc b/EduSystemServer/teacher/migrations/__pycache__/0001_initial.cpython-37.pyc
new file mode 100644
index 0000000..d917461
Binary files /dev/null and b/EduSystemServer/teacher/migrations/__pycache__/0001_initial.cpython-37.pyc differ
diff --git a/EduSystemServer/teacher/migrations/__pycache__/0002_auto_20230907_0859.cpython-36.pyc b/EduSystemServer/teacher/migrations/__pycache__/0002_auto_20230907_0859.cpython-36.pyc
new file mode 100644
index 0000000..00d8935
Binary files /dev/null and b/EduSystemServer/teacher/migrations/__pycache__/0002_auto_20230907_0859.cpython-36.pyc differ
diff --git a/EduSystemServer/teacher/migrations/__pycache__/__init__.cpython-36.pyc b/EduSystemServer/teacher/migrations/__pycache__/__init__.cpython-36.pyc
new file mode 100644
index 0000000..c867ece
Binary files /dev/null and b/EduSystemServer/teacher/migrations/__pycache__/__init__.cpython-36.pyc differ
diff --git a/EduSystemServer/teacher/migrations/__pycache__/__init__.cpython-37.pyc b/EduSystemServer/teacher/migrations/__pycache__/__init__.cpython-37.pyc
new file mode 100644
index 0000000..7039091
Binary files /dev/null and b/EduSystemServer/teacher/migrations/__pycache__/__init__.cpython-37.pyc differ
diff --git a/EduSystemServer/teacher/models.py b/EduSystemServer/teacher/models.py
index 7308cc0..1d6056c 100644
--- a/EduSystemServer/teacher/models.py
+++ b/EduSystemServer/teacher/models.py
@@ -10,6 +10,7 @@ class Teacher(models.Model):
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}