import { Router } from 'express';
import { requireTraceContext } from '../../core/guards/trace-context.guard';
import { requirePermission } from '../../core/guards/rbac.guard';
import {
  OmnichannelController,
  MarketingController,
  FulfillmentController,
  StoreCreationController,
  CrossBorderController,
} from '../controllers/OmnichannelController';

const router = Router();

// [BE-CS005] Omnichannel message aggregation
router.post(
  '/communication/aggregate',
  requireTraceContext,
  requirePermission('communication:read'),
  OmnichannelController.aggregateMessages
);

// [BE-CS006] Intelligent automated customer service
router.post(
  '/communication/auto-reply',
  requireTraceContext,
  requirePermission('communication:write'),
  OmnichannelController.autoReply
);

// [BE-CS007] Team collaboration management
router.post(
  '/communication/team-task',
  requireTraceContext,
  requirePermission('communication:write'),
  OmnichannelController.createTeamTask
);

// [BE-CS008] Customer fine-grained management
router.put(
  '/communication/customer/:customerId/profile',
  requireTraceContext,
  requirePermission('customer:write'),
  OmnichannelController.updateCustomerProfile
);

// [BE-CS009] Cross-border communication adaptation
router.post(
  '/communication/translate',
  requireTraceContext,
  requirePermission('communication:write'),
  OmnichannelController.translateMessage
);

// [BE-AD004] Multi-channel integration
router.post(
  '/marketing/channels',
  requireTraceContext,
  requirePermission('marketing:write'),
  MarketingController.integrateChannels
);

// [BE-AD005] Intelligent marketing automation
router.post(
  '/marketing/automation',
  requireTraceContext,
  requirePermission('marketing:write'),
  MarketingController.createAutomation
);

// [BE-AD006] Marketing effect analysis
router.get(
  '/marketing/campaign/:campaignId/analyze',
  requireTraceContext,
  requirePermission('marketing:read'),
  MarketingController.analyzeCampaign
);

// [BE-AD007] A/B test automation
router.post(
  '/marketing/ab-test',
  requireTraceContext,
  requirePermission('marketing:write'),
  MarketingController.runABTest
);

// [BE-O005] Multi-platform order unification
router.post(
  '/fulfillment/orders/unify',
  requireTraceContext,
  requirePermission('order:write'),
  FulfillmentController.unifyOrders
);

// [BE-O006] Intelligent order routing
router.post(
  '/fulfillment/order/:orderId/route',
  requireTraceContext,
  requirePermission('order:write'),
  FulfillmentController.routeOrder
);

// [BE-O007] Full-process fulfillment management
router.post(
  '/fulfillment/order/:orderId/manage',
  requireTraceContext,
  requirePermission('order:write'),
  FulfillmentController.manageFulfillment
);

// [BE-O008] Cross-platform status sync
router.post(
  '/fulfillment/order/:orderId/sync-status',
  requireTraceContext,
  requirePermission('order:write'),
  FulfillmentController.syncStatus
);

// [BE-SC001] Template-based website design
router.post(
  '/store/template',
  requireTraceContext,
  requirePermission('store:write'),
  StoreCreationController.createTemplate
);

// [BE-SC002] Drag-and-drop page editor
router.put(
  '/store/website/:websiteId/page/:pageId/components',
  requireTraceContext,
  requirePermission('store:write'),
  StoreCreationController.updatePageComponents
);

// [BE-SC003] Responsive layout adaptation
router.get(
  '/store/website/:websiteId/page/:pageId/adapt',
  requireTraceContext,
  StoreCreationController.adaptResponsiveLayout
);

// [BE-SC004] Multilingual support
router.post(
  '/store/website/:websiteId/multilingual',
  requireTraceContext,
  requirePermission('store:write'),
  StoreCreationController.setupMultilingual
);

// [BE-SC005] Brand identity and visual design
router.post(
  '/store/brand',
  requireTraceContext,
  requirePermission('store:write'),
  StoreCreationController.createBrand
);

// [BE-SC006] Brand story and content management
router.post(
  '/store/brand/:brandId/content',
  requireTraceContext,
  requirePermission('store:write'),
  StoreCreationController.manageContent
);

// [BE-SC007] Ecommerce feature integration
router.post(
  '/store/website/:websiteId/ecommerce',
  requireTraceContext,
  requirePermission('store:write'),
  StoreCreationController.integrateEcommerce
);

// [BE-SC008] Marketing tool integration
router.post(
  '/store/website/:websiteId/marketing',
  requireTraceContext,
  requirePermission('store:write'),
  StoreCreationController.integrateMarketing
);

// [BE-SC009] Shipping and delivery configuration
router.post(
  '/store/website/:websiteId/shipping',
  requireTraceContext,
  requirePermission('store:write'),
  StoreCreationController.configureShipping
);

// [BE-SC010] Data analysis and reporting
router.post(
  '/store/website/:websiteId/analytics',
  requireTraceContext,
  requirePermission('store:read'),
  StoreCreationController.generateAnalytics
);

// [BE-SC011] SEO optimization
router.post(
  '/store/website/:websiteId/seo',
  requireTraceContext,
  requirePermission('store:write'),
  StoreCreationController.optimizeSEO
);

// [BE-SC012] Social media integration
router.post(
  '/store/website/:websiteId/social',
  requireTraceContext,
  requirePermission('store:write'),
  StoreCreationController.integrateSocialMedia
);

// [BE-SC013] Content marketing support
router.post(
  '/store/website/:websiteId/content-marketing',
  requireTraceContext,
  requirePermission('store:write'),
  StoreCreationController.manageContentMarketing
);

// [BE-SC014] Brand story spreading
router.post(
  '/store/brand/:brandId/spread',
  requireTraceContext,
  requirePermission('store:write'),
  StoreCreationController.spreadBrandStory
);

// [BE-CB006] Sellbrite platform integration
router.post(
  '/cross-border/sellbrite',
  requireTraceContext,
  requirePermission('integration:write'),
  CrossBorderController.integrateSellbrite
);

// [BE-CB007] Shoplazza platform integration
router.post(
  '/cross-border/shoplazza',
  requireTraceContext,
  requirePermission('integration:write'),
  CrossBorderController.integrateShoplazza
);

// [BE-CB008] SaleSmartly platform integration
router.post(
  '/cross-border/salesmartly',
  requireTraceContext,
  requirePermission('integration:write'),
  CrossBorderController.integrateSaleSmartly
);

// [BE-CB009] Multi-platform inventory sync
router.post(
  '/cross-border/inventory/sync',
  requireTraceContext,
  requirePermission('inventory:write'),
  CrossBorderController.syncInventory
);

// [BE-CB010] Omnichannel marketing integration
router.post(
  '/cross-border/marketing',
  requireTraceContext,
  requirePermission('marketing:write'),
  CrossBorderController.integrateMarketing
);

// Get integration status
router.get(
  '/cross-border/integration',
  requireTraceContext,
  CrossBorderController.getIntegrationStatus
);

// Disconnect platform
router.delete(
  '/cross-border/integration/:platform',
  requireTraceContext,
  requirePermission('integration:write'),
  CrossBorderController.disconnectPlatform
);

export default router;
