diff --git a/.idea/dataSources.local.xml b/.idea/dataSources.local.xml
new file mode 100644
index 0000000..10cd63f
--- /dev/null
+++ b/.idea/dataSources.local.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+ forget
+
+
+
+
\ No newline at end of file
diff --git a/.idea/shelf/Update_at_2022_5_5_22_17__Default_Changelist_.xml b/.idea/shelf/Update_at_2022_5_5_22_17__Default_Changelist_.xml
new file mode 100644
index 0000000..c530e64
--- /dev/null
+++ b/.idea/shelf/Update_at_2022_5_5_22_17__Default_Changelist_.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/shelf/在Update之前未提交更改_at_2022_5_5_22_17_[Default_Changelist]/shelved.patch b/.idea/shelf/在Update之前未提交更改_at_2022_5_5_22_17_[Default_Changelist]/shelved.patch
new file mode 100644
index 0000000..bce2098
--- /dev/null
+++ b/.idea/shelf/在Update之前未提交更改_at_2022_5_5_22_17_[Default_Changelist]/shelved.patch
@@ -0,0 +1,201 @@
+Index: Apps/work/serializers.py
+IDEA additional info:
+Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
+<+>from rest_framework import serializers\r\nfrom .models import *\r\n\r\n\r\nclass HistoryInfoSerializer(serializers.ModelSerializer):\r\n class Meta:\r\n model = Works\r\n fields = '__all__'\r\n grade = serializers.CharField(label=\"年级\", required=True)\r\n name = serializers.CharField(label=\"事件名称\", max_length=30, required=True)\r\n description = serializers.CharField(label=\"事件描述\", max_length=200, required=True)\r\n img = serializers.ImageField(label=\"图片\", required=False)\r\n\r\n def validate_grade(self, value):\r\n if not (2010 < value <= 2021):\r\n raise serializers.ValidationError(\"不合法输入\")\r\n return value
+Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
+<+>UTF-8
+===================================================================
+--- Apps/work/serializers.py (revision c5874e8f6a4093a11d6cc1c13caa09639ef0ceeb)
++++ Apps/work/serializers.py (date 1651759994408)
+@@ -2,7 +2,7 @@
+ from .models import *
+
+
+-class HistoryInfoSerializer(serializers.ModelSerializer):
++class WorksInfoSerializer(serializers.ModelSerializer):
+ class Meta:
+ model = Works
+ fields = '__all__'
+@@ -11,6 +11,7 @@
+ description = serializers.CharField(label="事件描述", max_length=200, required=True)
+ img = serializers.ImageField(label="图片", required=False)
+
++
+ def validate_grade(self, value):
+ if not (2010 < value <= 2021):
+ raise serializers.ValidationError("不合法输入")
+Index: Apps/work/urls.py
+IDEA additional info:
+Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
+<+>from django.contrib import admin\r\nfrom django.urls import path\r\nfrom . import views\r\nfrom django.conf.urls.static import static\r\nfrom ITShowPlatform import settings\r\n\r\n\r\nurlpatterns = [\r\n path('work/', views.work.as_view()),\r\n]\r\n\r\nurlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
+Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
+<+>UTF-8
+===================================================================
+--- Apps/work/urls.py (revision c5874e8f6a4093a11d6cc1c13caa09639ef0ceeb)
++++ Apps/work/urls.py (date 1651759619601)
+@@ -9,4 +9,5 @@
+ path('work/', views.work.as_view()),
+ ]
+
+-urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
+\ No newline at end of file
++urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
++
+Index: .idea/workspace.xml
+IDEA additional info:
+Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
+<+>\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n 1650187837343\r\n \r\n \r\n 1650187837343\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n 1650187914913\r\n \r\n \r\n \r\n 1650187914913\r\n \r\n \r\n 1650785005055\r\n \r\n \r\n \r\n 1650785005055\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
+Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
+<+>UTF-8
+===================================================================
+--- .idea/workspace.xml (revision c5874e8f6a4093a11d6cc1c13caa09639ef0ceeb)
++++ .idea/workspace.xml (date 1651760172607)
+@@ -21,20 +21,15 @@
+
+
+
+-
++
+
+
+
+
+-
+-
+-
++
+
+-
+-
+-
+-
+-
++
++
+
+
+
+@@ -52,6 +47,11 @@
+
+
+
++
++
++
++
++
+
+
+
+@@ -152,7 +152,7 @@
+
+
+
+-
++
+
+
+ 1650187914913
+@@ -168,7 +168,14 @@
+
+ 1650785005055
+
+-
++
++ 1651759231786
++
++
++
++ 1651759231786
++
++
+
+
+
+@@ -185,7 +192,7 @@
+
+
+
+-
++
+
+
+
+@@ -202,7 +209,8 @@
+
+
+
+-
++
++
+
+
+
+@@ -234,26 +242,26 @@
+
+
+
+-
++
+
+
+
+-
+-
++
++
+
+
+
+-
+-
++
++
+
+
+
+-
+-
++
++
+
+
+
+-
++
+
+
+
+@@ -283,11 +291,11 @@
+
+
+
+-
++
+
+
+
+-
++
+
+
+
+@@ -304,9 +312,17 @@
+
+
+
++
++
++
++
+
+
+
+
++
++
++
++
+
+
+\ No newline at end of file
diff --git a/Apps/work/__init__.py b/Apps/work/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/Apps/work/admin.py b/Apps/work/admin.py
new file mode 100644
index 0000000..970b928
--- /dev/null
+++ b/Apps/work/admin.py
@@ -0,0 +1,6 @@
+from django.contrib import admin
+from .models import Works
+# Register your models here.
+
+admin.site.register(Works)
+
diff --git a/Apps/work/apps.py b/Apps/work/apps.py
new file mode 100644
index 0000000..1c07965
--- /dev/null
+++ b/Apps/work/apps.py
@@ -0,0 +1,6 @@
+from django.apps import AppConfig
+
+
+class WorksConfig(AppConfig):
+ default_auto_field = 'django.db.models.BigAutoField'
+ name = 'Apps.work'
diff --git a/Apps/work/migrations/0001_initial.py b/Apps/work/migrations/0001_initial.py
new file mode 100644
index 0000000..ce045ea
--- /dev/null
+++ b/Apps/work/migrations/0001_initial.py
@@ -0,0 +1,24 @@
+# Generated by Django 3.2.5 on 2022-05-05 21:56
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ initial = True
+
+ dependencies = [
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='Works',
+ fields=[
+ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('grade', models.IntegerField(verbose_name='年份')),
+ ('name', models.CharField(max_length=30, verbose_name='事件名称')),
+ ('description', models.CharField(max_length=200, verbose_name='事件描述')),
+ ('img', models.ImageField(upload_to='image', verbose_name='图片')),
+ ],
+ ),
+ ]
diff --git a/Apps/work/migrations/0002_alter_works_img.py b/Apps/work/migrations/0002_alter_works_img.py
new file mode 100644
index 0000000..d10f54b
--- /dev/null
+++ b/Apps/work/migrations/0002_alter_works_img.py
@@ -0,0 +1,18 @@
+# Generated by Django 3.2.5 on 2022-05-05 21:57
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('work', '0001_initial'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='works',
+ name='img',
+ field=models.ImageField(blank=True, null=True, upload_to='image', verbose_name='图片'),
+ ),
+ ]
diff --git a/Apps/work/migrations/__init__.py b/Apps/work/migrations/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/Apps/work/models.py b/Apps/work/models.py
new file mode 100644
index 0000000..2b5de0a
--- /dev/null
+++ b/Apps/work/models.py
@@ -0,0 +1,10 @@
+from django.db import models
+
+# Create your models here.
+
+
+class Works(models.Model):
+ grade = models.IntegerField(verbose_name="年份")
+ name = models.CharField(verbose_name="事件名称", max_length=30)
+ description = models.CharField(verbose_name="事件描述", max_length=200)
+ img = models.ImageField(verbose_name="图片", upload_to="image", null=True, blank=True)
diff --git a/Apps/work/serializers.py b/Apps/work/serializers.py
index 90a4fe3..b576c73 100644
--- a/Apps/work/serializers.py
+++ b/Apps/work/serializers.py
@@ -2,7 +2,7 @@ from rest_framework import serializers
from .models import *
-class HistoryInfoSerializer(serializers.ModelSerializer):
+class WorksInfoSerializer(serializers.ModelSerializer):
class Meta:
model = Works
fields = '__all__'
@@ -11,6 +11,7 @@ class HistoryInfoSerializer(serializers.ModelSerializer):
description = serializers.CharField(label="事件描述", max_length=200, required=True)
img = serializers.ImageField(label="图片", required=False)
+
def validate_grade(self, value):
if not (2010 < value <= 2021):
raise serializers.ValidationError("不合法输入")
diff --git a/Apps/work/tests.py b/Apps/work/tests.py
new file mode 100644
index 0000000..7ce503c
--- /dev/null
+++ b/Apps/work/tests.py
@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.
diff --git a/Apps/work/urls.py b/Apps/work/urls.py
index 33a66de..e0fdac6 100644
--- a/Apps/work/urls.py
+++ b/Apps/work/urls.py
@@ -9,4 +9,5 @@ urlpatterns = [
path('work/', views.work.as_view()),
]
-urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
\ No newline at end of file
+urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
+
diff --git a/Apps/work/views.py b/Apps/work/views.py
new file mode 100644
index 0000000..de680cd
--- /dev/null
+++ b/Apps/work/views.py
@@ -0,0 +1,35 @@
+import time
+from django.conf import settings
+import re
+from django.shortcuts import render
+from rest_framework.views import APIView
+from rest_framework.response import Response
+from .models import Works
+from .serializers import WorksInfoSerializer
+# Create your views here.
+
+
+class work(APIView):
+
+ def get(self, request):
+ key = []
+ data = {"data": key}
+ for i in range(2012, 2022):
+ temp = {}
+ try:
+ works_set = Works.objects.filter(grade=i)
+ if works_set:
+ serializer = WorksInfoSerializer(works_set, many=True)
+ temp['grade'] = i
+ temp['data'] = serializer.data
+ data['data'].append(temp)
+ except Exception:
+ pass
+ if len(data['data']) == 0:
+ data['code'] = 40000
+ data['msg'] = "error"
+ else:
+ data['code'] = 20000
+ data['msg'] = 'success'
+ return Response(data=data)
+
diff --git a/ITShowPlatform/.gitignore b/ITShowPlatform/.gitignore
index b9ad17b..2e9f9f4 100644
--- a/ITShowPlatform/.gitignore
+++ b/ITShowPlatform/.gitignore
@@ -1,3 +1,2 @@
config.ini
-settings.py