-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
165 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
概述 | ||
安装 | ||
作为智能助手 | ||
创建并运行项目 | ||
Studio | ||
代码生成说明 | ||
命令行 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# DTO生成说明 | ||
|
||
使用工具可以解析实体,并生成相应的DTO,以下说明具体生成的规则。 | ||
|
||
## 生成内容 | ||
|
||
一个实体通常会生成以下几个模型类: | ||
|
||
- `ItemDto`: 用于列表元素的模型 | ||
- `ShortDto`: 用于获取模型主要信息的模型 | ||
- `FilterDto`: 用于请求的筛选模型 | ||
- `AddDto`: 用于实体添加时的模型 | ||
- `UpdateDto`:用于更新的模型 | ||
|
||
## 生成说明 | ||
|
||
如果实体属性含有[JsonIgnore]属性,那么生成的DTO都会忽略该属性。 | ||
|
||
### ItemDto | ||
|
||
列表元素不会包括以下属性: | ||
|
||
- IsDeleted与UpdatedTime字段,但会包含CreatedTime | ||
- 数组或列表 | ||
- 长度大于1000的字符串 | ||
- 导航属性及对应Id | ||
|
||
### ShortDto | ||
|
||
在ItemDto的基础上,忽略 CreatedTime以及"Content"字段。 | ||
|
||
### FilterDto | ||
|
||
FilterDto生成内容如下: | ||
|
||
- 忽略 "Id", "CreatedTime", "UpdatedTime", "IsDeleted"等基础属性 | ||
- 忽略列表及导航属性 | ||
- 忽略最大长度在于1000的字符串属性 | ||
- 保留必需属性(但不为导航属性) | ||
- 包括枚举属性 | ||
|
||
### AddDto | ||
|
||
添加模型生成内容如下: | ||
|
||
- 忽略 "Id", "CreatedTime", "UpdatedTime", "IsDeleted"等基础属性 | ||
- 必须是可赋值的属性,即有`set`方法。 | ||
- 对于导航属性,会进行以下处理: | ||
- 忽略非必需的导航属性 | ||
- 忽略列表导航属性 | ||
- 对于必需的导航属性,会生成`属性名`+`Id`的形式来表示 | ||
|
||
### UpdateDto | ||
|
||
更新模型生成内容同添加模型,但是更新模型所有属性默认都为可空属性。 | ||
|
||
可空属性,意味着,如果该字段为空,更新时,会忽略该字段,以此来实现部分更新。 | ||
|
||
> [!TIP] | ||
> 如果你习惯进行全量更新,可直接复用`AddDto`模型。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Manager代码生成说明 | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# 创建并运行项目 | ||
|
||
## 创建解决方案 | ||
|
||
点击创建按钮,进入到解决方案创建页面。 | ||
|
||
:::image type="content" source="../images/createSolution.jpg" alt-text="create solution"::: | ||
|
||
你会看到以下页面,请填写解决方案名称和本地路径,然后点击创建。 | ||
|
||
:::image type="content" source="../images/createSolutionPage.jpg" alt-text="create solution page"::: | ||
|
||
## 运行解决方案 | ||
|
||
现在使用你喜欢的IDE打开解决方案,或者直接在Studio 点击打开按钮。 | ||
|
||
### 配置文件 | ||
|
||
请先检查配置文件内容,包括: | ||
|
||
- 配置数据库连接字符串。请在`Http.API`项目下,`appsettings.json`中的`ConnectionStrings`中配置相关的连接字符串。 | ||
- 在配置文件中`Components`的`Cache`配置,可选"Redis"或"Memory"。 | ||
|
||
你可参考以下配置说明: | ||
|
||
```json | ||
"ConnectionStrings": { | ||
// 可写数据库 | ||
"CommandDb": "Server=localhost;Port=5432;Database=MyProjectName;User Id=postgres;Password=root;", | ||
// 只读数据库 | ||
"QueryDb": "Server=localhost;Port=5432;Database=MyProjectName;User Id=postgres;Password=root;", | ||
// 缓存连接 | ||
"Cache": "localhost:6379", | ||
// 缓存前缀 | ||
"CacheInstanceName": "Dev", | ||
// 日志接收地址 | ||
"Logging": "http://localhost:4317" | ||
}, | ||
|
||
"Components": { | ||
//Memory/Redis | ||
"Cache": "Memory" | ||
}, | ||
// 邮件发送服务 | ||
"Smtp": { | ||
// smtp服务地址 | ||
"Host": "", | ||
"Port": 25, | ||
// 发件人名称 | ||
"DisplayName": "", | ||
// 发件人地址 | ||
"From": "", | ||
// 验证用户名 | ||
"Username": "", | ||
// 验证密码 | ||
"Password": "", | ||
"EnableSsl": true | ||
}, | ||
"Key": { | ||
// 默认用户密码 | ||
"DefaultPassword": "Hello.Net" | ||
}, | ||
``` | ||
|
||
### 数据库迁移 | ||
|
||
模板默认使用了PostgreSQL。如果你使用其他数据库提供程序,你可以在`Application`项目`AppServiceCollectionExtensions.cs`中找到注入数d据库服务的方法。 | ||
|
||
请在`Http.API`项目下,使用`dotnet ef`命令生成迁移代码。或者直接运行`EFMigrations.ps1`脚本来执行,如: | ||
|
||
```powershell | ||
.\EFMigrations.ps1 Init | ||
``` | ||
|
||
### 运行项目 | ||
|
||
由于8.0添加了对`.NET Aspire`的支持,现在你有两种方式运行程序。 | ||
|
||
1. 运行AppHost项目,这是使用 Aspire 提供的方式运行,它将打开`Dashboard`。 | ||
2. 直接运行`Http.API`项目,这将在浏览器中打开接口的`Swagger UI`。 | ||
|
||
你可以选择合适的方式运行程序。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
概述 | ||
快速入门 | ||
教程 | ||
快速入门 | ||
约定和规范 | ||
示例 | ||
自定义 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.