using Atomx.Common.Configuration;
using Atomx.Common.Constant;
using Atomx.Common.Entities;
using Atomx.Common.Enums;
using Atomx.Data;
using Atomx.Data.Services;
using Atomx.Utils.Extension;
using Atomx.Utils.Json;
using Microsoft.EntityFrameworkCore;

namespace Atomx.Admin.Extensions
{
    /// <summary>
    /// 数据迁移
    /// </summary>
    public static class DbMigrateExtension
    {
        /// <summary>
        /// ef core code first
        /// </summary>
        /// <param name="app"></param>
        public static void AddDataMigrate(this WebApplication app)
        {
            var idCreater = app.Services.CreateScope().ServiceProvider.GetRequiredService<IIdCreatorService>();
            var db = app.Services.CreateScope().ServiceProvider.GetRequiredService<DataContext>();
            //db.Database.EnsureCreated();
            if (db.Database.GetPendingMigrations().Any())
            {
                db.Database.Migrate();
            }
            if (db.Settings.Count(p => p.Key == ConfigKeys.General) == 0)
            {
                GeneralConfig config = new GeneralConfig();
                config.ContactEmail = "support@fireatom.com";
                config.Description = "";
                config.Domain = "fireatom.com";
                config.Keywords = "Atomx";
                config.Logo = "";
                config.Name = "Atomx";

                db.Settings.Add(new Setting() { Id = idCreater.NewId(), Name = "普通设置", Key = ConfigKeys.General, Content = config.ToJson() });
            }

            if (db.Settings.Count(p => p.Key == ConfigKeys.Upload) == 0)
            {
                UploadConfig config = new UploadConfig();
                config.FileTypes = "";
                config.RemoteAutoDownloadSave = true;
                config.FileMaxSize = 2048;
                config.ImageDomain = "http://img.sitecamp.com";
                config.ImageMaxSize = 2048;
                config.StorageServiceEnabled = false;
                config.ImageTypes = "";
                db.Settings.Add(new Setting() { Id = idCreater.NewId(), Name = "上传设置", Key = ConfigKeys.Upload, Content = config.ToJson() });
            }

            if (!db.Languages.Any())
            {
                Language language = new Language();
                language.Culture = "zh-cn";
                language.CreateTime = DateTime.UtcNow;
                language.UpdateTime = DateTime.UtcNow;
                language.Id = 1;
                language.Name = "中文";
                language.DisplayOrder = 0;
                language.Enabled = true;
                language.Title = "中文";
                db.Languages.Add(language);
            }

            if (!db.Permissions.Any())
            {
                foreach (var permission in Permissions.GetAllPermissions())
                {
                    db.Permissions.Add(new Permission() { Id = idCreater.NewId(), Name = permission, Description = Permissions.GetPermissionDescription(permission), Category = permission.Split('.')[0] });
                }
            }

            if (!db.Roles.Any())
            {
                db.Roles.Add(new Role()
                {
                    Name = "超级管理员",
                    IsSystemRole = true,
                    Permission = string.Join(',', Permissions.GetAllPermissions()),
                    CreateTime = DateTime.UtcNow,
                    Enabled = true

                });
            }



            if (!db.Admins.Any())
            {
                Common.Entities.Admin admin = new Common.Entities.Admin() { RoleId = 1, Id = idCreater.NewId(), Email = "admin@admin.com", Password = "admin888".ToMd5Password(), Username = "admin", Status = (int)DataStatus.Enable, CreateTime = DateTime.UtcNow };
                db.Admins.Add(admin);
            }


            if (!db.Menus.Any())
            {
                List<Menu> menus = new List<Menu>();
                var home = new Menu() { Type = 1, Code = "", Key = "", Url = "/", Icon = "Dashboard", Name = "主页面板", DisplayOrder = 100, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                home.Id = idCreater.NewId();
                home.ParentId = 0;
                home.Path = $"{home.Id}";
                menus.Add(home);

                //var content = new Menu() { Type = 1, Code = "", Key = "content", Url = "", Icon =  "Description", Name = "内容管理", DisplayOrder = 110, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                //content.Id = idCreater.NewId();
                //content.ParentId = 0;
                //content.Path = $"{content.Id}";
                //menus.Add(content);

                //var content_list = new Menu() { Type = 1, Code = "", Key = "content.list", Url = "/content/list", Icon =  "", Name = "文章内容", DisplayOrder = 1, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                //content_list.Id = idCreater.NewId();
                //content_list.ParentId = content.Id;
                //content_list.Depth = 1;
                //content_list.Path = $"{content.Id},{content_list.Id}";
                //menus.Add(content_list);

                //var comment = new Menu() { Type = 1, Code = "", Key = "content.comment", Url = "/comment/list", Icon =  "", Name = "评论管理", DisplayOrder = 3, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                //comment.Id = idCreater.NewId();
                //comment.ParentId = content.Id;
                //comment.Depth = 1;
                //comment.Path = $"{content.Id},{comment.Id}";
                //menus.Add(comment);

                //var content_category = new Menu() { Type = 1, Code = "", Key = "content.category", Url = "/content/category/list", Icon =  "", Name = "内容栏目", DisplayOrder = 5, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                //content_category.Id = idCreater.NewId();
                //content_category.ParentId = content.Id;
                //content_category.Depth = 1;
                //content_category.Path = $"{content.Id},{content_category.Id}";
                //menus.Add(content_category);

                //var content_column = new Menu() { Type = 1, Code = "", Key = "content.column", Url = "/content/column/list", Icon =  "", Name = "专栏主题", DisplayOrder = 6, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                //content_column.Id = idCreater.NewId();
                //content_column.ParentId = content.Id;
                //content_column.Depth = 1;
                //content_column.Path = $"{content.Id},{content_column.Id}";
                //menus.Add(content_column);

                //var content_page = new Menu() { Type = 1, Code = "", Key = "content.page", Url = "/page/list", Icon =  "", Name = "页面列表", DisplayOrder = 7, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                //content_page.Id = idCreater.NewId();
                //content_page.ParentId = content.Id;
                //content_page.Depth = 1;
                //content_page.Path = $"{content.Id},{content_page.Id}";
                //menus.Add(content_page);

                //var community_tops = new Menu() { Type = 1, Code = "", Key = "content.tops", Url = "/forums/topic/list", Icon =  "", Name = "社区帖子", DisplayOrder = 8, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                //community_tops.Id = idCreater.NewId();
                //community_tops.ParentId = content.Id;
                //community_tops.Depth = 1;
                //community_tops.Path = $"{content.Id},{community_tops.Id}";
                //menus.Add(community_tops);

                //var community_votes = new Menu() { Type = 1, Code = "", Key = "content.votes", Url = "/forums/votes/list", Icon =  "", Name = "社区投票", DisplayOrder = 9, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                //community_votes.Id = idCreater.NewId();
                //community_votes.ParentId = content.Id;
                //community_votes.Depth = 1;
                //community_votes.Path = $"{content.Id},{community_votes.Id}";
                //menus.Add(community_votes);

                //var community_category = new Menu() { Type = 1, Code = "", Key = "content.forums", Url = "/forums/category/list", Icon =  "", Name = "社区栏目", DisplayOrder = 10, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                //community_category.Id = idCreater.NewId();
                //community_category.ParentId = content.Id;
                //community_category.Depth = 1;
                //community_category.Path = $"{content.Id},{community_category.Id}";
                //menus.Add(community_category);





                var mall = new Menu() { Type = 1, Code = "", Key = "mall", Url = "", Icon = "Dataset", Name = "商品管理", DisplayOrder = 120, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                mall.Id = idCreater.NewId();
                mall.ParentId = 0;
                mall.Path = $"{mall.Id}";
                menus.Add(mall);

                var mall_catalog = new Menu() { Type = 1, Code = "", Key = "mall.category", Url = "/category/list", Icon = "", Name = "分类管理", DisplayOrder = 1, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                mall_catalog.Id = idCreater.NewId();
                mall_catalog.ParentId = mall.Id;
                mall_catalog.Depth = 1;
                mall_catalog.Path = $"{mall.Id},{mall_catalog.Id}";
                menus.Add(mall_catalog);

                var mall_product = new Menu() { Type = 1, Code = "", Key = "mall.product", Url = "/product/list", Icon = "", Name = "产品管理", DisplayOrder = 2, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                mall_product.Id = idCreater.NewId();
                mall_product.ParentId = mall.Id;
                mall_product.Depth = 1;
                mall_product.Path = $"{mall.Id},{mall_product.Id}";
                menus.Add(mall_product);

                var mall_product_stock = new Menu() { Type = 1, Code = "", Key = "mall.product", Url = "/product/stock/list", Icon = "", Name = "产品库存管理", DisplayOrder = 2, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                mall_product_stock.Id = idCreater.NewId();
                mall_product_stock.ParentId = mall.Id;
                mall_product_stock.Depth = 1;
                mall_product_stock.Path = $"{mall.Id},{mall_product_stock.Id}";
                menus.Add(mall_product_stock);

                var mall_manufacturer = new Menu() { Type = 1, Code = "", Key = "mall.manufacturer", Url = "/manufacturer/list", Icon = "", Name = "品牌厂商", DisplayOrder = 3, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                mall_manufacturer.Id = idCreater.NewId();
                mall_manufacturer.ParentId = mall.Id;
                mall_manufacturer.Depth = 1;
                mall_manufacturer.Path = $"{mall.Id},{mall_manufacturer.Id}";
                menus.Add(mall_manufacturer);

                var mall_warehouse = new Menu() { Type = 1, Code = "", Key = "mall.warehouse", Url = "/warehouse/list", Icon = "", Name = "货品仓储", DisplayOrder = 3, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                mall_warehouse.Id = idCreater.NewId();
                mall_warehouse.ParentId = mall.Id;
                mall_warehouse.Depth = 1;
                mall_warehouse.Path = $"{mall.Id},{mall_warehouse.Id}";
                menus.Add(mall_warehouse);



                var mall_attributes = new Menu() { Type = 1, Code = "", Key = "mall.attribute", Url = "", Icon = "", Name = "属性规格", DisplayOrder = 5, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                mall_attributes.Id = idCreater.NewId();
                mall_attributes.ParentId = mall.Id;
                mall_attributes.Depth = 1;
                mall_attributes.Path = $"{mall.Id},{mall_attributes.Id}";
                menus.Add(mall_attributes);

                var mall_product_attributes = new Menu() { Type = 1, Code = "", Key = "mall.attribute.product", Url = "/attribute/list", Icon = "", Name = "产品属性", DisplayOrder = 6, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                mall_product_attributes.Id = idCreater.NewId();
                mall_product_attributes.ParentId = mall_attributes.Id;
                mall_product_attributes.Depth = 2;
                mall_product_attributes.Path = $"{mall.Id},{mall_attributes.Id},{mall_product_attributes.Id}";
                menus.Add(mall_product_attributes);

                var mall_product_specification = new Menu() { Type = 1, Code = "", Key = "mall.attribute.specification", Url = "/specification/list", Icon = "", Name = "产品规格", DisplayOrder = 7, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                mall_product_specification.Id = idCreater.NewId();
                mall_product_specification.ParentId = mall_attributes.Id;
                mall_product_specification.Depth = 2;
                mall_product_specification.Path = $"{mall.Id},{mall_attributes.Id},{mall_product_specification.Id}";
                menus.Add(mall_product_specification);




                //var sales = new Menu() { Type = 1, Code = "", Key = "sales", Url = "", Icon =  "LocalGroceryStore", Name = "销售订单", DisplayOrder = 130, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                //sales.Id = idCreater.NewId();
                //sales.Path = $"{sales.Id}";
                //menus.Add(sales);

                //var sales_order = new Menu() { Type = 1, Code = "", Key = "sales.order", Url = "/order/list", Icon =  "", Name = "订单", DisplayOrder = 1, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                //sales_order.Id = idCreater.NewId();
                //sales_order.ParentId = sales.Id;
                //sales_order.Depth = 1;
                //sales_order.Path = $"{sales.Id},{sales_order.Id}";
                //menus.Add(sales_order);

                //var sales_shipment = new Menu() { Type = 1, Code = "", Key = "sales.shipment", Url = "/order/shipment/list", Icon =  "", Name = "发货", DisplayOrder = 2, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                //sales_shipment.Id = idCreater.NewId();
                //sales_shipment.ParentId = sales.Id;
                //sales_shipment.Depth = 1;
                //sales_shipment.Path = $"{sales.Id},{sales_shipment.Id}";
                //menus.Add(sales_shipment);

                //var sales_return = new Menu() { Type = 1, Code = "", Key = "sales.returnrequest", Url = "/order/returnrequest/list", Icon =  "", Name = "退货请求", DisplayOrder = 3, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                //sales_return.Id = idCreater.NewId();
                //sales_return.ParentId = sales.Id;
                //sales_return.Depth = 1;
                //sales_return.Path = $"{sales.Id},{sales_return.Id}";
                //menus.Add(sales_return);




                //var promotion = new Menu() { Type = 1, Code = "", Key = "promotion", Url = "", Icon =  "AllInclusive", Name = "销售促销", DisplayOrder = 150, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                //promotion.Id = idCreater.NewId();
                //promotion.Path = $"{promotion.Id}";
                //menus.Add(promotion);

                //var promotion_discount = new Menu() { Type = 1, Code = "", Key = "promotion.discount", Url = "/discount/list", Icon =  "", Name = "折扣", DisplayOrder = 1, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                //promotion_discount.Id = idCreater.NewId();
                //promotion_discount.ParentId = promotion.Id;
                //promotion_discount.Depth = 1;
                //promotion_discount.Path = $"{promotion.Id},{promotion_discount.Id}";
                //menus.Add(promotion_discount);

                //var promotion_coupon = new Menu() { Type = 1, Code = "", Key = "promotion.coupon", Url = "/coupon/list", Icon =  "", Name = "优惠券", DisplayOrder = 2, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                //promotion_coupon.Id = idCreater.NewId();
                //promotion_coupon.ParentId = promotion.Id;
                //promotion_coupon.Depth = 1;
                //promotion_coupon.Path = $"{promotion.Id},{promotion_coupon.Id}";
                //menus.Add(promotion_coupon);


                //var activity = new Menu() { Type = 1, Code = "", Key = "activity", Url = "", Icon =  "DisplaySettings", Name = "运营活动", DisplayOrder = 160, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                //activity.Id = idCreater.NewId();
                //activity.Path = $"{activity.Id}";
                //menus.Add(activity);

                //var activeity_signin = new Menu() { Type = 1, Code = "", Key = "activity.signin", Url = "", Icon =  "", Name = "签到打卡", DisplayOrder = 5, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                //activeity_signin.Id = idCreater.NewId();
                //activeity_signin.ParentId = activity.Id;
                //activeity_signin.Depth = 1;
                //activeity_signin.Path = $"{activity.Id},{activeity_signin.Id}";
                //menus.Add(activeity_signin);

                //var activeity_signin_scene = new Menu() { Type = 1, Code = "", Key = "activity.signin.scene", Url = "/signin/scene/list", Icon =  "", Name = "签到场景", DisplayOrder = 6, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                //activeity_signin_scene.Id = idCreater.NewId();
                //activeity_signin_scene.ParentId = activeity_signin.Id;
                //activeity_signin_scene.Depth = 2;
                //activeity_signin_scene.Path = $"{activity.Id},{activeity_signin.Id},{activeity_signin_scene.Id}";
                //menus.Add(activeity_signin_scene);

                //var activeity_signin_list = new Menu() { Type = 1, Code = "", Key = "activity.signin.list", Url = "/signin/list", Icon =  "", Name = "签到设置", DisplayOrder = 6, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                //activeity_signin_list.Id = idCreater.NewId();
                //activeity_signin_list.ParentId = activeity_signin.Id;
                //activeity_signin_list.Depth = 2;
                //activeity_signin_list.Path = $"{activity.Id},{activeity_signin.Id},{activeity_signin_list.Id}";
                //menus.Add(activeity_signin_list);


                //var activeity_mission = new Menu() { Type = 1, Code = "", Key = "activity.mission", Url = "", Icon =  "", Name = "任务设置", DisplayOrder = 20, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                //activeity_mission.Id = idCreater.NewId();
                //activeity_mission.ParentId = activity.Id;
                //activeity_mission.Depth = 1;
                //activeity_mission.Path = $"{activity.Id},{activeity_mission.Id}";
                //menus.Add(activeity_mission);

                //var activeity_mission_category = new Menu() { Type = 1, Code = "", Key = "activity.mission.category", Url = "/mission/category/list", Icon =  "", Name = "任务分类", DisplayOrder = 6, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                //activeity_mission_category.Id = idCreater.NewId();
                //activeity_mission_category.ParentId = activeity_mission.Id;
                //activeity_mission_category.Depth = 2;
                //activeity_mission_category.Path = $"{activity.Id},{activeity_mission.Id},{activeity_mission_category.Id}";
                //menus.Add(activeity_mission_category);

                //var activeity_mission_list = new Menu() { Type = 1, Code = "", Key = "activity.mission.list", Url = "/mission/list", Icon =  "", Name = "任务列表", DisplayOrder = 6, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                //activeity_mission_list.Id = idCreater.NewId();
                //activeity_mission_list.ParentId = activeity_mission.Id;
                //activeity_mission_list.Depth = 2;
                //activeity_mission_list.Path = $"{activity.Id},{activeity_mission.Id},{activeity_mission_list.Id}";
                //menus.Add(activeity_mission_list);


                //var activeity_redeem = new Menu() { Type = 1, Code = "", Key = "activity.redeem", Url = "/redeem/list", Icon =  "", Name = "兑换码", DisplayOrder = 30, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                //activeity_redeem.Id = idCreater.NewId();
                //activeity_redeem.ParentId = activity.Id;
                //activeity_redeem.Depth = 1;
                //activeity_redeem.Path = $"{activity.Id},{activeity_redeem.Id}";
                //menus.Add(activeity_redeem);

                //var activeity_redeem_log = new Menu() { Type = 1, Code = "", Key = "activity.redeem.log", Url = "/user/redeem/list", Icon =  "", Name = "兑换码记录", DisplayOrder = 31, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                //activeity_redeem_log.Id = idCreater.NewId();
                //activeity_redeem_log.ParentId = activity.Id;
                //activeity_redeem_log.Depth = 1;
                //activeity_redeem_log.Path = $"{activity.Id},{activeity_redeem_log.Id}";
                //menus.Add(activeity_redeem_log);


                var user = new Menu() { Type = 1, Code = "", Key = "user", Url = "", Icon = "People", Name = "客户会员", DisplayOrder = 170, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                user.Id = idCreater.NewId();
                user.Path = $"{user.Id}";
                menus.Add(user);

                var user_customer = new Menu() { Type = 1, Code = "", Key = "user.customer", Url = "", Icon = "", Name = "用户会员", DisplayOrder = 1, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                user_customer.Id = idCreater.NewId();
                user_customer.ParentId = user.Id;
                user_customer.Depth = 1;
                user_customer.Path = $"{user.Id},{user_customer.Id}";
                menus.Add(user_customer);

                var user_list = new Menu() { Type = 1, Code = "", Key = "user.list", Url = "user/list", Icon = "", Name = "用户列表", DisplayOrder = 1, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                user_list.Id = idCreater.NewId();
                user_list.ParentId = user_customer.Id;
                user_list.Depth = 2;
                user_list.Path = $"{user.Id},{user_customer.Id},{user_list.Id}";
                menus.Add(user_list);

                var user_online = new Menu() { Type = 1, Code = "", Key = "user.online", Url = "user/online/list", Icon = "", Name = "在线用户", DisplayOrder = 2, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                user_online.Id = idCreater.NewId();
                user_online.ParentId = user_customer.Id;
                user_online.Depth = 2;
                user_online.Path = $"{user.Id},{user_customer.Id},{user_online.Id}";
                menus.Add(user_online);

                var user_level = new Menu() { Type = 1, Code = "", Key = "user.level", Url = "user/level/list", Icon = "", Name = "会员等级", DisplayOrder = 3, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                user_level.Id = idCreater.NewId();
                user_level.ParentId = user_customer.Id;
                user_level.Depth = 2;
                user_level.Path = $"{user.Id},{user_customer.Id},{user_level.Id}";
                menus.Add(user_level);

                var user_corporation = new Menu() { Type = 1, Code = "", Key = "user.corporation", Url = "", Icon = "", Name = "企业客户", DisplayOrder = 3, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                user_corporation.Id = idCreater.NewId();
                user_corporation.ParentId = user.Id;
                user_corporation.Depth = 1;
                user_corporation.Path = $"{user.Id},{user_corporation.Id}";
                menus.Add(user_corporation);

                var user_corporation_list = new Menu() { Type = 1, Code = "", Key = "user.corporation.list", Url = "corporation/list", Icon = "", Name = "企业列表", DisplayOrder = 3, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                user_corporation_list.Id = idCreater.NewId();
                user_corporation_list.ParentId = user_corporation.Id;
                user_corporation_list.Depth = 2;
                user_corporation_list.Path = $"{user.Id},{user_corporation.Id},{user_corporation_list.Id}";
                menus.Add(user_corporation_list);

                //var user_corporation_staff_list = new Menu() { Type = 1, Code = "", Key = "user.corporation.list", Url = "corporation/staff/list", Icon =  "", Name = "企业帐号", DisplayOrder = 3, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                //user_corporation_staff_list.Id = idCreater.NewId();
                //user_corporation_staff_list.ParentId = user_corporation.Id;
                //user_corporation_staff_list.Depth = 2;
                //user_corporation_staff_list.Path = $"{user.Id},{user_corporation.Id},{user_corporation_staff_list.Id}";
                //menus.Add(user_corporation_staff_list);

                var user_corporation_shop_list = new Menu() { Type = 1, Code = "", Key = "user.corporation.shop", Url = "/corpotation/shop/list", Icon = "", Name = "企业店铺", DisplayOrder = 3, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                user_corporation_shop_list.Id = idCreater.NewId();
                user_corporation_shop_list.ParentId = user_corporation.Id;
                user_corporation_shop_list.Depth = 2;
                user_corporation_shop_list.Path = $"{user.Id},{user_corporation.Id},{user_corporation_shop_list.Id}";
                menus.Add(user_corporation_shop_list);


                //var payment = new Menu() { Type = 1, Code = "", Key = "payment", Url = "", Icon =  "CreditCard", Name = "充值提现", DisplayOrder = 180, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                //payment.Id = idCreater.NewId();
                //payment.Path = $"{payment.Id}";
                //menus.Add(payment);

                //var deposit = new Menu() { Type = 1, Code = "", Key = "payment.deposit", Url = "/deposit/list", Icon =  "", Name = "充值记录", DisplayOrder = 1, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                //deposit.Id = idCreater.NewId();
                //deposit.ParentId = payment.Id;
                //deposit.Depth = 1;
                //deposit.Path = $"{payment.Id},{deposit.Id}";
                //menus.Add(deposit);

                //var withdraw = new Menu() { Type = 1, Code = "", Key = "payment.withdraw", Url = "/withdraw/list", Icon =  "", Name = "提现记录", DisplayOrder = 2, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                //withdraw.Id = idCreater.NewId();
                //withdraw.ParentId = payment.Id;
                //withdraw.Depth = 1;
                //withdraw.Path = $"{payment.Id},{deposit.Id}";
                //menus.Add(withdraw);

                //var withdraw_audit = new Menu() { Type = 1, Code = "", Key = "paymentwithdraw.check", Url = "/withdraw/check", Icon =  "", Name = "提现审核", DisplayOrder = 3, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                //withdraw_audit.Id = idCreater.NewId();
                //withdraw_audit.ParentId = payment.Id;
                //withdraw_audit.Depth = 1;
                //withdraw_audit.Path = $"{payment.Id},{withdraw_audit.Id}";
                //menus.Add(withdraw_audit);


                var stats = new Menu() { Type = 1, Code = "", Key = "stats", Url = "", Icon = "Analytics", Name = "统计报告", DisplayOrder = 190, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                stats.Id = idCreater.NewId();
                stats.Path = $"{stats.Id}";
                menus.Add(stats);

                var stats_payment = new Menu() { Type = 1, Code = "", Key = "stats", Url = "", Icon = "", Name = "支付统计报告", DisplayOrder = 1, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                stats_payment.Id = idCreater.NewId();
                stats_payment.ParentId = stats.Id;
                stats_payment.Depth = 1;
                stats_payment.Path = $"{stats.Id},{stats_payment.Id}";
                menus.Add(stats_payment);

                var setting = new Menu() { Type = 1, Code = "", Key = "config", Url = "", Icon = "Api", Name = "系统配置", DisplayOrder = 200, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                setting.Id = idCreater.NewId();
                setting.Path = $"{setting.Id}";
                menus.Add(setting);

                var setting_base = new Menu() { Type = 1, Code = "", Key = "config.settings", Url = "/settings", Icon = "", Name = "系统设置", DisplayOrder = 1, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                setting_base.Id = idCreater.NewId();
                setting_base.ParentId = setting.Id;
                setting_base.Depth = 1;
                setting_base.Path = $"{setting.Id},{setting_base.Id}";
                menus.Add(setting_base);

                var setting_messagetemplate = new Menu() { Type = 1, Code = "", Key = "config.messagetemplate", Url = "/setting/messagetemplate/list", Icon = "", Name = "消息模板", DisplayOrder = 1, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                setting_messagetemplate.Id = idCreater.NewId();
                setting_messagetemplate.ParentId = setting.Id;
                setting_messagetemplate.Depth = 1;
                setting_messagetemplate.Path = $"{setting.Id},{setting_messagetemplate.Id}";
                menus.Add(setting_messagetemplate);

                //var setting_country = new Menu() { Type = 1, Code = "", Key = "config.country", Url = "/setting/country/list", Icon =  "", Name = "国家地区", DisplayOrder = 1, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                //setting_country.Id = idCreater.NewId();
                //setting_country.ParentId = setting.Id;
                //setting_country.Depth = 1;
                //setting_country.Path = $"{setting.Id},{setting_country.Id}";
                //menus.Add(setting_country);

                //var setting_language = new Menu() { Type = 1, Code = "", Key = "config.language", Url = "/setting/language/list", Icon =  "", Name = "语言设置", DisplayOrder = 1, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                //setting_language.Id = idCreater.NewId();
                //setting_language.ParentId = setting.Id;
                //setting_language.Depth = 1;
                //setting_language.Path = $"{setting.Id},{setting_language.Id}";
                //menus.Add(setting_language);

                //var setting_currency = new Menu() { Type = 1, Code = "", Key = "config.currency", Url = "/setting/currency/list", Icon =  "", Name = "货币", DisplayOrder = 1, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                //setting_currency.Id = idCreater.NewId();
                //setting_currency.ParentId = setting.Id;
                //setting_currency.Depth = 1;
                //setting_currency.Path = $"{setting.Id},{setting_currency.Id}";
                //menus.Add(setting_currency);

                var setting_provider = new Menu() { Type = 1, Code = "", Key = "config.provider", Url = "/setting/provider/list", Icon = "", Name = "服务供应商", DisplayOrder = 1, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                setting_provider.Id = idCreater.NewId();
                setting_provider.ParentId = setting.Id;
                setting_provider.Depth = 1;
                setting_provider.Path = $"{setting.Id},{setting_provider.Id}";
                menus.Add(setting_provider);

                var setting_methods = new Menu() { Type = 1, Code = "", Key = "config.payment", Url = "/payment/methods", Icon = "", Name = "支付方式", DisplayOrder = 1, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                setting_methods.Id = idCreater.NewId();
                setting_methods.ParentId = setting.Id;
                setting_methods.Depth = 1;
                setting_methods.Path = $"{setting.Id},{setting_methods.Id}";
                menus.Add(setting_methods);

                //var system_prop = new Menu() { Type = 1, Code = "", Key = "config.props", Url = "/props/list", Icon =  "", Name = "道具设置", DisplayOrder = 3, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                //system_prop.Id = idCreater.NewId();
                //system_prop.ParentId = setting.Id;
                //system_prop.Depth = 1;
                //system_prop.Path = $"{setting.Id},{system_prop.Id}";
                //menus.Add(system_prop);


                var system = new Menu() { Type = 1, Code = "", Key = "system", Url = "", Icon = "Settings", Name = "系统功能", DisplayOrder = 210, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                system.Id = idCreater.NewId();
                system.Path = $"{system.Id}";
                menus.Add(system);

                var system_admin = new Menu() { Type = 1, Code = "", Key = "system.admin", Url = "/admin/list", Icon = "", Name = "管理员管理", DisplayOrder = 1, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                system_admin.Id = idCreater.NewId();
                system_admin.ParentId = system.Id;
                system_admin.Depth = 1;
                system_admin.Path = $"{system.Id},{system_admin.Id}";
                menus.Add(system_admin);

                var system_role = new Menu() { Type = 1, Code = "", Key = "system.role", Url = "/system/role/list", Icon = "", Name = "角色管理", DisplayOrder = 2, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                system_role.Id = idCreater.NewId();
                system_role.ParentId = system.Id;
                system_role.Depth = 1;
                system_role.Path = $"{system.Id},{system_role.Id}";
                menus.Add(system_role);

                var system_version = new Menu() { Type = 1, Code = "", Key = "system.version", Url = "/system/app/version/list", Icon = "", Name = "版本管理", DisplayOrder = 1, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                system_version.Id = idCreater.NewId();
                system_version.ParentId = system.Id;
                system_version.Depth = 1;
                system_version.Path = $"{system.Id},{system_version.Id}";
                menus.Add(system_version);

                var system_menu = new Menu() { Type = 1, Code = "", Key = "system.menu", Url = "/system/menu/list", Icon = "", Name = "菜单设置", DisplayOrder = 3, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                system_menu.Id = idCreater.NewId();
                system_menu.ParentId = system.Id;
                system_menu.Depth = 1;
                system_menu.Path = $"{system.Id},{system_menu.Id}";
                menus.Add(system_menu);



                var system_manual = new Menu() { Type = 1, Code = "", Key = "system.tools", Url = "/system/tools", Icon = "", Name = "系统工具", DisplayOrder = 4, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                system_manual.Id = idCreater.NewId();
                system_manual.ParentId = system.Id;
                system_manual.Depth = 1;
                system_manual.Path = $"{system.Id},{system_manual.Id}";
                menus.Add(system_manual);

                var system_info = new Menu() { Type = 1, Code = "", Key = "system.info", Url = "/system/info", Icon = "", Name = "系统信息", DisplayOrder = 5, Enabled = true, CreateTime = DateTime.UtcNow, UpdateTime = DateTime.UtcNow };
                system_info.Id = idCreater.NewId();
                system_info.ParentId = system.Id;
                system_info.Depth = 1;
                system_info.Path = $"{system.Id},{system_info.Id}";
                menus.Add(system_info);

                db.Menus.AddRange(menus);

            }
            db.SaveChanges();
        }
    }
}
