diff --git a/OpenAuth.App/Resources/ResourceApp.cs b/OpenAuth.App/Resources/ResourceApp.cs
index d24852ab..92b566e2 100644
--- a/OpenAuth.App/Resources/ResourceApp.cs
+++ b/OpenAuth.App/Resources/ResourceApp.cs
@@ -1,8 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Security.AccessControl;
using System.Threading.Tasks;
using Infrastructure;
+using NUnit.Framework;
using OpenAuth.App.Interface;
using OpenAuth.App.Request;
using OpenAuth.App.Response;
@@ -105,6 +107,18 @@ namespace OpenAuth.App
return result;
}
+ ///
+ /// 获取资源类型
+ ///
+ ///
+ public async Task> GetResourceApps()
+ {
+ var types = await SugarClient.Queryable()
+ .Distinct()
+ .Select(u => new {u.AppId,u.AppName})
+ .ToListAsync();
+ return types.Select(u => new SysResourceApp(u.AppId, u.AppName)).ToList();
+ }
///
/// 同步站点API到资源列表
/// 读取站点API信息,如果资源列表中不存在,则添加
@@ -124,9 +138,12 @@ namespace OpenAuth.App
resource = new SysResource
{
+ Id = api.Path,
Name = api.Path,
Disable = true,
SortNo = 0,
+ AppId = $"{Define.API}_{api.Tag}",
+ AppName = $"API接口-{api.Tag}",
TypeId = Define.API,
TypeName = "API接口",
Description = api.Summary??"",
@@ -140,4 +157,9 @@ namespace OpenAuth.App
}
}
+
+ ///
+ /// 资源类型
+ ///
+ public record SysResourceApp(string Id, string Name);
}
\ No newline at end of file
diff --git a/OpenAuth.WebApi/Controllers/ResourcesController.cs b/OpenAuth.WebApi/Controllers/ResourcesController.cs
index dd1ea330..8e476712 100644
--- a/OpenAuth.WebApi/Controllers/ResourcesController.cs
+++ b/OpenAuth.WebApi/Controllers/ResourcesController.cs
@@ -126,5 +126,23 @@ namespace OpenAuth.WebApi.Controllers
return result;
}
+ ///
+ /// 获取资源所属应用
+ ///
+ [HttpGet]
+ public async Task>> GetResourceApps()
+ {
+ var result = new Response>();
+ try
+ {
+ result.Result = await _app.GetResourceApps();
+ }
+ catch (Exception e)
+ {
+ result.Code = 500;
+ result.Message = e.InnerException?.Message ?? e.Message;
+ }
+ return result;
+ }
}
}
\ No newline at end of file
diff --git a/docs/core/apiauth.md b/docs/core/apiauth.md
index 4336706f..27207cc5 100644
--- a/docs/core/apiauth.md
+++ b/docs/core/apiauth.md
@@ -1,3 +1,10 @@
+
# API权限控制
在使用OpenAuth.WebApi过程中,系统会对所有的Api进行权限控制。如果没有登录就访问Api接口,会提示下面信息:
@@ -30,6 +37,15 @@ Host: localhost:52789
X-Token: e4a5aa00
```
+## 按角色授权API资源
+
+目前主流的接口平台都提供按角色(或账号)授权访问API的功能,OpenAuth.Net也不例外。在OpenAuth.Net中,接口API被当作资源处理。如图:
+
+
+
+如果后端新增或删除API,点击【同步系统API资源】按钮,即可同步到资源列表中。在角色管理功能中,可以对登录的角色进行API资源授权。
+
+
## 不登录直接访问
diff --git a/docs/core/specialist.md b/docs/core/specialist.md
index bd104af1..1a202aab 100644
--- a/docs/core/specialist.md
+++ b/docs/core/specialist.md
@@ -1,23 +1,17 @@
-# 开发规范
+# 后端开发规范
-## 新增数据库名称规范
+## 数据库表及字段命名
-子系统名称+业务名称+表尾,其中表尾名称规则如下:
+SqlServer采用PascalCase命名,Oracle采用全大写命名,其他数据库采用camelCase命名。
+::: tip 提示
+
+开源版代码生成时,通过表结尾Dtbl来判断是否是生成明细表代码。因此建议数据库表命名时按:子系统名称+业务名称+表尾,其中表尾名称规则:
- 基础主数据以Mst结尾;
-
- 普通业务表以Tbl结尾;
-
- 业务明细表以Dtbl结尾;
-
-比如:
-
-- WMS系统客户主数据表:WmsCustomerMst
-
-- WMS系统入库订单头表:WmsInboundOrderTbl
-
-- WMS系统入库订单明细表:WmsInboundOrderDtbl
-
+如:WMS系统入库订单明细表:WmsInboundOrderDtbl
+:::
## 数据库字段类型