<?php

use Slim\App;
use Slim\Http\Request;
use Slim\Http\Response;

return function (App $app) {
    $container = $app->getContainer();

    //404 page not found
    unset($container['notFoundHandler']);
    $container['notFoundHandler'] = function ($c) {
        return function ($request, $response) use ($c) {
            $response = new \Slim\Http\Response(404);
            $data = array('error' => 'page not found');
            return $response->withJson($data);
        };
    };
    
    //405 Method not allowed
    unset($container['notAllowedHandler']);
    $container['notAllowedHandler'] = function ($c) {
        return function ($request, $response) use ($c) {
            $response = new \Slim\Http\Response(405);
            $data = array('error' => 'Method not allowed');
            return $response->withJson($data);
        };
    };

    $app->group('/home', function (App $app) {
        $app->get('/view', HomeController::class . ':view');
        $app->get('/check', HomeController::class . ':check');
        $app->get('/check/{checkType}', HomeController::class . ':check');
        $app->get('/login', HomeController::class . ':login');
    });

    $app->group('/account', function (App $app) {
        $app->any('/login', AccountController::class . ':login')->add(OperatorLog::class);
        $app->post('/logout', AccountController::class . ':logout')->add(OperatorLog::class);
        $app->post('/passLoginInfo', AccountController::class . ':passLoginInfo');
        $app->get('/session/reset/{uid}', AccountController::class . ':sessionReset');
        $app->get('/session/info/{uid}', AccountController::class . ':sessionInfo');
    });

    // Operation
    $app->group('/operation', function (App $app) {
        // Wallet
        $app->group('/wallet', function (App $app) {
            // Customer
            $app->get('/customerList', OperationWalletController::class . ':customerList');
            $app->post('/customerSearchList', OperationWalletController::class . ':postCustomerList');

            // Wallet
            $app->get('/walletList', OperationWalletController::class . ':walletList');
            $app->post('/walletSearchList', OperationWalletController::class . ':postWalletList');
            
            // Transact
            $app->get('/transactList', OperationWalletController::class . ':transactList');
            $app->post('/transactSearchList', OperationWalletController::class . ':postTransactList');
        });

        // Platform
        $app->group('/platform', function (App $app) {
            // User
            $app->get('/userList', OperationPlatformController::class . ':userList');
            $app->post('/userSearchList', OperationPlatformController::class . ':postUserList');

            // SUI Bridge
            $app->get('/bridgeList', OperationPlatformController::class . ':bridgeList');
            $app->post('/bridgeSearchList', OperationPlatformController::class . ':postBridgeList');
            $app->get('/bridgeDetail', OperationPlatformController::class . ':bridgeDetailList');
            $app->post('/bridgeQuantityList', OperationPlatformController::class . ':postBridgeQuantityList');

            // SUI Withdraw
            $app->get('/suiList', OperationPlatformController::class . ':suiList');
            $app->post('/suiSearchList', OperationPlatformController::class . ':postSuiList');
            $app->post('/withdraw', OperationPlatformController::class . ':postSuiWithdraw');
            $app->post('/reset', OperationPlatformController::class . ':postSuiStatusReset');
            
            // ONIT Burn Log
            $app->get('/burnLog', OperationPlatformController::class . ':burnLogList');
            $app->post('/burnLogDetail', OperationPlatformController::class . ':postBurnLogList');

            // Achievement Reward Log
            $app->get('/achievementLog', OperationPlatformController::class . ':achievementLogList');
            $app->post('/achievementSearchLog', OperationPlatformController::class . ':postAchievementLogList');

            // PreSales
            $app->get('/preSalesList', OperationPlatformController::class . ':preSalesList');
            $app->post('/preSalesSearchList', OperationPlatformController::class . ':postPreSalesList');
            $app->get('/claimList', OperationPlatformController::class . ':claimList');
            $app->post('/claimSearchList', OperationPlatformController::class . ':postClaimList');
            $app->post('/searchClaimIDList', OperationPlatformController::class . ':postClaimIDList');
            $app->get('/swapList', OperationPlatformController::class . ':swapList');
            $app->post('/swapSearchList', OperationPlatformController::class . ':postSwapList');
        });

        // Market
        $app->group('/market', function (App $app) {
            // Coin Purchase
            $app->get('/purchaseList', OperationMarketController::class . ':purchaseList');
            $app->post('/purchaseSearchList', OperationMarketController::class . ':postPurchaseList');

            // Bid
            $app->get('/bidList', OperationMarketController::class . ':bidList');
            $app->post('/bidSearchList', OperationMarketController::class . ':postBidList');

            // Product Purchase
            $app->get('/productPurchaseList', OperationMarketController::class . ':productPurchaseList');
            $app->post('/productPurchaseSearchList', OperationMarketController::class . ':postProductPurchaseList');

            // Swap
            $app->get('/swapList', OperationMarketController::class . ':swapList');
            $app->post('/swapSearchList', OperationMarketController::class . ':postSwapList');

            // Product Purchase Log
            $app->get('/productPurchaseLog', OperationMarketController::class . ':productPurchaseLogList');
            $app->post('/productPurchaseLogSearchList', OperationMarketController::class . ':postProductPurchaseLogList');
            
            // Payment Log
            $app->get('/paymentLog', OperationMarketController::class . ':paymentLogList');
            $app->post('/paymentSearchList', OperationMarketController::class . ':postpaymentLogList');
        });

        // Onchain
        $app->group('/onchain', function (App $app) {
            // Charge
            $app->get('/chargeList', OperationOnchainController::class . ':chargeList');
            $app->post('/chargeSearchList', OperationOnchainController::class . ':postChargeList');

            // GameOver
            $app->get('/gameOverList', OperationOnchainController::class . ':gameOverList');
            $app->post('/gameOverSearchList', OperationOnchainController::class . ':postGameOverList');
            
            // Shoot
            $app->get('/shootList', OperationOnchainController::class . ':shootList');
            $app->post('/shootSearchList', OperationOnchainController::class . ':postShootList');

            // RankReward
            $app->get('/rankRewardList', OperationOnchainController::class . ':rankRewardList');
            $app->post('/rankRewardSearchList', OperationOnchainController::class . ':postRankRewardList');
        });

        // SSRPS
        $app->group('/ssrps', function (App $app) {
            // User
            $app->group('/user', function (App $app) {
                // 유저 검색
                $app->get('/list', OperationSSRPSController::class . ':userList');
                $app->post('/searchList', OperationSSRPSController::class . ':postUserList');
                $app->put('/blockUpdate', OperationSSRPSController::class . ':putBlockUpdate');
            });

            // Coupon
            $app->group('/coupon', function (App $app) {
                // 사용자 쿠폰 사용 내역
                $app->get('/list', OperationSSRPSController::class . ':couponList');
                $app->post('/searchList', OperationSSRPSController::class . ':postCouponList');
            });
            
            // Game
            $app->group('/game', function (App $app) {
                // 게임 내역
                $app->get('/list', OperationSSRPSController::class . ':gameList');
                $app->post('/searchList', OperationSSRPSController::class . ':postGameList');
            });
            
            // Product Purchase
            $app->group('/product', function (App $app) {
                // 상품 구매 내역
                $app->get('/list', OperationSSRPSController::class . ':productList');
                $app->post('/searchList', OperationSSRPSController::class . ':postProductList');
            });
            
            // Pass
            $app->group('/pass', function (App $app) {
                // 패스 보상 내역
                $app->get('/list', OperationSSRPSController::class . ':passList');
                $app->post('/searchList', OperationSSRPSController::class . ':postPassList');
            });
        });

        // LeaderBoard
        $app->group('/leaderBoard', function (App $app) {
            // RagmonMarble
            $app->group('/ragmonMarble', function (App $app) {
                // DataSyncFatch
                $app->group('/dataSyncFatch', function (App $app) {
                    $app->get('/list', OperationLeaderBoardController::class . ':dataSyncFatchList');
                    $app->post('/searchList', OperationLeaderBoardController::class . ':postDataSyncFatchList');
                });
                
                $app->group('/season', function (App $app) {
                    // Season Rank
                    $app->get('/rankList', OperationLeaderBoardController::class . ':seasonRankist');
                    $app->post('/searchRankList', OperationLeaderBoardController::class . ':postSeasonRankList');

                    // Season Score
                    $app->get('/scoreList', OperationLeaderBoardController::class . ':seasonScoreList');
                    $app->post('/searchScoreList', OperationLeaderBoardController::class . ':postSeasonScoreList');

                    // Season Rank Reward
                    $app->get('/rewardList', OperationLeaderBoardController::class . ':seasonRewardList');
                    $app->post('/searchRewardList', OperationLeaderBoardController::class . ':postSeasonRewardList');
                });
            });
        });

        // Mirror Token
        $app->group('/mirror', function (App $app) {
            // Claim
            $app->get('/claimList', OperationMirrorController::class . ':claimList');
            $app->post('/searchClaimList', OperationMirrorController::class . ':postClaimList');

            // User
            $app->get('/userList', OperationMirrorController::class . ':userList');
            $app->post('/searchUserList', OperationMirrorController::class . ':postUserList');
        });
    })->add(OperatorLog::class)->add(SessionFilter::class);

    // Management
    $app->group('/management', function (App $app) {
        // Wallet
        $app->group('/wallet', function (App $app) {
            // BlockChainPlatform
            $app->group('/blockChainPlatform', function (App $app) {
                $app->get('/list', ManagementWalletController::class . ':blockChainList');
                $app->post('/update', ManagementWalletController::class . ':blockChainUpdate');
                $app->get('/input', ManagementWalletController::class . ':blockChainInsert');
                $app->post('/input', ManagementWalletController::class . ':postBlockChainInsert');
                $app->post('/delete', ManagementWalletController::class . ':blockChainDelete');
            });

            // Protocol
            $app->group('/protocol', function (App $app) {
                $app->get('/list', ManagementWalletController::class . ':protocolList');
                $app->post('/update', ManagementWalletController::class . ':protocolUpdate');
                $app->get('/input', ManagementWalletController::class . ':protocolInsert');
                $app->post('/input', ManagementWalletController::class . ':postProtocolInsert');
                $app->post('/delete', ManagementWalletController::class . ':protocolDelete');
            });

            // Contract
            $app->group('/contract', function (App $app) {
                $app->get('/list', ManagementWalletController::class . ':contractList');
                $app->post('/searchList', ManagementWalletController::class . ':postContractList');
                $app->get('/update', ManagementWalletController::class . ':contractUpdate');
                $app->post('/update', ManagementWalletController::class . ':postContractUpdate');
                $app->get('/input', ManagementWalletController::class . ':contractInsert');
                $app->post('/input', ManagementWalletController::class . ':postContractInsert');
                $app->post('/delete', ManagementWalletController::class . ':contractDelete');
            });

            // Webhook
            $app->group('/webhook', function (App $app) {
                $app->get('/list', ManagementWalletController::class . ':webhookList');
                $app->post('/update', ManagementWalletController::class . ':webhookUpdate');
                $app->get('/input', ManagementWalletController::class . ':webhookInsert');
                $app->post('/input', ManagementWalletController::class . ':postWebhookInsert');
                $app->post('/delete', ManagementWalletController::class . ':webhookDelete');
            });
        });

        // Platform
        $app->group('/platform', function (App $app) {
            // Artwork
            $app->group('/artwork', function (App $app) {
                $app->get('/list', ManagementPlatformController::class . ':artworkList');
                $app->post('/searchArtworkList', ManagementPlatformController::class . ':postArtworkList');
                $app->get('/input', ManagementPlatformController::class . ':artworkInsert');
                $app->post('/input', ManagementPlatformController::class . ':postArtworkInsert');
            });

            // INNO PLATFORM Maintenance
            $app->group('/innoMaintenance', function (App $app) {
                $app->get('/list', ManagementPlatformController::class . ':innoMaintenanceList');
                $app->post('/input', ManagementPlatformController::class . ':postInnoMaintenanceInsert');
            });

            // BRIDGE Maintenance
            $app->group('/bridgeMaintenance', function (App $app) {
                $app->get('/list', ManagementPlatformController::class . ':bridgeMaintenanceList');
                $app->post('/input', ManagementPlatformController::class . ':postBridgeMaintenanceInsert');
            });

            // NEWS
            $app->group('/news', function (App $app) {
                $app->get('/list', ManagementPlatformController::class . ':newsList');
                $app->post('/searchNewsList', ManagementPlatformController::class . ':postNewsList');
                $app->get('/input', ManagementPlatformController::class . ':newsInsert');
                $app->post('/input', ManagementPlatformController::class . ':postNewsInsert');
                $app->get('/detail', ManagementPlatformController::class . ':newsDetail');
                $app->post('/detail', ManagementPlatformController::class . ':postNewsUpdate');
                $app->post('/visible', ManagementPlatformController::class . ':postNewsVisible');
                $app->post('/transfer', ManagementPlatformController::class . ':postNewsTransfer');
                $app->post('/recieve', ManagementPlatformController::class . ':postNewsRecieve');
            });

            // Achievements
            $app->group('/achievements', function (App $app) {
                $app->get('/list', ManagementPlatformController::class . ':achievementsList');
                $app->post('/searchList', ManagementPlatformController::class . ':postAchievementsList');
                $app->post('/search', ManagementPlatformController::class . ':postAchievements');
                $app->post('/seasonList', ManagementPlatformController::class . ':postSeasonsList');
                $app->post('/season/input', ManagementPlatformController::class . ':postSeasonInsert');
                $app->post('/season/update', ManagementPlatformController::class . ':postSeasonUpdate');
                $app->get('/input', ManagementPlatformController::class . ':achievementInsert');
                $app->post('/input', ManagementPlatformController::class . ':postAchievementInsert');
                $app->get('/update', ManagementPlatformController::class . ':achievementUpdate');
                $app->post('/update', ManagementPlatformController::class . ':postAchievementUpdate');
                $app->put('/enable/update', ManagementPlatformController::class . ':putEnableUpdate');
                $app->put('/seasonEnable/update', ManagementPlatformController::class . ':putSeasonEnableUpdate');
                $app->post('/searchRewardsList', ManagementPlatformController::class . ':postRewardsList');
            });

            // NFT PreSales
            $app->group('/preSales', function (App $app) {
                // 사전 판매 이벤트(정보)
                $app->get('/list', ManagementPlatformController::class . ':preSalesList');
                $app->post('/searchList', ManagementPlatformController::class . ':postPreSalesList');
                $app->get('/input', ManagementPlatformController::class . ':preSalesInsert');
                $app->post('/input', ManagementPlatformController::class . ':postPreSalesInsert');
                $app->get('/detail', ManagementPlatformController::class . ':preSalesDetail');
                $app->post('/update', ManagementPlatformController::class . ':postPreSalesUpdate');

                // 사전 판매 Claim(상품)
                $app->get('/claimList', ManagementPlatformController::class . ':preSalesClaimList');
                $app->post('/searchClaimList', ManagementPlatformController::class . ':postPreSalesClaimList');
                $app->get('/claimInput', ManagementPlatformController::class . ':preSalesClaimInsert');
                $app->post('/claimInput', ManagementPlatformController::class . ':postPreSalesClaimInsert');
                $app->get('/claimDetail', ManagementPlatformController::class . ':preSalesClaimDetail');
                $app->post('/claimUpdate', ManagementPlatformController::class . ':postPreSalesClaimUpdate');
                $app->put('/claimEnableUpdate', ManagementPlatformController::class . ':putPreSalesClaimEnableUpdate');
                $app->post('/claimImageUpdate', ManagementPlatformController::class . ':postPreSalesClaimImageUpdate');
                $app->post('/searchNftPackList', ManagementPlatformController::class . ':postNftPackList');
                $app->post('/searchGachaNftList', ManagementPlatformController::class . ':postGachaNftList');
                $app->post('/claimGachaNftInput', ManagementPlatformController::class . ':postPreSalesClaimGachaNftInput');

                // 사전 판매 보상
                $app->get('/rewardList', ManagementPlatformController::class . ':preSalesRewardList');  // 보상 리스트
                $app->post('/rewardInput', ManagementPlatformController::class . ':postPreSalesClaimRewardInsert'); // 보상 등록
                $app->post('/rewardPrice', ManagementPlatformController::class . ':postPreSalesClaimPrice'); // 가격 등록, 수정
                $app->post('/gachaInput', ManagementPlatformController::class . ':postPreSalesClaimGachasInsert'); // 랜덤 보상 Gachas 등록
            });
        });

        // Market
        $app->group('/market', function (App $app) {
            // NFTPack
            $app->group('/nftpack', function (App $app) {
                // 리스트
                $app->get('/list', ManagementMarketController::class . ':nftList');
                $app->get('/ipfs/daemon', ManagementMarketController::class . ':IPFSState');
                $app->post('/ipfs/daemon', ManagementMarketController::class . ':IPFSDaemon');
                $app->delete('/ipfs/daemon', ManagementMarketController::class . ':IPFSDaemonKill');
                $app->get('/publish/state', ManagementMarketController::class . ':nftPublishStateList');
                $app->post('/publish/state', ManagementMarketController::class . ':postNftPublishState');
                
                $app->post('/transfer', ManagementMarketController::class . ':postNftPackTransfer');
                $app->post('/recieve', ManagementMarketController::class . ':postNftPackRecieve');

                // 상세페이지
                $app->get('/detail', ManagementMarketController::class . ':nftPackDetail');
                $app->post('/publish', ManagementMarketController::class . ':nftPublish');
                $app->post('/publish/stop', ManagementMarketController::class . ':nftPublishStop');
                $app->post('/input', ManagementMarketController::class . ':postNftInsert');
                $app->put('/application/merge', ManagementMarketController::class . ':putNftMerge');
                $app->post('/application', ManagementMarketController::class . ':nftApplication');
                
                // 수정페이지
                $app->get('/update', ManagementMarketController::class . ':nftPackUpdate');
                $app->post('/update', ManagementMarketController::class . ':postNftPackUpdate');

                // 등록페이지 - 일반등록
                $app->get('/inputGeneal', ManagementMarketController::class . ':nftPackInsert'); //NFTPackInsPage
                $app->post('/inputGeneal', ManagementMarketController::class . ':postNftPackInsert'); //NFTPackIns
                
                // 등록페이지 - PNG등록
                $app->get('/inputPng', ManagementMarketController::class . ':nftPackInsertPng'); //NFTPackInsPageG
                $app->post('/inputPng', ManagementMarketController::class . ':postNftPackInsertPng'); //NFTPackInsG
                
                // 등록페이지 - 대량등록
                $app->get('/inputBulk', ManagementMarketController::class . ':nftPackInsertBulk'); //NFTPackInsPageM
                $app->post('/inputBulk', ManagementMarketController::class . ':postNftPackInsertBulk'); //NFTPackInsM
                $app->post('/exists', ManagementMarketController::class . ':postNftExists'); //NFTExists
            });

            // Product
            $app->group('/product', function (App $app) {
                $app->get('/list', ManagementMarketController::class . ':productList');
                $app->post('/visible', ManagementMarketController::class . ':postProductVisible');
                $app->post('/visibleMulti', ManagementMarketController::class . ':postProductVisibleMulti');
                $app->get('/detail', ManagementMarketController::class . ':productDetail');
                $app->post('/price', ManagementMarketController::class . ':postProductPrice');
                $app->post('/nft', ManagementMarketController::class . ':postProductNft');
                $app->post('/status', ManagementMarketController::class . ':postProductStatus');
                $app->get('/input', ManagementMarketController::class . ':productInsert');
                $app->post('/input', ManagementMarketController::class . ':postProductInsert');
                $app->get('/nftPacks', ManagementMarketController::class . ':nftPackList');
                $app->get('/update', ManagementMarketController::class . ':productUpdate');
                $app->post('/update', ManagementMarketController::class . ':postProductUpdate');
            });

            // Section
            $app->group('/section', function (App $app) {
                $app->get('/list', ManagementMarketController::class . ':sectionList');
                $app->post('/searchSectionList', ManagementMarketController::class . ':postSectionList');
                $app->post('/update', ManagementMarketController::class . ':sectionUpdate');
            });

            // Merge
            $app->group('/merge', function (App $app) {
                $app->get('/list', ManagementMarketController::class . ':mergeList');
                $app->post('/searchMergeList', ManagementMarketController::class . ':postMergeList');
                $app->post('/apply', ManagementMarketController::class . ':postMerge');
                $app->put('/apply', ManagementMarketController::class . ':putMerge');
                $app->put('/enable', ManagementMarketController::class . ':putEnable');
                $app->post('/nftMerge', ManagementMarketController::class . ':postNftMerge');
            });

            // Dynamic NFT
            $app->group('/dynamicNft', function (App $app) {
                $app->get('/list', ManagementMarketController::class . ':dynamicNftList');
                $app->post('/searchList', ManagementMarketController::class . ':postDynamicNftList');
                $app->post('/update', ManagementMarketController::class . ':dynamicNftUpdate');
                $app->post('/searchWallet', ManagementMarketController::class . ':postWallet'); // 지갑 주소 검색
                $app->post('/searchBaseCoinWalletType', ManagementMarketController::class . ':postBaseCoinWalletType');
                $app->post('/input', ManagementMarketController::class . ':dynamicNftInsert');
            });
        });

        // Game
        $app->group('/game', function (App $app) {
            // DividendRate
            $app->group('/dividendRate', function (App $app) {
                $app->get('/list', ManagementGameController::class . ':dividendRateList');
                $app->post('/update', ManagementGameController::class . ':dividendRateUpdate');
            });
        });

        // Onchain
        $app->group('/onchain', function (App $app) {
            // Maintenance
            $app->group('/maintenance', function (App $app) {
                $app->get('/list', ManagementOnchainController::class . ':maintenanceList');
                $app->post('/input', ManagementOnchainController::class . ':postMaintenanceInsert');
            });
        });

        // Metadata
        $app->group('/metadata', function (App $app) {
            // Company
            $app->group('/company', function (App $app) {
                $app->get('/list', ManagementMetadataController::class . ':companyList');
                $app->post('/update', ManagementMetadataController::class . ':postCompanyUpdate');
                $app->post('/input', ManagementMetadataController::class . ':postCompanyInsert');
            });

            // Application
            $app->group('/application', function (App $app) {
                $app->get('/list', ManagementMetadataController::class . ':applicationList');
                $app->post('/searchApplicationList', ManagementMetadataController::class . ':postApplicationList');
                $app->post('/visible', ManagementMetadataController::class . ':postApplicationVisible');    // 활성화 여부 수정
                $app->get('/detail', ManagementMetadataController::class . ':applicationDetail');
                $app->post('/update', ManagementMetadataController::class . ':postApplicationUpdate');
                $app->get('/input', ManagementMetadataController::class . ':applicationInsert');
                $app->post('/input', ManagementMetadataController::class . ':postApplicationInsert');
            });

            // Basecoin
            $app->group('/basecoin', function (App $app) {
                $app->get('/list', ManagementMetadataController::class . ':basecoinList');
                $app->post('/update', ManagementMetadataController::class . ':postBasecoinUpdate');
                $app->post('/input', ManagementMetadataController::class . ':postBasecoinInsert');
            });

            // Coin
            $app->group('/coin', function (App $app) {
                $app->get('/list', ManagementMetadataController::class . ':coinList');
                $app->post('/searchCoinList', ManagementMetadataController::class . ':postCoinList');
                $app->get('/detail', ManagementMetadataController::class . ':coinDetail');
                $app->post('/update', ManagementMetadataController::class . ':postCoinUpdate');
                $app->get('/input', ManagementMetadataController::class . ':coinInsert');
                $app->post('/input', ManagementMetadataController::class . ':postCoinInsert');
            });

            // Point
            $app->group('/point', function (App $app) {
                $app->get('/list', ManagementMetadataController::class . ':pointList');
                $app->post('/update', ManagementMetadataController::class . ':postPointUpdate');
                $app->post('/input', ManagementMetadataController::class . ':postPointInsert');
            });

            // ApplicationCoin
            $app->group('/applicationCoin', function (App $app) {
                $app->get('/list', ManagementMetadataController::class . ':applicationCoinList');
                $app->post('/searchAppCoinList', ManagementMetadataController::class . ':postApplicationCoinList');
                $app->post('/input', ManagementMetadataController::class . ':postApplicationCoinInsert');
            });

            // ApplicationPoint
            $app->group('/applicationPoint', function (App $app) {
                $app->get('/list', ManagementMetadataController::class . ':applicationPointList');
                $app->post('/searchAppPointList', ManagementMetadataController::class . ':postApplicationPointList');
                $app->post('/input', ManagementMetadataController::class . ':postApplicationPointInsert');
                $app->post('/update', ManagementMetadataController::class . ':postApplicationPointUpdate');
            });

            // Swap
            $app->group('/swap', function (App $app) {
                $app->get('/list', ManagementMetadataController::class . ':swapList');
                $app->post('/searchSwpList', ManagementMetadataController::class . ':postSwapList');
                $app->post('/input', ManagementMetadataController::class . ':postSwapInsert');
                $app->post('/update', ManagementMetadataController::class . ':postSwapUpdate');
                $app->post('/searchTiersList', ManagementMetadataController::class . ':postTiersList');
                $app->post('/tiers', ManagementMetadataController::class . ':postTiers');
                $app->post('/searchTierConditionsList', ManagementMetadataController::class . ':postTierConditionsList');
                $app->post('/searchTierConditionsIDs', ManagementMetadataController::class . ':postTierConditionsIDs');
                $app->post('/tierConditions', ManagementMetadataController::class . ':postTierConditions');
            });

            // SSRPS Store
            $app->group('/store', function (App $app) {
                $app->get('/list', ManagementMetadataController::class . ':storeList');
                $app->post('/input', ManagementMetadataController::class . ':postStoreInsert');
            });

            // SSRPS Pass
            $app->group('/pass', function (App $app) {
                $app->get('/list', ManagementMetadataController::class . ':passList');
            });
        });

        // SSRPS
        $app->group('/ssrps', function (App $app) {
            // Coupon
            $app->group('/coupon', function (App $app) {
                $app->get('/list', ManagementSSRPSController::class . ':couponList');
                $app->post('/searchList', ManagementSSRPSController::class . ':postCouponList');
                $app->get('/input', ManagementSSRPSController::class . ':couponInsert');
                $app->post('/input', ManagementSSRPSController::class . ':postCouponInsert');
                $app->get('/detail', ManagementSSRPSController::class . ':preCouponDetail');
                $app->post('/update', ManagementSSRPSController::class . ':postCouponUpdate');
            });
        
        });

        // Leader Board
        $app->group('/leaderBoard', function (App $app) {
            // Ragmon Marble
            $app->group('/ragmonMarble', function (App $app) {
                // Metadata
                $app->group('/metadata', function (App $app) {
                    $app->get('/list', ManagementLeaderBoardController::class . ':metaDataList');
                    $app->post('/searchList', ManagementLeaderBoardController::class . ':postMetaDataList');
                    $app->post('/input', ManagementLeaderBoardController::class . ':postMetaDataInsert');
                    $app->post('/update', ManagementLeaderBoardController::class . ':postMetaDataUpdate');
                });
                
                // LeaderBoard
                $app->group('/leaderBoard', function (App $app) {
                    // Seasons
                    $app->get('/seasonList', ManagementLeaderBoardController::class . ':seasonList');
                    $app->post('/searchSeasonList', ManagementLeaderBoardController::class . ':postSeasonList');
                    $app->post('/seasonInput', ManagementLeaderBoardController::class . ':postSeasonInsert');
                    $app->post('/seasonUpdate', ManagementLeaderBoardController::class . ':postSeasonUpdate');

                    // Season Rank Rewards
                    $app->get('/seasonRankRewardList', ManagementLeaderBoardController::class . ':seasonRankRewardList');
                    $app->post('/searchSeasonRankRewardList', ManagementLeaderBoardController::class . ':postSeasonRankRewardList');
                    $app->post('/seasonRankRewardInput', ManagementLeaderBoardController::class . ':postSeasonRankRewardInsert');
                    $app->post('/seasonRankRewardUpdate', ManagementLeaderBoardController::class . ':postSeasonRankRewardUpdate');

                    // Season Rank Point Boosts
                    $app->get('/seasonRankPointBoostList', ManagementLeaderBoardController::class . ':seasonRankPointBoostList');
                    $app->post('/searchSeasonRankPointBoostList', ManagementLeaderBoardController::class . ':postSeasonRankPointBoostList');
                    $app->post('/seasonRankPointBoostInput', ManagementLeaderBoardController::class . ':postSeasonRankPointBoostInsert');
                    $app->post('/seasonRankPointBoostUpdate', ManagementLeaderBoardController::class . ':postSeasonRankPointBoostUpdate');
                });
            });
        });
    })->add(OperatorLog::class)->add(SessionFilter::class);

    // Statistics
    $app->group('/statistics', function (App $app) {
        // Wallet
        $app->group('/wallet', function (App $app) {
            $app->get('/coin', StatisticsWalletController::class . ':coinList');
            $app->post('/searchCustomerList', StatisticsWalletController::class . ':postCustomerList');
            $app->post('/searchCoinList', StatisticsWalletController::class . ':postCoinList');
            $app->get('/nft', StatisticsWalletController::class . ':nftList');
            $app->post('/searchNftList', StatisticsWalletController::class . ':postNftList');
        });

        // Platform
        $app->group('/platform', function (App $app) {
            $app->get('/ru', StatisticsPlatformController::class . ':ruList');
            $app->post('/searchRuList', StatisticsPlatformController::class . ':postRuList');
            $app->get('/coin', StatisticsPlatformController::class . ':coinList');
            $app->post('/searchCoinList', StatisticsPlatformController::class . ':postCoinList');
            $app->get('/point', StatisticsPlatformController::class . ':pointList');
            $app->post('/searchPointList', StatisticsPlatformController::class . ':postPointList');
            $app->get('/exchange', StatisticsPlatformController::class . ':exchangeList');
            $app->post('/searchExchangeList', StatisticsPlatformController::class . ':postExchangeList');
            $app->get('/user', StatisticsPlatformController::class . ':userList');
            $app->post('/searchUserList', StatisticsPlatformController::class . ':postUserList');
            $app->get('/swap', StatisticsPlatformController::class . ':swapList');
            $app->post('/searchSwapList', StatisticsPlatformController::class . ':postSwapList');
        });

        // market
        $app->group('/market', function (App $app) {
            $app->get('/product', StatisticsMarketController::class . ':productList');
            $app->post('/searchProductList', StatisticsMarketController::class . ':postProductList');
            $app->get('/nft', StatisticsMarketController::class . ':nftList');
            $app->post('/searchNftList', StatisticsMarketController::class . ':postNftList');
        });

        // game
        $app->group('/game', function (App $app) {
            $app->get('/payment', StatisticsGameController::class . ':paymentList');
            $app->post('/searchPaymentList', StatisticsGameController::class . ':postPaymentList');
        });

        // onchain
        $app->group('/onchain', function (App $app) {
            $app->get('/game', StatisticsOnchainController::class . ':gameList');
            $app->post('/searchGameList', StatisticsOnchainController::class . ':postGameList');
        });
    })->add(OperatorLog::class)->add(SessionFilter::class);
    
    // Authority
    $app->group('/authority', function (App $app) {
        $app->get('/view', AuthorityController::class . ':view');
        $app->post('/authoritySearchList', AuthorityController::class . ':postAuthorityList');
        $app->post('/autorityUpdate', AuthorityController::class . ':authorityUpdate');
        $app->get('/user', AuthorityController::class . ':user');
        $app->post('/input', AuthorityController::class . ':userInsert');
        $app->post('/searchUserList', AuthorityController::class . ':postSearchUserList');
        $app->post('/userUpdate', AuthorityController::class . ':userUpdate');
        $app->post('/delete', AuthorityController::class . ':userDelete');
    })->add(OperatorLog::class)->add(SessionFilter::class);

    $app->get('/', function ($request, $response, $args) {

        //serverParams
        $basePath = $request->getUri()->getBasePath();

        return $response->withRedirect($basePath . "/home/view");
    });

    $app->get('/maintenace', HomeController::class . ':maintenace');

    $app->get('/v1.0/version', function ($request, $response, $args) {
        $data = [
            'return' => 0,
            'message' => 'success',
            'value' => [
                'revision' => '',
                'version' => 'v1.0',
            ]
        ];
        return $response->withJson($data);
    });
    
    // BrickPop 통계
    $app->get('/onchain/brickPop', StatisticsOnchainController::class . ':brickPop');
};
