You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
107 lines
2.8 KiB
107 lines
2.8 KiB
3 weeks ago
|
# 项目结构
|
||
|
|
||
|
### WoodAdmin 解决方案
|
||
|
- 01 Framework 基础设施层
|
||
|
- Cache 数据缓存接口
|
||
|
- Wood.Cache.Interface 缓存抽象接口
|
||
|
- Wood.MemoryCache 内存缓存
|
||
|
- Wood.RedisCache Redis缓存
|
||
|
- Wood.EventBus 事件总线
|
||
|
- Wood.Util 工具类
|
||
|
- 02 DataAccess数据库核心层
|
||
|
- Wood.Data.Repository 数据库
|
||
|
- 03 Entity实体层
|
||
|
- Wood.Entity 实体
|
||
|
- 04 Business 业务逻辑层
|
||
|
- Wood.AutoJob 定时任务
|
||
|
- Wood.Service 核心服务
|
||
|
- Wood.Test.Service 示例
|
||
|
- 05 WebHost
|
||
|
- Wood.Admin.WebApi WebApi
|
||
|
|
||
|
# 快速开始
|
||
|
|
||
|
1. 在【03 Entity实体层】添加需要映射的实体
|
||
|
```csharp
|
||
|
/// <summary>
|
||
|
/// 测试信息
|
||
|
/// </summary>
|
||
|
[SugarTable("SysTest", "测试信息")]
|
||
|
public class TestEntity : EntityBaseExtra
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// 名称
|
||
|
/// </summary>
|
||
|
[SugarColumn(ColumnDescription = "名称",Length =64)]
|
||
|
[Required(ErrorMessage = "必须填写名称!")]
|
||
|
public string Name { get; set; } = "";
|
||
|
|
||
|
/// <summary>
|
||
|
/// 编码
|
||
|
/// </summary>
|
||
|
[SugarColumn(ColumnDescription = "编码", Length = 32)]
|
||
|
[Required]
|
||
|
[UniqueValue(ErrorMessage ="编码不能重复!")]
|
||
|
public string FormCode { get; set; } = "";
|
||
|
/// <summary>
|
||
|
/// 排序
|
||
|
/// </summary>
|
||
|
[SugarColumn(ColumnDescription = "排序")]
|
||
|
public int Sort { get; set; } = 0;
|
||
|
}
|
||
|
```
|
||
|
2. 在【04 Business 业务逻辑层】新建项目(名称以Service为结尾),添加对【Wood.Service】引用。
|
||
|
3. 在【04 Business 业务逻辑层】新建Service,继承【ApiService】。
|
||
|
```csharp
|
||
|
/// <summary>
|
||
|
/// 测试服务
|
||
|
/// </summary>
|
||
|
public class TestService : ApiService
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// 分页获取用户数据
|
||
|
/// </summary>
|
||
|
/// <param name="param"></param>
|
||
|
/// <returns></returns>
|
||
|
public TDataPaged<TestEntity> Paged(Pagination param)
|
||
|
{
|
||
|
return new TDataPaged<TestEntity>();
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 是否存在
|
||
|
/// </summary>
|
||
|
/// <returns></returns>
|
||
|
public bool GetExist()
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 获取树形结构
|
||
|
/// </summary>
|
||
|
/// <returns>树形结构</returns>
|
||
|
public List<TestEntity> TreeList()
|
||
|
{
|
||
|
return new List<TestEntity>();
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 获取明细
|
||
|
/// </summary>
|
||
|
/// <returns></returns>
|
||
|
public TestEntity GetDetail(BaseIdParam param)
|
||
|
{
|
||
|
return new TestEntity();
|
||
|
}
|
||
|
}
|
||
|
```
|
||
|
4. 在WebApi项目引用新建项目
|
||
|
5. 运行即可看到api列表,Get开头自动注册get请求,否则为post请求,特殊需要可以进行[HttpGet][HttpPost]标记。
|
||
|
|
||
|
### 项目约定:
|
||
|
- 实体 放在【Wood.Entity】
|
||
|
- Service类放在以Service为后缀的项目中
|
||
|
- AutoJob放在【Wood.AutoJob】
|
||
|
- 工具放在【Wood.Util】
|
||
|
- 自定义事件放在【Wood.EventBus】
|