feat: 配置所有 apps 的 URL 路由
- User URLs(用户相关) - Region URLs(版块相关) - Article URLs(文章相关) - FeaturedService URLs(特色服务相关) - Moderation URLs(版主管理相关) - Interaction URLs(交互功能相关) - 更新主 URL 配置,整合所有 API 端点 - 添加 JWT 认证端点
This commit is contained in:
10
backend/apps/articles/urls.py
Normal file
10
backend/apps/articles/urls.py
Normal file
@@ -0,0 +1,10 @@
|
||||
from django.urls import path, include
|
||||
from rest_framework.routers import DefaultRouter
|
||||
from .views import ArticleViewSet
|
||||
|
||||
router = DefaultRouter()
|
||||
router.register(r'articles', ArticleViewSet, basename='article')
|
||||
|
||||
urlpatterns = [
|
||||
path('', include(router.urls)),
|
||||
]
|
||||
10
backend/apps/featured_services/urls.py
Normal file
10
backend/apps/featured_services/urls.py
Normal file
@@ -0,0 +1,10 @@
|
||||
from django.urls import path, include
|
||||
from rest_framework.routers import DefaultRouter
|
||||
from .views import FeaturedServiceViewSet
|
||||
|
||||
router = DefaultRouter()
|
||||
router.register(r'services', FeaturedServiceViewSet, basename='featured_service')
|
||||
|
||||
urlpatterns = [
|
||||
path('', include(router.urls)),
|
||||
]
|
||||
18
backend/apps/interactions/urls.py
Normal file
18
backend/apps/interactions/urls.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from django.urls import path, include
|
||||
from rest_framework.routers import DefaultRouter
|
||||
from .views import (
|
||||
CommentViewSet,
|
||||
RatingViewSet,
|
||||
LikeViewSet,
|
||||
FavoriteViewSet
|
||||
)
|
||||
|
||||
router = DefaultRouter()
|
||||
router.register(r'comments', CommentViewSet, basename='comment')
|
||||
router.register(r'ratings', RatingViewSet, basename='rating')
|
||||
router.register(r'likes', LikeViewSet, basename='like')
|
||||
router.register(r'favorites', FavoriteViewSet, basename='favorite')
|
||||
|
||||
urlpatterns = [
|
||||
path('', include(router.urls)),
|
||||
]
|
||||
16
backend/apps/moderation/urls.py
Normal file
16
backend/apps/moderation/urls.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from django.urls import path, include
|
||||
from rest_framework.routers import DefaultRouter
|
||||
from .views import (
|
||||
ModeratorApplicationViewSet,
|
||||
ModeratorPermissionViewSet,
|
||||
PermissionRestrictionViewSet
|
||||
)
|
||||
|
||||
router = DefaultRouter()
|
||||
router.register(r'applications', ModeratorApplicationViewSet, basename='moderator_application')
|
||||
router.register(r'permissions', ModeratorPermissionViewSet, basename='moderator_permission')
|
||||
router.register(r'restrictions', PermissionRestrictionViewSet, basename='permission_restriction')
|
||||
|
||||
urlpatterns = [
|
||||
path('moderator/', include(router.urls)),
|
||||
]
|
||||
10
backend/apps/regions/urls.py
Normal file
10
backend/apps/regions/urls.py
Normal file
@@ -0,0 +1,10 @@
|
||||
from django.urls import path, include
|
||||
from rest_framework.routers import DefaultRouter
|
||||
from .views import RegionViewSet
|
||||
|
||||
router = DefaultRouter()
|
||||
router.register(r'regions', RegionViewSet, basename='region')
|
||||
|
||||
urlpatterns = [
|
||||
path('', include(router.urls)),
|
||||
]
|
||||
@@ -6,10 +6,29 @@ from django.contrib import admin
|
||||
from django.urls import path, include
|
||||
from django.conf import settings
|
||||
from django.conf.urls.static import static
|
||||
from rest_framework_simplejwt.views import (
|
||||
TokenObtainPairView,
|
||||
TokenRefreshView,
|
||||
)
|
||||
from apps.api.views import CustomTokenObtainPairView
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
|
||||
# Authentication
|
||||
path('api/auth/login/', CustomTokenObtainPairView.as_view(), name='token_obtain_pair'),
|
||||
path('api/auth/token/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
|
||||
|
||||
# API endpoints
|
||||
path('api/', include('apps.users.urls')),
|
||||
path('api/', include('apps.regions.urls')),
|
||||
path('api/', include('apps.articles.urls')),
|
||||
path('api/', include('apps.featured_services.urls')),
|
||||
path('api/', include('apps.moderation.urls')),
|
||||
path('api/', include('apps.interactions.urls')),
|
||||
path('api/', include('apps.api.urls')),
|
||||
|
||||
# GraphQL
|
||||
path('graphql/', include('apps.api.graphql_urls')),
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user