<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;

class AdminMenuSeeder extends Seeder
{
    public function run(): void
    {
        $now = now();

        $menus = [
            ['id' => 1, 'parent_id' => 0, 'name' => '系统', 'icon' => 'layui-icon layui-icon-set', 'path' => '', 'component' => null, 'permission_code' => null, 'type' => 1, 'visible' => 1, 'sort' => 99, 'status' => 1, 'terminal_type' => 'admin', 'app_id' => null],
            ['id' => 2, 'parent_id' => 13, 'name' => '用户管理', 'icon' => 'layui-icon layui-icon-username', 'path' => '/system/user', 'component' => 'system/user/index', 'permission_code' => null, 'type' => 2, 'visible' => 1, 'sort' => 1, 'status' => 1, 'terminal_type' => 'admin', 'app_id' => null],
            ['id' => 3, 'parent_id' => 13, 'name' => '角色管理', 'icon' => 'layui-icon layui-icon-auz', 'path' => '/system/role', 'component' => 'system/role/index', 'permission_code' => null, 'type' => 2, 'visible' => 1, 'sort' => 2, 'status' => 1, 'terminal_type' => 'admin', 'app_id' => null],
            ['id' => 4, 'parent_id' => 14, 'name' => '菜单管理', 'icon' => 'fa fa-indent', 'path' => '/system/menu', 'component' => 'system/menu/index', 'permission_code' => null, 'type' => 2, 'visible' => 1, 'sort' => 3, 'status' => 1, 'terminal_type' => 'admin', 'app_id' => null],
            ['id' => 5, 'parent_id' => 14, 'name' => '系统配置', 'icon' => 'layui-icon layui-icon-set-sm', 'path' => '/system/config', 'component' => 'system/config/index', 'permission_code' => null, 'type' => 2, 'visible' => 1, 'sort' => 4, 'status' => 1, 'terminal_type' => 'admin', 'app_id' => null],
            ['id' => 7, 'parent_id' => 15, 'name' => '附件管理', 'icon' => 'IconImage', 'path' => '/system/attachment', 'component' => 'system/attachment/index', 'permission_code' => null, 'type' => 2, 'visible' => 1, 'sort' => 1, 'status' => 1, 'terminal_type' => 'admin', 'app_id' => null],
            ['id' => 8, 'parent_id' => 15, 'name' => '系统日志', 'icon' => 'fa fa-list-ul', 'path' => '/system/log', 'component' => 'system/log/index', 'permission_code' => null, 'type' => 2, 'visible' => 1, 'sort' => 2, 'status' => 1, 'terminal_type' => 'admin', 'app_id' => null],
            ['id' => 9, 'parent_id' => 2, 'name' => '新增用户', 'icon' => null, 'path' => null, 'component' => null, 'permission_code' => 'admin.user.store', 'type' => 3, 'visible' => 1, 'sort' => 0, 'status' => 1, 'terminal_type' => 'admin', 'app_id' => null],
            ['id' => 10, 'parent_id' => 2, 'name' => '编辑用户', 'icon' => null, 'path' => null, 'component' => null, 'permission_code' => 'admin.user.update', 'type' => 3, 'visible' => 1, 'sort' => 1, 'status' => 1, 'terminal_type' => 'admin', 'app_id' => null],
            ['id' => 11, 'parent_id' => 2, 'name' => '删除用户', 'icon' => null, 'path' => null, 'component' => null, 'permission_code' => 'admin.user.destroy', 'type' => 3, 'visible' => 1, 'sort' => 2, 'status' => 1, 'terminal_type' => 'admin', 'app_id' => null],
            ['id' => 12, 'parent_id' => 15, 'name' => '操作日志', 'icon' => 'fa fa-file-text-o', 'path' => '/system/operation-log', 'component' => 'system/operation-log/index', 'permission_code' => null, 'type' => 2, 'visible' => 1, 'sort' => 3, 'status' => 1, 'terminal_type' => 'admin', 'app_id' => null],
            ['id' => 13, 'parent_id' => 1, 'name' => '系统账号', 'icon' => 'layui-icon layui-icon-username', 'path' => '/system', 'component' => null, 'permission_code' => null, 'type' => 1, 'visible' => 1, 'sort' => 1, 'status' => 1, 'terminal_type' => 'admin', 'app_id' => null],
            ['id' => 14, 'parent_id' => 1, 'name' => '系统设置', 'icon' => 'layui-icon layui-icon-util', 'path' => null, 'component' => null, 'permission_code' => null, 'type' => 1, 'visible' => 1, 'sort' => 9, 'status' => 1, 'terminal_type' => 'admin', 'app_id' => null],
            ['id' => 15, 'parent_id' => 1, 'name' => '系统维护', 'icon' => 'fa fa-server', 'path' => null, 'component' => null, 'permission_code' => null, 'type' => 1, 'visible' => 1, 'sort' => 10, 'status' => 1, 'terminal_type' => 'admin', 'app_id' => null],
            ['id' => 17, 'parent_id' => 0, 'name' => '首页', 'icon' => 'layui-icon layui-icon-home', 'path' => null, 'component' => null, 'permission_code' => null, 'type' => 1, 'visible' => 1, 'sort' => 0, 'status' => 1, 'terminal_type' => 'admin', 'app_id' => null],
            ['id' => 18, 'parent_id' => 17, 'name' => '我的账号', 'icon' => 'fa fa-address-card-o', 'path' => '/admin/account', 'component' => null, 'permission_code' => null, 'type' => 2, 'visible' => 1, 'sort' => 2, 'status' => 1, 'terminal_type' => 'admin', 'app_id' => null],
            ['id' => 20, 'parent_id' => 15, 'name' => '数据管理', 'icon' => 'fa fa-database', 'path' => '/system/database', 'component' => 'system/database/index', 'permission_code' => null, 'type' => 2, 'visible' => 1, 'sort' => 4, 'status' => 1, 'terminal_type' => 'admin', 'app_id' => null],
            ['id' => 21, 'parent_id' => 14, 'name' => '站点设置', 'icon' => 'fa fa-cog', 'path' => '/system/setting', 'component' => 'system/setting/index', 'permission_code' => null, 'type' => 2, 'visible' => 1, 'sort' => 1, 'status' => 1, 'terminal_type' => 'admin', 'app_id' => null],
            ['id' => 23, 'parent_id' => 17, 'name' => '首页', 'icon' => 'layui-icon layui-icon-home', 'path' => '/admin/dashboard', 'component' => null, 'permission_code' => null, 'type' => 2, 'visible' => 1, 'sort' => 1, 'status' => 1, 'terminal_type' => 'admin', 'app_id' => null],
            ['id' => 25, 'parent_id' => 0, 'name' => '管理', 'icon' => 'layui-icon layui-icon-tabs', 'path' => null, 'component' => null, 'permission_code' => null, 'type' => 1, 'visible' => 1, 'sort' => 2, 'status' => 1, 'terminal_type' => 'admin', 'app_id' => null],
            ['id' => 30, 'parent_id' => 25, 'name' => '内容管理', 'icon' => 'fa fa-newspaper-o', 'path' => '/admin/content', 'component' => null, 'permission_code' => null, 'type' => 1, 'visible' => 1, 'sort' => 2, 'status' => 1, 'terminal_type' => 'admin', 'app_id' => null],
            ['id' => 31, 'parent_id' => 30, 'name' => '内容分类', 'icon' => 'fa fa-navicon', 'path' => '/admin/content-category', 'component' => 'content/category/index', 'permission_code' => null, 'type' => 2, 'visible' => 1, 'sort' => 2, 'status' => 1, 'terminal_type' => 'admin', 'app_id' => null],
            ['id' => 32, 'parent_id' => 30, 'name' => '内容模型', 'icon' => 'layui-icon layui-icon-layouts', 'path' => '/admin/content-model', 'component' => 'content/model/index', 'permission_code' => null, 'type' => 2, 'visible' => 1, 'sort' => 3, 'status' => 1, 'terminal_type' => 'admin', 'app_id' => null],
            ['id' => 33, 'parent_id' => 30, 'name' => '内容列表', 'icon' => 'fa fa-list-alt', 'path' => '/admin/content', 'component' => 'content/index', 'permission_code' => null, 'type' => 2, 'visible' => 1, 'sort' => 1, 'status' => 1, 'terminal_type' => 'admin', 'app_id' => null],
            ['id' => 34, 'parent_id' => 0, 'name' => '应用', 'icon' => 'layui-icon layui-icon-app', 'path' => '', 'component' => null, 'permission_code' => null, 'type' => 1, 'visible' => 1, 'sort' => 90, 'status' => 1, 'terminal_type' => 'admin', 'app_id' => null],
            ['id' => 35, 'parent_id' => 34, 'name' => '已装应用', 'icon' => 'fa fa-cube', 'path' => '/admin/app', 'component' => 'app/index', 'permission_code' => null, 'type' => 2, 'visible' => 1, 'sort' => 1, 'status' => 1, 'terminal_type' => 'admin', 'app_id' => null],
            ['id' => 36, 'parent_id' => 34, 'name' => '应用市场', 'icon' => 'fa fa-shopping-bag', 'path' => '/admin/app/market', 'component' => 'app/market', 'permission_code' => null, 'type' => 2, 'visible' => 1, 'sort' => 2, 'status' => 1, 'terminal_type' => 'admin', 'app_id' => null],
            ['id' => 37, 'parent_id' => 34, 'name' => '应用日志', 'icon' => 'fa fa-history', 'path' => '/admin/app/log', 'component' => 'app/log', 'permission_code' => null, 'type' => 2, 'visible' => 1, 'sort' => 3, 'status' => 1, 'terminal_type' => 'admin', 'app_id' => null],
            ['id' => 44, 'parent_id' => 25, 'name' => '前台用户', 'icon' => 'IconUser', 'path' => '/admin/front-user', 'component' => null, 'permission_code' => null, 'type' => 1, 'visible' => 1, 'sort' => 1, 'status' => 1, 'terminal_type' => 'admin', 'app_id' => null],
            ['id' => 45, 'parent_id' => 44, 'name' => '用户管理', 'icon' => 'layui-icon layui-icon-username', 'path' => '/admin/front-user', 'component' => null, 'permission_code' => null, 'type' => 2, 'visible' => 1, 'sort' => 1, 'status' => 1, 'terminal_type' => 'admin', 'app_id' => null],
            ['id' => 46, 'parent_id' => 44, 'name' => '级别管理', 'icon' => 'layui-icon layui-icon-user', 'path' => '/admin/user-group', 'component' => null, 'permission_code' => null, 'type' => 2, 'visible' => 1, 'sort' => 2, 'status' => 1, 'terminal_type' => 'admin', 'app_id' => null],
        ];

        foreach ($menus as &$menu) {
            $menu['create_time'] = $now;
            $menu['update_time'] = $now;
        }

        DB::table('admin_menus')->whereNull('app_id')->delete();
        DB::table('admin_menus')->insert($menus);
    }
}
