├── ReadMe.txt ├── NLayer.Presentation.WebHost ├── Views │ ├── _ViewStart.cshtml │ ├── Shared │ │ ├── _Confirm.cshtml │ │ ├── _Layout.cshtml │ │ ├── Error.cshtml │ │ └── _Menus.cshtml │ ├── Web.config │ ├── Account │ │ └── Login.cshtml │ └── Home │ │ └── WhatCanIdo.cshtml ├── Areas │ ├── Samples │ │ ├── Views │ │ │ ├── _ViewStart.cshtml │ │ │ ├── Bootstrap │ │ │ │ └── Index.cshtml │ │ │ └── web.config │ │ ├── SamplesAreaRegistration.cs │ │ └── Controllers │ │ │ └── BootstrapController.cs │ └── UserSystem │ │ ├── Views │ │ ├── _ViewStart.cshtml │ │ ├── web.config │ │ ├── Role │ │ │ ├── EditGroup.cshtml │ │ │ └── EditRole.cshtml │ │ ├── User │ │ │ ├── EffectiveUserPermission.cshtml │ │ │ └── EditUser.cshtml │ │ └── Menu │ │ │ └── EditMenuPermission.cshtml │ │ ├── UserSystemBaseController.cs │ │ └── UserSystemAreaRegistration.cs ├── favicon.ico ├── Content │ ├── img │ │ ├── hue.png │ │ ├── alpha.png │ │ ├── larrow.png │ │ ├── line.png │ │ ├── logo.png │ │ ├── rarrow.png │ │ ├── sprite.png │ │ ├── demo │ │ │ ├── av1.jpg │ │ │ ├── av2.jpg │ │ │ └── av3.jpg │ │ ├── gritter.png │ │ ├── select2.png │ │ ├── spinner.gif │ │ ├── breadcrumb.png │ │ ├── menu-active.png │ │ ├── saturation.png │ │ ├── select2x2.png │ │ ├── signin │ │ │ ├── user.png │ │ │ ├── check.png │ │ │ ├── login-bg.png │ │ │ └── password.png │ │ ├── gritter-light.png │ │ ├── icons │ │ │ ├── 16 │ │ │ │ ├── book.png │ │ │ │ ├── home.png │ │ │ │ ├── lock.png │ │ │ │ ├── mail.png │ │ │ │ ├── pdf.png │ │ │ │ ├── tag.png │ │ │ │ ├── user.png │ │ │ │ ├── web.png │ │ │ │ ├── cabinet.png │ │ │ │ ├── client.png │ │ │ │ ├── graph.png │ │ │ │ ├── people.png │ │ │ │ ├── search.png │ │ │ │ ├── survey.png │ │ │ │ ├── wallet.png │ │ │ │ ├── calendar.png │ │ │ │ ├── database.png │ │ │ │ ├── download.png │ │ │ │ ├── piechart.png │ │ │ │ └── shopping-bag.png │ │ │ └── 32 │ │ │ │ ├── book.png │ │ │ │ ├── home.png │ │ │ │ ├── lock.png │ │ │ │ ├── mail.png │ │ │ │ ├── pdf.png │ │ │ │ ├── tag.png │ │ │ │ ├── user.png │ │ │ │ ├── web.png │ │ │ │ ├── cabinet.png │ │ │ │ ├── client.png │ │ │ │ ├── graph.png │ │ │ │ ├── people.png │ │ │ │ ├── search.png │ │ │ │ ├── survey.png │ │ │ │ ├── wallet.png │ │ │ │ ├── calendar.png │ │ │ │ ├── database.png │ │ │ │ ├── download.png │ │ │ │ ├── piechart.png │ │ │ │ └── shopping-bag.png │ │ ├── glyphicons-halflings.png │ │ └── glyphicons-halflings-white.png │ ├── common.css │ ├── error.css │ ├── bootstrap-duallistbox.min.css │ ├── colorpicker.css │ ├── prettify.css │ ├── bootstrap-duallistbox.css │ ├── login.css │ └── jquery.gritter.css ├── Global.asax ├── Helper │ ├── IServiceResolver.cs │ ├── NLayerServiceResolver.cs │ └── NLayerHtmlHelper.cs ├── App_Data │ └── Config │ │ └── autofac.xml ├── Controllers │ ├── BaseController.cs │ ├── HomeController.cs │ ├── BaseAuthorizeController.cs │ └── AccountController.cs ├── App_Start │ ├── FilterConfig.cs │ ├── RouteConfig.cs │ ├── CustomAjaxExceptionAttribute.cs │ ├── ExceptionExtensions.cs │ ├── BundleConfig.cs │ ├── AutofacConfig.cs │ └── DisplayExtensions.cs ├── Models │ └── AjaxResponse.cs ├── Scripts │ ├── samples │ │ ├── sample.gritter.js │ │ └── sample.tables.js │ ├── plugins │ │ └── jquery.unobtrusive │ │ │ └── jquery.unobtrusive-ajax.min.js │ └── common.js ├── Properties │ └── AssemblyInfo.cs ├── Web.Debug.config ├── Web.Release.config ├── Global.asax.cs ├── packages.config └── Resources │ └── CommonResource.Designer.cs ├── docs ├── role-user-design-database.png ├── role-user-design-database.vsdx ├── role-user-design-summary.png └── role-user-design-summary.vsdx ├── NLayer.Domain ├── packages.config ├── UserSystemModule │ └── Aggregates │ │ ├── MenuAgg │ │ ├── IPermissionRepository.cs │ │ ├── IMenuRepository.cs │ │ ├── Menu.cs │ │ └── Permission.cs │ │ ├── RoleGroupAgg │ │ ├── IRoleGroupRepository.cs │ │ └── RoleGroup.cs │ │ ├── RoleAgg │ │ ├── IRoleRepository.cs │ │ └── Role.cs │ │ └── UserAgg │ │ ├── IUserRepository.cs │ │ └── User.cs └── Properties │ └── AssemblyInfo.cs ├── NLayer.Application ├── packages.config ├── CommonModule │ └── DTOs │ │ └── IdNameDTO.cs ├── UserSystemModule │ ├── Converters │ │ ├── UserSystemConverters.cs │ │ ├── UserConverters.cs │ │ ├── RoleConverters.cs │ │ ├── RoleGroupConverters.cs │ │ └── MenuConverters.cs │ ├── DTOs │ │ ├── RoleGroupDTO.cs │ │ ├── RoleDTO.cs │ │ ├── PermissionDTO.cs │ │ ├── UserDTO.cs │ │ ├── MenuDTO.cs │ │ └── PermissionForAuthDTO.cs │ └── Services │ │ ├── IMenuService.cs │ │ ├── IRoleService.cs │ │ ├── IAuthService.cs │ │ ├── IUserService.cs │ │ └── IRoleGroupService.cs ├── Exceptions │ ├── DefinedException.cs │ ├── DataExistsException.cs │ ├── DataNotFoundException.cs │ ├── ArgumentEmptyException.cs │ ├── LoginPasswordIncorrectException.cs │ └── LoginNameNotFoundException.cs ├── Modules │ ├── NLayerModules.cs │ └── NLayerModulesManager.cs ├── Properties │ └── AssemblyInfo.cs └── Resources │ └── CommonResource.Designer.cs ├── NLayer.IocModules ├── packages.config ├── CommonIocModule.cs ├── App.config ├── Properties │ └── AssemblyInfo.cs └── UserSystemIocModule.cs ├── NLayer.Infrastructure ├── Entity │ ├── IAggregateRoot.cs │ └── IdentityGenerator.cs ├── Repository │ ├── IRepository.cs │ └── RepositoryBase.cs ├── Properties │ └── AssemblyInfo.cs ├── UnitOfWork │ └── IUnitOfWork.cs └── NLayer.Infrastructure.csproj ├── NLayer.Repository.Test ├── packages.config ├── App.config ├── Properties │ └── AssemblyInfo.cs └── AuthTests.cs ├── NLayer.Repository ├── packages.config ├── UnitOfWork │ └── INLayerUnitOfWork.cs ├── Initializer │ └── DbInitializer.cs ├── Migrations │ ├── 201505030357506_AddLoginInfo.cs │ ├── 201505030357506_AddLoginInfo.Designer.cs │ ├── 201504210841169_InitialCreate.Designer.cs │ ├── 201506161423201_ModifyRoleUser.Designer.cs │ ├── Configuration.cs │ └── 201506161423201_ModifyRoleUser.cs ├── App.config ├── UserSystemModule │ └── Repositories │ │ ├── PermissionRepository.cs │ │ ├── RoleGroupRepository.cs │ │ ├── RoleRepository.cs │ │ ├── MenuRepository.cs │ │ └── UserRepository.cs ├── Properties │ └── AssemblyInfo.cs └── SpecificRepositoryBase.cs ├── NLayer.Infrastructure.Utility ├── Helper │ ├── Const.cs │ └── TextHelper.cs ├── Extensions │ └── EnumerableExtensions.cs ├── Caching │ ├── ICacheManager.cs │ └── CacheExtensions.cs ├── Properties │ └── AssemblyInfo.cs ├── SecurityHelper.cs └── NLayer.Infrastructure.Utility.csproj ├── NLayer.Infrastructure.Authorize ├── AuthObject │ ├── MenuForAuthorize.cs │ ├── UserToken.cs │ ├── UserForAuthorize.cs │ └── PermissionForAuthorize.cs ├── PermissionAttribute.cs ├── IAuthorizeManager.cs ├── MenuAttribute.cs ├── Properties │ └── AssemblyInfo.cs └── AuthorizeException.cs └── .gitignore /ReadMe.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/ReadMe.txt -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "~/Views/Shared/_Layout.cshtml"; 3 | } 4 | -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Areas/Samples/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "~/Views/Shared/_Layout.cshtml"; 3 | } -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Areas/UserSystem/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "~/Views/Shared/_Layout.cshtml"; 3 | } -------------------------------------------------------------------------------- /docs/role-user-design-database.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/docs/role-user-design-database.png -------------------------------------------------------------------------------- /docs/role-user-design-database.vsdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/docs/role-user-design-database.vsdx -------------------------------------------------------------------------------- /docs/role-user-design-summary.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/docs/role-user-design-summary.png -------------------------------------------------------------------------------- /docs/role-user-design-summary.vsdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/docs/role-user-design-summary.vsdx -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/favicon.ico -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/hue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/hue.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Codebehind="Global.asax.cs" Inherits="NLayer.Presentation.WebHost.MvcApplication" Language="C#" %> 2 | -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/alpha.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/alpha.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/larrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/larrow.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/line.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/line.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/logo.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/rarrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/rarrow.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/sprite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/sprite.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/demo/av1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/demo/av1.jpg -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/demo/av2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/demo/av2.jpg -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/demo/av3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/demo/av3.jpg -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/gritter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/gritter.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/select2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/select2.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/spinner.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/spinner.gif -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/breadcrumb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/breadcrumb.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/menu-active.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/menu-active.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/saturation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/saturation.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/select2x2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/select2x2.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/signin/user.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/signin/user.png -------------------------------------------------------------------------------- /NLayer.Domain/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/gritter-light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/gritter-light.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/icons/16/book.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/icons/16/book.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/icons/16/home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/icons/16/home.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/icons/16/lock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/icons/16/lock.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/icons/16/mail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/icons/16/mail.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/icons/16/pdf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/icons/16/pdf.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/icons/16/tag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/icons/16/tag.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/icons/16/user.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/icons/16/user.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/icons/16/web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/icons/16/web.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/icons/32/book.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/icons/32/book.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/icons/32/home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/icons/32/home.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/icons/32/lock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/icons/32/lock.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/icons/32/mail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/icons/32/mail.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/icons/32/pdf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/icons/32/pdf.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/icons/32/tag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/icons/32/tag.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/icons/32/user.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/icons/32/user.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/icons/32/web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/icons/32/web.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/signin/check.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/signin/check.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/icons/16/cabinet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/icons/16/cabinet.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/icons/16/client.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/icons/16/client.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/icons/16/graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/icons/16/graph.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/icons/16/people.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/icons/16/people.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/icons/16/search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/icons/16/search.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/icons/16/survey.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/icons/16/survey.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/icons/16/wallet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/icons/16/wallet.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/icons/32/cabinet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/icons/32/cabinet.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/icons/32/client.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/icons/32/client.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/icons/32/graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/icons/32/graph.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/icons/32/people.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/icons/32/people.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/icons/32/search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/icons/32/search.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/icons/32/survey.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/icons/32/survey.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/icons/32/wallet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/icons/32/wallet.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/signin/login-bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/signin/login-bg.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/signin/password.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/signin/password.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/icons/16/calendar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/icons/16/calendar.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/icons/16/database.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/icons/16/database.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/icons/16/download.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/icons/16/download.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/icons/16/piechart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/icons/16/piechart.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/icons/32/calendar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/icons/32/calendar.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/icons/32/database.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/icons/32/database.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/icons/32/download.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/icons/32/download.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/icons/32/piechart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/icons/32/piechart.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/glyphicons-halflings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/glyphicons-halflings.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/icons/16/shopping-bag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/icons/16/shopping-bag.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/icons/32/shopping-bag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/icons/32/shopping-bag.png -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/img/glyphicons-halflings-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ningjg007/DDD-NLayer-Sample/HEAD/NLayer.Presentation.WebHost/Content/img/glyphicons-halflings-white.png -------------------------------------------------------------------------------- /NLayer.Application/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /NLayer.IocModules/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /NLayer.Infrastructure/Entity/IAggregateRoot.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace NLayer.Infrastructure.Entity 8 | { 9 | public interface IAggregateRoot 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /NLayer.Domain/UserSystemModule/Aggregates/MenuAgg/IPermissionRepository.cs: -------------------------------------------------------------------------------- 1 | using NLayer.Infrastructure.Repository; 2 | using PagedList; 3 | 4 | namespace NLayer.Domain.UserSystemModule.Aggregates.MenuAgg 5 | { 6 | public interface IPermissionRepository : IRepository 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Areas/UserSystem/UserSystemBaseController.cs: -------------------------------------------------------------------------------- 1 | using NLayer.Infrastructure.Authorize; 2 | using NLayer.Presentation.WebHost.Controllers; 3 | 4 | namespace NLayer.Presentation.WebHost.Areas.UserSystem 5 | { 6 | public class UserSystemBaseController : BaseAuthorizeController 7 | { 8 | } 9 | } -------------------------------------------------------------------------------- /NLayer.Repository.Test/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /NLayer.Repository/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Helper/IServiceResolver.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | 6 | namespace NLayer.Presentation.WebHost.Helper 7 | { 8 | public interface IServiceResolver 9 | { 10 | T Resolve(); 11 | 12 | object Resolve(Type type); 13 | } 14 | } -------------------------------------------------------------------------------- /NLayer.Domain/UserSystemModule/Aggregates/MenuAgg/IMenuRepository.cs: -------------------------------------------------------------------------------- 1 | using NLayer.Infrastructure.Repository; 2 | using PagedList; 3 | 4 | namespace NLayer.Domain.UserSystemModule.Aggregates.MenuAgg 5 | { 6 | public interface IMenuRepository : IRepository 7 | { 8 | IPagedList FindBy(string module, string name, int pageNumber, int pageSize); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /NLayer.Infrastructure.Utility/Helper/Const.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace NLayer.Infrastructure.Utility.Helper 8 | { 9 | public class Const 10 | { 11 | public static readonly DateTime SqlServerNullDateTime = DateTime.Parse("1900-01-01"); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /NLayer.Application/CommonModule/DTOs/IdNameDTO.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace NLayer.Application.CommonModule.DTOs 8 | { 9 | public class IdNameDTO 10 | { 11 | public Guid Id { get; set; } 12 | 13 | public string Name { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /NLayer.Domain/UserSystemModule/Aggregates/RoleGroupAgg/IRoleGroupRepository.cs: -------------------------------------------------------------------------------- 1 | using NLayer.Infrastructure.Repository; 2 | using PagedList; 3 | 4 | namespace NLayer.Domain.UserSystemModule.Aggregates.RoleGroupAgg 5 | { 6 | public interface IRoleGroupRepository : IRepository 7 | { 8 | IPagedList FindBy(string name, int pageNumber, int pageSize); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/App_Data/Config/autofac.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Controllers/BaseController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | using log4net; 7 | 8 | namespace NLayer.Presentation.WebHost.Controllers 9 | { 10 | public class BaseController : Controller 11 | { 12 | protected static readonly ILog Log = LogManager.GetLogger(typeof(BaseController)); 13 | } 14 | } -------------------------------------------------------------------------------- /NLayer.Application/UserSystemModule/Converters/UserSystemConverters.cs: -------------------------------------------------------------------------------- 1 | namespace NLayer.Application.UserSystemModule.Converters 2 | { 3 | public static partial class UserSystemConverters 4 | { 5 | static UserSystemConverters() 6 | { 7 | InitRoleMappers(); 8 | InitUserMappers(); 9 | InitRoleGroupMappers(); 10 | InitMenuMappers(); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /NLayer.Application/Exceptions/DefinedException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace NLayer.Application.Exceptions 8 | { 9 | public class DefinedException: Exception 10 | { 11 | public DefinedException(string message) 12 | : base(message) 13 | { 14 | 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/App_Start/FilterConfig.cs: -------------------------------------------------------------------------------- 1 | using System.Web; 2 | using System.Web.Mvc; 3 | 4 | namespace NLayer.Presentation.WebHost 5 | { 6 | public class FilterConfig 7 | { 8 | public static void RegisterGlobalFilters(GlobalFilterCollection filters) 9 | { 10 | filters.Add(new CustomAjaxExceptionAttribute()); 11 | filters.Add(new HandleErrorAttribute()); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /NLayer.Application/UserSystemModule/DTOs/RoleGroupDTO.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NLayer.Application.UserSystemModule.DTOs 4 | { 5 | public class RoleGroupDTO 6 | { 7 | public Guid Id { get; set; } 8 | 9 | public string Name { get; set; } 10 | 11 | public string Description { get; set; } 12 | 13 | public int SortOrder { get; set; } 14 | 15 | public DateTime Created { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /NLayer.Domain/UserSystemModule/Aggregates/RoleAgg/IRoleRepository.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NLayer.Domain.UserSystemModule.Aggregates.RoleGroupAgg; 3 | using NLayer.Infrastructure.Repository; 4 | using PagedList; 5 | 6 | namespace NLayer.Domain.UserSystemModule.Aggregates.RoleAgg 7 | { 8 | public interface IRoleRepository : IRepository 9 | { 10 | IPagedList FindBy(Guid roleGroupId, string name, int pageNumber, int pageSize); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /NLayer.Domain/UserSystemModule/Aggregates/UserAgg/IUserRepository.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NLayer.Infrastructure.Repository; 3 | using PagedList; 4 | 5 | namespace NLayer.Domain.UserSystemModule.Aggregates.UserAgg 6 | { 7 | public interface IUserRepository : IRepository 8 | { 9 | IPagedList FindBy(string name, int pageNumber, int pageSize); 10 | 11 | bool ExistsLoginName(User item); 12 | 13 | bool ExistsEmail(User item); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /NLayer.Application/UserSystemModule/DTOs/RoleDTO.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NLayer.Application.UserSystemModule.DTOs 4 | { 5 | public class RoleDTO 6 | { 7 | public Guid Id { get; set; } 8 | 9 | public string Name { get; set; } 10 | 11 | public string Description { get; set; } 12 | 13 | public int SortOrder { get; set; } 14 | 15 | public DateTime Created { get; set; } 16 | 17 | public Guid RoleGroupId { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /NLayer.Application/Exceptions/DataExistsException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace NLayer.Application.Exceptions 8 | { 9 | /// 10 | /// 数据已存在 11 | /// 12 | public class DataExistsException : DefinedException 13 | { 14 | public DataExistsException(string message) 15 | : base(message) 16 | { 17 | 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /NLayer.Application/Exceptions/DataNotFoundException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace NLayer.Application.Exceptions 8 | { 9 | /// 10 | /// 数据不存在 11 | /// 12 | public class DataNotFoundException : DefinedException 13 | { 14 | public DataNotFoundException(string message) 15 | : base(message) 16 | { 17 | 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /NLayer.Infrastructure.Authorize/AuthObject/MenuForAuthorize.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace NLayer.Infrastructure.Authorize.AuthObject 8 | { 9 | public class MenuForAuthorize 10 | { 11 | public int Module { get; set; } 12 | 13 | public Guid MenuId { get; set; } 14 | 15 | public string MenuName { get; set; } 16 | 17 | public string MenuUrl { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /NLayer.Application/Exceptions/ArgumentEmptyException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace NLayer.Application.Exceptions 8 | { 9 | /// 10 | /// 参数不能为空 11 | /// 12 | public class ArgumentEmptyException : DefinedException 13 | { 14 | public ArgumentEmptyException(string message) 15 | : base(message) 16 | { 17 | 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /NLayer.Application/Exceptions/LoginPasswordIncorrectException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace NLayer.Application.Exceptions 8 | { 9 | /// 10 | /// 登陆名不存在 11 | /// 12 | public class LoginNameNotFoundException : DefinedException 13 | { 14 | public LoginNameNotFoundException(string message) 15 | : base(message) 16 | { 17 | 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /NLayer.Application/Exceptions/LoginNameNotFoundException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace NLayer.Application.Exceptions 8 | { 9 | /// 10 | /// 登陆密码错误 11 | /// 12 | public class LoginPasswordIncorrectException : DefinedException 13 | { 14 | public LoginPasswordIncorrectException(string message) 15 | : base(message) 16 | { 17 | 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /NLayer.Application/UserSystemModule/DTOs/PermissionDTO.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NLayer.Application.UserSystemModule.DTOs 4 | { 5 | public class PermissionDTO 6 | { 7 | public Guid Id { get; set; } 8 | 9 | public string Name { get; set; } 10 | 11 | public string Code { get; set; } 12 | 13 | public string ActionUrl { get; set; } 14 | 15 | public int SortOrder { get; set; } 16 | 17 | public Guid MenuId { get; set; } 18 | 19 | public DateTime Created { get; set; } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /NLayer.Infrastructure.Authorize/AuthObject/UserToken.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace NLayer.Infrastructure.Authorize.AuthObject 8 | { 9 | public class UserToken 10 | { 11 | public Guid UserId { get; set; } 12 | 13 | public string LastLoginToken { get; set; } 14 | 15 | public string GetAuthToken() 16 | { 17 | return string.Format("{0}_{1}", this.UserId, this.LastLoginToken); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Views/Shared/_Confirm.cshtml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /NLayer.Application/UserSystemModule/DTOs/UserDTO.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NLayer.Application.UserSystemModule.DTOs 4 | { 5 | public class UserDTO 6 | { 7 | public Guid Id { get; set; } 8 | 9 | public string Name { get; set; } 10 | 11 | public string LoginName { get; set; } 12 | 13 | public string LoginPwd { get; set; } 14 | 15 | public string Email { get; set; } 16 | 17 | public DateTime Created { get; set; } 18 | 19 | public string LastLoginToken { get; set; } 20 | 21 | public DateTime LastLogin { get; set; } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /NLayer.Repository/UnitOfWork/INLayerUnitOfWork.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Data.Entity; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using NLayer.Infrastructure.UnitOfWork; 8 | 9 | namespace NLayer.Repository.UnitOfWork 10 | { 11 | public interface INLayerUnitOfWork : IUnitOfWork 12 | { 13 | IDbSet CreateSet() where TEntity : class; 14 | 15 | void ApplyCurrentValues(TEntity original, TEntity current) where TEntity : class; 16 | 17 | DbContext DbContext { get; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /NLayer.Infrastructure.Authorize/AuthObject/UserForAuthorize.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace NLayer.Infrastructure.Authorize.AuthObject 8 | { 9 | public class UserForAuthorize 10 | { 11 | public Guid UserId { get; set; } 12 | 13 | public string UserName { get; set; } 14 | 15 | public string LoginName { get; set; } 16 | 17 | public List Menus { get; set; } 18 | 19 | public List Permissions { get; set; } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | #ignore thumbnails created by windows 3 | Thumbs.db 4 | #Ignore files build by Visual Studio 5 | *.obj 6 | *.exe 7 | *.pdb 8 | *.user 9 | *.aps 10 | *.pch 11 | *.vspscc 12 | *_i.c 13 | *_p.c 14 | *.ncb 15 | *.suo 16 | *.tlb 17 | *.tlh 18 | *.bak 19 | *.cache 20 | *.ilk 21 | *.log 22 | [Bb]in 23 | [Dd]ebug*/ 24 | *.lib 25 | *.sbr 26 | obj/ 27 | [Rr]elease*/ 28 | _ReSharper*/ 29 | [Tt]est[Rr]esult* 30 | packages/ 31 | NLayer.Presentation.WebHost/logs/ 32 | NLayer.Presentation.WebHost/logs/debug 33 | NLayer.Presentation.WebHost/logs/error 34 | NLayer.Presentation.WebHost/logs/fatal 35 | NLayer.Presentation.WebHost/logs/info 36 | -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/common.css: -------------------------------------------------------------------------------- 1 | 2 | /* ===============表格行变色================ */ 3 | .table-bordered { 4 | border-color:#e5eff6; 5 | } 6 | 7 | .table-striped tbody > tr:nth-child(2n+1) > td, 8 | .table-striped tbody > tr:nth-child(2n+1) > th { 9 | background:#fcfcfc; 10 | } 11 | 12 | .table-striped tbody tr:hover td, 13 | .table-striped tbody tr:hover th { 14 | background:#f5fafd; 15 | } 16 | 17 | /* ===============表格链接颜色================ */ 18 | .table-striped a { 19 | color: #333333; 20 | font-size: 11px; 21 | } 22 | 23 | .table-striped a:hover { 24 | color: #666666; 25 | } 26 | 27 | .ajax-remove { 28 | 29 | } -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Models/AjaxResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | 6 | namespace NLayer.Presentation.WebHost.Models 7 | { 8 | public class AjaxResponse 9 | { 10 | public AjaxResponse() 11 | { 12 | this.ShowMessage = true; 13 | } 14 | 15 | public string RedirectUrl { get; set; } 16 | 17 | public string Message { get; set; } 18 | 19 | public bool ShowMessage { get; set; } 20 | 21 | public bool Succeeded { get; set; } 22 | 23 | public string ErrorMessage { get; set; } 24 | } 25 | } -------------------------------------------------------------------------------- /NLayer.Repository/Initializer/DbInitializer.cs: -------------------------------------------------------------------------------- 1 | using System.Data.Entity; 2 | using NLayer.Repository.Migrations; 3 | using NLayer.Repository.UnitOfWork; 4 | 5 | namespace NLayer.Repository.Initializer 6 | { 7 | public static class DbInitializer 8 | { 9 | /// 10 | /// 数据库初始化 11 | /// 12 | public static void Initialize() 13 | { 14 | // 初始化时使用 15 | //Database.SetInitializer(new MigrateDatabaseToLatestVersion()); 16 | 17 | // 运行时使用 18 | Database.SetInitializer(null); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /NLayer.Infrastructure.Utility/Extensions/EnumerableExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace NLayer.Infrastructure.Utility.Extensions 8 | { 9 | public static class EnumerableExtensions 10 | { 11 | public static IEnumerable DistinctBy 12 | (this IEnumerable source, Func keySelector) 13 | { 14 | var seenKeys = new HashSet(); 15 | return source.Where(element => seenKeys.Add(keySelector(element))); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /NLayer.Application/UserSystemModule/DTOs/MenuDTO.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace NLayer.Application.UserSystemModule.DTOs 5 | { 6 | public class MenuDTO 7 | { 8 | public Guid Id { get; set; } 9 | 10 | public string Name { get; set; } 11 | 12 | public string Code { get; set; } 13 | 14 | public string Url { get; set; } 15 | 16 | public string Module { get; set; } 17 | 18 | public int SortOrder { get; set; } 19 | 20 | public DateTime Created { get; set; } 21 | 22 | public virtual ICollection Permissions { get; set; } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /NLayer.Repository/Migrations/201505030357506_AddLoginInfo.cs: -------------------------------------------------------------------------------- 1 | namespace NLayer.Repository.Migrations 2 | { 3 | using System; 4 | using System.Data.Entity.Migrations; 5 | 6 | public partial class AddLoginInfo : DbMigration 7 | { 8 | public override void Up() 9 | { 10 | AddColumn("auth.User", "LastLoginToken", c => c.String(maxLength: 200)); 11 | AddColumn("auth.User", "LastLogin", c => c.DateTime(nullable: false)); 12 | } 13 | 14 | public override void Down() 15 | { 16 | DropColumn("auth.User", "LastLoginToken"); 17 | DropColumn("auth.User", "LastLogin"); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /NLayer.Application/UserSystemModule/Services/IMenuService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using NLayer.Application.UserSystemModule.DTOs; 4 | using PagedList; 5 | 6 | namespace NLayer.Application.UserSystemModule.Services 7 | { 8 | public interface IMenuService 9 | { 10 | MenuDTO Add(MenuDTO menuDTO); 11 | 12 | void Update(MenuDTO menuDTO); 13 | 14 | void Remove(Guid id); 15 | 16 | void UpdatePermission(MenuDTO menuDTO); 17 | 18 | MenuDTO FindBy(Guid id); 19 | 20 | IPagedList FindBy(string module, string name, int pageNumber, int pageSize); 21 | 22 | List FindByModule(string module); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /NLayer.Application/Modules/NLayerModules.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace NLayer.Application.Modules 8 | { 9 | public enum NLayerModulesType 10 | { 11 | UserSystem = 1, 12 | BootstrapSamples = 2, 13 | AuthMenuSample = 3, 14 | } 15 | 16 | public class NLayerModules 17 | { 18 | public NLayerModules(NLayerModulesType type, string name) 19 | { 20 | Type = type; 21 | Name = name; 22 | } 23 | 24 | public NLayerModulesType Type { get; set; } 25 | 26 | public string Name { get; set; } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/App_Start/RouteConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | using System.Web.Routing; 7 | 8 | namespace NLayer.Presentation.WebHost 9 | { 10 | public class RouteConfig 11 | { 12 | public static void RegisterRoutes(RouteCollection routes) 13 | { 14 | routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 15 | 16 | routes.MapRoute( 17 | name: "Default", 18 | url: "{controller}/{action}/{id}", 19 | defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } 20 | ); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /NLayer.Infrastructure.Utility/Caching/ICacheManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace NLayer.Infrastructure.Utility.Caching 8 | { 9 | public interface ICacheManager 10 | { 11 | T Get(string key); 12 | 13 | void Set(string key, object value, int minutes); 14 | 15 | void Set(string key, object value, int minutes, bool isAbsoluteExpiration, 16 | Action onRemove); 17 | 18 | bool IsSet(string key); 19 | 20 | void Remove(string key); 21 | 22 | void RemoveByPattern(string pattern); 23 | 24 | void ClearAll(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Areas/Samples/SamplesAreaRegistration.cs: -------------------------------------------------------------------------------- 1 | using System.Web.Mvc; 2 | 3 | namespace NLayer.Presentation.WebHost.Areas.Samples 4 | { 5 | public class SamplesAreaRegistration : AreaRegistration 6 | { 7 | public override string AreaName 8 | { 9 | get 10 | { 11 | return "Samples"; 12 | } 13 | } 14 | 15 | public override void RegisterArea(AreaRegistrationContext context) 16 | { 17 | context.MapRoute( 18 | "Samples_default", 19 | "Samples/{controller}/{action}/{id}", 20 | new { action = "Index", id = UrlParameter.Optional } 21 | ); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Areas/UserSystem/UserSystemAreaRegistration.cs: -------------------------------------------------------------------------------- 1 | using System.Web.Mvc; 2 | 3 | namespace NLayer.Presentation.WebHost.Areas.UserSystem 4 | { 5 | public class UserSystemAreaRegistration : AreaRegistration 6 | { 7 | public override string AreaName 8 | { 9 | get 10 | { 11 | return "UserSystem"; 12 | } 13 | } 14 | 15 | public override void RegisterArea(AreaRegistrationContext context) 16 | { 17 | context.MapRoute( 18 | "UserSystem_default", 19 | "UserSystem/{controller}/{action}/{id}", 20 | new { action = "Index", id = UrlParameter.Optional } 21 | ); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /NLayer.Application/UserSystemModule/Services/IRoleService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using NLayer.Application.UserSystemModule.DTOs; 4 | using PagedList; 5 | 6 | namespace NLayer.Application.UserSystemModule.Services 7 | { 8 | public interface IRoleService 9 | { 10 | RoleDTO Add(RoleDTO roleDTO); 11 | 12 | void Update(RoleDTO roleDTO); 13 | 14 | void Remove(Guid id); 15 | 16 | List FindAll(); 17 | 18 | RoleDTO FindBy(Guid id); 19 | 20 | IPagedList FindBy(Guid roleGroupId, string name, int pageNumber, int pageSize); 21 | 22 | void UpdateRolePermission(Guid id, List permissions); 23 | 24 | List GetRolePermission(Guid id); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /NLayer.Application/UserSystemModule/Converters/UserConverters.cs: -------------------------------------------------------------------------------- 1 | using AutoMapper; 2 | using NLayer.Application.UserSystemModule.DTOs; 3 | using NLayer.Domain.UserSystemModule.Aggregates.UserAgg; 4 | 5 | namespace NLayer.Application.UserSystemModule.Converters 6 | { 7 | public static partial class UserSystemConverters 8 | { 9 | public static void InitUserMappers() 10 | { 11 | Mapper.CreateMap(); 12 | Mapper.CreateMap(); 13 | } 14 | 15 | public static User ToModel(this UserDTO dto) 16 | { 17 | return Mapper.Map(dto); 18 | } 19 | 20 | public static UserDTO ToDto(this User model) 21 | { 22 | return Mapper.Map(model); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | using NLayer.Infrastructure.Authorize; 7 | 8 | namespace NLayer.Presentation.WebHost.Controllers 9 | { 10 | public class HomeController : BaseAuthorizeController 11 | { 12 | protected override void CheckLogin() 13 | { 14 | //base.CheckoutLogin(); 15 | } 16 | 17 | public ActionResult Index() 18 | { 19 | return View(); 20 | } 21 | public ActionResult Error() 22 | { 23 | return View(); 24 | } 25 | 26 | public ActionResult WhatCanIdo() 27 | { 28 | return View(); 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /NLayer.Application/UserSystemModule/Converters/RoleConverters.cs: -------------------------------------------------------------------------------- 1 | using AutoMapper; 2 | using NLayer.Application.UserSystemModule.DTOs; 3 | using NLayer.Domain.UserSystemModule.Aggregates.RoleAgg; 4 | 5 | namespace NLayer.Application.UserSystemModule.Converters 6 | { 7 | public static partial class UserSystemConverters 8 | { 9 | public static void InitRoleMappers() 10 | { 11 | Mapper.CreateMap(); 12 | 13 | Mapper.CreateMap(); 14 | } 15 | 16 | public static Role ToModel(this RoleDTO dto) 17 | { 18 | return Mapper.Map(dto); 19 | } 20 | 21 | public static RoleDTO ToDto(this Role model) 22 | { 23 | return Mapper.Map(model); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /NLayer.Application/UserSystemModule/Services/IAuthService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using NLayer.Application.UserSystemModule.DTOs; 4 | using PagedList; 5 | 6 | namespace NLayer.Application.UserSystemModule.Services 7 | { 8 | public interface IAuthService 9 | { 10 | UserDTO Login(string loginName, string password, bool updateLoginToken); 11 | 12 | bool ValidatePassword(Guid id, string password); 13 | 14 | void ChangePassword(Guid id, string password); 15 | 16 | bool ValidateLoginToken(Guid id, string token); 17 | 18 | UserDTO FindByLoginToken(Guid id, string token); 19 | 20 | List GetRolePermissions(Guid id); 21 | 22 | List GetUserPermissions(Guid id); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /NLayer.Infrastructure.Authorize/PermissionAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace NLayer.Infrastructure.Authorize 8 | { 9 | [AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = false)] 10 | public class PermissionAttribute : Attribute 11 | { 12 | public PermissionAttribute(string code) 13 | { 14 | Code = code; 15 | } 16 | 17 | public PermissionAttribute(string code, int sortOrder) 18 | { 19 | Code = code; 20 | SortOrder = sortOrder; 21 | } 22 | 23 | public string Code { get; private set; } 24 | 25 | public int SortOrder { get; private set; } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /NLayer.Application/UserSystemModule/Services/IUserService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using NLayer.Application.CommonModule.DTOs; 4 | using NLayer.Application.UserSystemModule.DTOs; 5 | using PagedList; 6 | 7 | namespace NLayer.Application.UserSystemModule.Services 8 | { 9 | public interface IUserService 10 | { 11 | UserDTO Add(UserDTO userDTO); 12 | 13 | void Update(UserDTO userDTO); 14 | 15 | void Remove(Guid id); 16 | 17 | UserDTO FindBy(Guid id); 18 | 19 | IPagedList FindBy(string name, int pageNumber, int pageSize); 20 | 21 | void UpdateUserPermission(Guid id, List permissions); 22 | 23 | List GetUserPermission(Guid id); 24 | 25 | List GetAllUsersIdName(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /NLayer.Infrastructure/Repository/IRepository.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using NLayer.Infrastructure.Entity; 7 | using NLayer.Infrastructure.UnitOfWork; 8 | 9 | namespace NLayer.Infrastructure.Repository 10 | { 11 | public interface IRepository where TEntity : class 12 | { 13 | IUnitOfWork UnitOfWork { get; } 14 | TEntity Get(object key); 15 | void Merge(TEntity persisted, TEntity current); 16 | IEnumerable FindAll(); 17 | void Add(TEntity item); 18 | void Remove(TEntity item); 19 | bool Exists(TEntity item); 20 | TEntity Find(Func acquire); 21 | IQueryable Collection { get; } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /NLayer.IocModules/CommonIocModule.cs: -------------------------------------------------------------------------------- 1 | using Autofac; 2 | using NLayer.Application.Managers; 3 | using NLayer.Infrastructure.Authorize; 4 | using NLayer.Infrastructure.Utility.Caching; 5 | using NLayer.Repository.UnitOfWork; 6 | 7 | namespace NLayer.IocModules 8 | { 9 | public class CommonIocModule : Module 10 | { 11 | protected override void Load(ContainerBuilder builder) 12 | { 13 | builder.RegisterType().As().InstancePerRequest(); 14 | 15 | builder.RegisterType().As().InstancePerRequest(); 16 | 17 | builder.RegisterType().As().InstancePerRequest(); 18 | 19 | builder.RegisterType().PropertiesAutowired(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /NLayer.IocModules/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /NLayer.Repository/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /NLayer.Application/UserSystemModule/Services/IRoleGroupService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using NLayer.Application.CommonModule.DTOs; 4 | using NLayer.Application.UserSystemModule.DTOs; 5 | using PagedList; 6 | 7 | namespace NLayer.Application.UserSystemModule.Services 8 | { 9 | public interface IRoleGroupService 10 | { 11 | RoleGroupDTO Add(RoleGroupDTO roleGroupDTO); 12 | 13 | void Update(RoleGroupDTO roleGroupDTO); 14 | 15 | void Remove(Guid id); 16 | 17 | List FindAll(); 18 | 19 | RoleGroupDTO FindBy(Guid id); 20 | 21 | IPagedList FindBy(string name, int pageNumber, int pageSize); 22 | 23 | List GetUsersIdName(Guid groupId); 24 | 25 | void UpdateGroupUsers(Guid id, List users); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /NLayer.Infrastructure.Authorize/IAuthorizeManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using NLayer.Infrastructure.Authorize.AuthObject; 7 | 8 | namespace NLayer.Infrastructure.Authorize 9 | { 10 | public interface IAuthorizeManager 11 | { 12 | string GetCurrentTokenFromCookies(); 13 | 14 | UserForAuthorize GetCurrentUserInfo(); 15 | 16 | void SignIn(string loginName, string password, bool rememberMe = false); 17 | 18 | void SignOut(); 19 | 20 | void RedirectToLoginPage(); 21 | 22 | bool ValidatePermission(string permissionCode, bool throwExceptionIfNotPass = true); 23 | 24 | UserForAuthorize GetAuthorizeUserInfo(UserToken user); 25 | 26 | void ClearCache(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Helper/NLayerServiceResolver.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | using Microsoft.Practices.ServiceLocation; 7 | 8 | namespace NLayer.Presentation.WebHost.Helper 9 | { 10 | public class NLayerServiceResolver : IServiceResolver 11 | { 12 | public T Resolve() 13 | { 14 | return (T)DependencyResolver.Current.GetService(typeof(T)); 15 | //return ServiceLocator.Current.GetInstance(); 16 | } 17 | 18 | public object Resolve(Type type) 19 | { 20 | var obj = DependencyResolver.Current.GetService(type); 21 | return obj; 22 | //var obj = ServiceLocator.Current.GetInstance(type); 23 | //return obj; 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /NLayer.Infrastructure.Utility/Helper/TextHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NLayer.Infrastructure.Utility.Helper 4 | { 5 | public static class TextHelper 6 | { 7 | /// 8 | /// 检查字符串是不是为空/Null/空白字符 9 | /// 10 | /// 要检查的字符串 11 | /// 12 | public static bool IsNullOrBlank(this string self) 13 | { 14 | return string.IsNullOrWhiteSpace(self); 15 | } 16 | 17 | public static bool NotNullOrBlank(this string self) 18 | { 19 | return !string.IsNullOrWhiteSpace(self); 20 | } 21 | 22 | public static bool EqualsIgnoreCase(this string self, string other) 23 | { 24 | return self.Equals(other, StringComparison.OrdinalIgnoreCase); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /NLayer.Domain/UserSystemModule/Aggregates/MenuAgg/Menu.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.ComponentModel.DataAnnotations.Schema; 5 | using NLayer.Infrastructure.Entity; 6 | 7 | namespace NLayer.Domain.UserSystemModule.Aggregates.MenuAgg 8 | { 9 | [Table("auth.Menu")] 10 | public class Menu : EntityBase 11 | { 12 | public override Guid Id { get; set; } 13 | 14 | public string Name { get; set; } 15 | 16 | public string Code { get; set; } 17 | 18 | public string Url { get; set; } 19 | 20 | public string Module { get; set; } 21 | 22 | public int SortOrder { get; set; } 23 | 24 | public DateTime Created { get; set; } 25 | 26 | public virtual ICollection Permissions { get; set; } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /NLayer.Application/UserSystemModule/Converters/RoleGroupConverters.cs: -------------------------------------------------------------------------------- 1 | using AutoMapper; 2 | using NLayer.Application.UserSystemModule.DTOs; 3 | using NLayer.Domain.UserSystemModule.Aggregates.RoleGroupAgg; 4 | 5 | namespace NLayer.Application.UserSystemModule.Converters 6 | { 7 | public static partial class UserSystemConverters 8 | { 9 | public static void InitRoleGroupMappers() 10 | { 11 | Mapper.CreateMap(); 12 | Mapper.CreateMap(); 13 | } 14 | 15 | public static RoleGroup ToModel(this RoleGroupDTO dto) 16 | { 17 | return Mapper.Map(dto); 18 | } 19 | 20 | public static RoleGroupDTO ToDto(this RoleGroup model) 21 | { 22 | return Mapper.Map(model); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /NLayer.Infrastructure.Utility/Caching/CacheExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace NLayer.Infrastructure.Utility.Caching 8 | { 9 | public static class CacheExtensions 10 | { 11 | public static T Get(this ICacheManager cacheManager, string key, Func acquire) 12 | { 13 | return Get(cacheManager, key, 60, acquire); 14 | } 15 | 16 | public static T Get(this ICacheManager cacheManager, string key, int cacheTimeInMinute, Func acquire) 17 | { 18 | if (cacheManager.IsSet(key)) 19 | return cacheManager.Get(key); 20 | 21 | var result = acquire(); 22 | cacheManager.Set(key, result, cacheTimeInMinute); 23 | return result; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Scripts/samples/sample.gritter.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Unicorn Admin Template 3 | * Diablo9983 -> diablo9983@gmail.com 4 | **/ 5 | $(document).ready(function(){ 6 | // === jQeury Gritter, a growl-like notifications === // 7 | $('#gritter-notify .normal').click(function(){ 8 | $.gritter.add({ 9 | title: 'Normal notification', 10 | text: 'This is a normal notification', 11 | sticky: false 12 | }); 13 | }); 14 | 15 | $('#gritter-notify .sticky').click(function(){ 16 | $.gritter.add({ 17 | title: 'Sticky notification', 18 | text: 'This is a sticky notification', 19 | sticky: true 20 | }); 21 | }); 22 | 23 | $('#gritter-notify .image').click(function(){ 24 | var imgsrc = $(this).attr('data-image'); 25 | $.gritter.add({ 26 | title: 'Unread messages', 27 | text: 'You have 9 unread messages.', 28 | image: imgsrc, 29 | sticky: false 30 | }); 31 | }); 32 | }); 33 | -------------------------------------------------------------------------------- /NLayer.Domain/UserSystemModule/Aggregates/RoleGroupAgg/RoleGroup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.ComponentModel.DataAnnotations.Schema; 5 | using NLayer.Domain.UserSystemModule.Aggregates.RoleAgg; 6 | using NLayer.Domain.UserSystemModule.Aggregates.UserAgg; 7 | using NLayer.Infrastructure.Entity; 8 | 9 | namespace NLayer.Domain.UserSystemModule.Aggregates.RoleGroupAgg 10 | { 11 | [Table("auth.RoleGroup")] 12 | public class RoleGroup : EntityBase 13 | { 14 | public override Guid Id { get; set; } 15 | 16 | public string Name { get; set; } 17 | 18 | public string Description { get; set; } 19 | 20 | public int SortOrder { get; set; } 21 | 22 | public DateTime Created { get; set; } 23 | 24 | public virtual ICollection Roles { get; set; } 25 | 26 | public virtual ICollection Users { get; set; } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Scripts/samples/sample.tables.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Unicorn Admin Template 3 | * Diablo9983 -> diablo9983@gmail.com 4 | **/ 5 | $(document).ready(function(){ 6 | 7 | $('.data-table').dataTable({ 8 | "bJQueryUI": true, 9 | "sPaginationType": "full_numbers", 10 | "sDom": '<""l>t<"F"fp>' 11 | }); 12 | 13 | $('input[type=checkbox],input[type=radio],input[type=file]').uniform(); 14 | 15 | $('select').select2(); 16 | 17 | $("span.icon input:checkbox, th input:checkbox").click(function() { 18 | var checkedStatus = this.checked; 19 | var checkbox = $(this).parents('.widget-box').find('tr td:first-child input:checkbox'); 20 | checkbox.each(function() { 21 | this.checked = checkedStatus; 22 | if (checkedStatus == this.checked) { 23 | $(this).closest('.checker > span').removeClass('checked'); 24 | } 25 | if (this.checked) { 26 | $(this).closest('.checker > span').addClass('checked'); 27 | } 28 | }); 29 | }); 30 | }); 31 | -------------------------------------------------------------------------------- /NLayer.Application/UserSystemModule/DTOs/PermissionForAuthDTO.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NLayer.Application.Modules; 3 | 4 | namespace NLayer.Application.UserSystemModule.DTOs 5 | { 6 | public class PermissionForAuthDTO 7 | { 8 | public Guid PermissionId { get; set; } 9 | 10 | public string PermissionCode { get; set; } 11 | 12 | public Guid MenuId { get; set; } 13 | 14 | public Guid RoleId { get; set; } 15 | 16 | public bool FromUser { get; set; } 17 | 18 | public string PermissionName { get; set; } 19 | 20 | public string MenuName { get; set; } 21 | 22 | public string MenuUrl { get; set; } 23 | 24 | public string RoleName { get; set; } 25 | 26 | public int PermissionSortOrder { get; set; } 27 | 28 | public int MenuSortOrder { get; set; } 29 | 30 | public NLayerModulesType Module { get; set; } 31 | 32 | public string ModuleName { get; set; } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /NLayer.Repository/Migrations/201505030357506_AddLoginInfo.Designer.cs: -------------------------------------------------------------------------------- 1 | // 2 | namespace NLayer.Repository.Migrations 3 | { 4 | using System.CodeDom.Compiler; 5 | using System.Data.Entity.Migrations; 6 | using System.Data.Entity.Migrations.Infrastructure; 7 | using System.Resources; 8 | 9 | [GeneratedCode("EntityFramework.Migrations", "6.1.3-40302")] 10 | public sealed partial class AddLoginInfo : IMigrationMetadata 11 | { 12 | private readonly ResourceManager Resources = new ResourceManager(typeof(AddLoginInfo)); 13 | 14 | string IMigrationMetadata.Id 15 | { 16 | get { return "201505030357506_AddLoginInfo"; } 17 | } 18 | 19 | string IMigrationMetadata.Source 20 | { 21 | get { return null; } 22 | } 23 | 24 | string IMigrationMetadata.Target 25 | { 26 | get { return Resources.GetString("Target"); } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /NLayer.Repository/Migrations/201504210841169_InitialCreate.Designer.cs: -------------------------------------------------------------------------------- 1 | // 2 | namespace NLayer.Repository.Migrations 3 | { 4 | using System.CodeDom.Compiler; 5 | using System.Data.Entity.Migrations; 6 | using System.Data.Entity.Migrations.Infrastructure; 7 | using System.Resources; 8 | 9 | [GeneratedCode("EntityFramework.Migrations", "6.1.3-40302")] 10 | public sealed partial class InitialCreate : IMigrationMetadata 11 | { 12 | private readonly ResourceManager Resources = new ResourceManager(typeof(InitialCreate)); 13 | 14 | string IMigrationMetadata.Id 15 | { 16 | get { return "201504210841169_InitialCreate"; } 17 | } 18 | 19 | string IMigrationMetadata.Source 20 | { 21 | get { return null; } 22 | } 23 | 24 | string IMigrationMetadata.Target 25 | { 26 | get { return Resources.GetString("Target"); } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /NLayer.Repository/Migrations/201506161423201_ModifyRoleUser.Designer.cs: -------------------------------------------------------------------------------- 1 | // 2 | namespace NLayer.Repository.Migrations 3 | { 4 | using System.CodeDom.Compiler; 5 | using System.Data.Entity.Migrations; 6 | using System.Data.Entity.Migrations.Infrastructure; 7 | using System.Resources; 8 | 9 | [GeneratedCode("EntityFramework.Migrations", "6.1.3-40302")] 10 | public sealed partial class ModifyRoleUser : IMigrationMetadata 11 | { 12 | private readonly ResourceManager Resources = new ResourceManager(typeof(ModifyRoleUser)); 13 | 14 | string IMigrationMetadata.Id 15 | { 16 | get { return "201506161423201_ModifyRoleUser"; } 17 | } 18 | 19 | string IMigrationMetadata.Source 20 | { 21 | get { return null; } 22 | } 23 | 24 | string IMigrationMetadata.Target 25 | { 26 | get { return Resources.GetString("Target"); } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /NLayer.Infrastructure.Authorize/AuthObject/PermissionForAuthorize.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace NLayer.Infrastructure.Authorize.AuthObject 8 | { 9 | public class PermissionForAuthorize 10 | { 11 | public Guid PermissionId { get; set; } 12 | 13 | public string PermissionCode { get; set; } 14 | 15 | public Guid MenuId { get; set; } 16 | 17 | public Guid RoleId { get; set; } 18 | 19 | public bool FromUser { get; set; } 20 | 21 | public string PermissionName { get; set; } 22 | 23 | public string MenuName { get; set; } 24 | 25 | public string MenuUrl { get; set; } 26 | 27 | public string RoleName { get; set; } 28 | 29 | public int PermissionSortOrder { get; set; } 30 | 31 | public int MenuSortOrder { get; set; } 32 | 33 | public int Module { get; set; } 34 | 35 | public string ModuleName { get; set; } 36 | 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /NLayer.Domain/UserSystemModule/Aggregates/MenuAgg/Permission.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.ComponentModel.DataAnnotations.Schema; 5 | using NLayer.Domain.UserSystemModule.Aggregates.RoleAgg; 6 | using NLayer.Domain.UserSystemModule.Aggregates.UserAgg; 7 | using NLayer.Infrastructure.Entity; 8 | 9 | namespace NLayer.Domain.UserSystemModule.Aggregates.MenuAgg 10 | { 11 | [Table("auth.Permission")] 12 | public class Permission : EntityBase 13 | { 14 | public override Guid Id { get; set; } 15 | 16 | public string Name { get; set; } 17 | 18 | public string Code { get; set; } 19 | 20 | public string ActionUrl { get; set; } 21 | 22 | public int SortOrder { get; set; } 23 | 24 | public DateTime Created { get; set; } 25 | 26 | public virtual Menu Menu { get; set; } 27 | 28 | public virtual ICollection Users { get; set; } 29 | 30 | public virtual ICollection Roles { get; set; } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /NLayer.Domain/UserSystemModule/Aggregates/RoleAgg/Role.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.ComponentModel.DataAnnotations.Schema; 5 | using NLayer.Domain.UserSystemModule.Aggregates.MenuAgg; 6 | using NLayer.Domain.UserSystemModule.Aggregates.RoleGroupAgg; 7 | using NLayer.Domain.UserSystemModule.Aggregates.UserAgg; 8 | using NLayer.Infrastructure.Entity; 9 | 10 | namespace NLayer.Domain.UserSystemModule.Aggregates.RoleAgg 11 | { 12 | [Table("auth.Role")] 13 | public class Role : EntityBase 14 | { 15 | public override Guid Id { get; set; } 16 | 17 | public string Name { get; set; } 18 | 19 | public string Description { get; set; } 20 | 21 | public int SortOrder { get; set; } 22 | 23 | public DateTime Created { get; set; } 24 | 25 | public virtual RoleGroup RoleGroup { get; set; } 26 | 27 | public virtual ICollection Users { get; set; } 28 | 29 | public virtual ICollection Permissions { get; set; } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Helper/NLayerHtmlHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | using System.Web.UI.WebControls; 7 | using NLayer.Application.Modules; 8 | using NLayer.Infrastructure.Utility.Helper; 9 | 10 | namespace NLayer.Presentation.WebHost 11 | { 12 | public static class NLayerHtmlHelper 13 | { 14 | public static List GetItemList(this List list, 15 | string includeOption, 16 | string defValue = "") 17 | { 18 | var result = list.Select(x => new SelectListItem() 19 | { 20 | Text = x.Name, 21 | Value = x.Type.ToString(), 22 | Selected = x.Type.ToString().EqualsIgnoreCase(defValue) 23 | }).ToList(); 24 | 25 | if (includeOption.NotNullOrBlank()) 26 | { 27 | result.Insert(0, new SelectListItem() { Text = includeOption, Value = "" }); 28 | } 29 | 30 | return result; 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /NLayer.Domain/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的常规信息通过以下 6 | // 特性集控制。更改这些特性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("NLayer.Domain")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("NLayer.Domain")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 将 ComVisible 设置为 false 使此程序集中的类型 18 | // 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, 19 | // 则将该类型上的 ComVisible 特性设置为 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 23 | [assembly: Guid("034a4b65-0f5b-42de-ac42-483b94be49ab")] 24 | 25 | // 程序集的版本信息由下面四个值组成: 26 | // 27 | // 主版本 28 | // 次版本 29 | // 生成号 30 | // 修订号 31 | // 32 | // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, 33 | // 方法是按如下所示使用“*”: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的常规信息是通过以下项进行控制的 6 | // 控制。更改这些特性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("NLayer.Presentation.WebHost")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("NLayer.Presentation.WebHost")] 13 | [assembly: AssemblyCopyright("版权所有(C) 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 将 ComVisible 设置为 false 将使此程序集中的类型 18 | // 对 COM 组件不可见。如果需要 19 | // 从 COM 访问此程序集中的某个类型,请针对该类型将 ComVisible 特性设置为 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 如果此项目向 COM 公开,则下列 GUID 用于 typelib 的 ID 23 | [assembly: Guid("df09f00c-03e3-4d1f-b648-89df4ca0d7f5")] 24 | 25 | // 程序集的版本信息由下列四个值组成: 26 | // 27 | // 主版本 28 | // 次版本 29 | // 内部版本号 30 | // 修订版本 31 | // 32 | // 你可以指定所有值,也可以让修订版本和内部版本号采用默认值, 33 | // 方法是按如下所示使用 "*": 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /NLayer.Repository/UserSystemModule/Repositories/PermissionRepository.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Data.Entity; 3 | using System.Linq; 4 | using EntityFramework.Extensions; 5 | using NLayer.Domain.UserSystemModule.Aggregates.MenuAgg; 6 | using NLayer.Infrastructure.Utility.Helper; 7 | using NLayer.Infrastructure.UnitOfWork; 8 | using NLayer.Repository.UnitOfWork; 9 | using PagedList; 10 | 11 | namespace NLayer.Repository.UserSystemModule.Repositories 12 | { 13 | public class PermissionRepository : SpecificRepositoryBase, IPermissionRepository 14 | { 15 | public PermissionRepository(INLayerUnitOfWork unitOfWork) 16 | : base(unitOfWork) 17 | { 18 | } 19 | 20 | public new bool Exists(Permission item) 21 | { 22 | IQueryable entities = Table; 23 | entities = entities.Where(x => x.Menu == item.Menu && x.Name == item.Name); 24 | if(item.Id != Guid.Empty) 25 | { 26 | entities = entities.Where(x => x.Id != item.Id); 27 | } 28 | return entities.Any(); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /NLayer.IocModules/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的常规信息通过以下 6 | // 特性集控制。更改这些特性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("NLayer.IocModules")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("NLayer.IocModules")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 将 ComVisible 设置为 false 使此程序集中的类型 18 | // 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, 19 | // 则将该类型上的 ComVisible 特性设置为 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 23 | [assembly: Guid("d2b26fb4-89bc-4c36-bfe0-9bd61149cbe3")] 24 | 25 | // 程序集的版本信息由下面四个值组成: 26 | // 27 | // 主版本 28 | // 次版本 29 | // 生成号 30 | // 修订号 31 | // 32 | // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, 33 | // 方法是按如下所示使用“*”: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Web.Debug.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /NLayer.Repository/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的常规信息通过以下 6 | // 特性集控制。更改这些特性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("NLayer.Repository")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("NLayer.Repository")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 将 ComVisible 设置为 false 使此程序集中的类型 18 | // 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, 19 | // 则将该类型上的 ComVisible 特性设置为 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 23 | [assembly: Guid("062d7b68-c9c0-4732-b230-5d5c2c5ff280")] 24 | 25 | // 程序集的版本信息由下面四个值组成: 26 | // 27 | // 主版本 28 | // 次版本 29 | // 生成号 30 | // 修订号 31 | // 32 | // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, 33 | // 方法是按如下所示使用“*”: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /NLayer.Application/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的常规信息通过以下 6 | // 特性集控制。更改这些特性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("NLayer.Application")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("NLayer.Application")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 将 ComVisible 设置为 false 使此程序集中的类型 18 | // 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, 19 | // 则将该类型上的 ComVisible 特性设置为 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 23 | [assembly: Guid("e1b108fe-33f0-4cc1-afea-c1f8abd92e64")] 24 | 25 | // 程序集的版本信息由下面四个值组成: 26 | // 27 | // 主版本 28 | // 次版本 29 | // 生成号 30 | // 修订号 31 | // 32 | // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, 33 | // 方法是按如下所示使用“*”: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /NLayer.Repository.Test/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /NLayer.Infrastructure/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的常规信息通过以下 6 | // 特性集控制。更改这些特性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("NLayer.Infrastructure")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("NLayer.Infrastructure")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 将 ComVisible 设置为 false 使此程序集中的类型 18 | // 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, 19 | // 则将该类型上的 ComVisible 特性设置为 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 23 | [assembly: Guid("c7e23c6c-fdaf-42ee-b07c-9bdbf90af615")] 24 | 25 | // 程序集的版本信息由下面四个值组成: 26 | // 27 | // 主版本 28 | // 次版本 29 | // 生成号 30 | // 修订号 31 | // 32 | // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, 33 | // 方法是按如下所示使用“*”: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /NLayer.Repository.Test/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的常规信息通过以下 6 | // 特性集控制。更改这些特性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("NLayer.Repository.Test")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("NLayer.Repository.Test")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 将 ComVisible 设置为 false 使此程序集中的类型 18 | // 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, 19 | // 则将该类型上的 ComVisible 特性设置为 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 23 | [assembly: Guid("fcb5c7e4-4c9d-4c6f-8bb6-224afb86b303")] 24 | 25 | // 程序集的版本信息由下面四个值组成: 26 | // 27 | // 主版本 28 | // 次版本 29 | // 生成号 30 | // 修订号 31 | // 32 | // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, 33 | // 方法是按如下所示使用“*”: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /NLayer.Infrastructure.Authorize/MenuAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Web.UI.WebControls; 7 | 8 | namespace NLayer.Infrastructure.Authorize 9 | { 10 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)] 11 | public class MenuAttribute : Attribute 12 | { 13 | public MenuAttribute(string code) 14 | { 15 | Code = code; 16 | SortOrder = 99; 17 | Depth = -1; 18 | } 19 | 20 | public MenuAttribute(string code, int sortOrder) 21 | { 22 | Code = code; 23 | SortOrder = sortOrder; 24 | Depth = -1; 25 | } 26 | 27 | public MenuAttribute(string code, int sortOrder, int depth) 28 | { 29 | Code = code; 30 | SortOrder = sortOrder; 31 | Depth = depth; 32 | } 33 | 34 | public string Code { get; private set; } 35 | 36 | public int SortOrder { get; private set; } 37 | 38 | public int Depth { get; private set; } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /NLayer.Infrastructure.Utility/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的常规信息通过以下 6 | // 特性集控制。更改这些特性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("NLayer.Infrastructure.Utility")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("NLayer.Infrastructure.Utility")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 将 ComVisible 设置为 false 使此程序集中的类型 18 | // 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, 19 | // 则将该类型上的 ComVisible 特性设置为 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 23 | [assembly: Guid("24b221b0-77b5-424d-a8f6-d0fecb330d92")] 24 | 25 | // 程序集的版本信息由下面四个值组成: 26 | // 27 | // 主版本 28 | // 次版本 29 | // 生成号 30 | // 修订号 31 | // 32 | // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, 33 | // 方法是按如下所示使用“*”: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /NLayer.Infrastructure.Authorize/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的常规信息通过以下 6 | // 特性集控制。更改这些特性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("NLayer.Infrastructure.Authorize")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("NLayer.Infrastructure.Authorize")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 将 ComVisible 设置为 false 使此程序集中的类型 18 | // 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, 19 | // 则将该类型上的 ComVisible 特性设置为 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 23 | [assembly: Guid("a25f4d35-8111-45f4-8d03-79551ab44dad")] 24 | 25 | // 程序集的版本信息由下面四个值组成: 26 | // 27 | // 主版本 28 | // 次版本 29 | // 生成号 30 | // 修订号 31 | // 32 | // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, 33 | // 方法是按如下所示使用“*”: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/error.css: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------ 2 | 3 | Layout: Content 4 | 5 | ------------------------------------------------------------------- */ 6 | #content { 7 | margin-top: 3em; 8 | margin-bottom: 8em; 9 | } 10 | #content .row { 11 | margin-top: 5em; 12 | } 13 | #content .row:first-child { 14 | margin-top: 0; 15 | } 16 | 17 | /*------------------------------------------------------------------ 18 | 19 | Error 20 | 21 | ------------------------------------------------------------------- */ 22 | .error-container { 23 | margin-top: 1em; 24 | margin-bottom: 6em; 25 | text-align: center; 26 | } 27 | .error-container h1 { 28 | margin-bottom: .5em; 29 | font-size: 120px; 30 | line-height: 1em; 31 | } 32 | .error-container h2 { 33 | margin-bottom: .75em; 34 | font-size: 28px; 35 | } 36 | .error-container .error-details { 37 | margin-bottom: 1.5em; 38 | font-size: 16px; 39 | } 40 | .error-container .error-actions a { 41 | margin: 0 .5em; 42 | } 43 | @media (max-width: 480px) { 44 | .error-container h1 { 45 | font-size: 72px; 46 | } 47 | } 48 | .error-container .alert { 49 | text-align: left; 50 | } -------------------------------------------------------------------------------- /NLayer.Domain/UserSystemModule/Aggregates/UserAgg/User.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.ComponentModel.DataAnnotations.Schema; 5 | using NLayer.Domain.UserSystemModule.Aggregates.MenuAgg; 6 | using NLayer.Domain.UserSystemModule.Aggregates.RoleAgg; 7 | using NLayer.Domain.UserSystemModule.Aggregates.RoleGroupAgg; 8 | using NLayer.Infrastructure.Entity; 9 | 10 | namespace NLayer.Domain.UserSystemModule.Aggregates.UserAgg 11 | { 12 | [Table("auth.User")] 13 | public class User : EntityBase 14 | { 15 | public override Guid Id { get; set; } 16 | 17 | public string Name { get; set; } 18 | 19 | public string LoginName { get; set; } 20 | 21 | public string LoginPwd { get; set; } 22 | 23 | public string Email { get; set; } 24 | 25 | public DateTime Created { get; set; } 26 | 27 | public string LastLoginToken { get; set; } 28 | 29 | public DateTime LastLogin { get; set; } 30 | 31 | public virtual ICollection Permissions { get; set; } 32 | 33 | public virtual ICollection Groups { get; set; } 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Web.Release.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Areas/Samples/Controllers/BootstrapController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | using NLayer.Infrastructure.Authorize; 7 | using NLayer.Presentation.WebHost.Controllers; 8 | 9 | namespace NLayer.Presentation.WebHost.Areas.Samples.Controllers 10 | { 11 | public class BootstrapController : BaseAuthorizeController 12 | { 13 | protected override void CheckLogin() 14 | { 15 | //base.CheckoutLogin(); 16 | } 17 | 18 | public ActionResult Index() 19 | { 20 | return View(); 21 | } 22 | 23 | public ActionResult Buttons() 24 | { 25 | return View(); 26 | } 27 | 28 | public ActionResult Elements() 29 | { 30 | return View(); 31 | } 32 | 33 | public ActionResult Tables() 34 | { 35 | return View(); 36 | } 37 | 38 | public ActionResult Forms() 39 | { 40 | return View(); 41 | } 42 | 43 | public ActionResult Layouts() 44 | { 45 | return View(); 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /NLayer.Infrastructure/UnitOfWork/IUnitOfWork.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace NLayer.Infrastructure.UnitOfWork 8 | { 9 | public interface IUnitOfWork : IDisposable 10 | { 11 | /// 12 | /// Commit all changes made in a container. 13 | /// 14 | /// 15 | /// If the entity have fixed properties and any optimistic concurrency problem exists, 16 | /// then an exception is thrown 17 | /// 18 | void Commit(); 19 | 20 | /// 21 | /// Commit all changes made in a container. 22 | /// 23 | /// 24 | /// If the entity have fixed properties and any optimistic concurrency problem exists, 25 | /// then 'client changes' are refreshed - Client wins 26 | /// 27 | void CommitAndRefreshChanges(); 28 | 29 | 30 | /// 31 | /// Rollback changes are not stored in the database at 32 | /// this moment. See references of UnitOfWork pattern 33 | /// 34 | void RollbackChanges(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /NLayer.Infrastructure.Authorize/AuthorizeException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace NLayer.Infrastructure.Authorize 8 | { 9 | public class AuthorizeException : Exception 10 | { 11 | public AuthorizeException(string message) : base(message) 12 | { 13 | } 14 | } 15 | 16 | public class AuthorizeTokenNotFoundException : Exception 17 | { 18 | private const String DefaultMessage = "Authorize Token Not Found"; 19 | 20 | public AuthorizeTokenNotFoundException() 21 | : base(DefaultMessage) 22 | { 23 | } 24 | } 25 | 26 | public class AuthorizeTokenInvalidException : Exception 27 | { 28 | private const String DefaultMessage = "Authorize Token Invalid"; 29 | 30 | public AuthorizeTokenInvalidException() 31 | : base(DefaultMessage) 32 | { 33 | } 34 | } 35 | 36 | public class AuthorizeNoPermissionException : Exception 37 | { 38 | private const String DefaultMessage = "Authorize No Permission"; 39 | 40 | public AuthorizeNoPermissionException() 41 | : base(DefaultMessage) 42 | { 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /NLayer.Repository/Migrations/Configuration.cs: -------------------------------------------------------------------------------- 1 | namespace NLayer.Repository.Migrations 2 | { 3 | using System; 4 | using System.Data.Entity; 5 | using System.Data.Entity.Migrations; 6 | using System.Linq; 7 | 8 | internal sealed class Configuration : DbMigrationsConfiguration 9 | { 10 | public Configuration() 11 | { 12 | AutomaticMigrationsEnabled = true; 13 | AutomaticMigrationDataLossAllowed = false; 14 | //AutomaticMigrationsEnabled = false; 15 | //ContextKey = "NLayer.Repository.UnitOfWork.NLayerUnitOfWork"; 16 | } 17 | 18 | protected override void Seed(NLayer.Repository.UnitOfWork.NLayerUnitOfWork context) 19 | { 20 | // This method will be called after migrating to the latest version. 21 | 22 | // You can use the DbSet.AddOrUpdate() helper extension method 23 | // to avoid creating duplicate seed data. E.g. 24 | // 25 | // context.People.AddOrUpdate( 26 | // p => p.FullName, 27 | // new Person { FullName = "Andrew Peters" }, 28 | // new Person { FullName = "Brice Lambson" }, 29 | // new Person { FullName = "Rowan Miller" } 30 | // ); 31 | // 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/App_Start/CustomAjaxExceptionAttribute.cs: -------------------------------------------------------------------------------- 1 | using System.Net; 2 | using System.Web; 3 | using System.Web.Mvc; 4 | using System.Web.Routing; 5 | using log4net; 6 | using NLayer.Presentation.WebHost.Models; 7 | 8 | namespace NLayer.Presentation.WebHost 9 | { 10 | public class CustomAjaxExceptionAttribute : FilterAttribute, IExceptionFilter //HandleErrorAttribute 11 | { 12 | private static readonly ILog Log = LogManager.GetLogger(typeof(CustomAjaxExceptionAttribute)); 13 | 14 | public void OnException(ExceptionContext filterContext) 15 | { 16 | if (filterContext.ExceptionHandled 17 | || !filterContext.RequestContext.HttpContext.Request.IsAjaxRequest()) 18 | { 19 | return; 20 | } 21 | 22 | var ex = filterContext.Exception; 23 | 24 | filterContext.Result = new JsonResult 25 | { 26 | Data = new AjaxResponse 27 | { 28 | Succeeded = false, 29 | ErrorMessage = ex.Message 30 | }, 31 | JsonRequestBehavior = JsonRequestBehavior.AllowGet 32 | }; 33 | 34 | Log.Error(ex.GetIndentedExceptionLog()); 35 | 36 | //写入日志 记录 37 | filterContext.ExceptionHandled = true; //设置异常已经处理 38 | filterContext.HttpContext.Response.TrySkipIisCustomErrors = true; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /NLayer.Application/UserSystemModule/Converters/MenuConverters.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using AutoMapper; 3 | using NLayer.Application.UserSystemModule.DTOs; 4 | using NLayer.Domain.UserSystemModule.Aggregates.MenuAgg; 5 | 6 | namespace NLayer.Application.UserSystemModule.Converters 7 | { 8 | public static partial class UserSystemConverters 9 | { 10 | public static void InitMenuMappers() 11 | { 12 | Mapper.CreateMap() 13 | .ForMember(x => x.Permissions, opt => opt.MapFrom(s => s.Permissions.Select(x=>x.ToDto()).ToList())); 14 | Mapper.CreateMap() 15 | .ForMember(x => x.Permissions, opt => opt.MapFrom(s => s.Permissions.Select(x => x.ToModel()).ToList())); 16 | 17 | Mapper.CreateMap(); 18 | Mapper.CreateMap(); 19 | } 20 | 21 | public static Menu ToModel(this MenuDTO dto) 22 | { 23 | return Mapper.Map(dto); 24 | } 25 | 26 | public static MenuDTO ToDto(this Menu model) 27 | { 28 | return Mapper.Map(model); 29 | } 30 | 31 | public static Permission ToModel(this PermissionDTO dto) 32 | { 33 | return Mapper.Map(dto); 34 | } 35 | 36 | public static PermissionDTO ToDto(this Permission model) 37 | { 38 | return Mapper.Map(model); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /NLayer.IocModules/UserSystemIocModule.cs: -------------------------------------------------------------------------------- 1 | using Autofac; 2 | using NLayer.Application.UserSystemModule.Services; 3 | using NLayer.Domain.UserSystemModule.Aggregates.MenuAgg; 4 | using NLayer.Domain.UserSystemModule.Aggregates.RoleAgg; 5 | using NLayer.Domain.UserSystemModule.Aggregates.RoleGroupAgg; 6 | using NLayer.Domain.UserSystemModule.Aggregates.UserAgg; 7 | using NLayer.Repository.UserSystemModule.Repositories; 8 | 9 | namespace NLayer.IocModules 10 | { 11 | public class UserSystemIocModule : Module 12 | { 13 | protected override void Load(ContainerBuilder builder) 14 | { 15 | builder.RegisterType().As().InstancePerRequest(); 16 | builder.RegisterType().As().InstancePerRequest(); 17 | builder.RegisterType().As(); 18 | 19 | builder.RegisterType().As().InstancePerRequest(); 20 | builder.RegisterType().As(); 21 | 22 | builder.RegisterType().As().InstancePerRequest(); 23 | builder.RegisterType().As(); 24 | 25 | builder.RegisterType().As().InstancePerRequest(); 26 | builder.RegisterType().As(); 27 | 28 | builder.RegisterType().As(); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/App_Start/ExceptionExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Web; 6 | 7 | namespace NLayer.Presentation.WebHost 8 | { 9 | public static class ExceptionExtensions 10 | { 11 | public static string GetIndentedExceptionLog(this Exception ex) 12 | { 13 | if (ex == null) 14 | { 15 | return string.Empty; 16 | } 17 | 18 | var sb = new StringBuilder(64); 19 | var innerExceptionLog = GetIndentedExceptionLog(ex.InnerException).Replace("\n", "\n\t"); 20 | sb.AppendFormat( 21 | "Message: {1}{0}Type: {2}{0}StackTrace: {3}{0}InnerException: {4}", 22 | Environment.NewLine, 23 | ex.Message, 24 | ex.GetType().FullName, 25 | ex.StackTrace, 26 | innerExceptionLog); 27 | 28 | return sb.ToString(); 29 | } 30 | 31 | public static string GetIndentedExceptionMessage(this Exception ex) 32 | { 33 | var sb = new StringBuilder(); 34 | var index = 1; 35 | sb.AppendLine(ex.Message); 36 | var e = ex; 37 | while (e.InnerException != null) 38 | { 39 | sb.AppendFormat("{0}{1}", Enumerable.Repeat("\t", index),e.InnerException.Message); 40 | sb.AppendLine(); 41 | e = e.InnerException; 42 | index++; 43 | } 44 | return sb.ToString(); 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/bootstrap-duallistbox.min.css: -------------------------------------------------------------------------------- 1 | /* 2 | * Bootstrap Duallistbox - v3.0.2 3 | * A responsive dual listbox widget optimized for Twitter Bootstrap. It works on all modern browsers and on touch devices. 4 | * http://www.virtuosoft.eu/code/bootstrap-duallistbox/ 5 | * 6 | * Made by István Ujj-Mészáros 7 | * Under Apache License v2.0 License 8 | */ 9 | 10 | .bootstrap-duallistbox-container .buttons{width:100%;margin-bottom:-1px}.bootstrap-duallistbox-container label{display:block}.bootstrap-duallistbox-container .info{display:inline-block;margin-bottom:5px;font-size:11px}.bootstrap-duallistbox-container .clear1,.bootstrap-duallistbox-container .clear2{display:none;font-size:10px}.bootstrap-duallistbox-container .box1.filtered .clear1,.bootstrap-duallistbox-container .box2.filtered .clear2{display:inline-block}.bootstrap-duallistbox-container .move,.bootstrap-duallistbox-container .remove{width:60%}.bootstrap-duallistbox-container .btn-group .btn{border-bottom-left-radius:0;border-bottom-right-radius:0}.bootstrap-duallistbox-container select{border-top-left-radius:0;border-top-right-radius:0}.bootstrap-duallistbox-container .moveall,.bootstrap-duallistbox-container .removeall{width:40%}.bootstrap-duallistbox-container.bs2compatible .btn-group>.btn+.btn{margin-left:0}.bootstrap-duallistbox-container select{width:100%;height:300px;padding:0}.bootstrap-duallistbox-container .filter{display:inline-block;width:100%;height:31px;margin:0 0 5px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.bootstrap-duallistbox-container .filter.placeholder{color:#aaa}.bootstrap-duallistbox-container.moveonselect .move,.bootstrap-duallistbox-container.moveonselect .remove{display:none}.bootstrap-duallistbox-container.moveonselect .moveall,.bootstrap-duallistbox-container.moveonselect .removeall{width:100%} -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Areas/Samples/Views/Bootstrap/Index.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewBag.Title = "Bootstrap示例 - 首页"; 3 | } 4 | 5 |
6 |

Bootstrap示例 - 首页

7 |
8 | 11 |
12 |
13 | 14 |
15 |
16 |
17 | 18 | 19 | 20 |
Bootstrap示例
21 |
22 |
23 |

24 | @Html.ActionLink("按钮&图标", "Buttons", "Bootstrap", new { area = "Samples" }, new { @class = "btn" }) 25 |

26 |

27 | @Html.ActionLink("UI元素", "Elements", "Bootstrap", new { area = "Samples" }, new { @class = "btn" }) 28 |

29 |

30 | @Html.ActionLink("表格", "Tables", "Bootstrap", new { area = "Samples" }, new { @class = "btn" }) 31 |

32 |

33 | @Html.ActionLink("表单", "Forms", "Bootstrap", new { area = "Samples" }, new { @class = "btn" }) 34 |

35 |

36 | @Html.ActionLink("布局", "Layouts", "Bootstrap", new { area = "Samples" }, new { @class = "btn" }) 37 |

38 |
39 |
40 |
41 | 42 |
43 |
44 | -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Views/Web.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |
7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Areas/Samples/Views/web.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |
7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Areas/UserSystem/Views/web.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |
7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /NLayer.Infrastructure/Entity/IdentityGenerator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NLayer.Infrastructure.Entity 4 | { 5 | public static class IdentityGenerator 6 | { 7 | /// 8 | /// This algorithm generates secuential GUIDs across system boundaries, ideal for databases 9 | /// 10 | /// 11 | public static Guid NewSequentialGuid() 12 | { 13 | byte[] uid = Guid.NewGuid().ToByteArray(); 14 | byte[] binDate = BitConverter.GetBytes(DateTime.UtcNow.Ticks); 15 | 16 | byte[] secuentialGuid = new byte[uid.Length]; 17 | 18 | secuentialGuid[0] = uid[0]; 19 | secuentialGuid[1] = uid[1]; 20 | secuentialGuid[2] = uid[2]; 21 | secuentialGuid[3] = uid[3]; 22 | secuentialGuid[4] = uid[4]; 23 | secuentialGuid[5] = uid[5]; 24 | secuentialGuid[6] = uid[6]; 25 | // set the first part of the 8th byte to '1100' so 26 | // later we'll be able to validate it was generated by us 27 | secuentialGuid[7] = (byte)(0xc0 | (0xf & uid[7])); 28 | // the last 8 bytes are sequential, 29 | // it minimizes index fragmentation 30 | // to a degree as long as there are not a large 31 | // number of Secuential-Guids generated per millisecond 32 | secuentialGuid[9] = binDate[0]; 33 | secuentialGuid[8] = binDate[1]; 34 | secuentialGuid[15] = binDate[2]; 35 | secuentialGuid[14] = binDate[3]; 36 | secuentialGuid[13] = binDate[4]; 37 | secuentialGuid[12] = binDate[5]; 38 | secuentialGuid[11] = binDate[6]; 39 | secuentialGuid[10] = binDate[7]; 40 | 41 | return new Guid(secuentialGuid); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/App_Start/BundleConfig.cs: -------------------------------------------------------------------------------- 1 | using System.Web; 2 | using System.Web.Optimization; 3 | 4 | namespace NLayer.Presentation.WebHost 5 | { 6 | public class BundleConfig 7 | { 8 | // 有关绑定的详细信息,请访问 http://go.microsoft.com/fwlink/?LinkId=301862 9 | public static void RegisterBundles(BundleCollection bundles) 10 | { 11 | bundles.Add(new ScriptBundle("~/bundles/jquery").Include( 12 | "~/Scripts/jquery-1.7.2.min.js", 13 | "~/Scripts/jquery.ui.custom.js", 14 | "~/Scripts/jquery.gritter.min.js", 15 | "~/Scripts/plugins/jquery.unobtrusive/jquery.unobtrusive-ajax.min.js")); 16 | 17 | bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include( 18 | "~/Scripts/bootstrap.min.js", 19 | "~/Scripts/bootstrap-datepicker.js", 20 | "~/Scripts/bootstrap-colorpicker.js", 21 | "~/Scripts/jquery.bootstrap-duallistbox.min.js")); 22 | 23 | bundles.Add(new ScriptBundle("~/bundles/unicorn").Include( 24 | "~/Scripts/unicorn.js")); 25 | 26 | bundles.Add(new ScriptBundle("~/bundles/common").Include( 27 | "~/Scripts/common.js")); 28 | 29 | bundles.Add(new StyleBundle("~/Content/css").Include( 30 | "~/Content/bootstrap.min.css", 31 | "~/Content/bootstrap-responsive.min.css", 32 | "~/Content/datepicker.css", 33 | "~/Content/colorpicker.css", 34 | "~/Content/bootstrap-duallistbox.min.css", 35 | "~/Content/prettify.css", 36 | "~/Content/common.css", 37 | "~/Content/unicorn.css", 38 | "~/Content/unicorn.main.css", 39 | "~/Content/unicorn.grey.css", 40 | "~/Content/jquery.gritter.css")); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /NLayer.Repository/UserSystemModule/Repositories/RoleGroupRepository.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Data.Entity; 3 | using System.Linq; 4 | using EntityFramework.Extensions; 5 | using NLayer.Domain.UserSystemModule.Aggregates.RoleAgg; 6 | using NLayer.Domain.UserSystemModule.Aggregates.RoleGroupAgg; 7 | using NLayer.Infrastructure.Utility.Helper; 8 | using NLayer.Repository.UnitOfWork; 9 | using PagedList; 10 | 11 | namespace NLayer.Repository.UserSystemModule.Repositories 12 | { 13 | public class RoleGroupRepository : SpecificRepositoryBase, IRoleGroupRepository 14 | { 15 | public RoleGroupRepository(INLayerUnitOfWork unitOfWork) : base(unitOfWork) 16 | { 17 | } 18 | 19 | public IPagedList FindBy(string name, int pageNumber, int pageSize) 20 | { 21 | IQueryable entities = Table; 22 | 23 | if (name.NotNullOrBlank()) 24 | { 25 | entities = 26 | entities.Where(x => x.Name.Contains(name)); 27 | } 28 | 29 | var totalCountQuery = entities.FutureCount(); 30 | var resultQuery = entities 31 | .OrderBy(x => x.SortOrder) 32 | .Skip((pageNumber - 1) * pageSize) 33 | .Take(pageSize) 34 | .Future(); 35 | 36 | var totalCount = totalCountQuery.Value; 37 | var result = resultQuery.ToList(); 38 | 39 | return new StaticPagedList( 40 | result, 41 | pageNumber, 42 | pageSize, 43 | totalCount); 44 | } 45 | 46 | public new bool Exists(RoleGroup item) 47 | { 48 | IQueryable entities = Table; 49 | entities = entities.Where(x => x.Name == item.Name); 50 | if (item.Id != Guid.Empty) 51 | { 52 | entities = entities.Where(x => x.Id != item.Id); 53 | } 54 | return entities.Any(); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Controllers/BaseAuthorizeController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | using System.Web.Routing; 7 | using Autofac; 8 | using NLayer.Application.Managers; 9 | using NLayer.Infrastructure.Authorize; 10 | using NLayer.Infrastructure.Authorize.AuthObject; 11 | using NLayer.Presentation.WebHost.App_Start; 12 | using NLayer.Presentation.WebHost.Helper; 13 | 14 | namespace NLayer.Presentation.WebHost.Controllers 15 | { 16 | public class BaseAuthorizeController : BaseController 17 | { 18 | private NLayerServiceResolver _serviceResolver; 19 | 20 | public NLayerServiceResolver ServiceResolver 21 | { 22 | get { return _serviceResolver ?? (_serviceResolver = new NLayerServiceResolver()); } 23 | } 24 | 25 | //public IServiceResolver ServiceResolver { get; set; } 26 | 27 | private IAuthorizeManager AuthorizeManager 28 | { 29 | get 30 | { 31 | return ServiceResolver.Resolve(); 32 | } 33 | } 34 | 35 | private UserForAuthorize _CurrentUser; 36 | 37 | public BaseAuthorizeController() 38 | { 39 | ViewBag.CurrentUser = GetCurrentUser(); 40 | } 41 | 42 | protected UserForAuthorize GetCurrentUser() 43 | { 44 | try 45 | { 46 | _CurrentUser = AuthorizeManager.GetCurrentUserInfo(); 47 | } 48 | catch (AuthorizeTokenNotFoundException) 49 | { 50 | } 51 | return _CurrentUser; 52 | } 53 | 54 | protected virtual void CheckLogin() 55 | { 56 | if (GetCurrentUser() == null) 57 | { 58 | AuthorizeManager.RedirectToLoginPage(); 59 | } 60 | 61 | } 62 | 63 | protected override void OnAuthorization(AuthorizationContext filterContext) 64 | { 65 | base.OnAuthorization(filterContext); 66 | 67 | CheckLogin(); 68 | } 69 | } 70 | } -------------------------------------------------------------------------------- /NLayer.Infrastructure/Repository/RepositoryBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Transactions; 7 | using NLayer.Infrastructure.Entity; 8 | using NLayer.Infrastructure.UnitOfWork; 9 | 10 | namespace NLayer.Infrastructure.Repository 11 | { 12 | public abstract class RepositoryBase : IRepository 13 | where TEntity : EntityBase 14 | { 15 | #region Members 16 | 17 | #endregion 18 | 19 | #region Constructor 20 | 21 | /// 22 | /// Create a new instance of repository 23 | /// 24 | /// Associated Unit Of Work 25 | protected RepositoryBase(IUnitOfWork unitOfWork) 26 | { 27 | if (unitOfWork == (IUnitOfWork)null) 28 | throw new ArgumentNullException("unitOfWork"); 29 | 30 | UnitOfWork = unitOfWork; 31 | } 32 | 33 | #endregion 34 | 35 | protected void SaveChangesIfNotInTransaction() 36 | { 37 | if (!IsInTransaction()) 38 | { 39 | SaveChanges(); 40 | } 41 | } 42 | 43 | /// 44 | /// Detect if is in transaction or not. 45 | /// 46 | /// 47 | protected virtual bool IsInTransaction() 48 | { 49 | return Transaction.Current != null; 50 | } 51 | 52 | public IUnitOfWork UnitOfWork { get; private set; } 53 | 54 | public abstract void SaveChanges(); 55 | 56 | public abstract TEntity Get(object key); 57 | public abstract void Merge(TEntity persisted, TEntity current); 58 | public abstract IEnumerable FindAll(); 59 | public abstract void Add(TEntity item); 60 | public abstract void Remove(TEntity item); 61 | public abstract bool Exists(TEntity item); 62 | public abstract TEntity Find(Func acquire); 63 | public abstract IQueryable Collection { get; } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /NLayer.Repository/UserSystemModule/Repositories/RoleRepository.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Data.Entity; 3 | using System.Linq; 4 | using EntityFramework.Extensions; 5 | using NLayer.Domain.UserSystemModule.Aggregates.RoleAgg; 6 | using NLayer.Infrastructure.Utility.Helper; 7 | using NLayer.Repository.UnitOfWork; 8 | using PagedList; 9 | 10 | namespace NLayer.Repository.UserSystemModule.Repositories 11 | { 12 | public class RoleRepository : SpecificRepositoryBase, IRoleRepository 13 | { 14 | public RoleRepository(INLayerUnitOfWork unitOfWork) : base(unitOfWork) 15 | { 16 | } 17 | 18 | public IPagedList FindBy(Guid roleGroupId, string name, int pageNumber, int pageSize) 19 | { 20 | IQueryable entities = Table; 21 | 22 | if (roleGroupId != Guid.Empty) 23 | { 24 | entities = 25 | entities.Where(x => x.RoleGroup.Id == roleGroupId); 26 | } 27 | 28 | if (name.NotNullOrBlank()) 29 | { 30 | entities = 31 | entities.Where(x => x.Name.Contains(name)); 32 | } 33 | 34 | var totalCountQuery = entities.FutureCount(); 35 | var resultQuery = entities 36 | .OrderBy(x => x.SortOrder) 37 | .Skip((pageNumber - 1) * pageSize) 38 | .Take(pageSize) 39 | .Future(); 40 | 41 | var totalCount = totalCountQuery.Value; 42 | var result = resultQuery.ToList(); 43 | 44 | return new StaticPagedList( 45 | result, 46 | pageNumber, 47 | pageSize, 48 | totalCount); 49 | } 50 | 51 | public new bool Exists(Role item) 52 | { 53 | IQueryable entities = Table; 54 | entities = entities.Where(x => x.RoleGroup.Id == item.RoleGroup.Id && x.Name == item.Name); 55 | if (item.Id != Guid.Empty) 56 | { 57 | entities = entities.Where(x => x.Id != item.Id); 58 | } 59 | return entities.Any(); 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Views/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 | @using NLayer.Infrastructure.Authorize.AuthObject 2 | @{ 3 | var user = ViewBag.CurrentUser as UserForAuthorize; 4 | var loginName = user == null ? string.Empty : user.LoginName; 5 | var menus = user == null ? new List() : user.Menus; 6 | } 7 | 8 | 9 | 10 | NLayer 11 | 12 | @Styles.Render("~/Content/css") 13 | 14 | 15 | 16 | @Html.Partial("_Confirm") 17 | 18 | 21 | 22 | 24 | 32 | 33 | @Html.Partial("_Menus", menus) 34 | 35 | @Scripts.Render("~/bundles/jquery") 36 | 37 |
38 | 39 | @RenderBody() 40 | 41 |
42 | 45 |
46 | 47 |
48 | 49 | @Scripts.Render("~/bundles/bootstrap") 50 | @Scripts.Render("~/bundles/unicorn") 51 | @Scripts.Render("~/bundles/common") 52 | @RenderSection("scripts", required: false) 53 | 54 | 55 | -------------------------------------------------------------------------------- /NLayer.Repository/UserSystemModule/Repositories/MenuRepository.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Data.Entity; 3 | using System.Linq; 4 | using EntityFramework.Extensions; 5 | using NLayer.Domain.UserSystemModule.Aggregates.MenuAgg; 6 | using NLayer.Infrastructure.Utility.Helper; 7 | using NLayer.Infrastructure.UnitOfWork; 8 | using NLayer.Repository.UnitOfWork; 9 | using PagedList; 10 | 11 | namespace NLayer.Repository.UserSystemModule.Repositories 12 | { 13 | public class MenuRepository : SpecificRepositoryBase, IMenuRepository 14 | { 15 | public MenuRepository(INLayerUnitOfWork unitOfWork) : base(unitOfWork) 16 | { 17 | } 18 | 19 | public IPagedList FindBy(string module, string name, int pageNumber, int pageSize) 20 | { 21 | IQueryable entities = Table; 22 | 23 | if (name.NotNullOrBlank()) 24 | { 25 | entities = 26 | entities.Where(x => x.Name.Contains(name)); 27 | } 28 | 29 | if (module.NotNullOrBlank()) 30 | { 31 | entities = 32 | entities.Where(x => x.Module == module); 33 | } 34 | 35 | var totalCountQuery = entities.FutureCount(); 36 | var resultQuery = entities 37 | .OrderBy(x => x.Module) 38 | .ThenBy(x => x.SortOrder) 39 | .Skip((pageNumber - 1) * pageSize) 40 | .Take(pageSize) 41 | .Future(); 42 | 43 | var totalCount = totalCountQuery.Value; 44 | var result = resultQuery.ToList(); 45 | 46 | return new StaticPagedList( 47 | result, 48 | pageNumber, 49 | pageSize, 50 | totalCount); 51 | } 52 | 53 | public new bool Exists(Menu item) 54 | { 55 | IQueryable entities = Table; 56 | entities = entities.Where(x => x.Module == item.Module && x.Name == item.Name); 57 | if(item.Id != Guid.Empty) 58 | { 59 | entities = entities.Where(x => x.Id != item.Id); 60 | } 61 | return entities.Any(); 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Controllers/AccountController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Web; 6 | using System.Web.Mvc; 7 | using NLayer.Application.Exceptions; 8 | using NLayer.Infrastructure.Authorize; 9 | using NLayer.Presentation.WebHost.Models; 10 | 11 | namespace NLayer.Presentation.WebHost.Controllers 12 | { 13 | public class AccountController : BaseController 14 | { 15 | IAuthorizeManager AuthorizeManager; 16 | 17 | public AccountController(IAuthorizeManager authorizeManager) 18 | { 19 | AuthorizeManager = authorizeManager; 20 | } 21 | 22 | public ActionResult Login() 23 | { 24 | var returnUrl = Request["ReturnUrl"] ?? "/"; 25 | if (returnUrl.IndexOf("Logout", StringComparison.OrdinalIgnoreCase) > -1) 26 | { 27 | returnUrl = "/"; 28 | } 29 | ViewBag.ReturnUrl = returnUrl; 30 | return View(); 31 | } 32 | 33 | public ActionResult Forbidden() 34 | { 35 | return View(); 36 | } 37 | 38 | public ActionResult Logout() 39 | { 40 | AuthorizeManager.SignOut(); 41 | AuthorizeManager.RedirectToLoginPage(); 42 | return null; 43 | } 44 | 45 | [HttpPost] 46 | public ActionResult SignIn(string returnUrl, string loginName, string password, bool? rememberMe) 47 | { 48 | var response = new AjaxResponse(); 49 | try 50 | { 51 | AuthorizeManager.SignIn(loginName, password, rememberMe.HasValue && rememberMe.Value); 52 | response.Succeeded = true; 53 | response.RedirectUrl = returnUrl; 54 | } 55 | catch (Exception ex) 56 | { 57 | if (!(ex is DefinedException)) 58 | { 59 | Log.Error(ex.GetIndentedExceptionLog()); 60 | } 61 | response.Succeeded = false; 62 | response.ErrorMessage = ex.Message; 63 | response.ShowMessage = true; 64 | } 65 | return Json(response); 66 | } 67 | } 68 | } -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/colorpicker.css: -------------------------------------------------------------------------------- 1 | /* 2 | Colorpicker for Bootstrap 3 | Copyright 2012 Stefan Petre 4 | Licensed under the Apache License v2.0 5 | http://www.apache.org/licenses/LICENSE-2.0 6 | */ 7 | .colorpicker-saturation { width: 100px; height: 100px; background-image: url('img/saturation.png'); cursor: crosshair; float: left; } .colorpicker-saturation i { display: block; height: 5px; width: 5px; border: 1px solid #000; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; position: absolute; top: 0; left: 0; margin: -4px 0 0 -4px; } .colorpicker-saturation i b { display: block; height: 5px; width: 5px; border: 1px solid #fff; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; } .colorpicker-hue, .colorpicker-alpha { width: 15px; height: 100px; float: left; cursor: row-resize; margin-left: 4px; margin-bottom: 4px; } .colorpicker-hue i, .colorpicker-alpha i { display: block; height: 1px; background: #000; border-top: 1px solid #fff; position: absolute; top: 0; left: 0; width: 100%; margin-top: -1px; } .colorpicker-hue { background-image: url('img/hue.png'); } .colorpicker-alpha { background-image: url('img/alpha.png'); display: none; } .colorpicker { *zoom: 1; top: 0; left: 0; padding: 4px; min-width: 120px; margin-top: 1px; -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; } .colorpicker:before, .colorpicker:after { display: table; content: ""; } .colorpicker:after { clear: both; } .colorpicker:before { content: ''; display: inline-block; border-left: 7px solid transparent; border-right: 7px solid transparent; border-bottom: 7px solid #ccc; border-bottom-color: rgba(0, 0, 0, 0.2); position: absolute; top: -7px; left: 6px; } .colorpicker:after { content: ''; display: inline-block; border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 6px solid #ffffff; position: absolute; top: -6px; left: 7px; } .colorpicker div { position: relative; } .colorpicker.alpha { min-width: 140px; } .colorpicker.alpha .colorpicker-alpha { display: block; } .colorpicker-color { height: 10px; margin-top: 5px; clear: both; background-image: url('img/alpha.png'); background-position: 0 100%; } .colorpicker-color div { height: 10px; } .input-append.color .add-on i, .input-prepend.color .add-on i { display: block; cursor: pointer; width: 16px; height: 16px; } -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = null; 3 | } 4 | @model HandleErrorInfo 5 | @{ 6 | var statusCode = (HttpStatusCode)ViewBag.StatusCode; 7 | } 8 | 9 | 10 | 11 | 错误 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 |
23 | 24 | 25 |
26 | 27 |
28 | 29 |
30 | 31 |

Oops!

32 | 33 |

@Convert.ToInt32(statusCode) @statusCode

34 | 35 |
36 |

Sorry, an error has occured, Requested page @statusCode.ToString().ToLower()!

37 |
38 |
39 | 40 | Info:
41 | @Model.Exception.Message.Replace("NLayer.Presentation.WebHost.Areas.", "") 42 |
43 |
44 | 45 |
46 | 47 |
48 | 49 |
50 | 51 | 52 |
53 | 54 |
55 | 56 |
57 | 58 |
59 | 60 | 61 | 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /NLayer.Repository.Test/AuthTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using NLayer.Domain.UserSystemModule.Aggregates.RoleAgg; 8 | using NLayer.Domain.UserSystemModule.Aggregates.RoleGroupAgg; 9 | using NLayer.Domain.UserSystemModule.Aggregates.UserAgg; 10 | using NLayer.Infrastructure.Entity; 11 | using NLayer.Infrastructure.Utility; 12 | using NLayer.Infrastructure.Utility.Helper; 13 | using NLayer.Repository.UnitOfWork; 14 | using Xunit; 15 | 16 | namespace NLayer.Repository.Test 17 | { 18 | public class AuthTests 19 | { 20 | [Fact] 21 | public void AddAdmin() 22 | { 23 | var sw = new Stopwatch(); 24 | TimeSpan timeCost; 25 | 26 | using (var unitOfWork = new NLayerUnitOfWork()) 27 | { 28 | sw.Start(); 29 | 30 | #region AddOrUpdate 31 | 32 | const string loginName = "admin"; 33 | const string password = "123456"; 34 | 35 | var user = unitOfWork.Users.FirstOrDefault(x => x.LoginName.Equals(loginName)); 36 | 37 | if (user == null) 38 | { 39 | user = new User() 40 | { 41 | Id = IdentityGenerator.NewSequentialGuid(), 42 | Name = "管理员", 43 | LoginName = loginName, 44 | LoginPwd = SecurityHelper.EncryptPassword(password), 45 | Created = DateTime.UtcNow, 46 | LastLogin = Const.SqlServerNullDateTime 47 | }; 48 | 49 | unitOfWork.Users.Add(user); 50 | } 51 | else 52 | { 53 | user.Name = "管理员"; 54 | user.LoginPwd = SecurityHelper.EncryptPassword(password); 55 | user.Created = DateTime.UtcNow; 56 | } 57 | 58 | #endregion 59 | 60 | unitOfWork.DbContext.SaveChanges(); 61 | 62 | sw.Stop(); 63 | timeCost = sw.Elapsed; 64 | } 65 | 66 | Console.WriteLine("Elapsed: " + timeCost.Ticks); 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/prettify.css: -------------------------------------------------------------------------------- 1 | /* Hemisu Light */ 2 | /* Original theme - http://noahfrederick.com/vim-color-scheme-hemisu/ */ 3 | .prettyprint { 4 | background: transparent; 5 | font-family: Menlo, 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, Consolas, monospace; 6 | font-size: 12px; 7 | line-height: 1.5; 8 | border: none; 9 | padding: 10px; 10 | } 11 | 12 | .pln { 13 | color: #111111; 14 | } 15 | 16 | @media screen { 17 | .str { 18 | color: #739200; 19 | } 20 | 21 | .kwd { 22 | color: #739200; 23 | } 24 | 25 | .com { 26 | color: #999999; 27 | } 28 | 29 | .typ { 30 | color: #ff0055; 31 | } 32 | 33 | .lit { 34 | color: #538192; 35 | } 36 | 37 | .pun { 38 | color: #111111; 39 | } 40 | 41 | .opn { 42 | color: #111111; 43 | } 44 | 45 | .clo { 46 | color: #111111; 47 | } 48 | 49 | .tag { 50 | color: #111111; 51 | } 52 | 53 | .atn { 54 | color: #739200; 55 | } 56 | 57 | .atv { 58 | color: #ff0055; 59 | } 60 | 61 | .dec { 62 | color: #111111; 63 | } 64 | 65 | .var { 66 | color: #111111; 67 | } 68 | 69 | .fun { 70 | color: #538192; 71 | } 72 | } 73 | @media print, projection { 74 | .str { 75 | color: #006600; 76 | } 77 | 78 | .kwd { 79 | color: #006; 80 | font-weight: bold; 81 | } 82 | 83 | .com { 84 | color: #600; 85 | font-style: italic; 86 | } 87 | 88 | .typ { 89 | color: #404; 90 | font-weight: bold; 91 | } 92 | 93 | .lit { 94 | color: #004444; 95 | } 96 | 97 | .pun, .opn, .clo { 98 | color: #444400; 99 | } 100 | 101 | .tag { 102 | color: #006; 103 | font-weight: bold; 104 | } 105 | 106 | .atn { 107 | color: #440044; 108 | } 109 | 110 | .atv { 111 | color: #006600; 112 | } 113 | } 114 | /* Specify class=linenums on a pre to get line numbering */ 115 | ol.linenums { 116 | margin-top: 0; 117 | margin-bottom: 0; 118 | } 119 | 120 | /* IE indents via margin-left */ 121 | li.L0, 122 | li.L1, 123 | li.L2, 124 | li.L3, 125 | li.L4, 126 | li.L5, 127 | li.L6, 128 | li.L7, 129 | li.L8, 130 | li.L9 { 131 | /* */ 132 | } 133 | 134 | /* Alternate shading for lines */ 135 | li.L1, 136 | li.L3, 137 | li.L5, 138 | li.L7, 139 | li.L9 { 140 | /* */ 141 | } 142 | -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/bootstrap-duallistbox.css: -------------------------------------------------------------------------------- 1 | /* 2 | * Bootstrap Duallistbox - v3.0.2 3 | * A responsive dual listbox widget optimized for Twitter Bootstrap. It works on all modern browsers and on touch devices. 4 | * http://www.virtuosoft.eu/code/bootstrap-duallistbox/ 5 | * 6 | * Made by István Ujj-Mészáros 7 | * Under Apache License v2.0 License 8 | */ 9 | .bootstrap-duallistbox-container .buttons { 10 | width: 100%; 11 | margin-bottom: -1px; 12 | } 13 | 14 | .bootstrap-duallistbox-container label { 15 | display: block; 16 | } 17 | 18 | .bootstrap-duallistbox-container .info { 19 | display: inline-block; 20 | margin-bottom: 5px; 21 | font-size: 11px; 22 | } 23 | 24 | .bootstrap-duallistbox-container .clear1, 25 | .bootstrap-duallistbox-container .clear2 { 26 | display: none; 27 | font-size: 10px; 28 | } 29 | 30 | .bootstrap-duallistbox-container .box1.filtered .clear1, 31 | .bootstrap-duallistbox-container .box2.filtered .clear2 { 32 | display: inline-block; 33 | } 34 | 35 | .bootstrap-duallistbox-container .move, 36 | .bootstrap-duallistbox-container .remove { 37 | width: 60%; 38 | } 39 | 40 | .bootstrap-duallistbox-container .btn-group .btn { 41 | border-bottom-left-radius: 0; 42 | border-bottom-right-radius: 0; 43 | } 44 | .bootstrap-duallistbox-container select { 45 | border-top-left-radius: 0; 46 | border-top-right-radius: 0; 47 | } 48 | 49 | .bootstrap-duallistbox-container .moveall, 50 | .bootstrap-duallistbox-container .removeall { 51 | width: 40%; 52 | } 53 | 54 | .bootstrap-duallistbox-container.bs2compatible .btn-group > .btn + .btn { 55 | margin-left: 0; 56 | } 57 | 58 | .bootstrap-duallistbox-container select { 59 | width: 100%; 60 | height: 300px; 61 | padding: 0; 62 | } 63 | 64 | .bootstrap-duallistbox-container .filter { 65 | display: inline-block; 66 | width: 100%; 67 | height: 31px; 68 | margin: 0 0 5px 0; 69 | -webkit-box-sizing: border-box; 70 | -moz-box-sizing: border-box; 71 | box-sizing: border-box; 72 | } 73 | 74 | .bootstrap-duallistbox-container .filter.placeholder { 75 | color: #aaa; 76 | } 77 | 78 | .bootstrap-duallistbox-container.moveonselect .move, 79 | .bootstrap-duallistbox-container.moveonselect .remove { 80 | display:none; 81 | } 82 | 83 | .bootstrap-duallistbox-container.moveonselect .moveall, 84 | .bootstrap-duallistbox-container.moveonselect .removeall { 85 | width: 100%; 86 | } 87 | -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Global.asax.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net; 5 | using System.Web; 6 | using System.Web.Mvc; 7 | using System.Web.Optimization; 8 | using System.Web.Routing; 9 | using log4net; 10 | using NLayer.Presentation.WebHost.App_Start; 11 | using NLayer.Presentation.WebHost.Controllers; 12 | 13 | namespace NLayer.Presentation.WebHost 14 | { 15 | public class MvcApplication : System.Web.HttpApplication 16 | { 17 | private static readonly ILog Log = LogManager.GetLogger(typeof (MvcApplication)); 18 | 19 | protected void Application_Start() 20 | { 21 | Log.Info("Application starting..."); 22 | 23 | AutofacConfig.Config(); 24 | 25 | AreaRegistration.RegisterAllAreas(); 26 | FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); 27 | RouteConfig.RegisterRoutes(RouteTable.Routes); 28 | BundleTable.EnableOptimizations = true; 29 | BundleConfig.RegisterBundles(BundleTable.Bundles); 30 | 31 | Log.Info("Application started."); 32 | } 33 | 34 | protected void Application_End(object sender, EventArgs e) 35 | { 36 | Log.Info("Application stopped."); 37 | } 38 | 39 | protected void Application_Error(object sender, EventArgs e) 40 | { 41 | var ex = Server.GetLastError(); 42 | var log = LogManager.GetLogger(ex.GetType()); 43 | log.Error(ex.GetIndentedExceptionLog()); 44 | 45 | var httpStatusCode = (ex is HttpException) ? (ex as HttpException).GetHttpCode() : 500; //这里仅仅区分两种错误 46 | 47 | var httpContext = ((MvcApplication) sender).Context; 48 | httpContext.ClearError(); 49 | httpContext.Response.Clear(); 50 | httpContext.Response.StatusCode = httpStatusCode; 51 | 52 | var errorModel = new HandleErrorInfo(ex, "Home", "Error"); 53 | 54 | var routeData = new RouteData(); 55 | routeData.Values["controller"] = "Home"; 56 | routeData.Values["action"] = "Error"; 57 | 58 | var controller = new HomeController { ViewData = { Model = errorModel } }; 59 | controller.ViewBag.StatusCode = (HttpStatusCode) httpStatusCode; 60 | //通过代码路由到指定的路径 61 | ((IController) controller).Execute(new RequestContext(new HttpContextWrapper(httpContext), routeData)); 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Areas/UserSystem/Views/Role/EditGroup.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewBag.Title = "角色管理"; 3 | var groupName = ViewBag.GroupName; 4 | } 5 | @model NLayer.Application.UserSystemModule.DTOs.RoleGroupDTO 6 |
7 |

角色组

8 |
9 | 14 |
15 | 16 | 17 |
18 |
19 |
20 |
21 | 22 | 23 | 24 |
添加 / 编辑角色组
25 |
26 |
27 | @using (Ajax.BeginForm("EditGroup", new { id = Model.Id }, new AjaxOptions { HttpMethod = "Post", OnSuccess = "ajaxRequestSuccess" }, new { @class = "form-horizontal" })) 28 | { 29 |
30 | 31 |
32 | @Html.TextBoxFor(x => x.Name, new { placeholder = "角色组名称" }) 33 |
34 |
35 |
36 | 37 |
38 | @Html.TextAreaFor(x => x.Description, new { placeholder = "对该角色组的描述" }) 39 |
40 |
41 |
42 | 43 |
44 | @Html.TextBoxFor(x => x.SortOrder, new { placeholder = "排序" }) 45 |
46 |
47 |
48 | 49 |
50 | } 51 |
52 |
53 |
54 | 55 |
56 | 57 |
-------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/login.css: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------ 2 | 3 | Signin 4 | 5 | ------------------------------------------------------------------- */ 6 | body.login { 7 | color: #838383; 8 | font: 13px/1.7em 'Open Sans'; 9 | background: url(img/signin/login-bg.png); 10 | } 11 | .account-container { 12 | width: 380px; 13 | display: block; 14 | margin: 85px auto 0 auto; 15 | background: #f9f9f9; 16 | border: 1px solid #d5d5d5; 17 | -webkit-border-radius: 4px; 18 | -moz-border-radius: 4px; 19 | border-radius: 4px; 20 | } 21 | .account-container h1 { 22 | margin-bottom: .4em; 23 | color: #263849; 24 | font-size: 30px; 25 | } 26 | .content { 27 | padding: 16px 28px 23px; 28 | } 29 | .login-fields .field { 30 | margin-bottom: 1.25em; 31 | } 32 | .login-fields label { 33 | display: none; 34 | } 35 | .login-fields input { 36 | font-family: 'Open Sans'; 37 | font-size: 13px; 38 | color: #8e8d8d; 39 | padding: 11px 15px 10px 50px; 40 | background-color: #fdfdfd; 41 | width: 255px; 42 | display: block; 43 | margin: 0; 44 | box-shadow: inset 2px 2px 4px #f1f1f1; 45 | } 46 | .login-fields .username-field { 47 | background: url(img/signin/user.png) no-repeat; 48 | } 49 | .login-fields .password-field { 50 | background: url(img/signin/password.png) no-repeat; 51 | } 52 | .login-actions { 53 | float: left; 54 | width: 100%; 55 | margin-top: 0; 56 | margin-bottom: 1.25em; 57 | } 58 | .login-social { 59 | float: left; 60 | padding: 10px 0 15px; 61 | border: 1px dotted #CCC; 62 | border-right: none; 63 | border-left: none; 64 | } 65 | .login-social p { 66 | margin-bottom: 1em; 67 | } 68 | .login-extra { 69 | display: block; 70 | width: 300px; 71 | margin: 1.5em auto; 72 | text-align: center; 73 | line-height: 19px; 74 | text-shadow: 1px 1px 0px #fff; 75 | } 76 | span.login-checkbox { 77 | float: left; 78 | margin-top: 31px; 79 | } 80 | span.login-checkbox > input[type='checkbox'] { 81 | opacity: 0; 82 | float: left; 83 | width: 15px; 84 | } 85 | span.login-checkbox > input[type='checkbox'] + label { 86 | clear: none; 87 | height: 15px; 88 | display: block; 89 | padding: 0 0 0 22px; 90 | margin: 0; 91 | font-size: 12px; 92 | line-height: 1.2em; 93 | background: url(img/signin/check.png) no-repeat 0 0; 94 | cursor: pointer; 95 | } 96 | span.login-checkbox > input[type='checkbox']:checked + label { 97 | background-position: 0 -15px; 98 | } 99 | 100 | .login-actions button { 101 | float: right; 102 | } -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/App_Start/AutofacConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using System.Web; 6 | using System.Web.Compilation; 7 | using System.Web.Mvc; 8 | using Autofac; 9 | using Autofac.Configuration; 10 | using Autofac.Extras.CommonServiceLocator; 11 | using Autofac.Integration.Mvc; 12 | using Autofac.Integration.WebApi; 13 | using Microsoft.Practices.ServiceLocation; 14 | using NLayer.Application.Managers; 15 | using NLayer.Infrastructure.Authorize; 16 | using NLayer.IocModules; 17 | using NLayer.Presentation.WebHost.Controllers; 18 | using NLayer.Presentation.WebHost.Helper; 19 | 20 | namespace NLayer.Presentation.WebHost.App_Start 21 | { 22 | public static class AutofacConfig 23 | { 24 | public static IContainer Container { get; private set; } 25 | 26 | public static void Config() 27 | { 28 | var builder = new ContainerBuilder(); 29 | 30 | //builder.RegisterModule(new ConfigurationSettingsReader("autofac")); 31 | 32 | var executingAssembly = Assembly.GetExecutingAssembly(); 33 | 34 | builder.RegisterApiControllers(executingAssembly) 35 | .InstancePerRequest();//注册api容器的实现 36 | 37 | builder.RegisterControllers(executingAssembly) 38 | .InstancePerRequest();//注册mvc容器的实现 39 | builder.RegisterModelBinderProvider(); 40 | builder.RegisterModule(new AutofacWebTypesModule()); 41 | builder.RegisterSource(new ViewRegistrationSource()); 42 | builder.RegisterFilterProvider(); 43 | 44 | // 系统定义的模块 45 | builder.RegisterModule(); 46 | builder.RegisterModule(); 47 | 48 | //builder.RegisterType().As(); 49 | 50 | //builder.RegisterType().PropertiesAutowired(); 51 | 52 | //builder.Register(c => new BaseAuthorizeController()).OnActivated(e => 53 | //{ 54 | // e.Instance.AuthorizeManager = e.Context.Resolve(); 55 | //}).InstancePerRequest(); 56 | 57 | //builder.Register(c => new BaseAuthorizeController() { AuthorizeManager = c.Resolve() }).InstancePerRequest(); 58 | 59 | Container = builder.Build(); 60 | DependencyResolver.SetResolver(new AutofacDependencyResolver(Container));//注册mvc容器 61 | 62 | //var csl = new AutofacServiceLocator(Container); 63 | //ServiceLocator.SetLocatorProvider(() => csl); 64 | } 65 | } 66 | } -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/App_Start/DisplayExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Linq.Expressions; 5 | using NLayer.Application.Modules; 6 | using PagedList.Mvc; 7 | 8 | namespace NLayer.Presentation.WebHost 9 | { 10 | public static class DisplayExtensions 11 | { 12 | public static string Display(this DateTime dateTime) 13 | { 14 | var t = dateTime.ToLocalTime(); 15 | 16 | return t.ToString("yyyy/MM/dd HH:mm:ss"); 17 | } 18 | 19 | public static string Display(this DateTime? dateTime) 20 | { 21 | return dateTime.HasValue ? dateTime.Value.Display() : ""; 22 | } 23 | 24 | public static string DisplayDate(this DateTime dateTime) 25 | { 26 | var t = dateTime.ToLocalTime(); 27 | 28 | return t.ToString("yyyy/MM/dd"); 29 | } 30 | 31 | public static string DisplayDate(this DateTime? dateTime) 32 | { 33 | return dateTime.HasValue ? dateTime.Value.DisplayDate() : ""; 34 | } 35 | 36 | public static string DisplayDateHourMinute(this DateTime dateTime) 37 | { 38 | var t = dateTime.ToLocalTime(); 39 | 40 | return t.ToString("yyyy/MM/dd HH:mm"); 41 | } 42 | 43 | public static string DisplayDateHourMinute(this DateTime? dateTime) 44 | { 45 | return dateTime.HasValue ? dateTime.Value.DisplayDateHourMinute() : ""; 46 | } 47 | 48 | public static string Display(this Decimal value) 49 | { 50 | return value.ToString("#,##0.00"); 51 | } 52 | 53 | public static string Display(this Decimal? value) 54 | { 55 | return value.HasValue ? value.Value.Display() : ""; 56 | } 57 | 58 | public static PagedListRenderOptions PagedListRenderOptions 59 | { 60 | get 61 | { 62 | return new PagedListRenderOptions 63 | { 64 | LinkToFirstPageFormat = "首页", 65 | LinkToNextPageFormat = "下页", 66 | LinkToPreviousPageFormat = "上页", 67 | LinkToLastPageFormat = "末页", 68 | MaximumPageNumbersToDisplay = 5, 69 | DisplayEllipsesWhenNotShowingAllPageNumbers = false, 70 | }; 71 | } 72 | } 73 | 74 | public static int DefaultPageSize = 15; 75 | 76 | public static string Display(this NLayerModulesType value) 77 | { 78 | return NLayerModulesManager.Instance.GetModulesName(value); 79 | } 80 | } 81 | } -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Views/Shared/_Menus.cshtml: -------------------------------------------------------------------------------- 1 | @using NLayer.Application.Modules 2 | @model List 3 | @{ 4 | var menuGroups = Model.Where(x => x.Module > 2).GroupBy(x => x.Module).OrderBy(x => x.Key); 5 | } 6 | 7 | 49 | -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Areas/UserSystem/Views/Role/EditRole.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewBag.Title = "角色管理"; 3 | var groupName = ViewBag.GroupName; 4 | var groupId = ViewBag.GroupId; 5 | } 6 | @model NLayer.Application.UserSystemModule.DTOs.RoleDTO 7 |
8 |

角色

9 |
10 | 16 |
17 | 18 | 19 |
20 |
21 |
22 |
23 | 24 | 25 | 26 |
添加 / 编辑角色
27 |
28 |
29 | @using (Ajax.BeginForm("EditRole", new { groupId = @groupId, id = Model.Id }, new AjaxOptions { HttpMethod = "Post", OnSuccess = "ajaxRequestSuccess" }, new { @class = "form-horizontal" })) 30 | { 31 |
32 | 33 |
34 | @Html.TextBoxFor(x => x.Name, new { placeholder = "角色名称" }) 35 |
36 |
37 |
38 | 39 |
40 | @Html.TextAreaFor(x => x.Description, new { placeholder = "对该角色的描述" }) 41 |
42 |
43 |
44 | 45 |
46 | @Html.TextBoxFor(x => x.SortOrder, new { placeholder = "排序" }) 47 |
48 |
49 |
50 | 51 |
52 | } 53 |
54 |
55 |
56 | 57 |
58 | 59 |
-------------------------------------------------------------------------------- /NLayer.Repository/UserSystemModule/Repositories/UserRepository.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Data.Entity; 3 | using System.Linq; 4 | using EntityFramework.Extensions; 5 | using NLayer.Domain.UserSystemModule.Aggregates.UserAgg; 6 | using NLayer.Infrastructure.Utility.Helper; 7 | using NLayer.Repository.UnitOfWork; 8 | using PagedList; 9 | 10 | namespace NLayer.Repository.UserSystemModule.Repositories 11 | { 12 | public class UserRepository : SpecificRepositoryBase, IUserRepository 13 | { 14 | public UserRepository(INLayerUnitOfWork unitOfWork) : base(unitOfWork) 15 | { 16 | } 17 | 18 | public IPagedList FindBy(string name, int pageNumber, int pageSize) 19 | { 20 | IQueryable entities = Table; 21 | 22 | if (name.NotNullOrBlank()) 23 | { 24 | entities = 25 | entities.Where(x => x.Name.Contains(name)); 26 | } 27 | 28 | var totalCountQuery = entities.FutureCount(); 29 | var resultQuery = entities 30 | .OrderByDescending(x => x.Created) 31 | .Skip((pageNumber - 1) * pageSize) 32 | .Take(pageSize) 33 | .Future(); 34 | 35 | var totalCount = totalCountQuery.Value; 36 | var result = resultQuery.ToList(); 37 | 38 | return new StaticPagedList( 39 | result, 40 | pageNumber, 41 | pageSize, 42 | totalCount); 43 | } 44 | 45 | public bool ExistsLoginName(User item) 46 | { 47 | IQueryable entities = Table; 48 | entities = entities.Where(x => x.LoginName == item.LoginName); 49 | if (item.Id != Guid.Empty) 50 | { 51 | entities = entities.Where(x => x.Id != item.Id); 52 | } 53 | return entities.Any(); 54 | } 55 | 56 | public bool ExistsEmail(User item) 57 | { 58 | IQueryable entities = Table; 59 | entities = entities.Where(x => x.Email == item.Email); 60 | if (item.Id != Guid.Empty) 61 | { 62 | entities = entities.Where(x => x.Id != item.Id); 63 | } 64 | return entities.Any(); 65 | } 66 | 67 | public new bool Exists(User item) 68 | { 69 | IQueryable entities = Table; 70 | entities = entities.Where(x => x.Name == item.Name); 71 | if (item.Id != Guid.Empty) 72 | { 73 | entities = entities.Where(x => x.Id != item.Id); 74 | } 75 | return entities.Any(); 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /NLayer.Repository/Migrations/201506161423201_ModifyRoleUser.cs: -------------------------------------------------------------------------------- 1 | namespace NLayer.Repository.Migrations 2 | { 3 | using System; 4 | using System.Data.Entity.Migrations; 5 | 6 | public partial class ModifyRoleUser : DbMigration 7 | { 8 | public override void Up() 9 | { 10 | DropForeignKey("auth.Role_User", "User_Id", "auth.User"); 11 | DropForeignKey("auth.Role_User", "Role_Id", "auth.Role"); 12 | DropIndex("auth.Role_User", new[] { "User_Id" }); 13 | DropIndex("auth.Role_User", new[] { "Role_Id" }); 14 | CreateTable( 15 | "auth.RoleGroup_User", 16 | c => new 17 | { 18 | User_Id = c.Guid(nullable: false), 19 | RoleGroup_Id = c.Guid(nullable: false), 20 | }) 21 | .PrimaryKey(t => new { t.User_Id, t.RoleGroup_Id }) 22 | .ForeignKey("auth.User", t => t.User_Id, cascadeDelete: true) 23 | .ForeignKey("auth.RoleGroup", t => t.RoleGroup_Id, cascadeDelete: true) 24 | .Index(t => t.User_Id) 25 | .Index(t => t.RoleGroup_Id); 26 | 27 | AddColumn("auth.User", "Role_Id", c => c.Guid()); 28 | CreateIndex("auth.User", "Role_Id"); 29 | AddForeignKey("auth.User", "Role_Id", "auth.Role", "Id"); 30 | DropTable("auth.Role_User"); 31 | } 32 | 33 | public override void Down() 34 | { 35 | CreateTable( 36 | "auth.Role_User", 37 | c => new 38 | { 39 | User_Id = c.Guid(nullable: false), 40 | Role_Id = c.Guid(nullable: false), 41 | }) 42 | .PrimaryKey(t => new { t.User_Id, t.Role_Id }); 43 | 44 | DropForeignKey("auth.User", "Role_Id", "auth.Role"); 45 | DropForeignKey("auth.RoleGroup_User", "RoleGroup_Id", "auth.RoleGroup"); 46 | DropForeignKey("auth.RoleGroup_User", "User_Id", "auth.User"); 47 | DropIndex("auth.RoleGroup_User", new[] { "RoleGroup_Id" }); 48 | DropIndex("auth.RoleGroup_User", new[] { "User_Id" }); 49 | DropIndex("auth.User", new[] { "Role_Id" }); 50 | DropColumn("auth.User", "Role_Id"); 51 | DropTable("auth.RoleGroup_User"); 52 | CreateIndex("auth.Role_User", "Role_Id"); 53 | CreateIndex("auth.Role_User", "User_Id"); 54 | AddForeignKey("auth.Role_User", "Role_Id", "auth.Role", "Id", cascadeDelete: true); 55 | AddForeignKey("auth.Role_User", "User_Id", "auth.User", "Id", cascadeDelete: true); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Scripts/plugins/jquery.unobtrusive/jquery.unobtrusive-ajax.min.js: -------------------------------------------------------------------------------- 1 | /* 2 | ** Unobtrusive Ajax support library for jQuery 3 | ** Copyright (C) Microsoft Corporation. All rights reserved. 4 | */ 5 | (function(a){var b="unobtrusiveAjaxClick",g="unobtrusiveValidation";function c(d,b){var a=window,c=(d||"").split(".");while(a&&c.length)a=a[c.shift()];if(typeof a==="function")return a;b.push(d);return Function.constructor.apply(null,b)}function d(a){return a==="GET"||a==="POST"}function f(b,a){!d(a)&&b.setRequestHeader("X-HTTP-Method-Override",a)}function h(c,b,e){var d;if(e.indexOf("application/x-javascript")!==-1)return;d=(c.getAttribute("data-ajax-mode")||"").toUpperCase();a(c.getAttribute("data-ajax-update")).each(function(f,c){var e;switch(d){case"BEFORE":e=c.firstChild;a("
").html(b).contents().each(function(){c.insertBefore(this,e)});break;case"AFTER":a("
").html(b).contents().each(function(){c.appendChild(this)});break;default:a(c).html(b)}})}function e(b,e){var j,k,g,i;j=b.getAttribute("data-ajax-confirm");if(j&&!window.confirm(j))return;k=a(b.getAttribute("data-ajax-loading"));i=b.getAttribute("data-ajax-loading-duration")||0;a.extend(e,{type:b.getAttribute("data-ajax-method")||undefined,url:b.getAttribute("data-ajax-url")||undefined,beforeSend:function(d){var a;f(d,g);a=c(b.getAttribute("data-ajax-begin"),["xhr"]).apply(this,arguments);a!==false&&k.show(i);return a},complete:function(){k.hide(i);c(b.getAttribute("data-ajax-complete"),["xhr","status"]).apply(this,arguments)},success:function(a,e,d){h(b,a,d.getResponseHeader("Content-Type")||"text/html");c(b.getAttribute("data-ajax-success"),["data","status","xhr"]).apply(this,arguments)},error:c(b.getAttribute("data-ajax-failure"),["xhr","status","error"])});e.data.push({name:"X-Requested-With",value:"XMLHttpRequest"});g=e.type.toUpperCase();if(!d(g)){e.type="POST";e.data.push({name:"X-HTTP-Method-Override",value:g})}a.ajax(e)}function i(c){var b=a(c).data(g);return!b||!b.validate||b.validate()}a(document).on("click","a[data-ajax=true]",function(a){a.preventDefault();e(this,{url:this.href,type:"GET",data:[]})});a(document).on("click","form[data-ajax=true] input[type=image]",function(c){var g=c.target.name,d=a(c.target),f=d.parents("form")[0],e=d.offset();a(f).data(b,[{name:g+".x",value:Math.round(c.pageX-e.left)},{name:g+".y",value:Math.round(c.pageY-e.top)}]);setTimeout(function(){a(f).removeData(b)},0)});a(document).on("click","form[data-ajax=true] :submit",function(c){var e=c.target.name,d=a(c.target).parents("form")[0];a(d).data(b,e?[{name:e,value:c.target.value}]:[]);setTimeout(function(){a(d).removeData(b)},0)});a(document).on("submit","form[data-ajax=true]",function(d){var c=a(this).data(b)||[];d.preventDefault();if(!i(this))return;e(this,{url:this.action,type:this.method||"GET",data:c.concat(a(this).serializeArray())})})})(jQuery); -------------------------------------------------------------------------------- /NLayer.Application/Modules/NLayerModulesManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using NLayer.Application.Resources; 7 | 8 | namespace NLayer.Application.Modules 9 | { 10 | public class NLayerModulesManager 11 | { 12 | private static List _modules; 13 | private static readonly object LockObject = new object(); 14 | 15 | private static void Init() 16 | { 17 | lock (LockObject) 18 | { 19 | _modules = new List 20 | { 21 | new NLayerModules(NLayerModulesType.UserSystem, 22 | ModulesResource.UserSystem), 23 | 24 | new NLayerModules(NLayerModulesType.BootstrapSamples, 25 | ModulesResource.BootstrapSamples), 26 | 27 | new NLayerModules(NLayerModulesType.AuthMenuSample, 28 | ModulesResource.AuthMenuSample), 29 | }; 30 | } 31 | } 32 | 33 | private NLayerModulesManager() 34 | { 35 | Init(); 36 | } 37 | 38 | private static NLayerModulesManager _Instance; 39 | public static NLayerModulesManager Instance 40 | { 41 | get { return _Instance ?? (_Instance = new NLayerModulesManager()); } 42 | } 43 | 44 | public int GetModulesType(string typeStr) 45 | { 46 | NLayerModulesType type; 47 | if (Enum.TryParse(typeStr, true, out type)) 48 | { 49 | var m = _modules.FirstOrDefault(x => x.Type == type); 50 | if (m != null) 51 | { 52 | return (int)m.Type; 53 | } 54 | } 55 | 56 | return 0; 57 | } 58 | 59 | public string GetModulesName(string typeStr) 60 | { 61 | NLayerModulesType type; 62 | if (Enum.TryParse(typeStr, true, out type)) 63 | { 64 | var m = _modules.FirstOrDefault(x => x.Type == type); 65 | if (m != null) 66 | { 67 | return m.Name; 68 | } 69 | } 70 | 71 | return string.Empty; 72 | } 73 | 74 | public List ListAll() 75 | { 76 | return _modules; 77 | } 78 | 79 | public string GetModulesName(NLayerModulesType type) 80 | { 81 | var modules = _modules.FirstOrDefault(x => x.Type == type); 82 | 83 | if (modules == null) 84 | { 85 | throw new ArgumentException(type.ToString(), "type"); 86 | } 87 | 88 | return modules.Name; 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /NLayer.Infrastructure.Utility/SecurityHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using NLayer.Infrastructure.Utility.Helper; 8 | 9 | namespace NLayer.Infrastructure.Utility 10 | { 11 | public static class SecurityHelper 12 | { 13 | private static string AuthSecret 14 | { 15 | get 16 | { 17 | var authSecret = ConfigurationManager.AppSettings["NLayer:AuthSecret"]; 18 | if (authSecret.IsNullOrBlank()) 19 | { 20 | throw new ConfigurationErrorsException("missing \"NLayer:AuthSecret\" appSetting."); 21 | } 22 | return authSecret; 23 | } 24 | } 25 | 26 | public static int GetRandomSeed() 27 | { 28 | var bytes = new byte[4]; 29 | var rng = new System.Security.Cryptography.RNGCryptoServiceProvider(); 30 | rng.GetBytes(bytes); 31 | return BitConverter.ToInt32(bytes, 0); 32 | } 33 | 34 | /// 35 | /// 0~9 A~Z字符串 36 | /// 37 | public static string RandomString09Az = "0123456789ABCDEFGHIJKMLNOPQRSTUVWXYZ"; 38 | 39 | public static string NetxtString(int size) 40 | { 41 | var rnd = new Random(GetRandomSeed()); 42 | return rnd.NetxtString(RandomString09Az, size); 43 | } 44 | 45 | /// 46 | /// 依据指定字符串来生成随机字符串 47 | /// 48 | /// Random 49 | /// 指定字符串 50 | /// 字符串长度 51 | /// 随机字符串 52 | public static string NetxtString(this Random random, string randomString, int size) 53 | { 54 | var nextString = string.Empty; 55 | if (random == null || string.IsNullOrEmpty(randomString)) return nextString; 56 | var builder = new StringBuilder(size); 57 | int maxCount = randomString.Length - 1; 58 | for (var i = 0; i < size; i++) 59 | { 60 | var number = random.Next(0, maxCount); 61 | builder.Append(randomString[number]); 62 | } 63 | nextString = builder.ToString(); 64 | return nextString; 65 | } 66 | 67 | public static string EncryptPassword(string password) 68 | { 69 | byte[] bytes = System.Text.Encoding.UTF8.GetBytes(password + "_" + AuthSecret); 70 | byte[] sha1Bytes = System.Security.Cryptography.SHA1.Create().ComputeHash(bytes); 71 | string secretPart = BitConverter.ToString(sha1Bytes).Replace("-", string.Empty); 72 | return secretPart; 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Scripts/common.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function () { 2 | $('.ajax-remove').click(function () { 3 | $('#confirm_modal').modal(); 4 | var url = $(this).attr('href'); 5 | $('#confirm_title').html('删除确认'); 6 | var name = $(this).attr('data-name'); 7 | $('#confirm_content').html('确认删除【' + name + '】吗?'); 8 | $('#confirm_confirm').one('click',function () { 9 | $.ajax({ 10 | type: "GET", 11 | url: url, 12 | dataType: "json", 13 | success: ajaxRequestSuccess 14 | }); 15 | $('#confirm_modal').modal('hide'); 16 | return false; 17 | }); 18 | return false; 19 | }); 20 | 21 | var url = location.href; 22 | $(".submenu").each(function() { 23 | var menu = $(this).data("menu"); 24 | if (url.match("/" + menu)) { 25 | $(this).addClass("open"); 26 | } 27 | }); 28 | 29 | $("#sidebar .open li a").each(function () { 30 | if (url.match($(this).attr("href"))) { 31 | $(this).parent().addClass("active"); 32 | } 33 | }); 34 | 35 | $(".chkAll").click(function () { 36 | var checked = this.checked; 37 | var depth = $(this).attr("depth"); 38 | var node = $(this); 39 | while (depth>0) { 40 | node = node.parent(); 41 | depth--; 42 | } 43 | $("input[type=checkbox]", node).each(function() { 44 | $(this).attr("checked", checked); 45 | }); 46 | }); 47 | }); 48 | 49 | function ajaxRequestSuccess(resp) { 50 | if (!!resp) { 51 | if (resp.Succeeded) { 52 | var url = null; 53 | var msg = "Succeed!!!"; 54 | if (!!resp.RedirectUrl && resp.RedirectUrl.trim().length > 0) { 55 | url = resp.RedirectUrl; 56 | } 57 | if (resp.ShowMessage) { 58 | if (!/^\s*$/.test(resp.Message) && resp.Message != null) { 59 | msg = resp.Message; 60 | } 61 | } else { 62 | msg = null; 63 | } 64 | if (!!url) { 65 | if (!!msg) { 66 | setTimeout(function () { 67 | window.location.href = url; 68 | }, 1500); 69 | } else { 70 | window.location.href = url; 71 | } 72 | } 73 | if (!!msg) { 74 | $.gritter.add({ 75 | title: '提示', 76 | text: msg, 77 | sticky: false 78 | }); 79 | } 80 | } else { 81 | $.gritter.add({ 82 | title: '提示', 83 | text: resp.ErrorMessage, 84 | sticky: false 85 | }); 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Views/Account/Login.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = null; 3 | } 4 | @{ 5 | var ReturnUrl = ViewBag.ReturnUrl as String; 6 | } 7 | 8 | 9 | 10 | 登陆 11 | 12 | @Styles.Render("~/Content/css") 13 | 14 | @Scripts.Render("~/bundles/jquery") 15 | 16 | 17 | 18 | 19 | 20 | 76 | @Scripts.Render("~/bundles/bootstrap") 77 | @Scripts.Render("~/bundles/unicorn") 78 | @Scripts.Render("~/bundles/common") 79 | 80 | 81 | -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Areas/UserSystem/Views/User/EffectiveUserPermission.cshtml: -------------------------------------------------------------------------------- 1 | @using NLayer.Infrastructure.Authorize.AuthObject 2 | 3 | @{ 4 | ViewBag.Title = "生效权限"; 5 | 6 | var user = ViewBag.AuthorizeUser as UserForAuthorize; 7 | } 8 | 9 |
10 | 11 |
12 |
13 |
14 |
15 | 16 | 17 | 18 |
生效权限
19 |
20 |
21 | @if (user == null) 22 | { 23 |

找不到用户信息

24 | } 25 | else 26 | { 27 |

@user.UserName 的权限如下:

28 | 29 |
30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | @{ 42 | var i = 1; 43 | } 44 | @foreach (var item in user.Permissions) 45 | { 46 | 47 | 48 | 49 | 50 | 51 | @if (@item.FromUser) 52 | { 53 | 54 | } 55 | else 56 | { 57 | 58 | } 59 | 60 | } 61 | 62 |
序号模块菜单权限来自
@(i++)@item.ModuleName@item.MenuName@item.PermissionName独立权限@item.RoleName
63 |
64 | } 65 |
66 |
67 |
68 |
69 |
70 | 71 | -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Views/Home/WhatCanIdo.cshtml: -------------------------------------------------------------------------------- 1 | @using NLayer.Infrastructure.Authorize.AuthObject 2 | 3 | @{ 4 | ViewBag.Title = "我的权限"; 5 | 6 | var user = ViewBag.CurrentUser as UserForAuthorize; 7 | } 8 | 9 |
10 | 11 |
12 |
13 |
14 |
15 | 16 | 17 | 18 |
我的权限
19 |
20 |
21 | @if (user == null) 22 | { 23 |

还没有登陆

24 | } 25 | else 26 | { 27 |

@user.UserName 你好!

28 |

你的权限如下:

29 | 30 |
31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | @{ 43 | var i = 1; 44 | } 45 | @foreach (var item in user.Permissions) 46 | { 47 | 48 | 49 | 50 | 51 | 52 | @if (@item.FromUser) 53 | { 54 | 55 | } 56 | else 57 | { 58 | 59 | } 60 | 61 | } 62 | 63 |
序号模块菜单权限来自
@(i++)@item.ModuleName@item.MenuName@item.PermissionName独立权限@item.RoleName
64 |
65 | } 66 |
67 |
68 |
69 |
70 |
71 | 72 | -------------------------------------------------------------------------------- /NLayer.Infrastructure/NLayer.Infrastructure.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {CEFB2502-74E9-4688-8B9E-DFF48DE1CC6A} 8 | Library 9 | Properties 10 | NLayer.Infrastructure 11 | NLayer.Infrastructure 12 | v4.5 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 60 | -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Areas/UserSystem/Views/User/EditUser.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewBag.Title = "用户管理"; 3 | var groupName = ViewBag.GroupName; 4 | var isEdit = Model.Id != Guid.Empty; 5 | } 6 | @model NLayer.Application.UserSystemModule.DTOs.UserDTO 7 |
8 |

用户管理

9 |
10 | 14 |
15 | 16 |
17 |
18 |
19 |
20 | 21 | 22 | 23 |
添加 / 编辑用户
24 |
25 |
26 | @using (Ajax.BeginForm("EditUser", new { id = Model.Id }, new AjaxOptions { HttpMethod = "Post", OnSuccess = "ajaxRequestSuccess" }, new { @class = "form-horizontal" })) 27 | { 28 |
29 | 30 |
31 | @Html.TextBoxFor(x => x.Name, new { placeholder = "名称" }) 32 |
33 |
34 |
35 | 36 |
37 | @Html.TextBoxFor(x => x.LoginName, new { placeholder = "用户的登录名" }) 38 |
39 |
40 |
41 | 42 |
43 | @Html.PasswordFor(x => x.LoginPwd, new { placeholder = "用户的登录密码" }) 44 |
45 |
46 |
47 | 48 |
49 | @Html.TextBoxFor(x => x.Email, new { placeholder = "用户的邮箱地址" }) 50 |
51 |
52 | 53 |
54 | 55 |
56 | } 57 |
58 |
59 |
60 |
61 |
-------------------------------------------------------------------------------- /NLayer.Repository/SpecificRepositoryBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Data.Entity; 4 | using System.Linq; 5 | using NLayer.Infrastructure.Entity; 6 | using NLayer.Infrastructure.Repository; 7 | using NLayer.Repository.UnitOfWork; 8 | 9 | namespace NLayer.Repository 10 | { 11 | public abstract class SpecificRepositoryBase : RepositoryBase 12 | where TEntity : EntityBase 13 | { 14 | protected SpecificRepositoryBase(INLayerUnitOfWork unitOfWork) 15 | : base(unitOfWork) 16 | { 17 | } 18 | 19 | private IDbSet _Table; 20 | 21 | protected IDbSet Table 22 | { 23 | get 24 | { 25 | if (_Table == null) 26 | { 27 | _Table = (UnitOfWork as INLayerUnitOfWork).CreateSet(); 28 | } 29 | return _Table; 30 | } 31 | } 32 | 33 | public void Dispose() 34 | { 35 | Dispose(true); 36 | GC.SuppressFinalize(this); 37 | } 38 | 39 | public override void SaveChanges() 40 | { 41 | ((INLayerUnitOfWork) UnitOfWork).DbContext.SaveChanges(); 42 | } 43 | 44 | public virtual void Dispose(bool isDisposing) 45 | { 46 | if (!isDisposing) 47 | { 48 | return; 49 | } 50 | 51 | if (UnitOfWork != null) 52 | { 53 | UnitOfWork.Dispose(); 54 | } 55 | } 56 | 57 | public override TEntity Get(object key) 58 | { 59 | return Table.Find(key); 60 | } 61 | 62 | public override void Merge(TEntity persisted, TEntity current) 63 | { 64 | ((INLayerUnitOfWork)UnitOfWork).ApplyCurrentValues(persisted, current); 65 | } 66 | 67 | public override IEnumerable FindAll() 68 | { 69 | return Table.ToList(); 70 | } 71 | 72 | public override void Add(TEntity item) 73 | { 74 | if (item == null) throw new ArgumentNullException("item"); 75 | Table.Add(item); 76 | } 77 | 78 | public override void Remove(TEntity item) 79 | { 80 | if (item == null) throw new ArgumentNullException("item"); 81 | Table.Remove(item); 82 | } 83 | 84 | public override bool Exists(TEntity item) 85 | { 86 | throw new NotImplementedException(); 87 | } 88 | 89 | public override TEntity Find(Func acquire) 90 | { 91 | return Table.FirstOrDefault(acquire); 92 | } 93 | 94 | public override IQueryable Collection 95 | { 96 | get { return Table.AsQueryable(); } 97 | } 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Content/jquery.gritter.css: -------------------------------------------------------------------------------- 1 | /* the norm */ 2 | #gritter-notice-wrapper { 3 | position:fixed; 4 | top:50px; 5 | right:10px; 6 | width:301px; 7 | z-index:989; 8 | } 9 | #gritter-notice-wrapper.top-left { 10 | left: 20px; 11 | right: auto; 12 | } 13 | #gritter-notice-wrapper.bottom-right { 14 | top: auto; 15 | left: auto; 16 | bottom: 20px; 17 | right: 20px; 18 | } 19 | #gritter-notice-wrapper.bottom-left { 20 | top: auto; 21 | right: auto; 22 | bottom: 20px; 23 | left: 20px; 24 | } 25 | .gritter-item-wrapper { 26 | position:relative; 27 | margin:0 0 10px 0; 28 | } 29 | 30 | .gritter-top, .gritter-bottom { 31 | height: 0; 32 | } 33 | 34 | .gritter-item { 35 | display:block; 36 | background: #545454; /* Old browsers */ 37 | background: -moz-linear-gradient(top, #545454 0%, #232323 100%); /* FF3.6+ */ 38 | background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#545454), color-stop(100%,#232323)); /* Chrome,Safari4+ */ 39 | background: -webkit-linear-gradient(top, #545454 0%,#232323 100%); /* Chrome10+,Safari5.1+ */ 40 | background: -o-linear-gradient(top, #545454 0%,#232323 100%); /* Opera 11.10+ */ 41 | background: -ms-linear-gradient(top, #545454 0%,#232323 100%); /* IE10+ */ 42 | background: linear-gradient(to bottom, #545454 0%,#232323 100%); /* W3C */ 43 | filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#545454', endColorstr='#232323',GradientType=0 ); /* IE6-9 */ 44 | border-radius: 6px; 45 | color:#eee; 46 | padding:7px 10px 10px; 47 | font-size: 11px; 48 | font-family:verdana; 49 | border: 1px solid #000000; 50 | box-shadow: 0 1px 4px #000000,0 1px 0 rgba(255,255,255,0.3) inset; 51 | } 52 | .hover .gritter-item { 53 | border: 1px solid #ffffff; 54 | } 55 | .gritter-item p { 56 | padding:0; 57 | margin:0; 58 | word-wrap:break-word; 59 | font-size: 10px; 60 | line-height: 14px; 61 | } 62 | .gritter-close { 63 | display:none; 64 | position:absolute; 65 | top:-5px; 66 | right:-5px; 67 | background:url(img/gritter.png) no-repeat left top; 68 | cursor:pointer; 69 | width:30px; 70 | height:30px; 71 | } 72 | .gritter-title { 73 | font-size:12px; 74 | font-weight:bold; 75 | padding:0 0 7px 0; 76 | display:block; 77 | text-shadow:0px -1px 0 #000; /* Not supported by IE :( */ 78 | } 79 | .gritter-image { 80 | width:32px; 81 | height:32px; 82 | float:left; 83 | margin: 5px; 84 | } 85 | .gritter-with-image, 86 | .gritter-without-image { 87 | padding:0; 88 | } 89 | .gritter-with-image { 90 | width:220px; 91 | float:right; 92 | } 93 | /* for the light (white) version of the gritter notice */ 94 | .gritter-light .gritter-item, 95 | .gritter-light .gritter-bottom, 96 | .gritter-light .gritter-top, 97 | .gritter-light .gritter-close { 98 | background-image: url(img/gritter-light.png); 99 | color: #222; 100 | } 101 | .gritter-light .gritter-title { 102 | text-shadow: none; 103 | } 104 | -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Resources/CommonResource.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.34209 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace NLayer.Presentation.WebHost.Resources { 12 | /// 13 | /// 一个强类型的资源类,用于查找本地化的字符串等。 14 | /// 15 | // 此类是由 StronglyTypedResourceBuilder 16 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 17 | // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen 18 | // (以 /str 作为命令选项),或重新生成 VS 项目。 19 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 20 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 21 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 22 | internal class CommonResource { 23 | 24 | private static global::System.Resources.ResourceManager resourceMan; 25 | 26 | private static global::System.Globalization.CultureInfo resourceCulture; 27 | 28 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 29 | internal CommonResource() { 30 | } 31 | 32 | /// 33 | /// 返回此类使用的缓存的 ResourceManager 实例。 34 | /// 35 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 36 | internal static global::System.Resources.ResourceManager ResourceManager { 37 | get { 38 | if (object.ReferenceEquals(resourceMan, null)) { 39 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("NLayer.Presentation.WebHost.Resources.CommonResource", typeof(CommonResource).Assembly); 40 | resourceMan = temp; 41 | } 42 | return resourceMan; 43 | } 44 | } 45 | 46 | /// 47 | /// 使用此强类型资源类,为所有资源查找 48 | /// 重写当前线程的 CurrentUICulture 属性。 49 | /// 50 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 51 | internal static global::System.Globalization.CultureInfo Culture { 52 | get { 53 | return resourceCulture; 54 | } 55 | set { 56 | resourceCulture = value; 57 | } 58 | } 59 | 60 | /// 61 | /// 查找类似 操作成功 的本地化字符串。 62 | /// 63 | internal static string Msg_Operate_Ok { 64 | get { 65 | return ResourceManager.GetString("Msg_Operate_Ok", resourceCulture); 66 | } 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /NLayer.Application/Resources/CommonResource.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.34209 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace NLayer.Application.Resources { 12 | using System; 13 | 14 | 15 | /// 16 | /// 一个强类型的资源类,用于查找本地化的字符串等。 17 | /// 18 | // 此类是由 StronglyTypedResourceBuilder 19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 20 | // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen 21 | // (以 /str 作为命令选项),或重新生成 VS 项目。 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class CommonResource { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal CommonResource() { 33 | } 34 | 35 | /// 36 | /// 返回此类使用的缓存的 ResourceManager 实例。 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("NLayer.Application.Resources.CommonResource", typeof(CommonResource).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// 使用此强类型资源类,为所有资源查找 51 | /// 重写当前线程的 CurrentUICulture 属性。 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// 查找类似 操作成功 的本地化字符串。 65 | /// 66 | internal static string Msg_Operate_Ok { 67 | get { 68 | return ResourceManager.GetString("Msg_Operate_Ok", resourceCulture); 69 | } 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /NLayer.Infrastructure.Utility/NLayer.Infrastructure.Utility.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {F4F08667-3FC3-4B94-8CAA-A66289270C21} 8 | Library 9 | Properties 10 | NLayer.Infrastructure.Utility 11 | NLayer.Infrastructure.Utility 12 | v4.5 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 61 | -------------------------------------------------------------------------------- /NLayer.Presentation.WebHost/Areas/UserSystem/Views/Menu/EditMenuPermission.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewBag.Title = "菜单管理"; 3 | var menuName = ViewBag.MenuName; 4 | var menuId = ViewBag.MenuId; 5 | } 6 | @model NLayer.Application.UserSystemModule.DTOs.PermissionDTO 7 |
8 |

菜单权限

9 |
10 | 16 |
17 | 18 |
19 |
20 |
21 |
22 | 23 | 24 | 25 |
添加 / 编辑权限
26 |
27 |
28 | @using (Ajax.BeginForm("EditMenuPermission", new { menuId = @menuId, id = Model.Id }, new AjaxOptions { HttpMethod = "Post", OnSuccess = "ajaxRequestSuccess" }, new { @class = "form-horizontal" })) 29 | { 30 |
31 | 32 |
33 | @Html.TextBoxFor(x => x.Name, new { placeholder = "名称" }) 34 |
35 |
36 |
37 | 38 |
39 | @Html.TextAreaFor(x => x.Code, new { placeholder = "菜单代码" }) 40 |
41 |
42 |
43 | 44 |
45 | @Html.TextBoxFor(x => x.ActionUrl, new { placeholder = "权限链接" }) 46 |
47 |
48 |
49 | 50 |
51 | @Html.TextBoxFor(x => x.SortOrder, new { placeholder = "排序" }) 52 |
53 |
54 | 55 |
56 | 57 |
58 | } 59 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------