创建项目
This commit is contained in:
parent
0e489901c6
commit
c48a50c1a7
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
.idea/
|
||||||
|
.venv/
|
0
CMS_Django_Backend/__init__.py
Normal file
0
CMS_Django_Backend/__init__.py
Normal file
BIN
CMS_Django_Backend/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
CMS_Django_Backend/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
BIN
CMS_Django_Backend/__pycache__/settings.cpython-311.pyc
Normal file
BIN
CMS_Django_Backend/__pycache__/settings.cpython-311.pyc
Normal file
Binary file not shown.
BIN
CMS_Django_Backend/__pycache__/urls.cpython-311.pyc
Normal file
BIN
CMS_Django_Backend/__pycache__/urls.cpython-311.pyc
Normal file
Binary file not shown.
BIN
CMS_Django_Backend/__pycache__/wsgi.cpython-311.pyc
Normal file
BIN
CMS_Django_Backend/__pycache__/wsgi.cpython-311.pyc
Normal file
Binary file not shown.
16
CMS_Django_Backend/asgi.py
Normal file
16
CMS_Django_Backend/asgi.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
"""
|
||||||
|
ASGI config for CMS_Django_Backend project.
|
||||||
|
|
||||||
|
It exposes the ASGI callable as a module-level variable named ``application``.
|
||||||
|
|
||||||
|
For more information on this file, see
|
||||||
|
https://docs.djangoproject.com/en/5.1/howto/deployment/asgi/
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
from django.core.asgi import get_asgi_application
|
||||||
|
|
||||||
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'CMS_Django_Backend.settings')
|
||||||
|
|
||||||
|
application = get_asgi_application()
|
136
CMS_Django_Backend/settings.py
Normal file
136
CMS_Django_Backend/settings.py
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
"""
|
||||||
|
Django settings for CMS_Django_Backend project.
|
||||||
|
|
||||||
|
Generated by 'django-admin startproject' using Django 5.1.
|
||||||
|
|
||||||
|
For more information on this file, see
|
||||||
|
https://docs.djangoproject.com/en/5.1/topics/settings/
|
||||||
|
|
||||||
|
For the full list of settings and their values, see
|
||||||
|
https://docs.djangoproject.com/en/5.1/ref/settings/
|
||||||
|
"""
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||||
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||||
|
|
||||||
|
|
||||||
|
# Quick-start development settings - unsuitable for production
|
||||||
|
# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/
|
||||||
|
|
||||||
|
# SECURITY WARNING: keep the secret key used in production secret!
|
||||||
|
SECRET_KEY = 'django-insecure-mm$)j^vw#wtb$%f2m-=p@4d4ziy^-_zv^t21(i@9j+7+#eqzby'
|
||||||
|
|
||||||
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
|
DEBUG = True
|
||||||
|
|
||||||
|
ALLOWED_HOSTS = []
|
||||||
|
|
||||||
|
|
||||||
|
# Application definition
|
||||||
|
|
||||||
|
INSTALLED_APPS = [
|
||||||
|
# 'django.contrib.admin',
|
||||||
|
# 'django.contrib.auth',
|
||||||
|
'django.contrib.contenttypes',
|
||||||
|
# 'django.contrib.sessions',
|
||||||
|
# 'django.contrib.messages',
|
||||||
|
'django.contrib.staticfiles',
|
||||||
|
'apps.auth.apps.AuthConfig',
|
||||||
|
'apps.api.apps.ApiConfig',
|
||||||
|
]
|
||||||
|
|
||||||
|
MIDDLEWARE = [
|
||||||
|
# 'django.middleware.security.SecurityMiddleware',
|
||||||
|
# 'django.contrib.sessions.middleware.SessionMiddleware',
|
||||||
|
'django.middleware.common.CommonMiddleware',
|
||||||
|
'django.middleware.csrf.CsrfViewMiddleware',
|
||||||
|
# 'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||||
|
# 'django.contrib.messages.middleware.MessageMiddleware',
|
||||||
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||||
|
]
|
||||||
|
|
||||||
|
ROOT_URLCONF = 'CMS_Django_Backend.urls'
|
||||||
|
|
||||||
|
TEMPLATES = [
|
||||||
|
{
|
||||||
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||||
|
'DIRS': [BASE_DIR / 'templates']
|
||||||
|
,
|
||||||
|
'APP_DIRS': True,
|
||||||
|
'OPTIONS': {
|
||||||
|
'context_processors': [
|
||||||
|
'django.template.context_processors.debug',
|
||||||
|
'django.template.context_processors.request',
|
||||||
|
'django.contrib.auth.context_processors.auth',
|
||||||
|
'django.contrib.messages.context_processors.messages',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
WSGI_APPLICATION = 'CMS_Django_Backend.wsgi.application'
|
||||||
|
|
||||||
|
|
||||||
|
# Database
|
||||||
|
# https://docs.djangoproject.com/en/5.1/ref/settings/#databases
|
||||||
|
|
||||||
|
DATABASES = {
|
||||||
|
'default': {
|
||||||
|
'ENGINE': 'django.db.backends.sqlite3',
|
||||||
|
'NAME': BASE_DIR / 'data/db.sqlite3',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Password validation
|
||||||
|
# https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators
|
||||||
|
|
||||||
|
AUTH_PASSWORD_VALIDATORS = [
|
||||||
|
{
|
||||||
|
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
# Internationalization
|
||||||
|
# https://docs.djangoproject.com/en/5.1/topics/i18n/
|
||||||
|
|
||||||
|
LANGUAGE_CODE = 'en-us'
|
||||||
|
|
||||||
|
TIME_ZONE = 'UTC'
|
||||||
|
|
||||||
|
USE_I18N = True
|
||||||
|
|
||||||
|
USE_TZ = True
|
||||||
|
|
||||||
|
|
||||||
|
# Static files (CSS, JavaScript, Images)
|
||||||
|
# https://docs.djangoproject.com/en/5.1/howto/static-files/
|
||||||
|
|
||||||
|
STATIC_URL = 'static/'
|
||||||
|
|
||||||
|
# Default primary key field type
|
||||||
|
# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field
|
||||||
|
|
||||||
|
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||||
|
|
||||||
|
# session设置
|
||||||
|
# 设置会话cookie的有效期(默认为两周)
|
||||||
|
# SESSION_COOKIE_AGE = 1209600 # 2 weeks, in seconds
|
||||||
|
|
||||||
|
# 设置会话cookie的过期时间(默认为False,表示关闭浏览器时失效)
|
||||||
|
SESSION_EXPIRE_AT_BROWSER_CLOSE = True
|
||||||
|
|
||||||
|
# 如果设置了True,每次用户会话更新时,会话cookie的过期时间都会被更新
|
||||||
|
SESSION_SAVE_EVERY_REQUEST = False
|
26
CMS_Django_Backend/urls.py
Normal file
26
CMS_Django_Backend/urls.py
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
"""
|
||||||
|
URL configuration for CMS_Django_Backend project.
|
||||||
|
|
||||||
|
The `urlpatterns` list routes URLs to views. For more information please see:
|
||||||
|
https://docs.djangoproject.com/en/5.1/topics/http/urls/
|
||||||
|
Examples:
|
||||||
|
Function views
|
||||||
|
1. Add an import: from my_app import views
|
||||||
|
2. Add a URL to urlpatterns: path('', views.home, name='home')
|
||||||
|
Class-based views
|
||||||
|
1. Add an import: from other_app.views import Home
|
||||||
|
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
|
||||||
|
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 django.contrib import admin
|
||||||
|
from django.urls import path, include
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
# path('admin/', admin.site.urls),
|
||||||
|
# path('login', include('apps.login.urls'))
|
||||||
|
# path('auth', include('apps.auth.urls'))
|
||||||
|
path('api/', include('apps.api.urls')),
|
||||||
|
path('auth/', include('apps.auth.urls'))
|
||||||
|
]
|
16
CMS_Django_Backend/wsgi.py
Normal file
16
CMS_Django_Backend/wsgi.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
"""
|
||||||
|
WSGI config for CMS_Django_Backend project.
|
||||||
|
|
||||||
|
It exposes the WSGI callable as a module-level variable named ``application``.
|
||||||
|
|
||||||
|
For more information on this file, see
|
||||||
|
https://docs.djangoproject.com/en/5.1/howto/deployment/wsgi/
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
from django.core.wsgi import get_wsgi_application
|
||||||
|
|
||||||
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'CMS_Django_Backend.settings')
|
||||||
|
|
||||||
|
application = get_wsgi_application()
|
0
apps/api/__init__.py
Normal file
0
apps/api/__init__.py
Normal file
BIN
apps/api/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
apps/api/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
BIN
apps/api/__pycache__/apps.cpython-311.pyc
Normal file
BIN
apps/api/__pycache__/apps.cpython-311.pyc
Normal file
Binary file not shown.
BIN
apps/api/__pycache__/models.cpython-311.pyc
Normal file
BIN
apps/api/__pycache__/models.cpython-311.pyc
Normal file
Binary file not shown.
BIN
apps/api/__pycache__/urls.cpython-311.pyc
Normal file
BIN
apps/api/__pycache__/urls.cpython-311.pyc
Normal file
Binary file not shown.
BIN
apps/api/__pycache__/views.cpython-311.pyc
Normal file
BIN
apps/api/__pycache__/views.cpython-311.pyc
Normal file
Binary file not shown.
3
apps/api/admin.py
Normal file
3
apps/api/admin.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
# Register your models here.
|
6
apps/api/apps.py
Normal file
6
apps/api/apps.py
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class ApiConfig(AppConfig):
|
||||||
|
default_auto_field = 'django.db.models.BigAutoField'
|
||||||
|
name = 'apps.api'
|
28
apps/api/migrations/0001_initial.py
Normal file
28
apps/api/migrations/0001_initial.py
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
# Generated by Django 5.1 on 2024-08-17 09:50
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='SysConfig',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(primary_key=True, serialize=False, unique=True, verbose_name='id')),
|
||||||
|
('name', models.CharField(blank=True, max_length=50, null=True, unique=True, verbose_name='名称')),
|
||||||
|
('identity', models.CharField(blank=True, max_length=100, null=True, verbose_name='标识')),
|
||||||
|
('param', models.CharField(blank=True, max_length=200, null=True, verbose_name='参数')),
|
||||||
|
('desc', models.CharField(max_length=500, verbose_name='描述')),
|
||||||
|
('create_by', models.CharField(max_length=50, verbose_name='创建人')),
|
||||||
|
('create_time', models.DateTimeField(verbose_name='创建时间')),
|
||||||
|
('update_by', models.CharField(max_length=50, verbose_name='更新人')),
|
||||||
|
('update_time', models.DateTimeField(auto_now=True, verbose_name='更新时间')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
17
apps/api/migrations/0002_alter_sysconfig_options.py
Normal file
17
apps/api/migrations/0002_alter_sysconfig_options.py
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# Generated by Django 5.1 on 2024-08-17 15:22
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('api', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterModelOptions(
|
||||||
|
name='sysconfig',
|
||||||
|
options={'verbose_name': '系统配置表'},
|
||||||
|
),
|
||||||
|
]
|
0
apps/api/migrations/__init__.py
Normal file
0
apps/api/migrations/__init__.py
Normal file
BIN
apps/api/migrations/__pycache__/0001_initial.cpython-311.pyc
Normal file
BIN
apps/api/migrations/__pycache__/0001_initial.cpython-311.pyc
Normal file
Binary file not shown.
Binary file not shown.
BIN
apps/api/migrations/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
apps/api/migrations/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
24
apps/api/models.py
Normal file
24
apps/api/models.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
from django.db import models
|
||||||
|
|
||||||
|
|
||||||
|
# Create your models here.
|
||||||
|
class SysConfig(models.Model):
|
||||||
|
"""
|
||||||
|
系统配置表
|
||||||
|
"""
|
||||||
|
id = models.AutoField(verbose_name="id", primary_key=True, unique=True)
|
||||||
|
name = models.CharField(max_length=50, unique=True, verbose_name="名称", null=True, blank=True)
|
||||||
|
identity = models.CharField(max_length=100, verbose_name="标识", null=True, blank=True)
|
||||||
|
param = models.CharField(max_length=200, verbose_name="参数", null=True, blank=True)
|
||||||
|
desc = models.CharField(max_length=500, verbose_name="描述")
|
||||||
|
create_by = models.CharField(verbose_name="创建人", max_length=50)
|
||||||
|
create_time = models.DateTimeField(verbose_name="创建时间")
|
||||||
|
update_by = models.CharField(verbose_name="更新人", max_length=50)
|
||||||
|
update_time = models.DateTimeField(verbose_name="更新时间", auto_now=True)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.name
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
verbose_name = "系统配置表"
|
||||||
|
|
3
apps/api/tests.py
Normal file
3
apps/api/tests.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
6
apps/api/urls.py
Normal file
6
apps/api/urls.py
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
from django.urls import path
|
||||||
|
from apps.api import views
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
path("getconfig/", views.getconfig, name="getconfig"),
|
||||||
|
]
|
15
apps/api/views.py
Normal file
15
apps/api/views.py
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
from django.shortcuts import HttpResponse
|
||||||
|
from apps.api import models as m_api
|
||||||
|
from django.views.decorators.http import require_http_methods, require_POST, require_GET
|
||||||
|
|
||||||
|
|
||||||
|
# Create your views here.
|
||||||
|
@require_POST
|
||||||
|
def getconfig(request):
|
||||||
|
try:
|
||||||
|
param = request.POST.get("param")
|
||||||
|
title = m_api.SysConfig.objects.filter(identity=param).first().param
|
||||||
|
return HttpResponse(title)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"报错了:{e}")
|
||||||
|
return HttpResponse("报错了")
|
0
apps/auth/__init__.py
Normal file
0
apps/auth/__init__.py
Normal file
BIN
apps/auth/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
apps/auth/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
BIN
apps/auth/__pycache__/apps.cpython-311.pyc
Normal file
BIN
apps/auth/__pycache__/apps.cpython-311.pyc
Normal file
Binary file not shown.
BIN
apps/auth/__pycache__/models.cpython-311.pyc
Normal file
BIN
apps/auth/__pycache__/models.cpython-311.pyc
Normal file
Binary file not shown.
BIN
apps/auth/__pycache__/urls.cpython-311.pyc
Normal file
BIN
apps/auth/__pycache__/urls.cpython-311.pyc
Normal file
Binary file not shown.
BIN
apps/auth/__pycache__/views.cpython-311.pyc
Normal file
BIN
apps/auth/__pycache__/views.cpython-311.pyc
Normal file
Binary file not shown.
3
apps/auth/admin.py
Normal file
3
apps/auth/admin.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
# Register your models here.
|
6
apps/auth/apps.py
Normal file
6
apps/auth/apps.py
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class AuthConfig(AppConfig):
|
||||||
|
default_auto_field = 'django.db.models.BigAutoField'
|
||||||
|
name = 'apps.auth'
|
30
apps/auth/migrations/0001_initial.py
Normal file
30
apps/auth/migrations/0001_initial.py
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# Generated by Django 5.1 on 2024-08-17 15:22
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='User',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(primary_key=True, serialize=False, unique=True, verbose_name='id')),
|
||||||
|
('username', models.CharField(blank=True, max_length=50, null=True, unique=True, verbose_name='用户名')),
|
||||||
|
('pwd', models.CharField(blank=True, max_length=1000, null=True, verbose_name='密码')),
|
||||||
|
('email', models.CharField(blank=True, max_length=100, null=True, verbose_name='电子邮件')),
|
||||||
|
('phone', models.CharField(max_length=11, verbose_name='手机')),
|
||||||
|
('create_time', models.DateTimeField(verbose_name='注册时间')),
|
||||||
|
('avatar', models.ImageField(upload_to='', verbose_name='头像')),
|
||||||
|
('last_login_time', models.DateTimeField(auto_now=True, verbose_name='最后登录时间')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': '用户表',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
0
apps/auth/migrations/__init__.py
Normal file
0
apps/auth/migrations/__init__.py
Normal file
BIN
apps/auth/migrations/__pycache__/0001_initial.cpython-311.pyc
Normal file
BIN
apps/auth/migrations/__pycache__/0001_initial.cpython-311.pyc
Normal file
Binary file not shown.
BIN
apps/auth/migrations/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
apps/auth/migrations/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
22
apps/auth/models.py
Normal file
22
apps/auth/models.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
from django.db import models
|
||||||
|
|
||||||
|
|
||||||
|
# Create your models here.
|
||||||
|
class User(models.Model):
|
||||||
|
"""
|
||||||
|
用户表
|
||||||
|
"""
|
||||||
|
id = models.AutoField(verbose_name="id", primary_key=True, unique=True)
|
||||||
|
username = models.CharField(max_length=50, unique=True, verbose_name="用户名", null=True, blank=True)
|
||||||
|
pwd = models.CharField(max_length=1000, verbose_name="密码", null=True, blank=True)
|
||||||
|
email = models.CharField(max_length=100, verbose_name="电子邮件")
|
||||||
|
phone = models.CharField(max_length=11, verbose_name="手机", null=True, blank=True)
|
||||||
|
create_time = models.DateTimeField(verbose_name="注册时间")
|
||||||
|
avatar = models.ImageField(verbose_name="头像")
|
||||||
|
last_login_time = models.DateTimeField(verbose_name="最后登录时间", auto_now=True)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.username
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
verbose_name = '用户表'
|
3
apps/auth/tests.py
Normal file
3
apps/auth/tests.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
7
apps/auth/urls.py
Normal file
7
apps/auth/urls.py
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
from django.urls import path
|
||||||
|
from apps.auth import views
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
path("gettoken/", views.gettoken, name="getToken"),
|
||||||
|
path("searchuser/", views.search_user, name="searchuser"),
|
||||||
|
]
|
44
apps/auth/views.py
Normal file
44
apps/auth/views.py
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
import json
|
||||||
|
from django.shortcuts import HttpResponse
|
||||||
|
from django.middleware.csrf import get_token
|
||||||
|
from django.views.decorators.http import require_GET, require_POST
|
||||||
|
from apps.auth import models as auth_models
|
||||||
|
|
||||||
|
|
||||||
|
# Create your views here.
|
||||||
|
@require_GET
|
||||||
|
def gettoken(request):
|
||||||
|
"""
|
||||||
|
获取token
|
||||||
|
:param request:
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
token = get_token(request)
|
||||||
|
return HttpResponse(json.dumps({'token': token}), content_type="application/json,charset=utf-8")
|
||||||
|
|
||||||
|
|
||||||
|
@require_POST
|
||||||
|
def search_user(request):
|
||||||
|
"""
|
||||||
|
查询用户名
|
||||||
|
:param request:
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
username = request.POST.get('username')
|
||||||
|
user = auth_models.User.objects.filter(username=username)
|
||||||
|
if user.exists():
|
||||||
|
return HttpResponse("用户名已存在")
|
||||||
|
else:
|
||||||
|
return HttpResponse(True)
|
||||||
|
|
||||||
|
|
||||||
|
@require_POST
|
||||||
|
def adduser(request):
|
||||||
|
"""
|
||||||
|
用户注册
|
||||||
|
:param request: POST提交注册信息
|
||||||
|
:return: 注册结果
|
||||||
|
|
||||||
|
先查询数据库中用户名username是否存在,如果存在则提示用户更改用户名,若不存在则进行存储
|
||||||
|
"""
|
||||||
|
return HttpResponse("添加用户成功")
|
BIN
data/db.sqlite3
Normal file
BIN
data/db.sqlite3
Normal file
Binary file not shown.
0
data/db.sqlite3.sql
Normal file
0
data/db.sqlite3.sql
Normal file
16
data/initdata.json
Normal file
16
data/initdata.json
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"model": "api.sysconfig",
|
||||||
|
"pk": 1,
|
||||||
|
"fields": {
|
||||||
|
"name": "系统名称",
|
||||||
|
"identity":"SysTitle",
|
||||||
|
"param":"图书管理系统",
|
||||||
|
"desc":"登录界面显示的系统标题",
|
||||||
|
"create_by":"admin",
|
||||||
|
"create_time":"2024-08-16 23:39:50",
|
||||||
|
"update_by":"admin",
|
||||||
|
"update_time":"2024-08-16 23:39:50"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
22
manage.py
Normal file
22
manage.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
"""Django's command-line utility for administrative tasks."""
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
"""Run administrative tasks."""
|
||||||
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'CMS_Django_Backend.settings')
|
||||||
|
try:
|
||||||
|
from django.core.management import execute_from_command_line
|
||||||
|
except ImportError as exc:
|
||||||
|
raise ImportError(
|
||||||
|
"Couldn't import Django. Are you sure it's installed and "
|
||||||
|
"available on your PYTHONPATH environment variable? Did you "
|
||||||
|
"forget to activate a virtual environment?"
|
||||||
|
) from exc
|
||||||
|
execute_from_command_line(sys.argv)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
Loading…
Reference in New Issue
Block a user