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 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__/urls.cpython-37.pyc b/EduSystemServer/API/__pycache__/urls.cpython-37.pyc
index fde68bc..d0e5e43 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-37.pyc b/EduSystemServer/API/__pycache__/views.cpython-37.pyc
index 815b487..67ffb3d 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/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 8ea2b0a..b8e0d6c 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-37.pyc b/EduSystemServer/EduSystemServer/__pycache__/urls.cpython-37.pyc
index 9930cea..657ef8d 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..284e6ad
Binary files /dev/null and b/EduSystemServer/EduSystemServer/__pycache__/utils.cpython-37.pyc differ
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 0000000..89af00e
Binary files /dev/null and b/EduSystemServer/Eduadmin/__pycache__/apps.cpython-37.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/__pycache__/0001_initial.cpython-37.pyc b/EduSystemServer/Eduadmin/migrations/__pycache__/0001_initial.cpython-37.pyc
new file mode 100644
index 0000000..11aa473
Binary files /dev/null and b/EduSystemServer/Eduadmin/migrations/__pycache__/0001_initial.cpython-37.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__/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-37.pyc b/EduSystemServer/Student/__pycache__/models.cpython-37.pyc
index cd68912..ceec81f 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-37.pyc b/EduSystemServer/Student/__pycache__/urls.cpython-37.pyc
new file mode 100644
index 0000000..c4da221
Binary files /dev/null and b/EduSystemServer/Student/__pycache__/urls.cpython-37.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..da4ae69
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/__pycache__/0001_initial.cpython-37.pyc b/EduSystemServer/Student/migrations/__pycache__/0001_initial.cpython-37.pyc
new file mode 100644
index 0000000..4493e78
Binary files /dev/null and b/EduSystemServer/Student/migrations/__pycache__/0001_initial.cpython-37.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 daa5a52..138d99b 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")
- 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)
- 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)
+ 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, "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}
+ 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}
class Meta:
db_table = "student"
diff --git a/EduSystemServer/Student/urls.py b/EduSystemServer/Student/urls.py
index 594bc98..518c9e4 100644
--- a/EduSystemServer/Student/urls.py
+++ b/EduSystemServer/Student/urls.py
@@ -4,4 +4,5 @@ from Student.views import *
urlpatterns = [
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 e177196..7ee3e1f 100644
--- a/EduSystemServer/Student/views.py
+++ b/EduSystemServer/Student/views.py
@@ -19,6 +19,14 @@ def studnets(request):
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)
@@ -90,3 +98,12 @@ def studnets(request):
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:
+ response_json["data"].append(student.to_dict())
+ return JsonResponse(response_json)
+
+
+def get_select_course_by_id(request):
+ pass
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-37.pyc b/EduSystemServer/course/__pycache__/models.cpython-37.pyc
index 144b12c..a7d2704 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__/views.cpython-37.pyc b/EduSystemServer/course/__pycache__/views.cpython-37.pyc
new file mode 100644
index 0000000..2244580
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/__pycache__/0001_initial.cpython-37.pyc b/EduSystemServer/course/migrations/__pycache__/0001_initial.cpython-37.pyc
new file mode 100644
index 0000000..6504fc1
Binary files /dev/null and b/EduSystemServer/course/migrations/__pycache__/0001_initial.cpython-37.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 c9d7d8d..4f56f8e 100644
--- a/EduSystemServer/course/models.py
+++ b/EduSystemServer/course/models.py
@@ -7,8 +7,8 @@ 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")
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-37.pyc b/EduSystemServer/teacher/__pycache__/models.cpython-37.pyc
index 495ea71..0544e4d 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/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/__pycache__/0001_initial.cpython-37.pyc b/EduSystemServer/teacher/migrations/__pycache__/0001_initial.cpython-37.pyc
new file mode 100644
index 0000000..de517af
Binary files /dev/null and b/EduSystemServer/teacher/migrations/__pycache__/0001_initial.cpython-37.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 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"