diff --git a/.idea/dbnavigator.xml b/.idea/dbnavigator.xml
index f671dc2..3e7e6b1 100644
--- a/.idea/dbnavigator.xml
+++ b/.idea/dbnavigator.xml
@@ -14,14 +14,19 @@
25000;
+select * from congestion where congestion_id >46200;
select * from location;
select * from daily_congestion_statistic where daily_congestion_statistic_id > 2900;
select * from weekly_congestion_statistic ;
+SELECT * FROM congestion ORDER BY congestion_id DESC;
-select * from users;]]>
+select * from users;
+
+select * from ban;
+select * from report;
+select * from BlackList;]]>
@@ -40,6 +45,9 @@ select * from users;]]>
+
+
+
diff --git a/buzzing_admin/swagger.py b/buzzing_admin/swagger.py
new file mode 100644
index 0000000..d359b76
--- /dev/null
+++ b/buzzing_admin/swagger.py
@@ -0,0 +1,82 @@
+from drf_yasg.utils import swagger_auto_schema
+from drf_yasg.inspectors import SwaggerAutoSchema
+from drf_yasg import openapi
+
+class BearerTokenAutoSchema(SwaggerAutoSchema):
+ def get_security_definitions(self, auto_schema_context):
+ security_definitions = super(BearerTokenAutoSchema, self).get_security_definitions(auto_schema_context)
+ security_definitions['Bearer'] = openapi.SecurityScheme(
+ type=openapi.TYPE_API_KEY,
+ in_=openapi.IN_HEADER,
+ name='Authorization',
+ description="JWT 토큰 키를 입력해주세요!"
+ )
+ return security_definitions
+
+def admin_login_view_schema():
+ return {
+ 'request_body': openapi.Schema(
+ type=openapi.TYPE_OBJECT,
+ properties={
+ 'social_email': openapi.Schema(type=openapi.TYPE_STRING, description='Admin email', example="admin@example.com"),
+ 'password': openapi.Schema(type=openapi.TYPE_STRING, description='Admin password', example="passwd1234"),
+ },
+ ),
+ 'responses': {
+ 200: openapi.Response(description='Successful Login', schema=openapi.Schema(type=openapi.TYPE_OBJECT, properties={'AccessToken': openapi.Schema(type=openapi.TYPE_STRING, example="sampleAccessToken12345")})),
+ 400: 'INVALID_DATA',
+ 403: 'NO_PERMISSION',
+ 401: 'INVALID_USER'
+ },
+ 'operation_description': "Admin login view \n 관리자 아이디로 접속시, users.USER_ROLE이 ADMIN일시 토큰발급"
+ }
+
+
+def admin_main_view_schema():
+ return {
+ 'responses': {
+ 200: openapi.Response(description='Get reported contents and banned users'),
+ },
+ 'operation_description': "관리자 메인 페이지"
+ }
+
+def unban_user_view_schema():
+ return {
+ 'responses': {
+ 200: "유저 정지 해제 완료.",
+ 400: "밴 데이터가 없습니다."
+ },
+ 'operation_description': "유저 정지 해제"
+ }
+
+def report_detail_view_get_schema():
+ return {
+ 'responses': {
+ 200: openapi.Response(description='Get report detail'),
+ },
+ 'operation_description': "리폿 상세뷰 가져오기"
+ }
+
+def report_detail_view_post_schema():
+ return {
+ 'request_body': openapi.Schema(
+ type=openapi.TYPE_OBJECT,
+ properties={
+ 'action': openapi.Schema(type=openapi.TYPE_STRING, description='Action to take (무고, 30일 정지, 블랙리스트)'),
+ 'ban_reason': openapi.Schema(type=openapi.TYPE_STRING, description='밴 사유'),
+ 'ban_reason_title': openapi.Schema(type=openapi.TYPE_STRING, description='밴 사유 제목'),
+ },
+ required=['action', 'ban_reason', 'ban_reason_title'],
+ example={
+ 'action': '30일 정지',
+ 'ban_reason': '비매너 행동으로 다수의 신고가 접수됨',
+ 'ban_reason_title': '비매너 행동'
+ }
+ ),
+ 'responses': {
+ 200: "신고 처리 완료.",
+ 400: "유저가 이미 밴 상태입니다..",
+ },
+ 'operation_description': "리폿 처리"
+ }
+
diff --git a/config/settings.py b/config/settings.py
index 19895af..eb9665d 100644
--- a/config/settings.py
+++ b/config/settings.py
@@ -62,8 +62,40 @@
#스케줄러
'django_crontab',
'buzzing_admin',
+
+ #swagger
+ 'drf_yasg',
+ 'rest_framework',
]
+SWAGGER_SETTINGS = {
+ 'DEFAULT_AUTO_SCHEMA_CLASS': 'buzzing_admin.swagger.BearerTokenAutoSchema',
+ 'SECURITY_DEFINITIONS': {
+ 'Bearer': {
+ 'type': 'apiKey',
+ 'name': 'Authorization',
+ 'in': 'header'
+ }
+ },
+ 'DEFAULT_SECURITY': [
+ {
+ 'Bearer': []
+ }
+ ],
+
+ 'USE_SESSION_AUTH': False,
+
+ 'DEFAULT_FIELD_INSPECTORS': [
+ 'drf_yasg.inspectors.CamelCaseJSONFilter',
+ 'drf_yasg.inspectors.InlineSerializerInspector',
+ 'drf_yasg.inspectors.RelatedFieldInspector',
+ 'drf_yasg.inspectors.ChoiceFieldInspector',
+ 'drf_yasg.inspectors.FileFieldInspector',
+ 'drf_yasg.inspectors.DictFieldInspector',
+ 'drf_yasg.inspectors.SerializerMethodFieldInspector',
+ ],
+}
+
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
diff --git a/config/urls.py b/config/urls.py
index 507183e..11e2e96 100644
--- a/config/urls.py
+++ b/config/urls.py
@@ -14,9 +14,23 @@
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,re_path
from getApi import views
from buzzing_admin import admin_views
+from rest_framework import permissions
+from drf_yasg.views import get_schema_view
+from drf_yasg import openapi
+
+
+schema_view = get_schema_view(
+ openapi.Info(
+ title="API",
+ default_version='v1',
+ description="🚀 Realtime Congestion Based Location Recommendation Service - 복쟉복쟉 admin_Server의 API 명세서입니다.",
+ ),
+ public=True,
+ permission_classes=(permissions.AllowAny,),
+)
urlpatterns = [
path('admin/', admin.site.urls),
@@ -26,6 +40,9 @@
path('auth/admin/main/', admin_views.AdminMainView.as_view()),
path('auth/admin/report//', admin_views.ReportDetailView.as_view()),
path('auth/admin/report//unBan/', admin_views.UnbanUserView.as_view(), name='unBan'),
+ re_path(r'^swagger(?P\.json|\.yaml)$', schema_view.without_ui(cache_timeout=0), name='schema-json'),
+ path('swagger/', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
+ path('redoc/', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'),
]
diff --git a/install.txt b/install.txt
index 05a99a6..a3d305c 100644
--- a/install.txt
+++ b/install.txt
@@ -40,3 +40,5 @@ urllib3==1.26.15
uWSGI==2.0.21
xlwt==1.3.0
xmltodict==0.13.0
+drf-yasg==1.21.7
+