<?php

use Illuminate\Support\Facades\Route;

// 관리자
use App\Http\Controllers\AdminController;
use App\Http\Controllers\Admin\AjaxController;
use App\Http\Controllers\Admin\Config;
use App\Http\Controllers\Admin\Config\Setting;
use App\Http\Controllers\Admin\Config\Layout;
use App\Http\Controllers\Admin\Config\Register;
use App\Http\Controllers\Admin\Config\Form;
use App\Http\Controllers\Admin\Config\Test;
use App\Http\Controllers\Admin\Page;
use App\Http\Controllers\Admin\Page\Banner;
use App\Http\Controllers\Admin\Popup;
use App\Http\Controllers\Admin\User;
use App\Http\Controllers\Admin\User\Dormant;
use App\Http\Controllers\Admin\Board;
use App\Http\Controllers\Admin\Board\Group;
use App\Http\Controllers\Admin\Board\Trash;

/**
|--------------------------------------------------------------------------
| 관리자
|--------------------------------------------------------------------------
 */
Route::prefix('admin')->name('admin.')->middleware(['web', 'auth', 'admin', 'verified'])->group(function()
{
    // 관리자 권한 확인, 상황판
    Route::get('', [AdminController::class, 'index'])->name('index');

    /*********************************
     * 환경
     *********************************/

    // Server 정보
    Route::get('config/server', [Config\ServerController::class, 'server'])->name('server')->name('config.server');
    Route::get('config/server/ajaxData', [Config\ServerController::class, 'ajaxData'])->name('config.server.ajax');

    // PHP 정보
    Route::get('config/server/php', [Config\ServerController::class, 'php'])->name('config.server.php');

    // DB 정보
    Route::get('config/server/db', [Config\ServerController::class, 'db'])->name('config.server.db');

    // 환경 > 기본 설정
    Route::resource('config/setting/basic', Setting\BasicController::class)->names('config.setting.basic');
    Route::resource('config/setting/access', Setting\AccessController::class)->names('config.setting.access');
    Route::resource('config/setting/notify', Setting\NotifyController::class)->names('config.setting.notify');
    Route::resource('config/setting/company', Setting\CompanyController::class)->names('config.setting.company');
    Route::resource('config/setting/exp', Setting\ExpController::class)->names('config.setting.exp');

    // 환경 > 속성 설정
    Route::resource('config/layout/meta', Layout\MetaController::class)->names('config.layout.meta');
    Route::resource('config/layout/logo', Layout\LogoController::class)->names('config.layout.logo');

    // 환경 > 회원가입 설정
    Route::resource('config/register/basic', Register\BasicController::class)->names('config.register.basic');
    Route::resource('config/register/login', Register\LoginController::class)->names('config.register.login');
    Route::resource('config/register/modify', Register\ModifyController::class)->names('config.register.modify');
    Route::resource('config/register/notify', Register\NotifyController::class)->names('config.register.notify');

    // 환경 > 알림 발송 양식
    Route::get('config/form/email/layout', [Form\EmailController::class, 'layout'])->name('config.form.email.layout');
    Route::resource('config/form/email', Form\EmailController::class)->names('config.form.email');
    Route::resource('config/form/telegram', Form\TelegramController::class)->names('config.form.telegram');

    // 환경 > 알림 발송 확인
    Route::resource('config/test/email', Test\EmailController::class)->names('config.test.email');
    Route::resource('config/test/telegram', Test\TelegramController::class)->names('config.test.telegram');

    // 환경 > 복구 / 최적화
    Route::get('config/optimize', [Config\OptimizeController::class, 'index'])->name('config.optimize');
    Route::get('config/optimize/clear/appCache', [Config\OptimizeController::class, 'clear'])->name('config.optimize.clear.appCache');
    Route::get('config/optimize/clear/routeCache', [Config\OptimizeController::class, 'clear'])->name('config.optimize.clear.routeCache');
    Route::get('config/optimize/clear/configCache', [Config\OptimizeController::class, 'clear'])->name('config.optimize.clear.configCache');
    Route::get('config/optimize/clear/viewCache', [Config\OptimizeController::class, 'clear'])->name('config.optimize.clear.viewCache');

    /*********************************
     * 일반
     *********************************/

    // 일반 > 메뉴
    Route::resource('page/menu', Page\MenuController::class)->names('page.menu');

    // 일반 > 메뉴 관리
    Route::get('page/menu/up/{id}', [Page\MenuController::class, 'up'])->name('page.menu.up');
    Route::get('page/menu/down/{id}', [Page\MenuController::class, 'down'])->name('page.menu.down');

    // 일반 > 문서
    Route::resource('page/document', Page\DocumentController::class)->names('page.document');

    // 일반 > 팝업
    Route::resource('page/popup', Page\PopupController::class)->names('page.popup');

    // 일반 > 배너 그룹
    Route::resource('page/banner/group', Banner\GroupController::class)->names('page.banner.group');

    // 일반 > 배너
    Route::resource('page/banner', Banner\ListController::class)->names('page.banner');

    /*********************************
     * 회원
     *********************************/

    // 회원 > 회원 관리
    Route::post('user/list/withdraw', [User\ListController::class, 'withdraw'])->name('user.list.withdraw');
    Route::resource('user/list', User\ListController::class)->names('user.list');

    // 회원 > 이름 변경 이력
    Route::resource('user/log/name', User\Log\NameController::class)->names('user.log.name');

    // 회원 > 이메일 변경 이력
    Route::resource('user/log/email', User\Log\EmailController::class)->names('user.log.email');

    // 회원 > 로그인 이력
    Route::resource('user/log/login/stat', User\Log\Login\StatController::class)->names('user.log.login.stat');
    Route::resource('user/log/login', User\Log\Login\LogController::class)->names('user.log.login');

    // 회원 > 휴면계정 관리
    Route::resource('user/dormant/config', Dormant\ConfigController::class)->names('user.dormant.config');
    Route::resource('user/dormant/list', Dormant\ListController::class)->names('user.dormant.list');
    Route::post('user/dormant/list/notify', [Dormant\ListController::class, 'notify'])->name('user.dormant.list.notify');
    Route::post('user/dormant/list/dormancy', [Dormant\ListController::class, 'dormancy'])->name('user.dormant.list.dormancy');
    Route::post('user/dormant/list/recover', [Dormant\ListController::class, 'recover'])->name('user.dormant.list.recover');
    Route::resource('user/dormant/notify', Dormant\NotifyController::class)->names('user.dormant.notify');
    Route::resource('user/dormant/form/email', Dormant\Form\EmailController::class)->names('user.dormant.form.email');
    Route::resource('user/dormant/form/sms', Dormant\Form\SmsController::class)->names('user.dormant.form.sms');

    // 회원 검색
    Route::get('popup/user', [Popup\UserController::class, 'index'])->name('popup.user');

    /*********************************
     * 게시판
     *********************************/

    // 게시판 > 게시판 관리 (기본, 목록, 열람, 작성, 카테고리, 댓글, 일반, 경험치, 알람, 권한, 관리자)
    Route::put('board/board/list/listUpdate', [Board\Board\ListController::class, 'listUpdate'])->name('board.board.index.update');
    Route::resource('board/board/list', Board\Board\ListController::class)->names('board.board.list');
    Route::resource('board/board/post', Board\Board\PostController::class)->names('board.board.post');
    Route::resource('board/board/view', Board\Board\ViewController::class)->names('board.board.view');
    Route::resource('board/board/write', Board\Board\WriteController::class)->names('board.board.write');
    Route::resource('board/board/category', Board\Board\CategoryController::class)->names('board.board.category');
    Route::resource('board/board/comment', Board\Board\CommentController::class)->names('board.board.comment');
    Route::resource('board/board/general', Board\Board\GeneralController::class)->names('board.board.general');
    Route::resource('board/board/notify', Board\Board\NotifyController::class)->names('board.board.notify');
    Route::resource('board/board/authority', Board\Board\AuthorityController::class)->names('board.board.authority');
    Route::resource('board/board/exp', Board\Board\ExpController::class)->names('board.board.exp');
    Route::resource('board/board/manager', Board\Board\ManagerController::class)->names('board.board.manager');

    // 게시판 > 게시판 그룹 관리
    Route::put('board/group/list/listUpdate', [Group\ListController::class, 'listUpdate'])->name('board.group.list.index.update');
    Route::resource('board/group/list', Group\ListController::class)->names('board.group.list');
    Route::resource('board/group/manager', Group\ManagerController::class)->names('board.group.manager');

    // 게시판 > 휴지통 (게시글)
    Route::get('board/trash/post/truncate', [Trash\PostController::class, 'truncate'])->name('board.trash.post.truncate');
    Route::post('board/trash/post/recovery', [Trash\PostController::class, 'recovery'])->name('board.trash.post.recovery');
    Route::resource('board/trash/post', Trash\PostController::class)->names('board.trash.post');

    // 게시판 > 휴지통 (댓글)
    Route::get('board/trash/comment/truncate', [Trash\CommentController::class, 'truncate'])->name('board.trash.comment.truncate');
    Route::post('board/trash/comment/recovery', [Trash\CommentController::class, 'recovery'])->name('board.trash.comment.recovery');
    Route::resource('board/trash/comment', Trash\CommentController::class)->names('board.trash.comment');

    // 게시판 > 게시글 변경 이력
    Route::resource('board/history/post', Board\History\PostController::class)->names('board.history.post');

    // 게시판 > 댓글 변경 이력
    Route::resource('board/history/comment', Board\History\CommentController::class)->names('board.history.comment');

    // 게시판 > 게시물 관리
    Route::resource('board/post', Board\PostController::class)->names('board.post');

    // 게시판 > 댓글 관리
    Route::resource('board/comment', Board\CommentController::class)->names('board.comment');

    // 게시판 > 태그 관리
    Route::resource('board/tag', Board\TagController::class)->names('board.tag');

    // 게시판 > 첨부 파일 (업로드)
    Route::resource('board/file/upload', Board\File\UploadController::class)->names('board.file.upload');

    // 게시판 > 첨부 파일 (다운로드)
    Route::resource('board/file/download', Board\File\DownloadController::class)->names('board.file.download');

    // 게시판 > 게시판 이미지
    Route::resource('board/image', Board\ImageController::class)->names('board.image');

    // 게시판 > URL 클릭 > 목록
    Route::resource('board/link/list', Board\Link\ListController::class)->names('board.link.list');

    // 게시판 > URL 클릭 > 기록
    Route::resource('board/link/log', Board\Link\LogController::class)->names('board.link.log');

    // 게시판 > 추천/비추천
    Route::resource('board/like/post', Board\Like\PostController::class)->names('board.like.post');
    Route::resource('board/like/comment', Board\Like\CommentController::class)->names('board.like.comment');

    // 게시판 > 신고 관리
    Route::resource('board/blame/post', Board\Blame\PostController::class)->names('board.blame.post');
    Route::resource('board/blame/comment', Board\Blame\CommentController::class)->names('board.blame.comment');

    // 게시판 > 분류 관리 > 분류 순서 조절
    Route::get('board/board/category/up/{boardID}', [Board\Board\CategoryController::class, 'up'])->name('board.board.category.up');
    Route::get('board/board/category/down/{boardID}', [Board\Board\CategoryController::class, 'down'])->name('board.board.category.down');

    /*********************************
     * POPUP
     *********************************/

    Route::get('popup/user', [Popup\UserController::class, 'index'])->name('popup.user');
    Route::get('popup/user/group', [Popup\UserController::class, 'group'])->name('popup.user.group');

    /*********************************
     * Ajax
     *********************************/
    Route::post('ajax/postBlameResultUpdate', [AjaxController::class, 'postBlameResultUpdate'])->name('post.blame.result.update');
    Route::post('ajax/commentBlameResultUpdate', [AjaxController::class, 'commentBlameResultUpdate'])->name('comment.blame.result.update');
});
