1
0
forked from erp-dev/erp

fix: rebuild stock change record

This commit is contained in:
2025-11-05 16:57:54 +08:00
parent d88bf367f8
commit a759030cdc
16 changed files with 1116 additions and 66 deletions

View File

@@ -18,6 +18,7 @@ except ImportError:
import django.utils.encoding
django.utils.encoding.force_text = force_text
from datetime import timedelta
from pathlib import Path
from environ import Env
@@ -58,8 +59,11 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles', # 使用七牛云存储不需要staticfiles app
'rest_framework',
'drf_spectacular',
'basic_info',
'stock',
'api_v1',
]
MIDDLEWARE = [
@@ -72,6 +76,31 @@ MIDDLEWARE = [
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework_simplejwt.authentication.JWTAuthentication',
),
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.IsAuthenticated',
],
'DEFAULT_SCHEMA_CLASS': 'drf_spectacular.openapi.AutoSchema',
}
# JWT 配置
SIMPLE_JWT = {
'ACCESS_TOKEN_LIFETIME': timedelta(days=7),
'REFRESH_TOKEN_LIFETIME': timedelta(days=7),
'ROTATE_REFRESH_TOKENS': True,
'UPDATE_LAST_LOGIN': True,
}
SPECTACULAR_SETTINGS = {
'TITLE': 'Flower API',
'DESCRIPTION': 'API documentation for the Flower project',
'VERSION': '1.0.0',
'SERVE_INCLUDE_SCHEMA': False,
}
ROOT_URLCONF = 'flower.urls'
TEMPLATES = [

View File

@@ -15,10 +15,25 @@ Including another URLconf
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from django.urls import path, include
from stock.views import router
from rest_framework_simplejwt.views import (
TokenObtainPairView,
TokenRefreshView,
)
from drf_spectacular.views import SpectacularAPIView, SpectacularSwaggerView
urlpatterns = [
# JWT 登录
path('api/auth/login/', TokenObtainPairView.as_view(), name='token_obtain_pair'),
# path('api/auth/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
# API 文档
path('api/schema/', SpectacularAPIView.as_view(), name='schema'),
path('api/docs/', SpectacularSwaggerView.as_view(url_name='schema'), name='swagger-ui'),
path('admin/', admin.site.urls),
path('stock/', router.urls),
path('api/v1/', include('api_v1.urls')),
]