from django.urls import path, include, re_path
from rest_framework.routers import DefaultRouter
from .views import (
    ESP32ConfigViewSet, OrderViewSet, order_check_view, 
    ServiceViewSet, VCCourseViewSet, ServiceOrderViewSet, 
    payment_finish, pay, send_sms_code, wechat_login, update_user_info, DistributorViewSet,
    CourseEnrollmentViewSet, phone_login, bind_phone, WeChatUserViewSet, upload_image
)

router = DefaultRouter()
router.register(r'configs', ESP32ConfigViewSet)
router.register(r'orders', OrderViewSet)
router.register(r'services', ServiceViewSet)
router.register(r'courses', VCCourseViewSet)
router.register(r'course-enrollments', CourseEnrollmentViewSet)
router.register(r'service-orders', ServiceOrderViewSet)
router.register(r'distributor', DistributorViewSet, basename='distributor')
router.register(r'users', WeChatUserViewSet, basename='wechatuser')

urlpatterns = [
    re_path(r'^finish/?$', payment_finish, name='payment-finish'),
    re_path(r'^pay/?$', pay, name='wechat-pay-v3'),
    path('auth/send-sms/', send_sms_code, name='send-sms'),
    path('wechat/login/', wechat_login, name='wechat-login'),
    path('auth/phone-login/', phone_login, name='phone-login'),
    path('auth/bind-phone/', bind_phone, name='bind-phone'),
    path('wechat/update/', update_user_info, name='wechat-update'),
    path('upload/image/', upload_image, name='upload-image'),
    path('page/check-order/', order_check_view, name='check-order-page'),
    path('', include(router.urls)),
]
