1
0
forked from erp-dev/erp
Files
erpnew/api_v1/urls.py

102 lines
6.5 KiB
Python

from django.urls import path, include
from rest_framework.routers import DefaultRouter
from .views import (
stock_change_views,
healthy,
user_info,
inventory,
product_image,
stateflow,
users,
print_count,
)
from .views.business.purchase import views as purchase_views
from .views.business.sales import views as sales_views
from .views.business.payment import views as payment_views
from .views.business.receipt import views as receipt_views
from .views.business.balance import views as balance_views
from .views.business.purchase_return import views as purchase_return_views
from .views.business.sales_return import views as sales_return_views
from .views.business.statements import views as statement_views
from .views.stock_change_views.snapshot import StockSnapshotListView
from .views.printing.views import PrintingOrderViewSet, PrintingJobViewSet, PlateOrderViewSet
from .views.upload import UploadFileViewSet
from .views.products import ProductQuickViewSet
from .views.parameters import StateParameterViewSet
from .views.users import CreateUserWithProfileView
# 创建 DRF Router for Stateflow
stateflow_router = DefaultRouter()
stateflow_router.register(r'states', stateflow.StateViewSet, basename='state')
stateflow_router.register(r'processes', stateflow.ProcessViewSet, basename='process')
stateflow_router.register(r'business-objects', stateflow.BusinessObjectViewSet, basename='business-object')
# 创建主 Router
main_router = DefaultRouter()
main_router.register(r'printing-orders', PrintingOrderViewSet, basename='printing-order')
main_router.register(r'printing-jobs', PrintingJobViewSet, basename='printing-job')
main_router.register(r'plate-orders', PlateOrderViewSet, basename='plate-order')
main_router.register(r'upload', UploadFileViewSet, basename='upload')
main_router.register(r'products/quick', ProductQuickViewSet, basename='product-quick')
main_router.register(r'parameters', StateParameterViewSet, basename='parameter')
urlpatterns = [
# 库存变动相关API
path('stock-snapshots/', StockSnapshotListView.as_view(), name='list_stock_snapshots'),
path('stock-changes/', stock_change_views.list_stock_changes, name='list_stock_changes'),
path('stock-change-details/', stock_change_views.list_stock_change_details, name='list_stock_change_details'),
path('stock-change/', stock_change_views.create_full_stock_change, name='create_full_stock_change'),
path('stock-change/relaxed/', stock_change_views.create_relaxed_stock_change, name='create_relaxed_stock_change'),
path('stock-change/restrict/', stock_change_views.create_restrict_stock_change, name='create_restrict_stock_change'),
path('stock-change/transfer/', stock_change_views.transfer_stock_change, name='stock_transfer'),
path('stock-change/<int:record_id>/', stock_change_views.get_stock_change, name='get_stock_change'),
path('stock-change/<int:record_id>/finish/', stock_change_views.finish_stock_change, name='finish_stock_change'),
path('stock-change/<int:record_id>/offset/', stock_change_views.offset_stock_change, name='offset_stock_change'),
path(
'set-merchant-auto-complete-stock-change/',
stock_change_views.set_merchant_auto_complete_stock_change,
name='set_merchant_auto_complete_stock_change',
),
# 用户信息 API
path('user-info/', user_info.user_info, name='user_info'),
# 用户创建 API
path('users/create/', CreateUserWithProfileView.as_view(), name='create_user_with_profile'),
# 库存查询 API
path('inventory/', inventory.InventoryAPIView.as_view(), name='inventory'),
path('purchase-orders/', purchase_views.PurchaseOrderView.as_view(), name='purchase_orders'),
path('purchase-orders/<int:pk>/', purchase_views.PurchaseOrderDetailView.as_view(), name='purchase_order_detail'),
path('purchase-orders/<int:pk>/review/', purchase_views.PurchaseOrderReviewView.as_view(), name='purchase_order_review'),
path('purchase-return-orders/', purchase_return_views.PurchaseReturnOrderView.as_view(), name='purchase_return_orders'),
path('purchase-return-orders/<int:pk>/', purchase_return_views.PurchaseReturnOrderDetailView.as_view(), name='purchase_return_order_detail'),
path('purchase-return-orders/<int:pk>/review/', purchase_return_views.PurchaseReturnOrderReviewView.as_view(), name='purchase_return_order_review'),
path('sales-orders/', sales_views.SalesOrderView.as_view(), name='sales_orders'),
path('sales-orders/<int:pk>/', sales_views.SalesOrderDetailView.as_view(), name='sales_order_detail'),
path('sales-orders/<int:pk>/review/', sales_views.SalesOrderReviewView.as_view(), name='sales_order_review'),
path('sales-return-orders/', sales_return_views.SalesReturnOrderView.as_view(), name='sales_return_orders'),
path('sales-return-orders/<int:pk>/', sales_return_views.SalesReturnOrderDetailView.as_view(), name='sales_return_order_detail'),
path('sales-return-orders/<int:pk>/review/', sales_return_views.SalesReturnOrderReviewView.as_view(), name='sales_return_order_review'),
path('payment-orders/', payment_views.PaymentOrderView.as_view(), name='payment_orders'),
path('payment-orders/<int:pk>/review/', payment_views.PaymentOrderReviewView.as_view(), name='payment_order_review'),
path('receipt-orders/', receipt_views.ReceiptOrderView.as_view(), name='receipt_orders'),
path('receipt-orders/<int:pk>/review/', receipt_views.ReceiptOrderReviewView.as_view(), name='receipt_order_review'),
path('customers/<int:customer_id>/balance/', balance_views.CustomerBalanceView.as_view(), name='customer_balance'),
path('suppliers/<int:supplier_id>/balance/', balance_views.SupplierBalanceView.as_view(), name='supplier_balance'),
path('customers/<int:customer_id>/statements/', statement_views.CustomerStatementView.as_view(), name='customer_statements'),
path('suppliers/<int:supplier_id>/statements/', statement_views.SupplierStatementView.as_view(), name='supplier_statements'),
path('statements/record/', statement_views.StatementRecordView.as_view(), name='statement_record'),
path('health/', healthy.HealthCheckView.as_view(), name='health_check'),
path('print-count/delta/', print_count.adjust_print_count, name='print_count_delta'),
# 产品图片上传 API
path('products/<int:product_id>/image/', product_image.ProductImageUploadView.as_view(), name='product_image_upload'),
# Stateflow API (使用 Router)
path('stateflow/', include(stateflow_router.urls)),
# 主 Router (printing-orders 等)
path('', include(main_router.urls)),
]