<?php

namespace lib\Configs;

use lib\Controllers\DBMS\Client\CouponController;
use lib\Controllers\DBMS\Client\MemoController;
use lib\Controllers\DBMS\Client\OnetimeController;
use lib\Controllers\DBMS\Client\PaymentController;
use lib\Controllers\DBMS\DashboardController;
use lib\Controllers\DBMS\DefenceController;
use lib\Controllers\DBMS\GearlistController;
use lib\Controllers\DBMS\NavigatorController;
use lib\Controllers\DBMS\ServerController;
use lib\Controllers\DBMS\ServiceController;
use lib\Core\Router;

$router->group('dbms/client/dashboard', function (Router $router) {
  // 동적 파라미터 없이 기본 path에 추가 파라미터를 받아 key/value 형식으로 처리
  $router->add('GET', 'totalcount', function ($params) {
    $controller = new \lib\Controllers\DBMS\Client\DashboardController();
    return $controller->totalcount($params);
    // Response::view($result);
  });
});
$router->group('dbms/client/memo', function (Router $router) {
  $router->add('GET', 'update_form', function ($params) {
    $controller = new MemoController();
    return $controller->update_form($params);
    // Response::view($result);
  });
  $router->add('POST', 'update', function ($params) {
    $controller = new MemoController();
    return $controller->update($params);
    // Response::view($result);
  });
});
$router->group('dbms/client/onetime', function (Router $router) {
  $router->add('GET', 'coupon', function ($params) {
    $controller = new OnetimeController();
    return $controller->coupon($params);
    // Response::view($result);
  });
  // $router->add('POST', 'buy', function ($params) {
  //   $controller = new OnetimeController();
  //   return $controller->update($params);
  //   // Response::view($result);
  // });
  // $router->add('POST', 'use', function ($params) {
  //   $controller = new OnetimeController();
  //   return $controller->update($params);
  //   // Response::view($result);
  // });
});
$router->group('dbms/client/coupon', function (Router $router) {
  $router->add('GET', 'index', function ($params) {
    $controller = new CouponController();
    return $controller->index($params);
    // Response::view($result);
  });
  $router->add('GET', 'client', function ($params) {
    $controller = new CouponController();
    return $controller->client($params);
    // Response::view($result);
  });
  $router->add('GET', 'insert_form', function ($params) {
    $controller = new CouponController();
    return $controller->insert_form($params);
    // Response::view($result);
  });
  $router->add('POST', 'insert', function ($params) {
    $controller = new CouponController();
    return $controller->insert($params);
    // Response::view($result);
  });
});
$router->group('dbms/client/payment', function (Router $router) {
  $router->add('GET', 'billpaper', function ($params) {
    $controller = new PaymentController();
    return $controller->billpaper($params);
    // Response::view($result);
  });
  $router->add('GET', 'nonpayment', function ($params) {
    $controller = new PaymentController();
    return $controller->nonpayment($params);
    // Response::view($result);
  });
});


// 예제 라우트 그룹: dbms/dashboard/index 이후에 key/value 파라미터 허용
$router->group('dbms/dashboard', function (Router $router) {
  // // 동적 파라미터 없이 기본 path에 추가 파라미터를 받아 key/value 형식으로 처리
  // $router->add('GET', 'index', function ($params) {
  //   Response::json([
  //     'message' => 'DashboardController::index 실행됨',
  //     'params' => $params
  //   ]);
  // });
  // 동적 파라미터 없이 기본 path에 추가 파라미터를 받아 key/value 형식으로 처리
  $router->add('GET', 'topboard', function ($params) {
    $controller = new DashboardController();
    return $controller->topboard();
    // Response::view($result);
  });
  $router->add('GET', 'totalcount', function ($params) {
    $controller = new DashboardController();
    return $controller->totalcount($params);
    // Response::view($result);
  });
  $router->add('GET', 'latest_service', function ($params) {
    $controller = new DashboardController();
    return $controller->latest_service($params);
    // Response::view($result);
  });
  $router->add('GET', 'latest_history', function ($params) {
    $controller = new DashboardController();
    return $controller->latest_history($params);
    // Response::view($result);
  });
  $router->add('GET', 'cscount', function ($params) {
    $controller = new DashboardController();
    return $controller->cscount($params);
    // Response::view($result);
  });
  $router->add('GET', 'coupon', function ($params) {
    $controller = new DashboardController();
    return $controller->coupon($params);
    // Response::view($result);
  });
});

$router->group('dbms/navigator', function (Router $router) {
  // 동적 파라미터 없이 기본 path에 추가 파라미터를 받아 key/value 형식으로 처리
  $router->add('GET', 'ipsearch', function ($params) {
    $controller = new NavigatorController();
    return $controller->ipsearch($params);
    // Response::view($result);
  });
});

$router->group('dbms/defence', function (Router $router) {
  // 동적 파라미터 없이 기본 path에 추가 파라미터를 받아 key/value 형식으로 처리
  $router->add('GET', 'mk', function ($params) {
    $controller = new DefenceController();
    return $controller->mk($params);
    // Response::view($result);
  });
});

$router->group('dbms/service', function (Router $router) {
  // 동적 파라미터 없이 기본 path에 추가 파라미터를 받아 key/value 형식으로 처리
  $router->add('GET', 'extra', function ($params) {
    $controller = new ServiceController();
    return $controller->extra($params);
    // Response::view($result);
  });
});

$router->group('dbms/gearlist', function (Router $router) {
  $router->add('GET', 'index', function ($params) {
    $controller = new GearlistController();
    return $controller->index($params);
    // Response::view($result);
  });
});


$router->group('dbms/server', function (Router $router) {
  $router->add('GET', 'index', function ($params) {
    $controller = new ServerController();
    return $controller->index($params);
    // Response::view($result);
  });
});
