Ejemplo n.º 1
0
        /// <summary>
        /// 添加菜单
        /// </summary>
        /// <param name="dto">菜单模型</param>
        /// <returns></returns>
        public async Task <string> AddAsync(MenuDto dto)
        {
            var entity = _mapper.Map <MenuDto, MenuEntity>(dto);

            entity.Init();
            var dbSet         = _context.Menus;
            var pathCodeDbSet = _pathCodeService.GetPathCodes();

            var existsCode = await dbSet.Where(item => item.ParentId == dto.ParentId)
                             .Select(item => item.Code).ToListAsync();

            var pathCode = pathCodeDbSet.FirstOrDefault(item => !existsCode.Contains(item));

            entity.Code = pathCode.Trim();
            if (entity.ParentId.IsNotBlank())
            {
                var parent = await dbSet.FirstOrDefaultAsync(m => m.Id == entity.ParentId);

                entity.PathCode = string.Concat(parent.PathCode.Trim(), entity.Code.Trim());
                entity.Type     = parent.Type == 1 ? (byte)MenuType.Menu : (byte)MenuType.Action;
            }
            else
            {
                entity.PathCode = entity.Code.Trim();
                entity.Type     = (byte)MenuType.Module;
            }
            dbSet.Add(entity);

            return(await _context.SaveChangesAsync() > 0 ? entity.Id : string.Empty);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 发送站内信
        /// </summary>
        /// <param name="message"></param>
        public async Task SendAsync(MessageDto message)
        {
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }
            var entity  = _mapper.Map <MessageDto, MessageEntity>(message);
            var userIds = new List <string>();

            if (message.IsToAll)
            {
                var ids = await _context.Users.Select(x => x.Id).ToListAsync();

                userIds.AddRange(ids);
            }
            else
            {
                userIds.AddRange(message.UserIds);
            }
            entity.MessageReceivers = userIds.Distinct().Select(userId => new MessageReceiverEntity
            {
                UserId = userId
            }).ToList();
            entity.MessageReceivers.ForEach(x => x.Init());
            entity.Init();
            entity.SetNumber();
            await _context.Messages.AddAsync(entity);

            await _context.SaveChangesAsync();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 创建任务流模板
        /// </summary>
        public async Task <string> CreateAsync(TaskTemplateDto templateDto, CurrentUserDto user)
        {
            if (templateDto.Name.IsBlank())
            {
                throw new BusinessException("模板名称不能为空");
            }
            if (templateDto.Id.IsNotBlank())
            {
                var template = await _context.TaskTemplates.FindAsync(templateDto.Id);

                if (template != null)
                {
                    template.Name = templateDto.Name;
                }
            }
            else
            {
                var template = new TaskTemplateEntity {
                    Name = templateDto.Name
                };
                template.CreateBy(user.UserId);
                template.SetStep(TaskTemplateStep.Save);
                await _context.AddAsync(template);

                templateDto.Id = template.Id;
            }

            await _context.SaveChangesAsync();

            return(templateDto.Id);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 增
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public async Task <string> AddAsync(StationDto dto)
        {
            var entity = _mapper.Map <StationDto, StationEntity>(dto);

            entity.Init();
            _context.Stations.Add(entity);
            return(await _context.SaveChangesAsync() > 0 ? entity.Id : string.Empty);
        }
Ejemplo n.º 5
0
        //增
        public async Task <string> AddAsync(GisProDto dto)
        {
            var entity = _mapper.Map <GisProDto, GisProEntity>(dto);

            entity.Init();
            _context.GisPros.Add(entity);
            return(await _context.SaveChangesAsync() > 0 ? entity.Id : string.Empty);
        }
Ejemplo n.º 6
0
        //增
        public async Task <string> AddAsync(CameraPathDto dto)
        {
            var entity = _mapper.Map <CameraPathDto, CameraPathEntity>(dto);

            entity.Init();
            _context.CameraPaths.Add(entity);
            return(await _context.SaveChangesAsync() > 0 ? entity.Id : string.Empty);
        }
        public async Task <IActionResult> Create([Bind("id,title,elecname,electricity,watername,water,airname,air,alarmname,alarm,point,isOnline")] MarkerArrEntity markerArrEntity)
        {
            if (ModelState.IsValid)
            {
                _context.Add(markerArrEntity);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(markerArrEntity));
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 添加角色
        /// </summary>
        /// <param name="dto">角色模型</param>
        /// <returns></returns>
        public async Task <string> AddAsync(RoleDto dto)
        {
            var entity = _mapper.Map <RoleDto, RoleEntity>(dto);

            entity.Init();
            var dbSet = _context.Roles;

            dbSet.Add(entity);

            return(await _context.SaveChangesAsync() > 0 ? entity.Id : string.Empty);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 添加部门
        /// </summary>
        /// <param name="dto">部门模型</param>
        /// <returns></returns>
        public async Task <string> Add(DepartmentDto dto)
        {
            var entity = _mapper.Map <DepartmentDto, DepartmentEntity>(dto);

            entity.Init();
            await SetDepartment(entity);

            _context.Departments.Add(entity);
            await _context.SaveChangesAsync();

            return(entity.Id);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="dto">模型</param>
        /// <returns></returns>
        public async Task <string> Add(AreaDto dto)
        {
            var entity = _mapper.Map <AreaDto, AreaEntity>(dto);

            entity.Init();
            entity.PathCode = await GetPathCode(entity.ParentId);

            entity.SimpleSpelling = entity.Name.GetChineseSpell();
            _context.Areas.Add(entity);
            await _context.SaveChangesAsync();

            return(entity.Id);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 添加或更新网站访问量
        /// </summary>
        /// <param name="day">日期</param>
        public async Task <bool> AddOrUpdate()
        {
            var day     = DateTime.Now;
            var date    = day.Date;
            var endDate = date.AddDays(1);
            var number  = await _context.PageViews.CountAsync(x => x.CreateDateTime > date && x.CreateDateTime < endDate);

            if (await _context.SiteViews.AnyAsync(x => x.Day == date))
            {
                var view = await _context.SiteViews.FirstOrDefaultAsync(x => x.Day == date);

                if (view != null)
                {
                    view.Number = number;
                }
            }
            else
            {
                var view = new SiteViewEntity
                {
                    Day    = date,
                    Number = number
                };
                view.Init();
                _context.SiteViews.Add(view);
            }
            await _context.SaveChangesAsync();

            return(true);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 添加用户
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public async Task <Guid> AddAsync(UserAddDto user)
        {
            var entity = _mapper.Map <UserAddDto, UserEntity>(user);

            entity.Init();
            if (entity.UserRoles.AnyOne())
            {
                entity.UserRoles.ForEach(r => r.UserId = entity.Id);
            }
            entity.Password = entity.Password.ToMd5();
            _context.Users.Add(entity);

            return(await _context.SaveChangesAsync() > 0 ? entity.Id : Guid.Empty);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 添加用户
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public async Task <string> AddAsync(UserAddDto user)
        {
            var entity = _mapper.Map <UserAddDto, UserEntity>(user);

            entity.Init();
            //如果用户拥有角色,应该是外键了,另外的一个表中写入此用户的id,创建一条userroles的表然后添加一个userid,
            if (entity.UserRoles.AnyOne())
            {
                entity.UserRoles.ForEach(r => r.UserId = entity.Id);
            }
            //这里的密码进行了加密,我的就算了
            entity.Password = entity.Password.ToMd5();
            _context.Users.Add(entity);

            return(await _context.SaveChangesAsync() > 0 ? entity.Id : string.Empty);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 初始化
        /// </summary>
        public async Task <bool> InitAsync()
        {
            try
            {
                await _context.Database.MigrateAsync();

                if (await _context.SystemConfigs.AnyAsync(item => item.IsDataInited))
                {
                    return(false);
                }

                #region 用户

                var admin = new UserEntity
                {
                    Id             = Guid.NewGuid().ToString("N"),
                    LoginName      = "jucheap",
                    RealName       = "超级管理员",
                    Password       = "******".ToMd5(),
                    Email          = "*****@*****.**",
                    IsSuperMan     = true,
                    CreateDateTime = Now
                };
                var guest = new UserEntity
                {
                    Id             = Guid.NewGuid().ToString("N"),
                    LoginName      = "admin",
                    RealName       = "游客",
                    Password       = "******".ToMd5(),
                    Email          = "*****@*****.**",
                    CreateDateTime = Now
                };
                //用户
                var user = new List <UserEntity>
                {
                    admin,
                    guest
                };
                #endregion

                #region 菜单

                var system = new MenuEntity
                {
                    Id             = Guid.NewGuid().ToString("N"),
                    Name           = "系统设置",
                    Icon           = "fa fa-gear",
                    Url            = "#",
                    CreateDateTime = Now,
                    Order          = 1,
                    Code           = "AA",
                    PathCode       = "AA",
                    Type           = 1
                };//1
                var menuMgr = new MenuEntity
                {
                    Id             = Guid.NewGuid().ToString("N"),
                    ParentId       = system.Id,
                    Name           = "菜单管理",
                    Url            = "/Menu/Index",
                    CreateDateTime = Now,
                    Order          = 2,
                    Code           = "AA",
                    PathCode       = "AAAA",
                    Type           = 2
                };//2
                var roleMgr = new MenuEntity
                {
                    Id             = Guid.NewGuid().ToString("N"),
                    ParentId       = system.Id,
                    Name           = "角色管理",
                    Url            = "/Role/Index",
                    CreateDateTime = Now,
                    Order          = 3,
                    Code           = "AB",
                    PathCode       = "AAAB",
                    Type           = 2
                };//3
                var userMgr = new MenuEntity
                {
                    Id             = Guid.NewGuid().ToString("N"),
                    ParentId       = system.Id,
                    Name           = "用户管理",
                    Url            = "/User/Index",
                    CreateDateTime = Now,
                    Order          = 4,
                    Code           = "AC",
                    PathCode       = "AAAC",
                    Type           = 2
                };//4
                var departmentMgr = new MenuEntity
                {
                    Id             = Guid.NewGuid().ToString("N"),
                    ParentId       = system.Id,
                    Name           = "部门管理",
                    Url            = "/Department/Index",
                    CreateDateTime = Now,
                    Order          = 3,
                    Code           = "AG",
                    PathCode       = "AAAG",
                    Type           = 2
                };
                var userRoleMgr = new MenuEntity
                {
                    Id             = Guid.NewGuid().ToString("N"),
                    ParentId       = userMgr.Id,
                    Name           = "用户授权",
                    Url            = "/User/Authen",
                    CreateDateTime = Now,
                    Order          = 5,
                    Code           = "AD",
                    PathCode       = "AAAD",
                    Type           = 2
                };//5
                var giveRight = new MenuEntity
                {
                    Id             = Guid.NewGuid().ToString("N"),
                    ParentId       = userRoleMgr.Id,
                    Name           = "授权",
                    Url            = "/User/GiveRight",
                    CreateDateTime = Now,
                    Order          = 1,
                    Code           = "AA",
                    PathCode       = "AAADAA",
                    Type           = 3
                };
                var cancelRight = new MenuEntity
                {
                    Id             = Guid.NewGuid().ToString("N"),
                    ParentId       = userRoleMgr.Id,
                    Name           = "取消授权",
                    Url            = "/User/CancelRight",
                    CreateDateTime = Now,
                    Order          = 2,
                    Code           = "AB",
                    PathCode       = "AAADAB",
                    Type           = 3
                };
                var roleMenuMgr = new MenuEntity
                {
                    Id             = Guid.NewGuid().ToString("N"),
                    ParentId       = system.Id,
                    Name           = "角色授权",
                    Url            = "/Role/Authen",
                    CreateDateTime = Now,
                    Order          = 6,
                    Code           = "AE",
                    PathCode       = "AAAE",
                    Type           = 2
                };//6
                var sysConfig = new MenuEntity
                {
                    Id             = Guid.NewGuid().ToString("N"),
                    ParentId       = system.Id,
                    Name           = "系统配置",
                    Url            = "/System/Index",
                    CreateDateTime = Now,
                    Order          = 7,
                    Code           = "AF",
                    PathCode       = "AAAF",
                    Type           = 2
                };//7
                var areaConfig = new MenuEntity
                {
                    Id             = Guid.NewGuid().ToString("N"),
                    ParentId       = system.Id,
                    Name           = "省市区管理",
                    Url            = "/Area/Index",
                    CreateDateTime = Now,
                    Order          = 5,
                    Code           = "AH",
                    PathCode       = "AAAH",
                    Type           = 2
                };
                var sysConfigReloadPathCode = new MenuEntity
                {
                    Id             = Guid.NewGuid().ToString("N"),
                    ParentId       = sysConfig.Id,
                    Name           = "重置路径码",
                    Url            = "/System/ReloadPathCode",
                    CreateDateTime = Now,
                    Order          = 8,
                    Code           = "AAAF",
                    PathCode       = "AAAFAA",
                    Type           = 3
                };//8
                var log = new MenuEntity
                {
                    Id             = Guid.NewGuid().ToString("N"),
                    Name           = "日志查看",
                    Icon           = "fa fa-bars",
                    Url            = "#",
                    CreateDateTime = Now,
                    Order          = 2,
                    Code           = "AB",
                    PathCode       = "AB",
                    Type           = 1
                };//9
                var logLogin = new MenuEntity
                {
                    Id             = Guid.NewGuid().ToString("N"),
                    ParentId       = log.Id,
                    Name           = "登录日志",
                    Url            = "/Log/Logins",
                    CreateDateTime = Now,
                    Order          = 1,
                    Code           = "AA",
                    PathCode       = "ABAA",
                    Type           = 2
                };//10
                var logView = new MenuEntity
                {
                    Id             = Guid.NewGuid().ToString("N"),
                    ParentId       = log.Id,
                    Name           = "访问日志",
                    Url            = "/Log/Visits",
                    CreateDateTime = Now,
                    Order          = 2,
                    Code           = "AB",
                    PathCode       = "ABAB",
                    Type           = 2
                };//11

                //菜单
                var menus = new List <MenuEntity>
                {
                    system,
                    menuMgr,
                    roleMgr,
                    userMgr,
                    departmentMgr,
                    userRoleMgr,
                    giveRight,
                    cancelRight,
                    roleMenuMgr,
                    sysConfig,
                    areaConfig,
                    sysConfigReloadPathCode,
                    log,
                    logLogin,
                    logView
                };
                var menuBtns       = GetMenuButtons(menuMgr.Id, "Menu", "菜单", "AAAA", 12);
                var rolwBtns       = GetMenuButtons(roleMgr.Id, "Role", "角色", "AAAB", 15);
                var userBtns       = GetMenuButtons(userMgr.Id, "User", "用户", "AAAC", 18);
                var departmentBtns = GetMenuButtons(departmentMgr.Id, "Department", "部门", "AAAG", 19);
                var areaBtns       = GetMenuButtons(areaConfig.Id, "Area", "部门", "AAAH", 20);

                menus.AddRange(menuBtns);
                menus.AddRange(rolwBtns);
                menus.AddRange(userBtns);
                menus.AddRange(departmentBtns);
                menus.AddRange(areaBtns);
                menus.Add(new MenuEntity
                {
                    Id             = Guid.NewGuid().ToString("N"),
                    ParentId       = roleMenuMgr.Id,
                    Order          = 6,
                    Name           = "授权",
                    Type           = (byte)MenuType.Action,
                    Url            = "/Role/SetRoleMenus",
                    CreateDateTime = Now,
                    Code           = "AA",
                    PathCode       = "AAACAA"
                });
                menus.Add(new MenuEntity
                {
                    Id             = Guid.NewGuid().ToString("N"),
                    ParentId       = roleMenuMgr.Id,
                    Order          = 6,
                    Name           = "清空权限",
                    Type           = (byte)MenuType.Action,
                    Url            = "/Role/ClearRoleMenus",
                    CreateDateTime = Now,
                    Code           = "AB",
                    PathCode       = "AAACAB"
                });
                //示例页面
                var page = new MenuEntity
                {
                    Id             = Guid.NewGuid().ToString("N"),
                    Name           = "示例页面",
                    Icon           = "fa fa-file-o",
                    Url            = "#",
                    CreateDateTime = Now,
                    Order          = 3,
                    Code           = "AC",
                    PathCode       = "AC",
                    Type           = 1
                };
                var pageButton = new MenuEntity
                {
                    Id             = Guid.NewGuid().ToString("N"),
                    ParentId       = page.Id,
                    Name           = "按钮",
                    Url            = "/Pages/Buttons",
                    CreateDateTime = Now,
                    Order          = 0,
                    Code           = "AA",
                    PathCode       = "ACAA",
                    Type           = 2
                };
                var pageForm = new MenuEntity
                {
                    Id             = Guid.NewGuid().ToString("N"),
                    ParentId       = page.Id,
                    Name           = "表单",
                    Url            = "/Pages/Form",
                    CreateDateTime = Now,
                    Order          = 1,
                    Code           = "AB",
                    PathCode       = "ACAB",
                    Type           = 2
                };
                var pageFormAdvance = new MenuEntity
                {
                    Id             = Guid.NewGuid().ToString("N"),
                    ParentId       = page.Id,
                    Name           = "高级表单",
                    Url            = "/Pages/FormAdvance",
                    CreateDateTime = Now,
                    Order          = 2,
                    Code           = "AC",
                    PathCode       = "ACAC",
                    Type           = 2
                };
                var pageTable = new MenuEntity
                {
                    Id             = Guid.NewGuid().ToString("N"),
                    ParentId       = page.Id,
                    Name           = "表格",
                    Url            = "/Pages/Tables",
                    CreateDateTime = Now,
                    Order          = 3,
                    Code           = "AD",
                    PathCode       = "ACAD",
                    Type           = 2
                };
                var pageTabs = new MenuEntity
                {
                    Id             = Guid.NewGuid().ToString("N"),
                    ParentId       = page.Id,
                    Name           = "选项卡",
                    Url            = "/Pages/Tabs",
                    CreateDateTime = Now,
                    Order          = 4,
                    Code           = "AE",
                    PathCode       = "ACAE",
                    Type           = 2
                };
                var pageFonts = new MenuEntity
                {
                    Id             = Guid.NewGuid().ToString("N"),
                    ParentId       = page.Id,
                    Name           = "字体",
                    Url            = "/Pages/FontAwesome",
                    CreateDateTime = Now,
                    Order          = 5,
                    Code           = "AF",
                    PathCode       = "ACAF",
                    Type           = 2
                };

                menus.Add(page);
                menus.Add(pageButton);
                menus.Add(pageForm);
                menus.Add(pageFormAdvance);
                menus.Add(pageTable);
                menus.Add(pageTabs);
                menus.Add(pageFonts);

                #endregion

                #region 角色

                var superAdminRole = new RoleEntity
                {
                    Id          = Guid.NewGuid().ToString("N"),
                    Name        = "超级管理员",
                    Description = "超级管理员"
                };
                var guestRole = new RoleEntity
                {
                    Id          = Guid.NewGuid().ToString("N"),
                    Name        = "guest",
                    Description = "游客"
                };
                var roles = new List <RoleEntity>
                {
                    superAdminRole,
                    guestRole
                };

                #endregion

                #region 用户角色关系

                var userRoles = new List <UserRoleEntity>
                {
                    new UserRoleEntity
                    {
                        Id             = Guid.NewGuid().ToString("N"),
                        UserId         = admin.Id,
                        RoleId         = superAdminRole.Id,
                        CreateDateTime = Now
                    },
                    new UserRoleEntity
                    {
                        Id             = Guid.NewGuid().ToString("N"),
                        UserId         = guest.Id,
                        RoleId         = guestRole.Id,
                        CreateDateTime = Now
                    }
                };

                #endregion

                #region 角色菜单权限关系

                var roleMenus = new List <RoleMenuEntity>();
                //管理员授权(管理员有所有权限)
                menus.ForEach(m =>
                {
                    roleMenus.Add(new RoleMenuEntity
                    {
                        Id             = Guid.NewGuid().ToString("N"),
                        RoleId         = superAdminRole.Id,
                        MenuId         = m.Id,
                        CreateDateTime = Now
                    });
                });
                //guest授权(guest只有查看权限,没有按钮操作权限)
                menus.Where(item => item.Type != (byte)MenuType.Action).ForEach(m =>
                {
                    roleMenus.Add(new RoleMenuEntity
                    {
                        Id             = Guid.NewGuid().ToString("N"),
                        RoleId         = guestRole.Id,
                        MenuId         = m.Id,
                        CreateDateTime = Now
                    });
                });

                #endregion

                #region 系统配置

                var systemConfig = new SystemConfigEntity
                {
                    Id             = Guid.NewGuid().ToString("N"),
                    SystemName     = "JuCheap Core",
                    IsDataInited   = true,
                    DataInitedDate = Now,
                    CreateDateTime = Now,
                    IsDeleted      = false
                };

                #endregion

                _context.Menus.AddRange(menus.OrderBy(m => m.Order).ToArray());
                _context.Roles.AddRange(roles);
                _context.Users.AddRange(user);
                _context.UserRoles.AddRange(userRoles);
                _context.RoleMenus.AddRange(roleMenus);
                _context.SystemConfigs.Add(systemConfig);
                await _context.SaveChangesAsync();
                await InitPathCodeAsync();

                return(true);
            }
            catch
            {
                //todo log
            }
            return(false);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 初始化
        /// </summary>
        public async Task <bool> InitAsync(List <MenuDto> menues)
        {
            try
            {
                await _context.Database.MigrateAsync();

                if (await _context.SystemConfigs.AnyAsync(item => item.IsDataInited))
                {
                    return(false);
                }

                #region 用户

                var admin = new UserEntity
                {
                    Id             = Guid.NewGuid().ToString("N"),
                    LoginName      = "jucheap",
                    RealName       = "超级管理员",
                    Password       = "******".ToMd5(),
                    Email          = "*****@*****.**",
                    IsSuperMan     = true,
                    CreateDateTime = Now
                };
                var guest = new UserEntity
                {
                    Id             = Guid.NewGuid().ToString("N"),
                    LoginName      = "admin",
                    RealName       = "游客",
                    Password       = "******".ToMd5(),
                    Email          = "*****@*****.**",
                    CreateDateTime = Now
                };
                //用户
                var user = new List <UserEntity>
                {
                    admin,
                    guest
                };
                #endregion

                #region 菜单

                await _menuService.ReInitMenuesAsync(menues);

                var menus = await _context.Menus.ToListAsync();

                #endregion

                #region 角色

                var superAdminRole = new RoleEntity
                {
                    Id             = Guid.NewGuid().ToString("N"),
                    Name           = "超级管理员",
                    Description    = "超级管理员",
                    CreateDateTime = Now
                };
                var guestRole = new RoleEntity
                {
                    Id             = Guid.NewGuid().ToString("N"),
                    Name           = "guest",
                    Description    = "游客",
                    CreateDateTime = Now
                };
                var roles = new List <RoleEntity>
                {
                    superAdminRole,
                    guestRole
                };

                #endregion

                #region 用户角色关系

                var userRoles = new List <UserRoleEntity>
                {
                    new UserRoleEntity
                    {
                        Id             = Guid.NewGuid().ToString("N"),
                        UserId         = admin.Id,
                        RoleId         = superAdminRole.Id,
                        CreateDateTime = Now
                    },
                    new UserRoleEntity
                    {
                        Id             = Guid.NewGuid().ToString("N"),
                        UserId         = guest.Id,
                        RoleId         = guestRole.Id,
                        CreateDateTime = Now
                    }
                };

                #endregion

                #region 角色菜单权限关系

                var roleMenus = new List <RoleMenuEntity>();
                //guest授权(guest只有查看权限,没有按钮操作权限)
                menus.Where(item => item.Type != MenuType.Action).ForEach(m =>
                {
                    roleMenus.Add(new RoleMenuEntity
                    {
                        Id             = Guid.NewGuid().ToString("N"),
                        RoleId         = guestRole.Id,
                        MenuId         = m.Id,
                        CreateDateTime = Now
                    });
                });

                #endregion

                #region 系统配置

                var systemConfig = new SystemConfigEntity
                {
                    Id             = Guid.NewGuid().ToString("N"),
                    SystemName     = "JuCheap Core",
                    IsDataInited   = true,
                    DataInitedDate = Now,
                    CreateDateTime = Now,
                    IsDeleted      = false
                };

                #endregion

                _context.Roles.AddRange(roles);
                _context.Users.AddRange(user);
                _context.UserRoles.AddRange(userRoles);
                _context.RoleMenus.AddRange(roleMenus);
                _context.SystemConfigs.Add(systemConfig);
                await _context.SaveChangesAsync();
                await InitPathCodeAsync();

                return(true);
            }
            catch (Exception ex)
            {
                Log.Logger.Error(ex);
            }
            return(false);
        }