from apps.ads.views.web import record_click, record_impression
from apps.content.views import (
    ArticleCreateAPIView,
    ArticleHitAPIView,
    ArticleStaricRemove,
    ArticleStatusUpdateAPI,
)
from apps.content.views.article import ArticleListAPI, CreateAIArticle
from apps.content.views.search import increment_search_hits
from apps.content.views.tag import TagImportAPIView
from apps.content.views.wiki import WikiHitAPIView
from apps.core.api.secret_key_api import get_secret_key_info, reset_secret_key
from apps.core.services.django_sys import restart_sys
from apps.core.utils.captcha import ajax_captcha
from apps.core.utils.collect_static_files import collect_static
from apps.core.utils.health_check import health_check
from apps.core.utils.sensitive_filter import SensitiveWordsDownload
from apps.core.views.emails import TestEmailConfigView
from apps.core.views.txt_logs import get_ai_logs, get_article_update_status_logs
from apps.log_service.views import read_log_view, remove_old_logs
from django.conf import settings
from django.urls import include, path

# 下面写上API的
urlpatterns = [
    # 更新点击数
    path("api/articles/<int:pk>/hit/", ArticleHitAPIView.as_view(), name="article-hit"),
    # 更新点击数
    path("api/wikis/<int:pk>/hit/", WikiHitAPIView.as_view(), name="article-hit"),
    # 上传文章
    path("api/articles/upload", ArticleCreateAPIView.as_view(), name="article-create"),
    # 修改文章状态
    path("api/update_status99", ArticleStatusUpdateAPI.as_view(), name="article-update-status99"),
    # 获取文章状态修改日志
    path(
        "api/get_article_update_status_logs",
        get_article_update_status_logs,
        name="get_article_update_status_logs",
    ),
    # 敏感词设置获取敏感词
    path(
        f"{settings.ADMIN_DIR}sensitive_words/download",
        SensitiveWordsDownload.as_view(),
        name="sensitive_words_download",
    ),
    # 测试发送邮件
    path(
        f"{settings.ADMIN_DIR}test-email-config/",
        TestEmailConfigView.as_view(),
        name="test_email_config",
    ),
    # Ai生成文章
    path("api/create-ai-article", CreateAIArticle.as_view(), name="create_ai_article"),
    # 获取AI生成文章日志
    path("api/get_ai_logs", get_ai_logs, name="get_ai_logs"),
    # 评论
    path("comments/", include(("apps.comments.urls", "comments"), namespace="comment")),
    # 移除静态文件
    path("api/remove_static_file", ArticleStaricRemove.as_view(), name="remove_static_file"),
    # 升级
    path("upgrade/", include(("apps.upgrade.urls", "upgrade"), namespace="upgrade")),
    # 更新搜索历史点击数
    path("api/get_search_hits", increment_search_hits, name="search-hits-api"),
    # API重启系统
    path("api/restart_sys", restart_sys, name="restart_sys"),
    #     广告展示统计
    path("api/record_impression/", record_impression, name="record_impression"),
    #     广告点击统计
    path("api/record_click/", record_click, name="record_click"),
    #     游标分页AJAX API接口
    path("api/articles/", ArticleListAPI.as_view(), name="article-list-api"),
    #     tag导入API
    path("api/tags/import/", TagImportAPIView.as_view(), name="tag-import"),
    #     心跳检测接口,检测网站有没有重启成功
    path("api/health-check/", health_check, name="health_check"),
    #     收集静态文件
    path("api/collect-static/", collect_static, name="collect_static"),
    #     path('api/get_vip_auth/', get_vip_auth, name='get_vip_auth'),
    # 验证码
    path("api/ajax_captcha", ajax_captcha, name="ajax_captcha"),  # 验证验证码
    #     日志读取
    path("api/log_service/read/", read_log_view, name="log_service_read"),
    #     移除旧日志
    path("api/log_service/remove/", remove_old_logs, name="log_service_remove"),
    #     重置 SECRET_KEY API
    path("api/secret-key/reset/", reset_secret_key, name="reset_secret_key"),
    #     获取 SECRET_KEY 信息 API
    path("api/secret-key/info/", get_secret_key_info, name="get_secret_key_info"),
]
