项目结构【可以根据实际情况,自己添加或者修改】【特别注意:Swagger中Dto类不能重名】
- 0-Infrastructure
- xxx.Common【公共方法】
- xxx.Model
- xxx.Repository
- 1-Application
- xxx.Service
- xxx.Query【查询方法】
- xxx.Command【增删改方法】
- 2-App
- xxx.WebApi
- 3-UnitTest
- xxx.WebApi.UnitTest
ResponseDto【分页的在Repository里面】 Dto放置在WebApi里面大幅度减少代码量
增删改:
namespace NetFive.Service.Common
{
public class ResponseDto
{
/// <summary>
/// 状态
/// </summary>
public bool Success { get; set; }
/// <summary>
/// 提示信息
/// </summary>
public string Message { get; set; }
}
}
单个查询:
namespace NetFive.Service.Common
{
public class DataResponseDto<T> : ResponseDto
{
/// <summary>
/// 数据
/// </summary>
public T Data { get; set; }
}
}
多个对象:
using System.Collections.Generic;
namespace NetFive.Service.Common
{
public class DatasResponseDto<T> : ResponseDto
{
/// <summary>
/// 数据列表
/// </summary>
public IList<T> Data { get; set; }
}
}
XXX.Service【Dto类定义】根据实际场景自己定义
| 类名 | 注释 |
|---|---|
| AddEmployeeDto | 新增 |
| UpdateEmployeeDto | 更新 |
| UpdateStateEmployeeDto | 更新状态 |
| QueryEmployeeDto | 查询 |
| PageQueryEmployeeDto | 分页查询 |
| EmployeeShowDto | 展示数据列表 |
XXX.Service、XXX.Query、XXX.Command方法体:根据实际场景自己定义
- XXX.Service
- Employee【文件夹】
- Dto【文件夹】
- IEmployeeService
- EmployeeService
- Employee【文件夹】
- XXX.Query
- Employee
- IEmployeeQry
- EmployeeQry
- Employee
- XXX.Command
- Employee
- IEmployeeCmd
- EmployeeCmd
- Employee
| 方法 | 注释 |
|---|---|
| Add | 新增 |
| Update | 更新 |
| UpdateState | 更新状态 |
| Get | 查询详细信息 |
| List | 查询多条数据 |
| ListAll | 查询全部 |
| ListByXXX | 查询多条数据byXXX |
| ListConfig | 查询配置 |
| ListPaging | 分页查询 |
XXX.App【HttpGet、HttpPost方法名】根据实际场景自己定义
@约定1:传入多主键id,使用 int 或者 string 数组
| 方法 | 注释 |
|---|---|
| add | 新增 |
| update | 更新 |
| update-state | 更新状态 |
| get | 查询详细信息 |
| list | 查询多条数据 |
| list-all | 查询全部 |
| list-by | 查询数据by |
| list-config | 查询配置 |
| list-paging | 分页查询 |