updata models

scl-branch
jisyoona 1 year ago
parent ee2fc5dfd9
commit ad8e8b58d9

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.6" project-jdk-type="Python SDK" />
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9" project-jdk-type="Python SDK" />
</project>

@ -14,21 +14,7 @@
</component>
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<<<<<<< Updated upstream
=======
<<<<<<< Updated upstream
>>>>>>> Stashed changes
<<<<<<< HEAD
<orderEntry type="jdk" jdkName="Python 3.8 (2)" jdkType="Python SDK" />
=======
<orderEntry type="jdk" jdkName="Python 3.7 (EduSystemServer)" jdkType="Python SDK" />
>>>>>>> 7b09141c358f80dd8877b8665d0d55b629db72aa
<<<<<<< Updated upstream
=======
=======
<orderEntry type="jdk" jdkName="Python 3.7 (EduSystemServer)" jdkType="Python SDK" />
>>>>>>> Stashed changes
>>>>>>> Stashed changes
<orderEntry type="jdk" jdkName="Python 3.9" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TemplatesService">

@ -1,20 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="edu_sys@localhost" uuid="fc67d607-329d-4381-af5b-a0e372257c56">
<data-source source="LOCAL" name="@localhost" uuid="9660bbaf-5fdd-4aa5-8754-d2dc6487fc96">
<driver-ref>mysql.8</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
<jdbc-url>jdbc:mysql://localhost:3306/edu_sys</jdbc-url>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
<data-source source="LOCAL" name="Django default" uuid="ffb088a0-406e-44b2-aed0-9587474966bf">
<driver-ref>mysql.8</driver-ref>
<synchronize>true</synchronize>
<imported>true</imported>
<remarks>$PROJECT_DIR$/EduSystemServer/settings.py</remarks>
<jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
<jdbc-url>jdbc:mysql://127.0.0.1:3306/edu_sys</jdbc-url>
<jdbc-url>jdbc:mysql://localhost:3306</jdbc-url>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
</component>

@ -1,18 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<<<<<<< Updated upstream
=======
<<<<<<< Updated upstream
>>>>>>> Stashed changes
<<<<<<< HEAD
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8 (2)" project-jdk-type="Python SDK" />
=======
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7 (EduSystemServer)" project-jdk-type="Python SDK" />
>>>>>>> 7b09141c358f80dd8877b8665d0d55b629db72aa
<<<<<<< Updated upstream
=======
=======
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7 (EduSystemServer)" project-jdk-type="Python SDK" />
>>>>>>> Stashed changes
>>>>>>> Stashed changes
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9" project-jdk-type="Python SDK" />
</project>

@ -12,9 +12,7 @@ https://docs.djangoproject.com/en/2.2/ref/settings/
import os
<<<<<<< Updated upstream
=======
CORS_ALLOW_ORIGIN_WHITELIST = [
"http://localhost:8080", # 允许访问的来源
"http://localhost:8000", # 允许访问的来源
@ -22,7 +20,7 @@ CORS_ALLOW_ORIGIN_WHITELIST = [
]
CORS_ALLOW_CREDENTIALS = True # 允许跨域请求携带凭据例如Cookies
>>>>>>> Stashed changes
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
@ -65,7 +63,7 @@ MIDDLEWARE = [
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'corsheaders.middleware.CorsMiddleware',
<<<<<<< Updated upstream
'django.middleware.common.CommonMiddleware',
# 'API.middle.AuthMiddleware',
]
@ -86,13 +84,6 @@ CORS_ALLOW_HEADERS = (
'Pragma',
)
=======
# 'API.middle.AuthMiddleware',
]
>>>>>>> Stashed changes
ROOT_URLCONF = 'EduSystemServer.urls'
TEMPLATES = [

@ -16,26 +16,13 @@ Including another URLconf
from django.contrib import admin
from django.urls import path, include
from API.views import login, get_user_info
<<<<<<< Updated upstream
=======
>>>>>>> Stashed changes
urlpatterns = [
path('Eduadmin/', admin.site.urls),
path('api/', include(("API.urls", "api"), namespace="api")),
<<<<<<< Updated upstream
=======
<<<<<<< Updated upstream
>>>>>>> Stashed changes
path('api/', include(("API.urls", "API"), namespace="api")),
path('teacher/', include(("teacher.urls", "teacher"), namespace="teacher")),
path('student/', include(("Student.urls", "student"), namespace="student")),
path('student/', include(("Student.urls", "Student"), namespace="student")),
path('course/', include(("course.urls", "course"), namespace="course")),
=======
path('student/', include(("Student.urls", "studnet"), namespace="student")),
>>>>>>> Stashed changes
path('login', login),
path('userinfo', get_user_info),
]

@ -12,37 +12,37 @@ class Migration(migrations.Migration):
operations = [
migrations.AlterField(
model_name='student',
name='s_class_name',
name='class_name',
field=models.CharField(blank=True, max_length=50, verbose_name='班级'),
),
migrations.AlterField(
model_name='student',
name='s_grade',
name='grade',
field=models.CharField(blank=True, max_length=20, verbose_name='年级'),
),
migrations.AlterField(
model_name='student',
name='s_major',
name='major',
field=models.CharField(blank=True, max_length=50, verbose_name='专业名称'),
),
migrations.AlterField(
model_name='student',
name='s_name',
name='name',
field=models.CharField(blank=True, max_length=100, verbose_name='姓名'),
),
migrations.AlterField(
model_name='student',
name='s_password',
name='password',
field=models.CharField(blank=True, max_length=100, verbose_name='密码'),
),
migrations.AlterField(
model_name='student',
name='s_sex',
name='sex',
field=models.CharField(blank=True, max_length=4, verbose_name='性别'),
),
migrations.AlterField(
model_name='student',
name='s_username',
name='username',
field=models.CharField(blank=True, max_length=30, verbose_name='用户名称'),
),
migrations.AlterField(

@ -4,38 +4,6 @@ from django.db import models
# Create your models here.
class Student(models.Model):
sid = models.AutoField(primary_key=True, verbose_name="学生编号", name="sid")
<<<<<<< Updated upstream
=======
<<<<<<< Updated upstream
>>>>>>> Stashed changes
<<<<<<< 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)
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, "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
<<<<<<< Updated upstream
=======
=======
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)
@ -47,9 +15,6 @@ class Student(models.Model):
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}
>>>>>>> Stashed changes
>>>>>>> Stashed changes
class Meta:
db_table = "student"
verbose_name = "学生"

@ -1,22 +1,13 @@
from django.shortcuts import render
# Create your views here.
from django.http import JsonResponse
<<<<<<< Updated upstream
from .models import Student
=======
<<<<<<< HEAD
from EduSystemServer.utils import ResponseUtil
from Student.models import Student
=======
from .models import Student
>>>>>>> 1e084d20f30e0b66d5e309a483f87ce5cfe06c39
>>>>>>> Stashed changes
from django.views.decorators.csrf import csrf_exempt
from django.http import QueryDict
from io import BytesIO
from django.http.multipartparser import MultiPartParser
import json
@csrf_exempt
@ -34,47 +25,48 @@ def studnets(request):
student.class_name = request_data.get("class_name")
student.major = request_data.get("major")
student.save()
response = ResponseUtil.ok(student.to_dict(), "更新成功!")
response = ResponseUtil.ok(student.to_dict(), "添加成功!")
return JsonResponse(response)
except Exception as E:
return JsonResponse(ResponseUtil.error(E))
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')
name = request.GET.get('name')
sex = request.GET.get('sex')
grade = request.GET.get('grade')
class_name = request.GET.get('class_name')
major = request.GET.get('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)
elif name:
filtered = Student.objects.filter(name=name)
for student in filtered:
data.append(student.to_dict())
elif s_sex:
filtered = Student.objects.filter(s_sex=s_sex)
elif sex:
filtered = Student.objects.filter(sex=sex)
for student in filtered:
data.append(student.to_dict())
elif s_grade:
filtered = Student.objects.filter(s_grade=s_grade)
elif grade:
filtered = Student.objects.filter(grade=grade)
for student in filtered:
data.append(student.to_dict())
elif s_class_name:
filtered = Student.objects.filter(s_class_name=s_class_name)
elif class_name:
filtered = Student.objects.filter(class_name=class_name)
for student in filtered:
data.append(student.to_dict())
elif s_major:
filtered = Student.objects.filter(s_major=s_major)
elif major:
filtered = Student.objects.filter(major=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)
response = ResponseUtil.ok(data, "查询成功!")
return JsonResponse(response)
elif request.method == "DELETE":
parser = MultiPartParser(request.META, BytesIO(request.body), request.upload_handlers, request.encoding)
post_dict = parser.parse()
@ -82,42 +74,31 @@ def studnets(request):
try:
info = Student.objects.filter(sid=sid).get().to_dict()
Student.objects.filter(sid=sid).delete()
response = {"code": 200, "message": "删除成功!", "data": info}
response = ResponseUtil.ok(info, "删除成功!")
return JsonResponse(response)
except:
response = {"code": 200, "message": "删除失败,未找到学生信息!"}
return JsonResponse(response)
return JsonResponse(ResponseUtil.error("删除失败,未找到学生信息!"))
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']
username = put[0]['username']
name = put[0]['name']
sex = put[0]['sex']
grade = put[0]['grade']
class_name = put[0]['class_name']
major = put[0]['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)
Student.objects.filter(sid=sid).update(username=username, name=name, sex=sex, grade=grade,
class_name=class_name,
major=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)
Student.objects.create(sid=sid, username=username, name=name, sex=sex, grade=grade,
class_name=class_name,
major=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)
elif request.method == 'DELETE':
params = QueryDict(request.body)
key = next(iter(params.keys())) # 获取键名
value = params.get(key) # 获取值
xx = str(value).split('-')[0]
print(xx.split('\r\n'))
return JsonResponse({'code': 200, 'msg': 'success'}, safe=False)
return JsonResponse(ResponseUtil.ok(data, "修改成功!"))
def get_select_course_by_id(request):
pass

@ -12,12 +12,12 @@ class Migration(migrations.Migration):
operations = [
migrations.AlterField(
model_name='course',
name='c_name',
name='name',
field=models.CharField(blank=True, max_length=255, verbose_name='课程名称'),
),
migrations.AlterField(
model_name='course',
name='c_type',
name='type',
field=models.CharField(blank=True, max_length=128, verbose_name='课程类型'),
),
]

@ -13,7 +13,7 @@ class Course(models.Model):
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,
return {"cid": self.cid, "name": self.name, "type": self.type, "credit": self.credit,
"tid": self.tid}
class Meta:

@ -12,27 +12,27 @@ class Migration(migrations.Migration):
operations = [
migrations.AlterField(
model_name='teacher',
name='t_dept',
name='dept',
field=models.CharField(blank=True, max_length=128, verbose_name='教师所属院系'),
),
migrations.AlterField(
model_name='teacher',
name='t_education',
name='education',
field=models.CharField(blank=True, max_length=128, verbose_name='教师学历'),
),
migrations.AlterField(
model_name='teacher',
name='t_name',
name='name',
field=models.CharField(blank=True, max_length=255, verbose_name='教师名称'),
),
migrations.AlterField(
model_name='teacher',
name='t_sex',
name='sex',
field=models.CharField(blank=True, max_length=128, verbose_name='教师性别'),
),
migrations.AlterField(
model_name='teacher',
name='t_title',
name='title',
field=models.CharField(blank=True, max_length=128, verbose_name='教师职称'),
),
]

Loading…
Cancel
Save