修改Channel Layers配置为InMemoryChannelLayer并修复文档数量统计
This commit is contained in:
parent
5eb4ccd7fd
commit
58d0c021b3
@ -1,296 +1,291 @@
|
||||
"""
|
||||
Django settings for role_based_system project.
|
||||
|
||||
Generated by 'django-admin startproject' using Django 5.1.5.
|
||||
|
||||
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/
|
||||
"""
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
# API 配置
|
||||
API_BASE_URL = 'http://180.163.88.62:30331'
|
||||
|
||||
DEPARTMENT_GROUPS = {
|
||||
"技术部": ["开发组", "测试组", "运维组"],
|
||||
"产品部": ["产品组", "设计组"],
|
||||
"市场部": ["销售组", "推广组"],
|
||||
"行政部": ["人事组", "财务组"]
|
||||
}
|
||||
|
||||
# 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-5f*=0_2did)e(()n58=e#vd5gaf&y$thgt(h6&=p+wm1*r6mb='
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
# 开发配置
|
||||
# DEBUG = True
|
||||
|
||||
ALLOWED_HOSTS = ['*'] # 仅在开发环境使用
|
||||
# 服务器配置
|
||||
DEBUG = False
|
||||
|
||||
# ALLOWED_HOSTS = ['frptx.chiyong.fun', 'localhost', '127.0.0.1']
|
||||
|
||||
# Application definition
|
||||
|
||||
INSTALLED_APPS = [
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'rest_framework',
|
||||
'rest_framework.authtoken',
|
||||
'channels',
|
||||
'user_management',
|
||||
'channels_redis',
|
||||
'corsheaders',
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
'corsheaders.middleware.CorsMiddleware', # CORS中间件要放在CommonMiddleware前面
|
||||
'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',
|
||||
'user_management.middleware.UserActivityMiddleware',
|
||||
]
|
||||
|
||||
ROOT_URLCONF = 'role_based_system.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 = 'role_based_system.wsgi.application'
|
||||
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/5.1/ref/settings/#databases
|
||||
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.mysql',
|
||||
'NAME': 'rolebasedfilemanagement',
|
||||
'USER': 'root',
|
||||
'PASSWORD': '123456',
|
||||
'HOST': 'localhost',
|
||||
'PORT': '3306',
|
||||
'OPTIONS': {
|
||||
'charset': 'utf8mb4', # 使用 utf8mb4 字符集
|
||||
'init_command': "SET sql_mode='STRICT_TRANS_TABLES'; SET innodb_strict_mode=1; SET NAMES utf8mb4;",
|
||||
},
|
||||
'TEST': {
|
||||
'CHARSET': 'utf8mb4',
|
||||
'COLLATION': 'utf8mb4_unicode_ci',
|
||||
},
|
||||
}
|
||||
}
|
||||
# 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',
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
|
||||
LANGUAGE_CODE = 'en-us'
|
||||
|
||||
TIME_ZONE = 'UTC'
|
||||
|
||||
USE_I18N = True
|
||||
|
||||
USE_TZ = True
|
||||
|
||||
|
||||
|
||||
STATIC_URL = 'static/'
|
||||
|
||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||
|
||||
AUTH_USER_MODEL = 'user_management.User'
|
||||
|
||||
REST_FRAMEWORK = {
|
||||
'DEFAULT_AUTHENTICATION_CLASSES': [
|
||||
'rest_framework.authentication.TokenAuthentication',
|
||||
'rest_framework.authentication.SessionAuthentication',
|
||||
],
|
||||
'DEFAULT_PERMISSION_CLASSES': [
|
||||
'rest_framework.permissions.IsAuthenticated',
|
||||
]
|
||||
}
|
||||
|
||||
# Channels 配置
|
||||
ASGI_APPLICATION = "role_based_system.asgi.application"
|
||||
|
||||
# Channel Layers 配置
|
||||
CHANNEL_LAYERS = {
|
||||
"default": {
|
||||
"BACKEND": "channels_redis.core.RedisChannelLayer",
|
||||
"CONFIG": {
|
||||
"hosts": [("127.0.0.1", 6379)],
|
||||
"capacity": 1500, # 消息队列容量
|
||||
"expiry": 10, # 消息过期时间(秒)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
# CORS 配置
|
||||
CORS_ALLOW_ALL_ORIGINS = True
|
||||
CORS_ALLOW_CREDENTIALS = True
|
||||
CORS_ALLOWED_ORIGINS = [
|
||||
"http://localhost:8000",
|
||||
"http://127.0.0.1:8000",
|
||||
"http://124.222.236.141:8000",
|
||||
"ws://localhost:8000", # 添加 WebSocket
|
||||
"ws://127.0.0.1:8000", # 添加 WebSocket
|
||||
"ws://124.222.236.141:8000", # 添加 WebSocket
|
||||
]
|
||||
# 允许的请求头
|
||||
CORS_ALLOWED_HEADERS = [
|
||||
'accept',
|
||||
'accept-encoding',
|
||||
'authorization',
|
||||
'content-type',
|
||||
'dnt',
|
||||
'origin',
|
||||
'user-agent',
|
||||
'x-csrftoken',
|
||||
'x-requested-with',
|
||||
]
|
||||
|
||||
# 允许的请求方法
|
||||
CORS_ALLOWED_METHODS = [
|
||||
'DELETE',
|
||||
'GET',
|
||||
'OPTIONS',
|
||||
'PATCH',
|
||||
'POST',
|
||||
'PUT',
|
||||
]
|
||||
|
||||
|
||||
|
||||
# WebSocket 允许的来源
|
||||
CSRF_TRUSTED_ORIGINS = [
|
||||
'http://localhost:8000',
|
||||
'http://127.0.0.1:8000',
|
||||
'http://124.222.236.141:8000',
|
||||
'ws://localhost:8000', # 添加 WebSocket
|
||||
'ws://127.0.0.1:8000', # 添加 WebSocket
|
||||
'ws://124.222.236.141:8000', # 添加 WebSocket
|
||||
]
|
||||
# 服务器配置
|
||||
# 静态文件配置
|
||||
STATIC_URL = '/static/'
|
||||
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
|
||||
|
||||
# 媒体文件配置
|
||||
MEDIA_URL = '/media/'
|
||||
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
|
||||
|
||||
# 文件上传配置
|
||||
FILE_UPLOAD_MAX_MEMORY_SIZE = 10 * 1024 * 1024 # 10MB
|
||||
MAX_UPLOAD_SIZE = 10 * 1024 * 1024 # 10MB
|
||||
|
||||
# 日志配置
|
||||
LOGGING = {
|
||||
'version': 1,
|
||||
'disable_existing_loggers': False,
|
||||
'handlers': {
|
||||
'console': {
|
||||
'class': 'logging.StreamHandler',
|
||||
},
|
||||
'file': {
|
||||
'class': 'logging.FileHandler',
|
||||
'filename': 'debug.log',
|
||||
},
|
||||
},
|
||||
'root': {
|
||||
'handlers': ['console', 'file'],
|
||||
'level': 'DEBUG',
|
||||
},
|
||||
'loggers': {
|
||||
'django.security.csrf': {
|
||||
'handlers': ['file'],
|
||||
'level': 'WARNING',
|
||||
'propagate': True,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
# CSRF 配置
|
||||
CSRF_COOKIE_SECURE = False # 开发环境设置为 False
|
||||
CSRF_COOKIE_HTTPONLY = False
|
||||
CSRF_USE_SESSIONS = False
|
||||
CSRF_COOKIE_SAMESITE = 'Lax'
|
||||
CSRF_TRUSTED_ORIGINS = [
|
||||
'http://localhost:8000',
|
||||
'http://127.0.0.1:8000',
|
||||
'ws://localhost:8000', # 添加 WebSocket
|
||||
'ws://127.0.0.1:8000' # 添加 WebSocket
|
||||
]
|
||||
|
||||
# Session 配置
|
||||
SESSION_COOKIE_SECURE = False # 开发环境设置为 False
|
||||
SESSION_COOKIE_HTTPONLY = True
|
||||
SESSION_COOKIE_SAMESITE = 'Lax'
|
||||
|
||||
# REST Framework 配置
|
||||
REST_FRAMEWORK = {
|
||||
'DEFAULT_AUTHENTICATION_CLASSES': [
|
||||
'rest_framework.authentication.TokenAuthentication',
|
||||
'rest_framework.authentication.SessionAuthentication', # WebSocket 需要
|
||||
],
|
||||
'DEFAULT_PERMISSION_CLASSES': [
|
||||
'rest_framework.permissions.IsAuthenticated',
|
||||
],
|
||||
'DEFAULT_PARSER_CLASSES': [
|
||||
'rest_framework.parsers.JSONParser',
|
||||
'rest_framework.parsers.FormParser',
|
||||
'rest_framework.parsers.MultiPartParser'
|
||||
],
|
||||
}
|
||||
"""
|
||||
Django settings for role_based_system project.
|
||||
|
||||
Generated by 'django-admin startproject' using Django 5.1.5.
|
||||
|
||||
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/
|
||||
"""
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
# API 配置
|
||||
API_BASE_URL = 'http://81.69.223.133:48329'
|
||||
|
||||
DEPARTMENT_GROUPS = {
|
||||
"技术部": ["开发组", "测试组", "运维组"],
|
||||
"产品部": ["产品组", "设计组"],
|
||||
"市场部": ["销售组", "推广组"],
|
||||
"行政部": ["人事组", "财务组"]
|
||||
}
|
||||
|
||||
# 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-5f*=0_2did)e(()n58=e#vd5gaf&y$thgt(h6&=p+wm1*r6mb='
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
# 开发配置
|
||||
# DEBUG = True
|
||||
|
||||
ALLOWED_HOSTS = ['*'] # 仅在开发环境使用
|
||||
# 服务器配置
|
||||
DEBUG = False
|
||||
|
||||
# ALLOWED_HOSTS = ['frptx.chiyong.fun', 'localhost', '127.0.0.1']
|
||||
|
||||
# Application definition
|
||||
|
||||
INSTALLED_APPS = [
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'rest_framework',
|
||||
'rest_framework.authtoken',
|
||||
'channels',
|
||||
'user_management',
|
||||
'channels_redis',
|
||||
'corsheaders',
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
'corsheaders.middleware.CorsMiddleware', # CORS中间件要放在CommonMiddleware前面
|
||||
'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',
|
||||
'user_management.middleware.UserActivityMiddleware',
|
||||
]
|
||||
|
||||
ROOT_URLCONF = 'role_based_system.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 = 'role_based_system.wsgi.application'
|
||||
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/5.1/ref/settings/#databases
|
||||
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.mysql',
|
||||
'NAME': 'rolebasedfilemanagement',
|
||||
'USER': 'root',
|
||||
'PASSWORD': 'Ooin2025!',
|
||||
'HOST': 'localhost',
|
||||
'PORT': '3306',
|
||||
'OPTIONS': {
|
||||
'charset': 'utf8mb4', # 使用 utf8mb4 字符集
|
||||
'init_command': "SET sql_mode='STRICT_TRANS_TABLES'; SET innodb_strict_mode=1; SET NAMES utf8mb4;",
|
||||
},
|
||||
'TEST': {
|
||||
'CHARSET': 'utf8mb4',
|
||||
'COLLATION': 'utf8mb4_unicode_ci',
|
||||
},
|
||||
}
|
||||
}
|
||||
# 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',
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
|
||||
LANGUAGE_CODE = 'en-us'
|
||||
|
||||
TIME_ZONE = 'Asia/Shanghai'
|
||||
|
||||
USE_I18N = True
|
||||
|
||||
USE_TZ = False
|
||||
|
||||
|
||||
|
||||
STATIC_URL = 'static/'
|
||||
|
||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||
|
||||
AUTH_USER_MODEL = 'user_management.User'
|
||||
|
||||
REST_FRAMEWORK = {
|
||||
'DEFAULT_AUTHENTICATION_CLASSES': [
|
||||
'rest_framework.authentication.TokenAuthentication',
|
||||
'rest_framework.authentication.SessionAuthentication',
|
||||
],
|
||||
'DEFAULT_PERMISSION_CLASSES': [
|
||||
'rest_framework.permissions.IsAuthenticated',
|
||||
]
|
||||
}
|
||||
|
||||
# Channels 配置
|
||||
ASGI_APPLICATION = "role_based_system.asgi.application"
|
||||
|
||||
# Channel Layers 配置
|
||||
CHANNEL_LAYERS = {
|
||||
"default": {
|
||||
"BACKEND": "channels.layers.InMemoryChannelLayer",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
# CORS 配置
|
||||
CORS_ALLOW_ALL_ORIGINS = True
|
||||
CORS_ALLOW_CREDENTIALS = True
|
||||
CORS_ALLOWED_ORIGINS = [
|
||||
"http://localhost:8000",
|
||||
"http://127.0.0.1:8000",
|
||||
"http://124.222.236.141:8000",
|
||||
"ws://localhost:8000", # 添加 WebSocket
|
||||
"ws://127.0.0.1:8000", # 添加 WebSocket
|
||||
"ws://124.222.236.141:8000", # 添加 WebSocket
|
||||
]
|
||||
# 允许的请求头
|
||||
CORS_ALLOWED_HEADERS = [
|
||||
'accept',
|
||||
'accept-encoding',
|
||||
'authorization',
|
||||
'content-type',
|
||||
'dnt',
|
||||
'origin',
|
||||
'user-agent',
|
||||
'x-csrftoken',
|
||||
'x-requested-with',
|
||||
]
|
||||
|
||||
# 允许的请求方法
|
||||
CORS_ALLOWED_METHODS = [
|
||||
'DELETE',
|
||||
'GET',
|
||||
'OPTIONS',
|
||||
'PATCH',
|
||||
'POST',
|
||||
'PUT',
|
||||
]
|
||||
|
||||
|
||||
|
||||
# WebSocket 允许的来源
|
||||
CSRF_TRUSTED_ORIGINS = [
|
||||
'http://localhost:8000',
|
||||
'http://127.0.0.1:8000',
|
||||
'http://124.222.236.141:8000',
|
||||
'ws://localhost:8000', # 添加 WebSocket
|
||||
'ws://127.0.0.1:8000', # 添加 WebSocket
|
||||
'ws://124.222.236.141:8000', # 添加 WebSocket
|
||||
]
|
||||
# 服务器配置
|
||||
# 静态文件配置
|
||||
STATIC_URL = '/static/'
|
||||
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
|
||||
|
||||
# 媒体文件配置
|
||||
MEDIA_URL = '/media/'
|
||||
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
|
||||
|
||||
# 文件上传配置
|
||||
FILE_UPLOAD_MAX_MEMORY_SIZE = 10 * 1024 * 1024 # 10MB
|
||||
MAX_UPLOAD_SIZE = 10 * 1024 * 1024 # 10MB
|
||||
|
||||
# 日志配置
|
||||
LOGGING = {
|
||||
'version': 1,
|
||||
'disable_existing_loggers': False,
|
||||
'handlers': {
|
||||
'console': {
|
||||
'class': 'logging.StreamHandler',
|
||||
},
|
||||
'file': {
|
||||
'class': 'logging.FileHandler',
|
||||
'filename': 'debug.log',
|
||||
},
|
||||
},
|
||||
'root': {
|
||||
'handlers': ['console', 'file'],
|
||||
'level': 'DEBUG',
|
||||
},
|
||||
'loggers': {
|
||||
'django.security.csrf': {
|
||||
'handlers': ['file'],
|
||||
'level': 'WARNING',
|
||||
'propagate': True,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
# CSRF 配置
|
||||
CSRF_COOKIE_SECURE = False # 开发环境设置为 False
|
||||
CSRF_COOKIE_HTTPONLY = False
|
||||
CSRF_USE_SESSIONS = False
|
||||
CSRF_COOKIE_SAMESITE = 'Lax'
|
||||
CSRF_TRUSTED_ORIGINS = [
|
||||
'http://localhost:8000',
|
||||
'http://127.0.0.1:8000',
|
||||
'ws://localhost:8000', # 添加 WebSocket
|
||||
'ws://127.0.0.1:8000' # 添加 WebSocket
|
||||
]
|
||||
|
||||
# Session 配置
|
||||
SESSION_COOKIE_SECURE = False # 开发环境设置为 False
|
||||
SESSION_COOKIE_HTTPONLY = True
|
||||
SESSION_COOKIE_SAMESITE = 'Lax'
|
||||
|
||||
# REST Framework 配置
|
||||
REST_FRAMEWORK = {
|
||||
'DEFAULT_AUTHENTICATION_CLASSES': [
|
||||
'rest_framework.authentication.TokenAuthentication',
|
||||
'rest_framework.authentication.SessionAuthentication', # WebSocket 需要
|
||||
],
|
||||
'DEFAULT_PERMISSION_CLASSES': [
|
||||
'rest_framework.permissions.IsAuthenticated',
|
||||
],
|
||||
'DEFAULT_PARSER_CLASSES': [
|
||||
'rest_framework.parsers.JSONParser',
|
||||
'rest_framework.parsers.FormParser',
|
||||
'rest_framework.parsers.MultiPartParser'
|
||||
],
|
||||
}
|
||||
|
@ -1,46 +1,45 @@
|
||||
from django.urls import path, include
|
||||
from rest_framework.routers import DefaultRouter
|
||||
from .views import (
|
||||
KnowledgeBaseViewSet,
|
||||
PermissionViewSet,
|
||||
NotificationViewSet,
|
||||
verify_token,
|
||||
user_list,
|
||||
user_detail,
|
||||
user_update,
|
||||
user_delete,
|
||||
change_password,
|
||||
RegisterView,
|
||||
LoginView,
|
||||
LogoutView,
|
||||
ChatHistoryViewSet
|
||||
)
|
||||
|
||||
# 创建路由器
|
||||
router = DefaultRouter()
|
||||
|
||||
# 注册视图集
|
||||
router.register(r'knowledge-bases', KnowledgeBaseViewSet, basename='knowledge-base')
|
||||
router.register(r'knowledge-bases', KnowledgeBaseViewSet, basename='knowledge-bases')
|
||||
router.register(r'permissions', PermissionViewSet, basename='permission')
|
||||
router.register(r'notifications', NotificationViewSet, basename='notification')
|
||||
router.register(r'chat-history', ChatHistoryViewSet, basename='chat-history')
|
||||
|
||||
# URL patterns
|
||||
urlpatterns = [
|
||||
# API 路由
|
||||
path('', include(router.urls)),
|
||||
|
||||
# 用户认证相关
|
||||
path('auth/register/', RegisterView.as_view(), name='register'),
|
||||
path('auth/login/', LoginView.as_view(), name='login'),
|
||||
path('auth/logout/', LogoutView.as_view(), name='logout'),
|
||||
path('auth/verify-token/', verify_token, name='verify-token'),
|
||||
path('auth/change-password/', change_password, name='change-password'),
|
||||
|
||||
# 用户管理相关
|
||||
path('users/', user_list, name='user-list'),
|
||||
path('users/<str:pk>/', user_detail, name='user-detail'),
|
||||
path('users/<str:pk>/update/', user_update, name='user-update'),
|
||||
path('users/<str:pk>/delete/', user_delete, name='user-delete'),
|
||||
]
|
||||
from django.urls import path, include
|
||||
from rest_framework.routers import DefaultRouter
|
||||
from .views import (
|
||||
KnowledgeBaseViewSet,
|
||||
PermissionViewSet,
|
||||
NotificationViewSet,
|
||||
verify_token,
|
||||
user_list,
|
||||
user_detail,
|
||||
user_update,
|
||||
user_delete,
|
||||
change_password,
|
||||
RegisterView,
|
||||
LoginView,
|
||||
LogoutView,
|
||||
ChatHistoryViewSet
|
||||
)
|
||||
|
||||
# 创建路由器
|
||||
router = DefaultRouter()
|
||||
|
||||
# 注册视图集
|
||||
router.register(r'knowledge-bases', KnowledgeBaseViewSet, basename='knowledge-bases')
|
||||
router.register(r'permissions', PermissionViewSet, basename='permission')
|
||||
router.register(r'notifications', NotificationViewSet, basename='notification')
|
||||
router.register(r'chat-history', ChatHistoryViewSet, basename='chat-history')
|
||||
|
||||
# URL patterns
|
||||
urlpatterns = [
|
||||
# API 路由
|
||||
path('', include(router.urls)),
|
||||
|
||||
# 用户认证相关
|
||||
path('auth/register/', RegisterView.as_view(), name='register'),
|
||||
path('auth/login/', LoginView.as_view(), name='login'),
|
||||
path('auth/logout/', LogoutView.as_view(), name='logout'),
|
||||
path('auth/verify-token/', verify_token, name='verify-token'),
|
||||
path('auth/change-password/', change_password, name='change-password'),
|
||||
|
||||
# 用户管理相关
|
||||
path('users/', user_list, name='user-list'),
|
||||
path('users/<str:pk>/', user_detail, name='user-detail'),
|
||||
path('users/<str:pk>/update/', user_update, name='user-update'),
|
||||
path('users/<str:pk>/delete/', user_delete, name='user-delete'),
|
||||
]
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user