@ -0,0 +1,30 @@ |
|||
# ABP dokumentace |
|||
|
|||
ABP je **open source aplikační framework** se zaměřením na vývoj webových aplikací založených na ASP.NET Core, zároveň ho však lze využít i k vývoji jiných typů aplikací. |
|||
|
|||
K procházení dokumentace využijte navigační nabídky vlevo. |
|||
|
|||
## Stav projektu |
|||
|
|||
ABP je **novou generací** open source frameworku [ASP.NET Boilerplate](https://aspnetboilerplate.com/). V současné době je v ranné fázi a není připraven k ostrému nasazení. Na dokumentaci se stále pracuje a ještě zdaleka není dokončena. |
|||
|
|||
Pro aplikace na krátkodobé a ostré nasazení je doporučeno použít [ASP.NET Boilerplate](https://aspnetboilerplate.com/) framework, který je bohatý na funkce, vyspělý, aktivně udržovaný a aktuální. |
|||
|
|||
## Začínáme |
|||
|
|||
Nejsnazší cestou jak začít nový projekt s ABP je užití startovací šablony: |
|||
|
|||
* [ASP.NET Core MVC Šablona](Getting-Started-AspNetCore-MVC-Template.md) |
|||
|
|||
Pokud chcete začít od nuly (s prázdným projektem) tak manuálně nainstalujte ABP Framework s pomocí následujících tutoriálů: |
|||
|
|||
* [Konzolová Aplikace](Getting-Started-Console-Application.md) |
|||
* [ASP.NET Core Web Aplikace](Getting-Started-AspNetCore-Application.md) |
|||
|
|||
## Zdrojový kód |
|||
|
|||
ABP je hostovaný na GitHub. Zobrazit [zdrojový kód](https://github.com/abpframework/abp). |
|||
|
|||
## Chcete přispět? |
|||
|
|||
ABP je komunitně řízený open source projekt. Podívejte se na [průvodce pro přispěvatele](Contribution/Index.md) pokud chcete být součástí tohoto projektu. |
|||
@ -0,0 +1,292 @@ |
|||
{ |
|||
"items": [ |
|||
{ |
|||
"text": "Začínáme", |
|||
"items": [ |
|||
{ |
|||
"text": "Ze startovacích šablon", |
|||
"items": [ |
|||
{ |
|||
"text": "ASP.NET Core MVC", |
|||
"path": "Getting-Started-AspNetCore-MVC-Template.md" |
|||
} |
|||
] |
|||
}, |
|||
{ |
|||
"text": "Z prázdných projektů", |
|||
"items": [ |
|||
{ |
|||
"text": "S ASP.NET Core Web aplikací", |
|||
"path": "Getting-Started-AspNetCore-Application.md" |
|||
}, |
|||
{ |
|||
"text": "S konzolovou aplikací", |
|||
"path": "Getting-Started-Console-Application.md" |
|||
} |
|||
] |
|||
} |
|||
] |
|||
}, |
|||
{ |
|||
"text": "Tutoriály", |
|||
"items": [ |
|||
{ |
|||
"text": "Vývoj aplikace", |
|||
"items": [ |
|||
{ |
|||
"text": "S ASP.NET Core MVC", |
|||
"path": "Tutorials/AspNetCore-Mvc/Part-I.md" |
|||
} |
|||
] |
|||
} |
|||
] |
|||
}, |
|||
{ |
|||
"text": "CLI", |
|||
"path": "CLI.md" |
|||
}, |
|||
{ |
|||
"text": "Základy", |
|||
"items": [ |
|||
{ |
|||
"text": "Vkládání závislostí", |
|||
"path": "Dependency-Injection.md", |
|||
"items": [ |
|||
{ |
|||
"text": "AutoFac integrace", |
|||
"path": "Autofac-Integration.md" |
|||
} |
|||
] |
|||
}, |
|||
{ |
|||
"text": "Virtuální systém souborů", |
|||
"path": "Virtual-File-System.md" |
|||
}, |
|||
{ |
|||
"text": "Lokalizace", |
|||
"path": "Localization.md" |
|||
}, |
|||
{ |
|||
"text": "Zpracování výjimek", |
|||
"path": "Exception-Handling.md" |
|||
}, |
|||
{ |
|||
"text": "Validace" |
|||
}, |
|||
{ |
|||
"text": "Autorizace" |
|||
}, |
|||
{ |
|||
"text": "Ukládání do mezipaměti" |
|||
}, |
|||
{ |
|||
"text": "Audit" |
|||
}, |
|||
{ |
|||
"text": "Správa nastavení" |
|||
} |
|||
] |
|||
}, |
|||
{ |
|||
"text": "Události", |
|||
"items": [ |
|||
{ |
|||
"text": "Event bus (místní)" |
|||
}, |
|||
{ |
|||
"text": "Distribuovaný event bus", |
|||
"items": [ |
|||
{ |
|||
"text": "RabbitMQ integrace" |
|||
} |
|||
] |
|||
} |
|||
] |
|||
}, |
|||
{ |
|||
"text": "Služby", |
|||
"items": [ |
|||
{ |
|||
"text": "Serializace objektu" |
|||
}, |
|||
{ |
|||
"text": "Serializace JSON" |
|||
}, |
|||
{ |
|||
"text": "Emailování" |
|||
}, |
|||
{ |
|||
"text": "GUIDy" |
|||
}, |
|||
{ |
|||
"text": "Vláknování" |
|||
}, |
|||
{ |
|||
"text": "Časování" |
|||
} |
|||
] |
|||
}, |
|||
{ |
|||
"text": "Multitenance", |
|||
"path": "Multi-Tenancy.md" |
|||
}, |
|||
{ |
|||
"text": "Vývoj modulů", |
|||
"items": [ |
|||
{ |
|||
"text": "Základy", |
|||
"path": "Module-Development-Basics.md" |
|||
}, |
|||
{ |
|||
"text": "Zásuvné moduly" |
|||
}, |
|||
{ |
|||
"text": "Nejlepší praktiky", |
|||
"path": "Best-Practices/Index.md" |
|||
} |
|||
] |
|||
}, |
|||
{ |
|||
"text": "Domain driven design", |
|||
"path": "Domain-Driven-Design.md", |
|||
"items": [ |
|||
{ |
|||
"text": "Doménová vrstva", |
|||
"items": [ |
|||
{ |
|||
"text": "Entity & agregované kořeny", |
|||
"path": "Entities.md" |
|||
}, |
|||
{ |
|||
"text": "Hodnotové objekty" |
|||
}, |
|||
{ |
|||
"text": "Repozitáře", |
|||
"path": "Repositories.md" |
|||
}, |
|||
{ |
|||
"text": "Doménové služby" |
|||
}, |
|||
{ |
|||
"text": "Specifikace" |
|||
} |
|||
] |
|||
}, |
|||
{ |
|||
"text": "Aplikační vrstva", |
|||
"items": [ |
|||
{ |
|||
"text": "Aplikační služby", |
|||
"path": "Application-Services.md" |
|||
}, |
|||
{ |
|||
"text": "Objekty přenosu dat" |
|||
}, |
|||
{ |
|||
"text": "Jednotka práce" |
|||
} |
|||
] |
|||
} |
|||
] |
|||
}, |
|||
{ |
|||
"text": "ASP.NET Core", |
|||
"items": [ |
|||
{ |
|||
"text": "API", |
|||
"items": [ |
|||
{ |
|||
"text": "Automatické API řadiče", |
|||
"path": "AspNetCore/Auto-API-Controllers.md" |
|||
}, |
|||
{ |
|||
"text": "Dynamičtí C# API klienti", |
|||
"path": "AspNetCore/Dynamic-CSharp-API-Clients.md" |
|||
} |
|||
] |
|||
}, |
|||
{ |
|||
"text": "Uživatelské rozhraní", |
|||
"items": [ |
|||
{ |
|||
"text": "Správa klientských balíčků", |
|||
"path": "AspNetCore/Client-Side-Package-Management.md" |
|||
}, |
|||
{ |
|||
"text": "Svazování & minifikace", |
|||
"path": "AspNetCore/Bundling-Minification.md" |
|||
}, |
|||
{ |
|||
"text": "Tag pomocníci", |
|||
"path": "Tag-Helpers.md" |
|||
}, |
|||
{ |
|||
"text": "Motivy", |
|||
"path": "AspNetCore/Theming.md" |
|||
} |
|||
] |
|||
} |
|||
] |
|||
}, |
|||
{ |
|||
"text": "Přístup k datům", |
|||
"items": [ |
|||
{ |
|||
"text": "Entity Framework Core integrace", |
|||
"path": "Entity-Framework-Core.md" |
|||
}, |
|||
{ |
|||
"text": "MongoDB integrace", |
|||
"path": "MongoDB.md" |
|||
} |
|||
] |
|||
}, |
|||
{ |
|||
"text": "Pozadí", |
|||
"items": [ |
|||
{ |
|||
"text": "Úkony na pozadí", |
|||
"path": "Background-Jobs.md", |
|||
"items": [ |
|||
{ |
|||
"text": "Hangfire integrace", |
|||
"path": "Background-Jobs-Hangfire.md" |
|||
}, |
|||
{ |
|||
"text": "RabbitMQ integrace", |
|||
"path": "Background-Jobs-RabbitMq.md" |
|||
} |
|||
] |
|||
} |
|||
] |
|||
}, |
|||
{ |
|||
"text": "Vzorky", |
|||
"items": [ |
|||
{ |
|||
"text": "Mikroslužby demo", |
|||
"path": "Samples/Microservice-Demo.md" |
|||
} |
|||
] |
|||
}, |
|||
{ |
|||
"text": "Moduly aplikace", |
|||
"path": "Modules/Index.md" |
|||
}, |
|||
{ |
|||
"text": "Architektura mikroslužby", |
|||
"path": "Microservice-Architecture.md" |
|||
}, |
|||
{ |
|||
"text": "Testování" |
|||
}, |
|||
{ |
|||
"text": "Noční sestavení", |
|||
"path": "Nightly-Builds.md" |
|||
}, |
|||
{ |
|||
"text": "Průvodce pro přispěvatele", |
|||
"path": "Contribution/Index.md" |
|||
} |
|||
] |
|||
} |
|||
@ -0,0 +1,19 @@ |
|||
{ |
|||
"Languages":[ |
|||
{ |
|||
"DisplayName" : "Čeština", |
|||
"Code" : "cs", |
|||
"IsDefault": false |
|||
}, |
|||
{ |
|||
"DisplayName" : "English", |
|||
"Code" : "en", |
|||
"IsDefault": true |
|||
}, |
|||
{ |
|||
"DisplayName" : "简体中文", |
|||
"Code" : "zh-Hans", |
|||
"IsDefault": false |
|||
} |
|||
] |
|||
} |
|||
@ -1,3 +0,0 @@ |
|||
# Tag Helpers |
|||
|
|||
TODO |
|||
@ -0,0 +1,3 @@ |
|||
## Dynamic Forms |
|||
|
|||
This is not documented yet. You can see a [demo](http://bootstrap-taghelpers.abp.io/Components/DynamicForms) for now. |
|||
@ -0,0 +1,3 @@ |
|||
## Dynamic Proxying / Interceptors |
|||
|
|||
TODO |
|||
@ -0,0 +1,137 @@ |
|||
# ABP CLI |
|||
|
|||
ABP CLI (Command Line Interface) is a command line tool to perform some common operations for ABP based solutions. |
|||
|
|||
## Installation |
|||
|
|||
ABP CLI is a [dotnet global tool](https://docs.microsoft.com/en-us/dotnet/core/tools/global-tools). Install it using a command line window: |
|||
|
|||
````bash |
|||
dotnet tool install -g Volo.Abp.Cli |
|||
```` |
|||
|
|||
To update an existing installation: |
|||
|
|||
````bash |
|||
dotnet tool update -g Volo.Abp.Cli |
|||
```` |
|||
|
|||
## Commands |
|||
|
|||
### new |
|||
|
|||
Generates a new solution based on the ABP [startup templates](Startup-Templates/Index.md). |
|||
|
|||
Basic usage: |
|||
|
|||
````bash |
|||
abp new <solution-name> [options] |
|||
```` |
|||
|
|||
Example: |
|||
|
|||
````bash |
|||
abp new Acme.BookStore |
|||
```` |
|||
|
|||
* Acme.BookStore is the solution name here. |
|||
* Common convention is to name a solution is like *YourCompany.YourProject*. However, you can use different naming like *YourProject* (single level namespacing) or *YourCompany.YourProduct.YourModule* (three levels namespacing). |
|||
|
|||
#### Options |
|||
|
|||
* `--template` or `-t`: Specifies the template name. Default template name is `mvc`. Available templates: |
|||
* `mvc` (default): ASP.NET Core [MVC application template](Startup-Templates/Mvc.md). Additional options: |
|||
* `--database-provider` or `-d`: Specifies the database provider. Default provider is `ef`. Available providers: |
|||
* `ef`: Entity Framework Core. |
|||
* `mongodb`: MongoDB. |
|||
* `--tiered`: Creates a tiered solution where Web and Http API layers are physically separated. If not specified, it creates a layered solution which is less complex and suitable for most scenarios. |
|||
* `mvc-module`: ASP.NET Core [MVC module template](Startup-Templates/Mvc-Module.md). Additional options: |
|||
* `--no-ui`: Specifies to not include the UI. This makes possible to create service-only modules (a.k.a. microservices - without UI). |
|||
* `--output-folder` or `-o`: Specifies the output folder. Default value is the current directory. |
|||
|
|||
### add-package |
|||
|
|||
Adds a new ABP package to a project by, |
|||
|
|||
* Adding related nuget package as a dependency to the project. |
|||
* Adding `[DependsOn(...)]` attribute to the module class in the project (see the [module development document](Module-Development-Basics.md)). |
|||
|
|||
> Notice that the added module may require additional configuration which is generally indicated in the documentation of the related package. |
|||
|
|||
Basic usage: |
|||
|
|||
````bash |
|||
abp add-package <package-name> [options] |
|||
```` |
|||
|
|||
Example: |
|||
|
|||
```` |
|||
abp add-package Volo.Abp.MongoDB |
|||
```` |
|||
|
|||
* This example adds the Volo.Abp.MongoDB package to the project. |
|||
|
|||
#### Options |
|||
|
|||
* `--project` or `-p`: Specifies the project (.csproj) file path. If not specified, CLI tries to find a .csproj file in the current directory. |
|||
|
|||
### add-module |
|||
|
|||
Adds a multi-package module to a solution by finding all packages of the module, finding related projects in the solution and adding each package to the corresponding project in the solution. |
|||
|
|||
> A business module generally consists of several packages (because of layering, different database providr options or other reasons). Using `add-module` command dramatically simplifies adding a module to a solution. However, each module may require some additional configurations which is generally indicated in the documentation of the related module. |
|||
|
|||
Basic usage: |
|||
|
|||
````bash |
|||
abp add-module <module-name> [options] |
|||
```` |
|||
|
|||
Example: |
|||
|
|||
```bash |
|||
abp add-module Volo.Blogging |
|||
``` |
|||
|
|||
* This example add the Volo.Blogging module to the solution. |
|||
|
|||
#### Options |
|||
|
|||
* `--solution` or `-s`: Specifies the solution (.sln) file path. If not specified, CLI tries to find a .sln file in the current directory. |
|||
* `--skip-db-migrations`: For EF Core database provider, it automatically adds a new code first migration (`Add-Migration`) and updates the database (`Update-Database`) if necessary. Specify this option to skip this operation. |
|||
|
|||
### update |
|||
|
|||
Updating all ABP related packages can be tedious since there are many packages of the framework and modules. This command automatically updates all ABP related packages in a solution or project to the latest versions. |
|||
|
|||
Usage: |
|||
|
|||
````bash |
|||
abp update [options] |
|||
```` |
|||
|
|||
* If you run in a directory with a .sln file, it updates all ABP related packages of the all projects of the solution to the latest versions. |
|||
* If you run in a directory with a .csproj file, it updates all ABP related packages of the project to the latest versions. |
|||
|
|||
#### Options |
|||
|
|||
* `--include-previews` or `-p`: Includes preview, beta and rc packages while checking the latest versions. |
|||
|
|||
### help |
|||
|
|||
Writes basic usage information of the CLI. |
|||
|
|||
Usage: |
|||
|
|||
````bash |
|||
abp help [command-name] |
|||
```` |
|||
|
|||
Examples: |
|||
|
|||
````bash |
|||
abp help # Shows a general help. |
|||
abp help new # Shows help about the "new" command. |
|||
```` |
|||
|
|||
@ -0,0 +1,3 @@ |
|||
# Caching |
|||
|
|||
TODO |
|||
@ -0,0 +1,3 @@ |
|||
# Correlation ID |
|||
|
|||
TODO |
|||
@ -0,0 +1,3 @@ |
|||
# Data Filtering |
|||
|
|||
TODO |
|||
@ -0,0 +1,3 @@ |
|||
# Data Seeding |
|||
|
|||
TODO |
|||
@ -0,0 +1,3 @@ |
|||
# Distributed Event Bus |
|||
|
|||
TODO |
|||
@ -0,0 +1,3 @@ |
|||
# Extension Methods & Helpers |
|||
|
|||
TODO |
|||
@ -0,0 +1,3 @@ |
|||
# Integration Tests |
|||
|
|||
TODO! |
|||
@ -0,0 +1,3 @@ |
|||
## Dynamic JavaScript API Clients |
|||
|
|||
TODO |
|||
@ -0,0 +1,3 @@ |
|||
# Local Event Bus |
|||
|
|||
TODO |
|||
@ -0,0 +1,3 @@ |
|||
# Emailing |
|||
|
|||
TODO! |
|||
@ -0,0 +1,3 @@ |
|||
# Settings |
|||
|
|||
TODO! |
|||
@ -0,0 +1,3 @@ |
|||
# Specifications |
|||
|
|||
TODO! |
|||
@ -0,0 +1,11 @@ |
|||
# Startup Templates |
|||
|
|||
While you can start with an empty project and add needed packages manually, startup templates makes easy and comfortable to start a new solution with the ABP framework. |
|||
|
|||
Click to the name from the list below to see the documentation of the related startup template: |
|||
|
|||
* [**mvc**](Mvc.md): ASP.NET Core MVC application template. |
|||
* [**mvc-module**](Mvc-Module.md): ASP.NET Core MVC module/service template. |
|||
|
|||
|
|||
|
|||
@ -0,0 +1,160 @@ |
|||
# MVC Module Startup Template |
|||
|
|||
This template can be used to create a **reusable [application module](../Modules/Index.md)** based on the [module development best practices & conventions](../Best-Practices/Index.md). It is also suitable for creating **microservices** (with or without UI). |
|||
|
|||
## How to Start With? |
|||
|
|||
You can use the [ABP CLI](../CLI.md) to create a new project using this startup template. Alternatively, you can directly create & download from the [Get Started](https://abp.io/get-started) page. CLI approach is used here. |
|||
|
|||
First, install the ABP CLI if you haven't installed before: |
|||
|
|||
```bash |
|||
dotnet tool install -g Volo.Abp.Cli |
|||
``` |
|||
|
|||
Then use the `abp new` command in an empty folder to create a new solution: |
|||
|
|||
```bash |
|||
abp new Acme.IssueManagement -t mvc-module |
|||
``` |
|||
|
|||
- `Acme.IssueManagement` is the solution name, like *YourCompany.YourProduct*. You can use single level, two-levels or three-levels naming. |
|||
|
|||
### Without User Interface |
|||
|
|||
The template comes with a UI by default. You can use `--no-ui` option to not include the UI layer. |
|||
|
|||
````bash |
|||
abp new Acme.IssueManagement -t mvc-module --no-ui |
|||
```` |
|||
|
|||
## Solution Structure |
|||
|
|||
Based on the options you've specified, you will get a slightly different solution structure. If you don't specify any option, you will have a solution like shown below: |
|||
|
|||
 |
|||
|
|||
Projects are organized as `src`, `test` and `host` folders: |
|||
|
|||
* `src` folder contains the actual module which is layered based on [DDD](../Domain-Driven-Design.md) principles. |
|||
* `test` folder contains unit & integration tests. |
|||
* `host` folder contains applications with different configurations to demonstrate how to host the module in an application. These are not a part of the module, but useful on development. |
|||
|
|||
The diagram below shows the layers & project dependencies of the module: |
|||
|
|||
 |
|||
|
|||
Each section below will explain the related project & its dependencies. |
|||
|
|||
### .Domain.Shared Project |
|||
|
|||
This project contains constants, enums and other objects these are actually a part of the domain layer, but needed to be used by all layers/projects in the solution. |
|||
|
|||
An `IssueType` enum and an `IssueConts` class (which may have some constant fields for the `Issue` entity, like `MaxTitleLength`) are good candidates for this project. |
|||
|
|||
- This project has no dependency to other projects in the solution. All other projects depend on this directly or indirectly. |
|||
|
|||
### .Domain Project |
|||
|
|||
This is the domain layer of the solution. It mainly contains [entities, aggregate roots](../Entities.md), [domain services](../Domain-Services.md), [value types](../Value-Types.md), [repository interfaces](../Repositories.md) and other domain objects. |
|||
|
|||
An `Issue` entity, an `IssueManager` domain service and an `IIssueRepository` interface are good candidates for this project. |
|||
|
|||
- Depends on the `.Domain.Shared` because it uses constants, enums and other objects defined in that project. |
|||
|
|||
### .Application.Contracts Project |
|||
|
|||
This project mainly contains [application service](../Application-Services.md) **interfaces** and [Data Transfer Objects](../Data-Transfer-Objects.md) (DTO) of the application layer. It does exists to separate interface & implementation of the application layer. In this way, the interface project can be shared to the clients as a contract package. |
|||
|
|||
An `IIssueAppService` interface and an `IssueCreationDto` class are good candidates for this project. |
|||
|
|||
- Depends on the `.Domain.Shared` because it may use constants, enums and other shared objects of this project in the application service interfaces and DTOs. |
|||
|
|||
### .Application Project |
|||
|
|||
This project contains the [application service](../Application-Services.md) **implementations** of the interfaces defined in the `.Application.Contracts` project. |
|||
|
|||
An `IssueAppService` class is a good candidate for this project. |
|||
|
|||
- Depends on the `.Application.Contracts` project to be able to implement the interfaces and use the DTOs. |
|||
- Depends on the `.Domain` project to be able to use domain objects (entities, repository interfaces... etc.) to perform the application logic. |
|||
|
|||
### .EntityFrameworkCore Project |
|||
|
|||
This is the integration project for EF Core. It defines the `DbContext` and implements repository interfaces defined in the `.Domain` project. |
|||
|
|||
- Depends on the `.Domain` project to be able to reference to entities and repository interfaces. |
|||
|
|||
> You can delete this project if you don't want to support EF Core for your module. |
|||
|
|||
### .MongoDB Project |
|||
|
|||
This is the integration project for MongoDB. |
|||
|
|||
- Depends on the `.Domain` project to be able to reference to entities and repository interfaces. |
|||
|
|||
> You can delete this project if you don't want to support MongoDB for your module. |
|||
|
|||
### Test Projects |
|||
|
|||
The solution has multiple test projects, one for each layer: |
|||
|
|||
- `.Domain.Tests` is used to test the domain layer. |
|||
- `.Application.Tests` is used to test the application layer. |
|||
- `.EntityFrameworkCore.Tests` is used to test EF Core configuration and custom repositories. |
|||
- `.MongoDB.Tests` is used to test EF Core configuration and custom repositories. |
|||
- `.TestBase` is a base (shared) project for all tests. |
|||
|
|||
In addition, `.HttpApi.Client.ConsoleTestApp` is a console application (not an automated test project) which demonstrate the usage of HTTP APIs from a Dotnet application. |
|||
|
|||
Test projects are prepared for integration testing; |
|||
|
|||
- It is fully integrated to ABP framework and all services in your application. |
|||
- It uses SQLite in-memory database for EF Core. For MongoDB, it uses the [Mongo2Go](https://github.com/Mongo2Go/Mongo2Go) library. |
|||
- Authorization is disabled, so any application service can be easily used in tests. |
|||
|
|||
You can still create unit tests for your classes which will be harder to write (because you will need to prepare mock/fake objects), but faster to run (because it only tests a single class and skips all initialization process). |
|||
|
|||
> Domain & Application tests are using EF Core. If you remove EF Core integration or you want to use MongoDB for testing these layers, you should manually change project references & module dependencies. |
|||
|
|||
### Host Projects |
|||
|
|||
The solution has a few host applications to run your module on development. Host applications are used to run your module in a fully configured application. It is useful on development. Host applications includes some other modules in addition to the module being developed: |
|||
|
|||
* |
|||
|
|||
Host applications support two types of scenarios. |
|||
|
|||
#### Single (Unified) Application Scenario |
|||
|
|||
If your module has a UI, then `.Web.Unified` application is used to host the UI and API on a single point. It has its own `appsettings.json` file (that includes the database connection string) and EF Core database migrations. |
|||
|
|||
For the `.Web.Unified` application, there is a single database, named `YourProjectName_Unified` (like *IssueManagement_Unified* for this sample). |
|||
|
|||
> If you've selected the `--no-ui` option, this project will not be in your solution. |
|||
|
|||
##### How to Run? |
|||
|
|||
Set it as the startup project, run `Update-Database` command for the EF Core from Package Manager Console and run your application. Default username is `admin` and password is `1q2w3E*`. |
|||
|
|||
#### Separated Deployment & Databases Scenario |
|||
|
|||
In this scenario, there are three applications; |
|||
|
|||
* `.IdentityServer` application is an authentication server used by other applications. It has its own `appsettings.json` that contains database connection and other configurations. |
|||
* `.HttpApi.Host` hosts the HTTP API of the module. It has its own `appsettings.json` that contains database connections and other configurations. |
|||
* `.Web.Host` host the UI of the module. This project contains an `appsettings.json` file, but it does not have a connection string because it never connects to the database. Instead, it mainly contains endpoint of the remote API server and the authentication server. |
|||
|
|||
The diagram below shows the relation of the applications: |
|||
|
|||
 |
|||
|
|||
`.Web.Host` project uses OpenId Connect Authentication to get identity and access tokens for the current user from the `.IdentityServer`. Then uses the access token to call the `.HttpApi.Host`. HTTP API server uses bearer token authentication to obtain claims from the access token to authorize the current user. |
|||
|
|||
##### How to Run? |
|||
|
|||
You should run the application with the given order: |
|||
|
|||
- First, run the `.IdentityServer` since other applications depends on it. |
|||
- Then run the `.HttpApi.Host` since it is used by the `.Web.Host` application. |
|||
- Finally, you can run the `.Web.Host` project and login to the application using `admin` as the username and `1q2w3E*` as the password. |
|||
@ -0,0 +1,260 @@ |
|||
# MVC Application Startup Template |
|||
|
|||
## Introduction |
|||
|
|||
This template provides a layered (or tiered, based on the preference) application structure based on the [Domain Driven Design](../Domain-Driven-Design.md) (DDD) practices. |
|||
|
|||
This document explains the solution structure and projects in details. |
|||
|
|||
* See [Getting Started With the ASP.NET Core MVC Template](../Getting-Started-AspNetCore-MVC-Template.md) to create a new solution and run it for this template. |
|||
* See the [ASP.NET Core MVC Tutorial](../Tutorials/AspNetCore-Mvc/Part-I.md) to learn how to develop applications using this template. |
|||
|
|||
## How to Start With? |
|||
|
|||
You can use the [ABP CLI](../CLI.md) to create a new project using this startup template. Alternatively, you can directly create & download from the [Get Started](https://abp.io/get-started) page. CLI approach is used here. |
|||
|
|||
First, install the ABP CLI if you haven't installed before: |
|||
|
|||
````bash |
|||
dotnet tool install -g Volo.Abp.Cli |
|||
```` |
|||
|
|||
Then use the `abp new` command in an empty folder to create a new solution: |
|||
|
|||
````bash |
|||
abp new Acme.BookStore -t mvc |
|||
```` |
|||
|
|||
* `Acme.BookStore` is the solution name, like *YourCompany.YourProduct*. You can use single level, two-levels or three-levels naming. |
|||
* This example specified the template name (`-t` or `--template` option). However, `mvc` is already the default template if you don't specify it. |
|||
|
|||
### Specify the Database Provider |
|||
|
|||
This template supports the following database providers: |
|||
|
|||
- `ef`: Entity Framework Core (default) |
|||
- `mongodb`: MongoDB |
|||
|
|||
Use `-d` (or `--database-provider`) option to specify the database provider: |
|||
|
|||
````bash |
|||
abp new Acme.BookStore -d mongodb |
|||
```` |
|||
|
|||
### Create a Tiered Solution |
|||
|
|||
`--tiered` option is used to create a tiered solution where Web and Http API layers are physically separated. If not specified, it creates a layered solution which is less complex and suitable for most scenarios. |
|||
|
|||
````bash |
|||
abp new Acme.BookStore --tiered |
|||
```` |
|||
|
|||
See the "Tiered Structure" section below for the tiered approach. |
|||
|
|||
## Solution Structure |
|||
|
|||
Based on the options you've specified, you will get a slightly different solution structure. |
|||
|
|||
### Default Structure |
|||
|
|||
If you don't specify any option, you will have a solution like shown below: |
|||
|
|||
 |
|||
|
|||
Projects are organized in `src` and `test` folders. `src` folder contains the actual application which is layered based on [DDD](../Domain-Driven-Design.md) principles as mentioned before. |
|||
|
|||
The diagram below shows the layers & project dependencies of the application: |
|||
|
|||
 |
|||
|
|||
Each section below will explain the related project & its dependencies. |
|||
|
|||
#### .Domain.Shared Project |
|||
|
|||
This project contains constants, enums and other objects these are actually a part of the domain layer, but needed to be used by all layers/projects in the solution. |
|||
|
|||
A `BookType` enum and a `BookConts` class (which may have some constant fields for the `Book` entity, like `MaxNameLength`) are good candidates for this project. |
|||
|
|||
* This project has no dependency to other projects in the solution. All other projects depend on this directly or indirectly. |
|||
|
|||
#### .Domain Project |
|||
|
|||
This is the domain layer of the solution. It mainly contains [entities, aggregate roots](../Entities.md), [domain services](../Domain-Services.md), [value types](../Value-Types.md), [repository interfaces](../Repositories.md) and other domain objects. |
|||
|
|||
A `Book` entity, a `BookManager` domain service and an `IBookRepository` interface are good candidates for this project. |
|||
|
|||
* Depends on the `.Domain.Shared` because it uses constants, enums and other objects defined in that project. |
|||
|
|||
#### .Application.Contracts Project |
|||
|
|||
This project mainly contains [application service](../Application-Services.md) **interfaces** and [Data Transfer Objects](../Data-Transfer-Objects.md) (DTO) of the application layer. It does exists to separate interface & implementation of the application layer. In this way, the interface project can be shared to the clients as a contract package. |
|||
|
|||
An `IBookAppService` interface and a `BookCreationDto` class are good candidates for this project. |
|||
|
|||
* Depends on the `.Domain.Shared` because it may use constants, enums and other shared objects of this project in the application service interfaces and DTOs. |
|||
|
|||
#### .Application Project |
|||
|
|||
This project contains the [application service](../Application-Services.md) **implementations** of the interfaces defined in the `.Application.Contracts` project. |
|||
|
|||
A `BookAppService` class is a good candidate for this project. |
|||
|
|||
* Depends on the `.Application.Contracts` project to be able to implement the interfaces and use the DTOs. |
|||
* Depends on the `.Domain` project to be able to use domain objects (entities, repository interfaces... etc.) to perform the application logic. |
|||
|
|||
#### .EntityFrameworkCore Project |
|||
|
|||
This is the integration project for the EF Core. It defines the `DbContext` and implements repository interfaces defined in the `.Domain` project. |
|||
|
|||
* Depends on the `.Domain` project to be able to reference to entities and repository interfaces. |
|||
|
|||
> This project is available only if you are using EF Core as the database provider. If you select another database provider, its name will be different. |
|||
|
|||
#### .EntityFrameworkCore.DbMigrations Project |
|||
|
|||
Contains EF Core database migrations for the solution. It has a separated `DbContext` to dedicated to manage migrations. |
|||
|
|||
ABP is a modular framework and with an ideal design, each module has its own `DbContext` class. This is where the migration `DbContext` comes into play and unifies all `DbContext` configurations into a single model to maintain a single database schema. For more advanced scenarios, you can have multiple databases (each contains a single or a few module tables) and multiple migration `DbContext`s (each maintains a different database schema). |
|||
|
|||
Notice that the migration `DbContext` is only used for database migrations and *not used on runtime*. |
|||
|
|||
* Depends on the `.EntityFrameworkCore` project since it re-uses the configuration defined for the `DbContext` of the application. |
|||
|
|||
> This project is available only if you are using EF Core as the database provider. |
|||
|
|||
#### .DbMigrator Project |
|||
|
|||
This is a console application which simplifies to execute database migrations on development and production environments. When you run this application, it; |
|||
|
|||
* Creates the database if necessary. |
|||
* Applies the pending database migrations. |
|||
* Seeds initial data if needed. |
|||
|
|||
> This project has its own `appsettings.json` file. So, if you want to change the database connection string, remember to change this file too. |
|||
|
|||
Especially, seeding initial data is important at this point. ABP has a modular data seed infrastructure. See [its documentation](../Data-Seeding.md) for more about the data seeding. |
|||
|
|||
While creating database & applying migrations seems only necessary for relational databases, this projects comes even if you choose a NoSQL database provider (like MongoDB). In that case, it still seeds initial data which is necessary for the application. |
|||
|
|||
* Depends on the `.EntityFrameworkCore.DbMigrations` project (for EF Core) since it needs to access to the migrations. |
|||
* Depends on the `.Application.Contracts` project to be able to access permission definitions, because initial data seeder grants all permissions for the admin role by default. |
|||
|
|||
#### .HttpApi Project |
|||
|
|||
This project is used to define your API Controllers. |
|||
|
|||
Most of time you don't need to manually define API Controllers since ABP's [Auto API Controllers](../AspNetCore/Auto-API-Controllers.md) feature creates them automagically based on your application layer. However, in case of you need to write API controllers, this is the best place to do it. |
|||
|
|||
* Depends on the `.Application.Contracts` project to be able to inject the application service interfaces. |
|||
|
|||
#### .HttpApi.Client Project |
|||
|
|||
This is a project that defines C# client proxies to use the HTTP APIs of the solution. You can share this library to 3rd-party clients, so they can easily consume your HTTP APIs in their Dotnet applications (For other type of applications, they can still use your APIs, either manually or using a tool in their own platform) |
|||
|
|||
Most of time you don't need to manually create C# client proxies, thanks to ABP's [Dynamic C# API Clients](../AspNetCore/Dynamic-CSharp-API-Clients.md) feature. |
|||
|
|||
`.HttpApi.Client.ConsoleTestApp` project is a console application created to demonstrate the usage of the client proxies. |
|||
|
|||
* Depends on the `.Application.Contracts` project to be able to share the same application service interfaces and DTOs with the remote service. |
|||
|
|||
> You can delete this project & dependencies if you don't need to create C# client proxies for your APIs. |
|||
|
|||
#### .Web Project |
|||
|
|||
This project contains the User Interface (UI) of the application. It contains razor pages, JavaScript files, style files, images and so on... |
|||
|
|||
This project contains the main `appsettings.json` file that contains the connection string and other configuration of the application. |
|||
|
|||
* Depends on the `.HttpApi` since UI layer needs to use APIs and application service interfaces of the solution. |
|||
|
|||
> If you check the source code of the `.Web.csproj` file, you will see the references to the `.Application` and the `.EntityFrameworkCore.DbMigrations` projects. |
|||
> |
|||
> These references are actually not needed while coding your UI layer, because UI layer normally doesn't depend on the EF Core or the Application layer's implementation. This startup templates are ready for the tiered deployment, where API layer is hosted in a separate server than the UI layer. |
|||
> |
|||
> However, if you don't choose the `--tiered` option, these references will be in the .Web project to be able to host the Web, API and application layers in a single application endpoint. |
|||
> |
|||
> This gives you to ability to use domain entities & repositories in your presentation layer. However, this is considered as a bad practice according to the DDD. |
|||
|
|||
#### Test Projects |
|||
|
|||
The solution has multiple test projects, one for each layer: |
|||
|
|||
* `.Domain.Tests` is used to test the domain layer. |
|||
* `.Application.Tests` is used to test the application layer. |
|||
* `.EntityFrameworkCore.Tests` is used to test EF Core configuration and custom repositories. |
|||
* `.Web.Tests` is used to test the UI. |
|||
* `.TestBase` is a base (shared) project for all tests. |
|||
|
|||
In addition, `.HttpApi.Client.ConsoleTestApp` is a console application (not an automated test project) which demonstrate the usage of HTTP APIs from a Dotnet application. |
|||
|
|||
Test projects are prepared for integration testing; |
|||
|
|||
* It is fully integrated to ABP framework and all services in your application. |
|||
* It uses SQLite in-memory database for EF Core. For MongoDB, it uses the [Mongo2Go](https://github.com/Mongo2Go/Mongo2Go) library. |
|||
* Authorization is disabled, so any application service can be easily used in tests. |
|||
|
|||
You can still create unit tests for your classes which will be harder to write (because you will need to prepare mock/fake objects), but faster to run (because it only tests a single class and skips all initialization process). |
|||
|
|||
#### How to Run? |
|||
|
|||
Set `.Web` as the startup project and run the application. Default username is `admin` and password is `1q2w3E*`. |
|||
|
|||
See [Getting Started With the ASP.NET Core MVC Template](../Getting-Started-AspNetCore-MVC-Template.md) for more information. |
|||
|
|||
### Tiered Structure |
|||
|
|||
If you specify the `--tiered` option as described above, the solution created will be a tiered solution. The purpose of the tiered structure is to be able to **deploy Web application and HTTP API to different servers**: |
|||
|
|||
 |
|||
|
|||
* Browser runs your UI by executing HTML, CSS & JavaScript. |
|||
* Web servers hosts static UI files (CSS, JavaScript, image... etc.) & dynamic components (e.g. Razor pages). It performs HTTP requests to the API server to execute the business logic of the application. |
|||
* API Server hosts the HTTP APIs which then use application & domain layers of the application to perform the business logic. |
|||
* Finally, database server hosts your database. |
|||
|
|||
So, the resulting solution allows a 4-tiered deployment, by comparing to 3-tiered deployment of the default structure explained before. |
|||
|
|||
> Unless you actually need to such a 4-tiered deployment, its suggested to go with the default structure which is simpler to develop, deploy and maintain. |
|||
|
|||
The solution structure is shown below: |
|||
|
|||
 |
|||
|
|||
As different from the default structure, two new projects come into play: `.IdentityServer` & `.HttpApi.Host`. |
|||
|
|||
#### .IdentityServer Project |
|||
|
|||
This project is used as an authentication server for other projects. `.Web` project uses OpenId Connect Authentication to get identity and access tokens for the current user from the IdentityServer. Then uses the access token to call the HTTP API server. HTTP API server uses bearer token authentication to obtain claims from the access token to authorize the current user. |
|||
|
|||
 |
|||
|
|||
ABP uses the open source [IdentityServer4](https://identityserver.io/) framework for the authentication between applications. See [IdentityServer4 documentation](http://docs.identityserver.io) for details about the IdentityServer4 and OpenID Connect protocol. |
|||
|
|||
It has its own `appsettings.json` that contains database connection and other configurations. |
|||
|
|||
#### .HttpApi.Host Project |
|||
|
|||
This project is an application that hosts the API of the solution. It has its own `appsettings.json` that contains database connection and other configurations. |
|||
|
|||
#### .Web Project |
|||
|
|||
Just like the default structure, this project contains the User Interface (UI) of the application. It contains razor pages, JavaScript files, style files, images and so on... |
|||
|
|||
This project contains an `appsettings.json` file, but this time it does not have a connection string because it never connects to the database. Instead, it mainly contains endpoint of the remote API server and the authentication server. |
|||
|
|||
#### Pre-requirements |
|||
|
|||
* [Redis](https://redis.io/): The applications use Redis as as distributed cache. So, you need to have Redis installed & running. |
|||
|
|||
#### How to Run? |
|||
|
|||
You should run the application with the given order: |
|||
|
|||
* First, run the `.IdentityServer` since other applications depends on it. |
|||
* Then run the `.HttpApi.Host` since it is used by the `.Web` application. |
|||
* Finally, you can run the `.Web` project and login to the application (using `admin` as the username and `1q2w3E*` as the password). |
|||
|
|||
## What's Next? |
|||
|
|||
- See [Getting Started With the ASP.NET Core MVC Template](../Getting-Started-AspNetCore-MVC-Template.md) to create a new solution and run it for this template. |
|||
- See the [ASP.NET Core MVC Tutorial](../Tutorials/AspNetCore-Mvc/Part-I.md) to learn how to develop applications using this template. |
|||
@ -0,0 +1,3 @@ |
|||
# Testing |
|||
|
|||
TODO! |
|||
|
After Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 8.2 KiB |
|
After Width: | Height: | Size: 7.9 KiB |
|
Before Width: | Height: | Size: 8.5 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 6.2 KiB |
|
Before Width: | Height: | Size: 5.3 KiB |
|
After Width: | Height: | Size: 6.7 KiB |
|
Before Width: | Height: | Size: 7.2 KiB |
|
Before Width: | Height: | Size: 8.7 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 7.2 KiB |
@ -0,0 +1,3 @@ |
|||
## Value Objects |
|||
|
|||
TODO |
|||
|
After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 8.7 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 7.2 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 38 KiB |
|
After Width: | Height: | Size: 31 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 33 KiB |
@ -0,0 +1,136 @@ |
|||
# ABP CLI |
|||
|
|||
ABP CLI (命令行接口) 是一个命令行工具,用来执行基于ABP解决方案的一些常见操作. |
|||
|
|||
## Installation |
|||
|
|||
ABP CLI 是一个 [dotnet global tool](https://docs.microsoft.com/en-us/dotnet/core/tools/global-tools). 使用命令行窗口安装: |
|||
|
|||
````bash |
|||
dotnet tool install -g Volo.Abp.Cli |
|||
```` |
|||
|
|||
更新最新版本: |
|||
|
|||
````bash |
|||
dotnet tool update -g Volo.Abp.Cli |
|||
```` |
|||
|
|||
## Commands |
|||
|
|||
### new |
|||
|
|||
生成基于ABP[启动模板](Startup-Templates/Index.md)的新解决方案. |
|||
|
|||
基本用法: |
|||
|
|||
````bash |
|||
abp new <解决方案名称> [options] |
|||
```` |
|||
|
|||
示例: |
|||
|
|||
````bash |
|||
abp new Acme.BookStore |
|||
```` |
|||
|
|||
* Acme.BookStore是解决方案的名称. |
|||
* 常见的命名方式类似于 *YourCompany.YourProject*. 不过你可以使用自己喜欢的方式,如 *YourProject* (单级命名空间) 或 *YourCompany.YourProduct.YourModule* (三级命名空间). |
|||
|
|||
#### Options |
|||
|
|||
* `--template` 或 `-t`: 指定模板. 默认的模板是 `mvc`.可用的模板有: |
|||
* `mvc` (默认): ASP.NET Core [MVC应用程序模板](Startup-Templates/Mvc.md). 其他选项: |
|||
* `--database-provider` 或 `-d`: 指定数据库提供程序. 默认提供程序是 `ef`. 可用的提供程序有: |
|||
* `ef`: Entity Framework Core. |
|||
* `mongodb`: MongoDB. |
|||
* `--tiered`: 创建分层解决方案,Web和Http Api层在物理上是分开的. 如果未指定会创建一个分层的解决方案, 此解决方案没有那么复杂,适合大多数场景. |
|||
* `mvc-module`: ASP.NET Core [MVC模块模板](Startup-Templates/Mvc-Module.md). 其他选项: |
|||
* `--no-ui`: 不包含UI. 仅创建服务模块 (也称为微服务 - 没有UI). |
|||
* `--output-folder` 或 `-o`: 指定输出文件夹,默认是当前目录. |
|||
|
|||
### add-package |
|||
|
|||
添加新的ABP包到项目中 |
|||
|
|||
* 添加nuget包做为项目的依赖项目. |
|||
* 添加 `[DependsOn(...)]` attribute到项目的模块类 (请参阅 [模块开发文档](Module-Development-Basics.md)). |
|||
|
|||
> 需要注意的是添加的模块可能需要额外的配置,通常会在包的文档中指出. |
|||
|
|||
基本用法: |
|||
|
|||
````bash |
|||
abp add-package <包名> [options] |
|||
```` |
|||
|
|||
示例: |
|||
|
|||
```` |
|||
abp add-package Volo.Abp.MongoDB |
|||
```` |
|||
|
|||
* 示例中将Volo.Abp.MongoDB包添加到项目中. |
|||
|
|||
#### Options |
|||
|
|||
* `--project` 或 `-p`: 指定项目 (.csproj) 路径. 如果未指定,Cli会尝试在当前目录查找.csproj文件. |
|||
|
|||
### add-module |
|||
|
|||
通过查找模块的所有包,查找解决方案中的相关项目,并将每个包添加到解决方案中的相应项目,从而将多包模块添加到解决方案中. |
|||
|
|||
> 由于分层,不同的数据库提供程序选项或其他原因,业务模块通常由多个包组成. 使用`add-module`命令可以大大简化向模块添加模块的过程. 但是每个模块可能需要一些其他配置,这些配置通常在相关模块的文档中指出. |
|||
|
|||
基本用法: |
|||
|
|||
````bash |
|||
abp add-module <模块名称> [options] |
|||
```` |
|||
|
|||
示例: |
|||
|
|||
```bash |
|||
abp add-module Volo.Blogging |
|||
``` |
|||
|
|||
* 示例中将Volo.Blogging模块添加到解决方案中. |
|||
|
|||
#### Options |
|||
|
|||
* `--solution` 或 `-s`: 指定解决方案 (.sln) 路径. 如果未指定,CLI会尝试在当前目录中寻找.sln文件. |
|||
* `--skip-db-migrations`: 对于EF Core 数据库提供程序,它会自动添加新代码的第一次迁移 (`Add-Migration`) 并且在需要时更新数据库 (`Update-Database`). 指定此选项可跳过此操作. |
|||
|
|||
### update |
|||
|
|||
更新所有ABP相关的包可能会很繁琐,框架和模块都有很多包. 此命令自动将解决方案或项目中所有ABP相关的包更新到最新版本. |
|||
|
|||
用法: |
|||
|
|||
````bash |
|||
abp update [options] |
|||
```` |
|||
|
|||
* 如果你的文件夹中有.sln文件,运行命令会将解决方案中所有项目ABP相关的包更新到最新版本. |
|||
* 如果你的文件夹中有.csproj文件,运行命令会将项目中所有ABP相关的包更新到最新版本. |
|||
|
|||
#### Options |
|||
|
|||
* `--include-previews` 或 `-p`: 将预览版, 测试版本 和 rc 包 同时更新到最新版本. |
|||
|
|||
### help |
|||
|
|||
CLI的基本用法信息. |
|||
|
|||
用法: |
|||
|
|||
````bash |
|||
abp help [命令名] |
|||
```` |
|||
|
|||
示例: |
|||
|
|||
````bash |
|||
abp help # 显示常规帮助. |
|||
abp help new # 显示有关 "New" 命令的帮助. |
|||
```` |
|||
@ -0,0 +1,3 @@ |
|||
# Data Seeding |
|||
|
|||
TODO |
|||
@ -0,0 +1,3 @@ |
|||
## Dynamic JavaScript API Clients |
|||
|
|||
TODO |
|||
@ -1,68 +1,32 @@ |
|||
# ABP 文档 |
|||
|
|||
> 翻译来自[cnAbp](https://github.com/cnabp)组织,中文网会持续跟进翻译,目前Abp vNext的英文文档还未完成,大家对整体框架没有深入的理解,翻译难免存在一些问题.敬请见谅.😀 |
|||
> 中文文档翻译来自[cnAbp](https://github.com/cnabp)组织,Abp中文网会持续跟进翻译,目前Abp vNext的英文文档还未完成,大家对整体框架没有深入的理解,翻译难免存在一些问题.敬请见谅.😀 |
|||
|
|||
## 目录 |
|||
ABP是一个**开源应用程序框架**,专注于基于ASP.NET Core的Web应用程序开发,但也支持开发其他类型的应用程序. |
|||
|
|||
* 入门 |
|||
* 从启动模板开始 |
|||
* [ASP.NET Core MVC 模板](Getting-Started-AspNetCore-MVC-Template.md) |
|||
* 从空项目开始 |
|||
* [使用Console Application](Getting-Started-Console-Application.md) |
|||
* [使用 ASP.NET Core Web Application](Getting-Started-AspNetCore-Application.md) |
|||
* 教程 |
|||
* 应用开发 |
|||
* [使用 ASP.NET Core MVC](Tutorials/AspNetCore-Mvc/Part-I.md) |
|||
* 基础知识 |
|||
* [依赖注入](Dependency-Injection.md) |
|||
* AutoFac 集成 |
|||
* [虚拟文件系统](Virtual-File-System.md) |
|||
* [本地化](Localization.md) |
|||
* [异常处理](Exception-Handling.md) |
|||
* 验证 |
|||
* 授权 |
|||
* 缓存 |
|||
* 审计 |
|||
* 设置管理 |
|||
* 对象映射 |
|||
* AutoMapper 集成 |
|||
* 事件 |
|||
* 本地 Event Bus |
|||
* 分布式 Event Bus |
|||
* RabbitMQ 集成 |
|||
* 服务 |
|||
* 对象序列化 |
|||
* JSON序列化 |
|||
* 邮件 |
|||
* GUIDs |
|||
* 线程 |
|||
* 定时 |
|||
* [多租户](Multi-Tenancy.md) |
|||
* 模块开发 |
|||
* [基础](Module-Development-Basics.md) |
|||
* 模块插件 |
|||
* [最佳实践](Best-Practices/Index.md) |
|||
* 领域驱动设计 |
|||
* 领域层 |
|||
* [实体&聚合根](Entities.md) |
|||
* 值对象 |
|||
* [仓储](Repositories.md) |
|||
* 领域服务 |
|||
* 规约 |
|||
* 应用服务层 |
|||
* 应用服务 |
|||
* 数据传输对象(DTO) |
|||
* 工作单元 |
|||
* ASP.NET Core MVC |
|||
* API 版本控制 |
|||
* 用户界面 |
|||
* [客户端包管理](AspNetCore/Client-Side-Package-Management.md) |
|||
* [捆绑&压缩](AspNetCore/Bundling-Minification.md) |
|||
* [Tag Helpers](Tag-Helpers.md) |
|||
* [主题](AspNetCore/Theming.md) |
|||
* 后台服务 |
|||
* [后台作业](Background-Jobs.md) |
|||
* 数据访问 |
|||
* [Entity Framework Core 集成](Entity-Framework-Core.md) |
|||
* [MongoDB 集成](MongoDB.md) |
|||
* 测试 |
|||
浏览左侧导航菜单以深入了解文档. |
|||
|
|||
## 项目状态 |
|||
|
|||
ABP是开源[ASP.NET Boilerplate](https://aspnetboilerplate.com/)框架的**下一代框架**, 它目前处于早期预览阶段,尚未准备好在生产中使用. 文档仍在进行中,远未完成. |
|||
|
|||
对于短期和生产级应用程序, 建议使用[ASP.NET Boilerplate](https://aspnetboilerplate.com/)框架,该框架具有丰富的功能集,成熟,积极维护和最新. |
|||
|
|||
## 入门 |
|||
|
|||
使用ABP开发新项目的最简单方法是使用启动模板: |
|||
|
|||
* [ASP.NET Core MVC 模板](Getting-Started-AspNetCore-MVC-Template.md) |
|||
|
|||
如果您想从头开始(使用空项目),请手动安装ABP框架并使用以下教程: |
|||
|
|||
* [控制台应用程序](Getting-Started-Console-Application.md) |
|||
* [ASP.NET Core Web 应用程序](Getting-Started-AspNetCore-Application.md) |
|||
|
|||
## 源码 |
|||
|
|||
ABP托管在GitHub上, 参见[源代码](https://github.com/abpframework/abp). |
|||
|
|||
## 贡献代码 |
|||
|
|||
ABP是一个社区驱动的开源项目.如果你想成为该项目的一部分,请参阅[贡献指南](Contribution/Index.md). |
|||
|
|||
@ -0,0 +1,8 @@ |
|||
# 启动模板 |
|||
|
|||
虽然你可以从一个空项目开始并手动添加所需的包,但启动模板可以非常轻松,舒适地使用ABP框架启动新的解决方案. |
|||
|
|||
单击下面列表中的名称以查看相关启动模板的文档: |
|||
|
|||
* [**mvc**](Mvc.md): ASP.NET Core MVC应用程序模板. |
|||
* [**mvc-module**](Mvc-Module.md): ASP.NET Core MVC模块/服务模板. |
|||
@ -0,0 +1,6 @@ |
|||
# MVC Module 启动模板 |
|||
|
|||
TODO |
|||
|
|||
|
|||
|
|||
@ -0,0 +1,259 @@ |
|||
# MVC应用程序启动模板 |
|||
|
|||
## 介绍 |
|||
|
|||
MVC应用程序启动模板是基于[领域驱动设计](../Domain-Driven-Design.md)(DDD)分层(或根据偏好分层)的应用程序结构. |
|||
|
|||
在这篇文档中详细介绍了解决方案结构和项目 |
|||
|
|||
* 参阅[ASP.NET Core MVC 模板入门](../Getting-Started-AspNetCore-MVC-Template.md)创建此模板的新解决方案并运行它. |
|||
* 参阅[ASP.NET Core MVC 教程](../Tutorials/AspNetCore-Mvc/Part-I.md)学习使用此模板开发应用程序. |
|||
|
|||
## 如何开始 |
|||
|
|||
你要以使用[ABP CLI](../CLI.md)创建基于此启动模板的新项目,或者你也可以在[入门](https://abp.io/get-started)页面创建并下载项目. 在这里我们使用CLI创建新项目. |
|||
|
|||
如果未安装ABP CLI,第一步是安装ABP CLI |
|||
|
|||
````bash |
|||
dotnet tool install -g Volo.Abp.Cli |
|||
```` |
|||
|
|||
然后使用 `abp new` 命令在空文件夹中创建新解决方案: |
|||
|
|||
````bash |
|||
abp new Acme.BookStore -t mvc |
|||
```` |
|||
|
|||
* `Acme.BookStore` 是解决方案的名称, 如*YourCompany.YourProduct*. 你可以使用单级或多级名称. |
|||
* 示例中指定了启动模板 (`-t` 或 `--template` 选项). 不过 `mvc` 是默认模板,即使未指定也会创建 `MVC` 的模板项目. |
|||
|
|||
### 指定数据库提供程序 |
|||
|
|||
`MVC`模板支持以下数据库提供程序: |
|||
|
|||
- `ef`: Entity Framework Core (默认) |
|||
- `mongodb`: MongoDB |
|||
|
|||
使用 `-d` (或 `--database-provider`) 选项指定数据库提供程序: |
|||
|
|||
````bash |
|||
abp new Acme.BookStore -d mongodb |
|||
```` |
|||
|
|||
### 创建分层解决方案 |
|||
|
|||
使用 `--tiered` 选项创建分层解决方案, Web与WebApi层在物理上是分开的. 如果未指定,CLI会创建一个分层的解决方案,这个解决方案没有那么复杂,适合大多数场景. |
|||
|
|||
````bash |
|||
abp new Acme.BookStore --tiered |
|||
```` |
|||
|
|||
有关分层的方法,请参阅下面的"分层结构"部分. |
|||
|
|||
## 解决方案结构 |
|||
|
|||
根据命令的选项,会创建略有不同的解决方案结构. |
|||
|
|||
### 默认结构 |
|||
|
|||
如果未指定选项,你会得到如下所示的解决方案: |
|||
|
|||
 |
|||
|
|||
项目组织在`src`和`test`文件夹中. `src`文件夹包含实际应用程序,该应用程序基于前面提到的[DDD](../Domain-Driven-Design.md)原则进行分层. 下图展示了解决方案的层和项目的依赖关系: |
|||
|
|||
 |
|||
|
|||
下面介绍解决方案中的项目及依赖关系. |
|||
|
|||
#### .Domain.Shared 项目 |
|||
|
|||
项目包含常量,枚举和其他对象,这些对象实际上是领域层的一部分,但是解决方案中所有的层/项目中都会使用到. |
|||
|
|||
例如 `BookType` 枚举和 `BookConts` 类 (可能是 `Book` 实体用到的常数字段,像`MaxNameLength`)都适合放在这个项目中. |
|||
|
|||
* 该项目不依赖解决方案中的其他项目. 其他项目直接或间接依赖该项目 |
|||
|
|||
#### .Domain 项目 |
|||
|
|||
解决方案的领域层. 它主要包含 [实体, 集合根](../Entities.md), [领域服务](../Domain-Services.md), [值类型](../Value-Types.md), [仓储接口](../Repositories.md) 和解决方案的其他领域对象. |
|||
|
|||
例如 `Book` 实体和 `IBookRepository` 接口都适合放在这个项目中. |
|||
|
|||
* 它依赖 `.Domain.Shared` 项目,因为项目中会用到它的一些常量,枚举和定义其他对象. |
|||
|
|||
#### .Application.Contracts 项目 |
|||
|
|||
项目主要包含 [应用服务](../Application-Services.md) **interfaces** 和应用层的 [数据传输对象](../Data-Transfer-Objects.md) (DTO). 它用于分离应用层的接口和实现. 这种方式可以将接口项目做为约定包共享给客户端. |
|||
|
|||
* 它依赖 `.Domain.Shared` 因为它可能会在应用接口和DTO中使用常量,枚举和其他的共享对象. |
|||
|
|||
#### .Application 项目 |
|||
|
|||
项目包含 `.Application.Contracts` 项目的 [应用服务](../Application-Services.md) 接口**实现**. |
|||
|
|||
* 它依赖 `.Application.Contracts` 项目, 因为它需要实现接口与使用DTO. |
|||
* 它依赖 `.Domain` 项目,因为它需要使用领域对象(实体,仓储接口等)执行应用程序逻辑. |
|||
|
|||
#### .EntityFrameworkCore 项目 |
|||
|
|||
这是集成EF Core的项目. 它定义了 `DbContext` 并实现 `.Domain` 项目中定义的仓储接口. |
|||
|
|||
* 它依赖 `.Domain` 项目,因为它需要引用实体和仓储接口. |
|||
|
|||
> 只有在你使用了EF Core做为数据库提供程序时,此项目才会可用. 如果选择的是其他数据库提供程序那么项目的名称会改变 |
|||
|
|||
#### .EntityFrameworkCore.DbMigrations 项目 |
|||
|
|||
包含解决方案的EF Core数据库迁移. 它有独立的 `DbContext` 来专门管理迁移. |
|||
|
|||
ABP是一个模块化的框架,理想的设计是让每个模块都有自己的 `DbContext` 类. 这时用于迁移的 `DbContext` 就会发挥作用. 它将所有的 `DbContext` 配置统一到单个模型中以维护单个数据库的模式. 对于更高级的场景,可以程序可以拥有多个数据库(每个数据库有一个或多个模块表)和多个迁移`DbContext`(每个都维护不同的数据库模式) |
|||
|
|||
需要注意,迁移 `DbContext` 仅用于数据库迁移,而不在*运行时*使用. |
|||
|
|||
* 它依赖 `.EntityFrameworkCore` 项目,因为它重用了应用程序的 `DbContext` 配置 . |
|||
|
|||
> 只有在你使用了EF Core做为数据库提供程序时,此项目才会可用. |
|||
|
|||
#### .DbMigrator 项目 |
|||
|
|||
这是一个控制台应用唾弃,它简化了在开发和生产环境执行数据库迁移的操作.当你使用它时; |
|||
|
|||
* 必要时创建数据库(没有数据库时). |
|||
* 应用未迁移的数据库迁移. |
|||
* 初始化种子数据(当你需要时). |
|||
|
|||
> 这个项目有自己的 `appsettings.json` 文件. 所以如果要更改数据库连接字符串,请记得也要更改此文件. |
|||
|
|||
初始化种子数据很很要,ABP具有模块化的种子数据基础设施. 种子数据的更多信息,请参阅[文档](../Data-Seeding.md). |
|||
|
|||
虽然创建数据库和应用迁移似乎只对关系数据库有用,但即使您选择NoSQL数据库提供程序(如MongoDB),也会生成此项目. 这时,它会为应用程序提供必要的初始数据. |
|||
|
|||
* 它依赖 `.EntityFrameworkCore.DbMigrations` 项目 (针对EF Core),因为它需要访问迁移文件. |
|||
* 它依赖 `.Application.Contracts` 项目,因为它需要访问权限定义在初始化种子数据时为管理员用户赋予所有权限. |
|||
|
|||
#### .HttpApi 项目 |
|||
|
|||
用于定义API控制器. |
|||
|
|||
大多数情况下,你不需要手动定义API控制器,因为ABP的[动态API](../AspNetCore/Auto-API-Controllers.md)功能会根据你的应用层自动创建API控制器. 但是,如果你需要编写API控制器,那么它是最合适的地方. |
|||
|
|||
* 它依赖 `.Application.Contracts` 项目,因为它需要注入应用服务接口. |
|||
|
|||
#### .HttpApi.Client 项目 |
|||
|
|||
定义C#客户端代理使用解决方案的HTTP API项目. 可以将上编辑共享给第三方客户端,使其轻松的在DotNet应用程序中使用你的HTTP API(其他类型的应用程序可以手动或使用其平台的工具来使用你的API). |
|||
|
|||
ABP有[动态 C# API 客户端](../AspNetCore/Dynamic-CSharp-API-Clients.md)功能,所以大多数情况下你不需要手动的创建C#客户端代理. |
|||
|
|||
`.HttpApi.Client.ConsoleTestApp` 项目是一个用于演示客户端代理用法的控制台应用程序. |
|||
|
|||
* 它依赖 `.Application.Contracts` 项目,因为它需要使用应用服务接口和DTO. |
|||
|
|||
> 如果你不需要为API创建动态C#客户端代理,可以删除此项目和依赖项 |
|||
|
|||
#### .Web 项目 |
|||
|
|||
包含应用程序的用户界面(UI). 包括Razor页面,javascript文件,样式文件,图片等... |
|||
|
|||
包含应用程序主要的 `appsettings.json` 配置文件,用于配置数据库连接字符串和应用程序的其他配置 |
|||
|
|||
* 依赖 `.HttpApi` 项目,因为UI层需要使用解决方案的API和应用服务接口. |
|||
|
|||
> 如果查看 `.Web.csproj` 源码, 你会看到对 `.Application` 和 `.EntityFrameworkCore.DbMigrations` 项目的引用. |
|||
> |
|||
> 在编写UI层时实际上不需要这些引用. 因为UI层通常不依赖于EF Core或应用层的实现. 这个启动模板已经为分层部署做好了准备,API层托管在不同与UI层的服务器中. |
|||
> |
|||
> 但是如果你不选择 `--tiered` 选项, .Web项目会有这些引用,以便能够将Web,Api和应用层托管在单个应用程序站点. |
|||
> |
|||
> 你可以在表示层中使用领域实体和仓储,但是根据DDD的理论,这被认为是一种不好的做法. |
|||
|
|||
#### 测试项目 |
|||
|
|||
解决方案有多个测试项目,每一层都会有一个: |
|||
|
|||
* `.Domain.Tests` 用于测试领域层. |
|||
* `.Application.Tests` 用于测试应用层. |
|||
* `.EntityFrameworkCore.Tests` 用于测试EF Core配置与自定义仓储. |
|||
* `.Web.Tests` 用于测试UI. |
|||
* `.TestBase` 所有测试项目的基础(共享)项目. |
|||
|
|||
此外, `.HttpApi.Client.ConsoleTestApp` 是一个控制台应用程序(不是自动化测试项目),它用于演示DotNet应用程序中HTTP API的用法. |
|||
|
|||
测试项目已为集成测试做好准备: |
|||
|
|||
* 它完成集成到ABP框架和应用程序的所有服务. |
|||
* 如果数据库提供程序是EF Core,测试项目会使用SQLite内存数据库,如果是MongoDB,它使用[Mongo2Go](https://github.com/Mongo2Go/Mongo2Go)库. |
|||
* 授权被禁用,任何的应用服务都可以在测试中轻松调用. |
|||
|
|||
你依然可以编写单元测试,只不过它很难写(因为你需要准备mock/fake对象),但它的运行速度更快(因为只测试单个类并跳过所有初始化过程). |
|||
|
|||
#### 如何运行? |
|||
|
|||
设置`.Web`为启动项目. 默认用户名 `admin`, 密码 `1q2w3E*`. |
|||
|
|||
更多信息请参阅[ASP.NET Core MVC 模板入门](../Getting-Started-AspNetCore-MVC-Template.md). |
|||
|
|||
### 分层结构 |
|||
|
|||
如果你按上面的描述指定了 `--tiered` 选项,会创建分层解决方案. 分层结构的目的是**将Web应用程序和HTTP API部署到不同的服务器**: |
|||
|
|||
 |
|||
|
|||
* 浏览器渲染HTML,执行CSS和JavaScript来运行UI. |
|||
* Web服务器托管静态文件(CSS,JavaScript,图片...等)和动态组件(如Razor页面),它通过HTTP请求到API服务器执行应用程序的业务逻辑. |
|||
* API服务器托管HTTP API,使用应用程序的应用层和领域层执行业务逻辑. |
|||
* 最后数据库服务器托管数据库. |
|||
|
|||
与之前默认结构的三层部署比较,分层解决方案允许四层部署. |
|||
|
|||
> 除非你真的需要四层部署,一般建议采用默认结构,它更易于开发,部署和维护. |
|||
|
|||
解决方案结构如下所示: |
|||
|
|||
 |
|||
|
|||
与默认结构不同,我们得到了两个新项目: `.IdentityServer` 和 `.HttpApi.Host`. |
|||
|
|||
#### .IdentityServer 项目 |
|||
|
|||
用于其他项目的身份验证服务器. `.Web`项目使用OpenId Connect身份验证获取当前用户的身份和访问令牌. 然后使用访问令牌调用HTTP API服务器. HTTP API服务器使用bearer token从访问令牌获取声明授权当前用户. |
|||
|
|||
 |
|||
|
|||
ABP使用开源的[IdentityServer4](https://identityserver.io/)框架做应用程序间的身份验证. 有关IdentityServer4和OpenId Connect协议的详细信息请参阅[IdentityServer4文档](http://docs.identityserver.io). |
|||
|
|||
它有自己的`appsettings.json`文件(数据库连接字符串等其他配置). |
|||
|
|||
#### .HttpApi.Host 项目 |
|||
|
|||
该项目是一个承载解决方案API的应用程序. |
|||
|
|||
它有自己的`appsettings.json`文件(数据库连接字符串等其他配置). |
|||
|
|||
#### .Web 项目 |
|||
|
|||
与默认结构一样,包含应用程序的用户界面(UI). 包括Razor页面,javascript文件,样式文件,图片等... |
|||
|
|||
项目包含`appsetting.json`文件,但没有连接字符串配置, 它不需要连接到数据库. 文件中主要包含远程API服务器端点和身份验证服务器 |
|||
|
|||
#### 前置条件 |
|||
|
|||
* [Redis](https://redis.io/): 应用程序使用Redis做分布式缓存,你需要安装并运行Redis. |
|||
|
|||
#### 如何运行? |
|||
|
|||
你应该按照以下顺序运行应用: |
|||
|
|||
* 首先运行`.IdentityServer`,因为其他应用程序依赖它做身份验证. |
|||
* 然后运行`.HttpApi.Server`,因为`.Web`应用程序需要访问HTTI API. |
|||
* 最后运行`.Web`并登录到应用程序(用户名: `admin` 密码: `1q2w3E*`). |
|||
|
|||
### 其他数据库提供程序 |
|||
|
|||
TODO |
|||
|
|||
#### MongoDB |
|||
|
|||
TODO |
|||
|
After Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 8.2 KiB |
|
After Width: | Height: | Size: 7.9 KiB |
|
Before Width: | Height: | Size: 8.5 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 6.2 KiB |
|
Before Width: | Height: | Size: 5.3 KiB |
|
After Width: | Height: | Size: 6.7 KiB |
|
Before Width: | Height: | Size: 7.2 KiB |
|
Before Width: | Height: | Size: 8.7 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 7.2 KiB |
@ -0,0 +1,3 @@ |
|||
## Value Objects |
|||
|
|||
TODO |
|||
|
After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 8.7 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 7.2 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 24 KiB |