<?php

namespace lib\Configs;

use lib\Controllers\Client\ClientController;
use lib\Controllers\Client\CouponController;
use lib\Controllers\Client\DashboardController as ClientDashboardController;
use lib\Controllers\Client\PaymentController;
use lib\Controllers\Client\PointController;
use lib\Controllers\DashboardController;
use lib\Controllers\DefenceController;
use lib\Controllers\GearlistController;
use lib\Controllers\OnetimeController;
use lib\Controllers\ServiceController;
use lib\Core\Router;

//Client관련련
$router->group('dbms/client', function (Router $router) {
  //Dashboard관련
  $router->group('dashboard', function (Router $router) {
    $router->add('GET', 'totalcount', function ($params) {
      $controller = new ClientDashboardController($params);
      return $controller->totalcount();
      // Response::view($result);
    });
  });
  //메모변경관련
  $router->add('GET', 'update_form', function ($params) {
    $controller = new ClientController($params);
    return $controller->update_form();
    // Response::view($result);
  });
  $router->add('POST', 'update', function ($params) {
    $controller = new ClientController($params);
    return $controller->update();
    // Response::view($result);
  });
  //쿠폰관련
  $router->group('coupon', function (Router $router) {
    $router->add('GET', 'index', function ($params) {
      $controller = new CouponController($params);
      return $controller->index();
      // Response::view($result);
    });
    $router->add('GET', 'update_form', function ($params) {
      $controller = new CouponController($params);
      return $controller->update_form();
      // Response::view($result);
    });
    $router->add('POST', 'update', function ($params) {
      $controller = new CouponController($params);
      return $controller->update();
      // Response::view($result);
    });
  });
  //Point관련
  $router->group('point', function (Router $router) {
    $router->add('GET', 'index', function ($params) {
      $controller = new PointController($params);
      return $controller->index();
      // Response::view($result);
    });
    $router->add('GET', 'insert_form', function ($params) {
      $controller = new PointController($params);
      return $controller->insert_form();
      // Response::view($result);
    });
    $router->add('POST', 'insert', function ($params) {
      $controller = new PointController($params);
      return $controller->insert();
      // Response::view($result);
    });
  });
  //결제관련
  $router->group('payment', function (Router $router) {
    $router->add('GET', 'index', function ($params) {
      $controller = new PaymentController($params);
      return $controller->index();
      // Response::view($result);
    });
    $router->add('GET', 'billpaper', function ($params) {
      $controller = new PaymentController($params);
      return $controller->billpaper();
      // Response::view($result);
    });
  });
});

$router->group('dbms/onetime', function (Router $router) {
  // 동적 파라미터 없이 기본 path에 추가 파라미터를 받아 key/value 형식으로 처리
  $router->add('GET', 'index', function ($params) {
    $controller = new OnetimeController($params);
    return $controller->index();
    // 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($params);
    return $controller->topboard();
    // Response::view($result);
  });
  $router->add('GET', 'totalcount', function ($params) {
    $controller = new DashboardController($params);
    return $controller->totalcount();
    // Response::view($result);
  });
  $router->add('GET', 'latest_service', function ($params) {
    $controller = new DashboardController($params);
    return $controller->latest_service();
    // Response::view($result);
  });
  $router->add('GET', 'latest_history', function ($params) {
    $controller = new DashboardController($params);
    return $controller->latest_history();
    // Response::view($result);
  });
  $router->add('GET', 'cscount', function ($params) {
    $controller = new DashboardController($params);
    return $controller->cscount();
    // Response::view($result);
  });
  $router->add('GET', 'coupon', function ($params) {
    $controller = new DashboardController($params);
    return $controller->coupon();
    // Response::view($result);
  });
});

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

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

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