Skip to content

Commit 351cbdd

Browse files
committed
规则库
0 parents  commit 351cbdd

30 files changed

+12396
-0
lines changed

Production/__init__.py

Whitespace-only changes.

Production/asgi.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
ASGI config for Production project.
3+
4+
It exposes the ASGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.asgi import get_asgi_application
13+
14+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Production.settings")
15+
16+
application = get_asgi_application()

Production/settings.py

+128
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
"""
2+
Django settings for Production project.
3+
4+
Generated by 'django-admin startproject' using Django 4.2.11.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/4.2/topics/settings/
8+
9+
For the full list of settings and their values, see
10+
https://docs.djangoproject.com/en/4.2/ref/settings/
11+
"""
12+
13+
from pathlib import Path
14+
15+
# Build paths inside the project like this: BASE_DIR / 'subdir'.
16+
BASE_DIR = Path(__file__).resolve().parent.parent
17+
18+
19+
# Quick-start development settings - unsuitable for production
20+
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
21+
22+
# SECURITY WARNING: keep the secret key used in production secret!
23+
SECRET_KEY = "django-insecure-bgs357n&iae0(650l4#nfpur9r%9k_5!e^0yj0wc&-#im2x@p^"
24+
25+
# SECURITY WARNING: don't run with debug turned on in production!
26+
DEBUG = True
27+
28+
ALLOWED_HOSTS = []
29+
30+
31+
# Application definition
32+
33+
INSTALLED_APPS = [
34+
"django.contrib.admin",
35+
"django.contrib.auth",
36+
"django.contrib.contenttypes",
37+
"django.contrib.sessions",
38+
"django.contrib.messages",
39+
"django.contrib.staticfiles",
40+
"app",
41+
"corsheaders",
42+
]
43+
44+
MIDDLEWARE = [
45+
"corsheaders.middleware.CorsMiddleware",
46+
"django.middleware.security.SecurityMiddleware",
47+
"django.contrib.sessions.middleware.SessionMiddleware",
48+
"django.middleware.common.CommonMiddleware",
49+
# "django.middleware.csrf.CsrfViewMiddleware",
50+
"django.contrib.auth.middleware.AuthenticationMiddleware",
51+
"django.contrib.messages.middleware.MessageMiddleware",
52+
"django.middleware.clickjacking.XFrameOptionsMiddleware",
53+
]
54+
55+
ROOT_URLCONF = "Production.urls"
56+
57+
TEMPLATES = [
58+
{
59+
"BACKEND": "django.template.backends.django.DjangoTemplates",
60+
"DIRS": [],
61+
"APP_DIRS": True,
62+
"OPTIONS": {
63+
"context_processors": [
64+
"django.template.context_processors.debug",
65+
"django.template.context_processors.request",
66+
"django.contrib.auth.context_processors.auth",
67+
"django.contrib.messages.context_processors.messages",
68+
],
69+
},
70+
},
71+
]
72+
73+
WSGI_APPLICATION = "Production.wsgi.application"
74+
75+
76+
# Database
77+
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
78+
79+
DATABASES = {
80+
"default": {
81+
"ENGINE": "django.db.backends.sqlite3",
82+
"NAME": BASE_DIR / "db.sqlite3",
83+
}
84+
}
85+
86+
87+
# Password validation
88+
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
89+
90+
AUTH_PASSWORD_VALIDATORS = [
91+
{
92+
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
93+
},
94+
{
95+
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
96+
},
97+
{
98+
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
99+
},
100+
{
101+
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
102+
},
103+
]
104+
105+
106+
# Internationalization
107+
# https://docs.djangoproject.com/en/4.2/topics/i18n/
108+
109+
LANGUAGE_CODE = "en-us"
110+
111+
TIME_ZONE = "UTC"
112+
113+
USE_I18N = True
114+
115+
USE_TZ = True
116+
117+
118+
# Static files (CSS, JavaScript, Images)
119+
# https://docs.djangoproject.com/en/4.2/howto/static-files/
120+
121+
STATIC_URL = "static/"
122+
123+
# Default primary key field type
124+
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
125+
126+
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
127+
CORS_ORIGIN_ALLOW_ALL = True
128+
CORS_ALLOW_CREDENTIALS = True

Production/urls.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"""
2+
URL configuration for Production project.
3+
4+
The `urlpatterns` list routes URLs to views. For more information please see:
5+
https://docs.djangoproject.com/en/4.2/topics/http/urls/
6+
Examples:
7+
Function views
8+
1. Add an import: from my_app import views
9+
2. Add a URL to urlpatterns: path('', views.home, name='home')
10+
Class-based views
11+
1. Add an import: from other_app.views import Home
12+
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
13+
Including another URLconf
14+
1. Import the include() function: from django.urls import include, path
15+
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
16+
"""
17+
from django.contrib import admin
18+
from django.urls import path
19+
from app import views
20+
21+
urlpatterns = [
22+
path("api/getnode/", views.getnode),
23+
path("api/getedge/", views.getedge),
24+
]

Production/wsgi.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
WSGI config for Production project.
3+
4+
It exposes the WSGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/4.2/howto/deployment/wsgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.wsgi import get_wsgi_application
13+
14+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Production.settings")
15+
16+
application = get_wsgi_application()

app/__init__.py

Whitespace-only changes.

app/admin.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.contrib import admin
2+
3+
# Register your models here.

app/apps.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from django.apps import AppConfig
2+
3+
4+
class AppConfig(AppConfig):
5+
default_auto_field = "django.db.models.BigAutoField"
6+
name = "app"

app/migrations/__init__.py

Whitespace-only changes.

app/models.py

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from django.db import models
2+
3+
# Create your models here.
4+
5+
class Edge(models.Model):
6+
id = models.IntegerField(primary_key=True)
7+
node1 = models.IntegerField(blank=True, null=True)
8+
node2 = models.IntegerField(blank=True, null=True)
9+
10+
class Meta:
11+
managed = False
12+
db_table = 'edge'
13+
14+
15+
class Node(models.Model):
16+
id = models.IntegerField(primary_key=True)
17+
description = models.CharField(max_length=100, blank=True, null=True)
18+
19+
class Meta:
20+
managed = False
21+
db_table = 'node'

app/tests.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.test import TestCase
2+
3+
# Create your tests here.

app/views.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from django.http import JsonResponse
2+
from app.models import Node,Edge
3+
4+
# Create your views here.
5+
6+
def getnode(request):
7+
res=list(Node.objects.all().values())
8+
return JsonResponse({
9+
'data':res,
10+
'code':200,
11+
})
12+
13+
def getedge(request):
14+
res=list(Edge.objects.all().values())
15+
return JsonResponse({
16+
'data':res,
17+
'code':200,
18+
})

create.sql

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
DROP TABLE IF EXISTS node;
2+
DROP TABLE IF EXISTS edge;
3+
CREATE TABLE node(
4+
id INTEGER,
5+
description VARCHAR(50)
6+
);
7+
CREATE TABLE edge(
8+
id INTEGER PRIMARY KEY,
9+
node1 INTEGER,
10+
node2 INTEGER
11+
);
12+
INSERT INTO node(id,description) VALUES
13+
(1,'高度不超过几米'),
14+
(2,'在开花和结果后会整个植株枯死'),
15+
(3,'茎部柔软'),
16+
(4,'茎部中空'),
17+
(5,'叶子为长条形或披针形'),
18+
(6,'花为黄色'),
19+
(7,'果实为荚果'),
20+
(8,'植物为攀援植物或灌木'),
21+
(9,'花为白色或粉色'),
22+
(10,'果实为蒴果'),
23+
(11,'叶子为心形或箭头形'),
24+
(12,'叶子为羽状复叶'),
25+
(13,'果实为豆荚状'),
26+
(14,'花为紫色或白色'),
27+
(15,'植物的高度超过2米'),
28+
(16,'草本植物'),
29+
(17,'向日葵'),
30+
(18,'凌霄花'),
31+
(19,'豌豆'),
32+
(20,'紫丁香');
33+
INSERT INTO edge(node1,node2) VALUES
34+
(1,16),
35+
(2,16),
36+
(3,16),
37+
(4,17),
38+
(5,17),
39+
(6,17),
40+
(7,17),
41+
(8,18),
42+
(9,18),
43+
(10,18),
44+
(11,18),
45+
(12,19),
46+
(13,19),
47+
(14,19),
48+
(11,20),
49+
(13,20),
50+
(14,20),
51+
(15,20),
52+
(16,17),
53+
(16,18);

db.sqlite3

16 KB
Binary file not shown.

frontend/.gitignore

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
.DS_Store
2+
node_modules
3+
/dist
4+
5+
6+
# local env files
7+
.env.local
8+
.env.*.local
9+
10+
# Log files
11+
npm-debug.log*
12+
yarn-debug.log*
13+
yarn-error.log*
14+
pnpm-debug.log*
15+
16+
# Editor directories and files
17+
.idea
18+
.vscode
19+
*.suo
20+
*.ntvs*
21+
*.njsproj
22+
*.sln
23+
*.sw?

frontend/README.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# frontend
2+
3+
## Project setup
4+
```
5+
npm install
6+
```
7+
8+
### Compiles and hot-reloads for development
9+
```
10+
npm run serve
11+
```
12+
13+
### Compiles and minifies for production
14+
```
15+
npm run build
16+
```
17+
18+
### Lints and fixes files
19+
```
20+
npm run lint
21+
```
22+
23+
### Customize configuration
24+
See [Configuration Reference](https://cli.vuejs.org/config/).

frontend/babel.config.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
presets: [
3+
'@vue/cli-plugin-babel/preset'
4+
]
5+
}

frontend/jsconfig.json

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es5",
4+
"module": "esnext",
5+
"baseUrl": "./",
6+
"moduleResolution": "node",
7+
"paths": {
8+
"@/*": [
9+
"src/*"
10+
]
11+
},
12+
"lib": [
13+
"esnext",
14+
"dom",
15+
"dom.iterable",
16+
"scripthost"
17+
]
18+
}
19+
}

0 commit comments

Comments
 (0)