diff --git a/OpenAuth.WebApi/Controllers/AccessObjsController.cs b/OpenAuth.WebApi/Controllers/AccessObjsController.cs index f45fd438..590167be 100644 --- a/OpenAuth.WebApi/Controllers/AccessObjsController.cs +++ b/OpenAuth.WebApi/Controllers/AccessObjsController.cs @@ -13,7 +13,7 @@ namespace OpenAuth.WebApi.Controllers /// [Route("api/[controller]/[action]")] [ApiController] - [ApiExplorerSettings(GroupName = "AccessObjs")] + [ApiExplorerSettings(GroupName = "分配资源_AccessObjs")] public class AccessObjsController : ControllerBase { private readonly RevelanceManagerApp _app; diff --git a/OpenAuth.WebApi/Controllers/ApplicationsController.cs b/OpenAuth.WebApi/Controllers/ApplicationsController.cs index a9b6b503..880bf4a2 100644 --- a/OpenAuth.WebApi/Controllers/ApplicationsController.cs +++ b/OpenAuth.WebApi/Controllers/ApplicationsController.cs @@ -11,7 +11,7 @@ namespace OpenAuth.WebApi.Controllers /// [Route("api/[controller]/[action]")] [ApiController] - [ApiExplorerSettings(GroupName = "Applications")] + [ApiExplorerSettings(GroupName = "应用管理_Applications")] public class ApplicationsController : ControllerBase { private readonly AppManager _app; diff --git a/OpenAuth.WebApi/Controllers/BuilderTableColumnsController.cs b/OpenAuth.WebApi/Controllers/BuilderTableColumnsController.cs index daad4877..bc2e7580 100644 --- a/OpenAuth.WebApi/Controllers/BuilderTableColumnsController.cs +++ b/OpenAuth.WebApi/Controllers/BuilderTableColumnsController.cs @@ -14,7 +14,7 @@ namespace OpenAuth.WebApi.Controllers /// [Route("api/[controller]/[action]")] [ApiController] - [ApiExplorerSettings(GroupName = "BuilderTableColumns")] + [ApiExplorerSettings(GroupName = "代码生成器_字段_BuilderTableColumns")] public class BuilderTableColumnsController : ControllerBase { private readonly BuilderTableColumnApp _app; diff --git a/OpenAuth.WebApi/Controllers/BuilderTablesController.cs b/OpenAuth.WebApi/Controllers/BuilderTablesController.cs index 36db44d8..91e2639f 100644 --- a/OpenAuth.WebApi/Controllers/BuilderTablesController.cs +++ b/OpenAuth.WebApi/Controllers/BuilderTablesController.cs @@ -14,7 +14,7 @@ namespace OpenAuth.WebApi.Controllers /// [Route("api/[controller]/[action]")] [ApiController] - [ApiExplorerSettings(GroupName = "BuilderTables")] + [ApiExplorerSettings(GroupName = "代码生成器_表_BuilderTables")] public class BuilderTablesController : ControllerBase { private readonly BuilderTableApp _app; diff --git a/OpenAuth.WebApi/Controllers/CategoryTypesController.cs b/OpenAuth.WebApi/Controllers/CategoryTypesController.cs index e77880bc..230f9ef6 100644 --- a/OpenAuth.WebApi/Controllers/CategoryTypesController.cs +++ b/OpenAuth.WebApi/Controllers/CategoryTypesController.cs @@ -13,7 +13,7 @@ using OpenAuth.App.Response; /// [Route("api/[controller]/[action]")] [ApiController] - [ApiExplorerSettings(GroupName = "CategoryTypes")] + [ApiExplorerSettings(GroupName = "字典所属分类_CategoryTypes")] public class CategoryTypesController : ControllerBase { private readonly CategoryTypeApp _app; diff --git a/OpenAuth.WebApi/Controllers/CategorysController.cs b/OpenAuth.WebApi/Controllers/CategorysController.cs index 662fe648..e1b2e28b 100644 --- a/OpenAuth.WebApi/Controllers/CategorysController.cs +++ b/OpenAuth.WebApi/Controllers/CategorysController.cs @@ -14,7 +14,7 @@ namespace OpenAuth.WebApi.Controllers /// [Route("api/[controller]/[action]")] [ApiController] - [ApiExplorerSettings(GroupName = "Categorys")] + [ApiExplorerSettings(GroupName = "分类字典_Categorys")] public class CategorysController : ControllerBase { private readonly CategoryApp _app; diff --git a/OpenAuth.WebApi/Controllers/CheckController.cs b/OpenAuth.WebApi/Controllers/CheckController.cs index c4cb3f2b..63d0b86a 100644 --- a/OpenAuth.WebApi/Controllers/CheckController.cs +++ b/OpenAuth.WebApi/Controllers/CheckController.cs @@ -33,7 +33,7 @@ namespace OpenAuth.WebApi.Controllers /// [Route("api/[controller]/[action]")] [ApiController] - [ApiExplorerSettings(GroupName = "Check")] + [ApiExplorerSettings(GroupName = "登录验证_Check")] public class CheckController : ControllerBase { private readonly IAuth _authUtil; @@ -341,7 +341,7 @@ namespace OpenAuth.WebApi.Controllers { var result = new LoginResult(); try - { + { result = _authUtil.Login(request.AppKey, request.Account, request.Password); } catch (Exception ex) diff --git a/OpenAuth.WebApi/Controllers/DataPrivilegeRulesController.cs b/OpenAuth.WebApi/Controllers/DataPrivilegeRulesController.cs index a8987992..e5dd0977 100644 --- a/OpenAuth.WebApi/Controllers/DataPrivilegeRulesController.cs +++ b/OpenAuth.WebApi/Controllers/DataPrivilegeRulesController.cs @@ -14,7 +14,7 @@ namespace OpenAuth.WebApi.Controllers /// [Route("api/[controller]/[action]")] [ApiController] - [ApiExplorerSettings(GroupName = "DataPrivilegeRules")] + [ApiExplorerSettings(GroupName = "数据权限_DataPrivilegeRules")] public class DataPrivilegeRulesController : ControllerBase { private readonly DataPrivilegeRuleApp _app; diff --git a/OpenAuth.WebApi/Controllers/FilesController.cs b/OpenAuth.WebApi/Controllers/FilesController.cs index 7d63bed6..b7634e1b 100644 --- a/OpenAuth.WebApi/Controllers/FilesController.cs +++ b/OpenAuth.WebApi/Controllers/FilesController.cs @@ -18,7 +18,7 @@ namespace OpenAuth.WebApi.Controllers [Route("api/[controller]/[action]")] [ApiController] - [ApiExplorerSettings(GroupName = "Files")] + [ApiExplorerSettings(GroupName = "文件管理_Files")] public class FilesController :ControllerBase { diff --git a/OpenAuth.WebApi/Controllers/FlowInstancesController.cs b/OpenAuth.WebApi/Controllers/FlowInstancesController.cs index 6e60cd64..3cb6878e 100644 --- a/OpenAuth.WebApi/Controllers/FlowInstancesController.cs +++ b/OpenAuth.WebApi/Controllers/FlowInstancesController.cs @@ -22,7 +22,7 @@ namespace OpenAuth.WebApi.Controllers /// [Route("api/[controller]/[action]")] [ApiController] - [ApiExplorerSettings(GroupName = "FlowInstances")] + [ApiExplorerSettings(GroupName = "流程实例_FlowInstances")] public class FlowInstancesController : ControllerBase { private readonly FlowInstanceApp _app; diff --git a/OpenAuth.WebApi/Controllers/FlowSchemesController.cs b/OpenAuth.WebApi/Controllers/FlowSchemesController.cs index cd5e6082..f517084d 100644 --- a/OpenAuth.WebApi/Controllers/FlowSchemesController.cs +++ b/OpenAuth.WebApi/Controllers/FlowSchemesController.cs @@ -14,7 +14,7 @@ namespace OpenAuth.WebApi.Controllers /// [Route("api/[controller]/[action]")] [ApiController] - [ApiExplorerSettings(GroupName = "FlowSchemes")] + [ApiExplorerSettings(GroupName = "流程模版_FlowSchemes")] public class FlowSchemesController : ControllerBase { private readonly FlowSchemeApp _app; diff --git a/OpenAuth.WebApi/Controllers/FormsController.cs b/OpenAuth.WebApi/Controllers/FormsController.cs index 50d1f9a3..69d2b93c 100644 --- a/OpenAuth.WebApi/Controllers/FormsController.cs +++ b/OpenAuth.WebApi/Controllers/FormsController.cs @@ -14,7 +14,7 @@ namespace OpenAuth.WebApi.Controllers /// [Route("api/[controller]/[action]")] [ApiController] - [ApiExplorerSettings(GroupName = "Forms")] + [ApiExplorerSettings(GroupName = "表单_Forms")] public class FormsController : ControllerBase { private readonly FormApp _app; diff --git a/OpenAuth.WebApi/Controllers/ModulesController.cs b/OpenAuth.WebApi/Controllers/ModulesController.cs index 79fedaf3..b58af267 100644 --- a/OpenAuth.WebApi/Controllers/ModulesController.cs +++ b/OpenAuth.WebApi/Controllers/ModulesController.cs @@ -14,7 +14,7 @@ namespace OpenAuth.WebApi.Controllers /// [Route("api/[controller]/[action]")] [ApiController] - [ApiExplorerSettings(GroupName = "Modules")] + [ApiExplorerSettings(GroupName = "模块菜单_Modules")] public class ModulesController : ControllerBase { private ModuleManagerApp _app; diff --git a/OpenAuth.WebApi/Controllers/OpenJobsController.cs b/OpenAuth.WebApi/Controllers/OpenJobsController.cs index 7a6282ef..eb02eeb9 100644 --- a/OpenAuth.WebApi/Controllers/OpenJobsController.cs +++ b/OpenAuth.WebApi/Controllers/OpenJobsController.cs @@ -16,7 +16,7 @@ namespace OpenAuth.WebApi.Controllers /// [Route("api/[controller]/[action]")] [ApiController] - [ApiExplorerSettings(GroupName = "OpenJobs")] + [ApiExplorerSettings(GroupName = "定时任务_OpenJobs")] public class OpenJobsController : ControllerBase { private readonly OpenJobApp _app; diff --git a/OpenAuth.WebApi/Controllers/OrgsController.cs b/OpenAuth.WebApi/Controllers/OrgsController.cs index 07cd5cc7..4e2d4980 100644 --- a/OpenAuth.WebApi/Controllers/OrgsController.cs +++ b/OpenAuth.WebApi/Controllers/OrgsController.cs @@ -11,7 +11,7 @@ namespace OpenAuth.WebApi.Controllers /// [Route("api/[controller]/[action]")] [ApiController] - [ApiExplorerSettings(GroupName = "Orgs")] + [ApiExplorerSettings(GroupName = "组织机构_Orgs")] public class OrgsController : ControllerBase { private readonly OrgManagerApp _app; diff --git a/OpenAuth.WebApi/Controllers/ResourcesController.cs b/OpenAuth.WebApi/Controllers/ResourcesController.cs index 6ad7e65e..a7e63c98 100644 --- a/OpenAuth.WebApi/Controllers/ResourcesController.cs +++ b/OpenAuth.WebApi/Controllers/ResourcesController.cs @@ -17,7 +17,7 @@ namespace OpenAuth.WebApi.Controllers /// [Route("api/[controller]/[action]")] [ApiController] - [ApiExplorerSettings(GroupName = "Resources")] + [ApiExplorerSettings(GroupName = "资源管理_Resources")] public class ResourcesController : ControllerBase { private readonly ResourceApp _app; diff --git a/OpenAuth.WebApi/Controllers/RolesController.cs b/OpenAuth.WebApi/Controllers/RolesController.cs index a1e69a74..a49d7e6c 100644 --- a/OpenAuth.WebApi/Controllers/RolesController.cs +++ b/OpenAuth.WebApi/Controllers/RolesController.cs @@ -14,7 +14,7 @@ namespace OpenAuth.WebApi.Controllers /// [Route("api/[controller]/[action]")] [ApiController] - [ApiExplorerSettings(GroupName = "Roles")] + [ApiExplorerSettings(GroupName = "角色管理_Roles")] public class RolesController : ControllerBase { private readonly RoleApp _app; diff --git a/OpenAuth.WebApi/Controllers/SysConfController.cs b/OpenAuth.WebApi/Controllers/SysConfController.cs index 535d8911..1e35cb67 100644 --- a/OpenAuth.WebApi/Controllers/SysConfController.cs +++ b/OpenAuth.WebApi/Controllers/SysConfController.cs @@ -11,7 +11,7 @@ namespace OpenAuth.WebApi.Controllers /// [Route("api/[controller]/[action]")] [ApiController] - [ApiExplorerSettings(GroupName = "SysConf")] + [ApiExplorerSettings(GroupName = "系统配置_SysConf")] public class SysConfController :ControllerBase { private IOptions _appConfiguration; diff --git a/OpenAuth.WebApi/Controllers/SysLogsController.cs b/OpenAuth.WebApi/Controllers/SysLogsController.cs index ed849a84..cc788e2c 100644 --- a/OpenAuth.WebApi/Controllers/SysLogsController.cs +++ b/OpenAuth.WebApi/Controllers/SysLogsController.cs @@ -14,7 +14,7 @@ namespace OpenAuth.WebApi.Controllers /// [Route("api/[controller]/[action]")] [ApiController] - [ApiExplorerSettings(GroupName = "SysLogs")] + [ApiExplorerSettings(GroupName = "系统日志_SysLogs")] public class SysLogsController : ControllerBase { private readonly SysLogApp _app; diff --git a/OpenAuth.WebApi/Controllers/SysMessagesController.cs b/OpenAuth.WebApi/Controllers/SysMessagesController.cs index bb47f790..40033754 100644 --- a/OpenAuth.WebApi/Controllers/SysMessagesController.cs +++ b/OpenAuth.WebApi/Controllers/SysMessagesController.cs @@ -14,7 +14,7 @@ namespace OpenAuth.WebApi.Controllers /// [Route("api/[controller]/[action]")] [ApiController] - [ApiExplorerSettings(GroupName = "SysMessages")] + [ApiExplorerSettings(GroupName = "消息中心_SysMessages")] public class SysMessagesController : ControllerBase { private readonly SysMessageApp _app; diff --git a/OpenAuth.WebApi/Controllers/UsersController.cs b/OpenAuth.WebApi/Controllers/UsersController.cs index 27db6e74..2774eac0 100644 --- a/OpenAuth.WebApi/Controllers/UsersController.cs +++ b/OpenAuth.WebApi/Controllers/UsersController.cs @@ -13,7 +13,7 @@ namespace OpenAuth.WebApi.Controllers /// [Route("api/[controller]/[action]")] [ApiController] - [ApiExplorerSettings(GroupName = "Users")] + [ApiExplorerSettings(GroupName = "用户管理_Users")] public class UsersController : ControllerBase { private readonly UserManagerApp _app; diff --git a/OpenAuth.WebApi/Controllers/WmsInboundOrderDtblsController.cs b/OpenAuth.WebApi/Controllers/WmsInboundOrderDtblsController.cs index 1cc88ab8..8104b2cd 100644 --- a/OpenAuth.WebApi/Controllers/WmsInboundOrderDtblsController.cs +++ b/OpenAuth.WebApi/Controllers/WmsInboundOrderDtblsController.cs @@ -15,7 +15,7 @@ namespace OpenAuth.WebApi.Controllers /// [Route("api/[controller]/[action]")] [ApiController] - [ApiExplorerSettings(GroupName = "WmsInboundOrderDtbls")] + [ApiExplorerSettings(GroupName = "订单明细_WmsInboundOrderDtbls")] public class WmsInboundOrderDtblsController : ControllerBase { private readonly WmsInboundOrderDtblApp _app; diff --git a/OpenAuth.WebApi/Controllers/WmsInboundOrderTblsController.cs b/OpenAuth.WebApi/Controllers/WmsInboundOrderTblsController.cs index 08bcf3a4..da3b10eb 100644 --- a/OpenAuth.WebApi/Controllers/WmsInboundOrderTblsController.cs +++ b/OpenAuth.WebApi/Controllers/WmsInboundOrderTblsController.cs @@ -14,7 +14,7 @@ namespace OpenAuth.WebApi.Controllers /// [Route("api/[controller]/[action]")] [ApiController] - [ApiExplorerSettings(GroupName = "WmsInboundOrderTbls")] + [ApiExplorerSettings(GroupName = "订单_WmsInboundOrderTbls")] public class WmsInboundOrderTblsController : ControllerBase { private readonly WmsInboundOrderTblApp _app; diff --git a/OpenAuth.WebApi/Startup.cs b/OpenAuth.WebApi/Startup.cs index c3c96a3b..fcfe4313 100644 --- a/OpenAuth.WebApi/Startup.cs +++ b/OpenAuth.WebApi/Startup.cs @@ -41,11 +41,8 @@ namespace OpenAuth.WebApi // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - //在startup中需要强制创建log4net - var loggerFactory = LoggerFactory.Create(builder => - { - builder.AddLog4Net(); - }); + //在startup中需要强制创建log4net + var loggerFactory = LoggerFactory.Create(builder => { builder.AddLog4Net(); }); ILogger logger = loggerFactory.CreateLogger(); var identityServer = @@ -62,29 +59,32 @@ namespace OpenAuth.WebApi options.Audience = "openauthapi"; }); } + // 添加MiniProfiler服务 services.AddMiniProfiler(options => { // 设定访问分析结果URL的路由基地址 options.RouteBasePath = "/profiler"; - + options.ColorScheme = StackExchange.Profiling.ColorScheme.Auto; options.PopupRenderPosition = StackExchange.Profiling.RenderPosition.BottomLeft; options.PopupShowTimeWithChildren = true; options.PopupShowTrivial = true; options.SqlFormatter = new StackExchange.Profiling.SqlFormatters.InlineFormatter(); // options.IgnoredPaths.Add("/swagger/"); - }).AddEntityFramework();//显示SQL语句及耗时 + }).AddEntityFramework(); //显示SQL语句及耗时 //添加swagger services.AddSwaggerGen(option => { foreach (var controller in GetControllers()) { - option.SwaggerDoc(controller.Name.Replace("Controller", ""), new OpenApiInfo + var groupname = GetSwaggerGroupName(controller); + + option.SwaggerDoc(groupname, new OpenApiInfo { Version = "v1", - Title = controller.Name.Replace("Controller", ""), + Title = groupname, Description = "by yubaolee" }); } @@ -173,22 +173,11 @@ namespace OpenAuth.WebApi services.AddDataProtection().PersistKeysToFileSystem(new DirectoryInfo(Configuration["DataProtection"])); - //设置定时启动的任务 services.AddHostedService(); } - private List GetControllers() - { - Assembly asm = Assembly.GetExecutingAssembly(); - - var controlleractionlist = asm.GetTypes() - .Where(type => typeof(ControllerBase).IsAssignableFrom(type)) - .OrderBy(x => x.Name).ToList(); - return controlleractionlist; - } - public void ConfigureContainer(ContainerBuilder builder) { AutofacExt.InitAutofac(builder); @@ -234,25 +223,56 @@ namespace OpenAuth.WebApi //配置ServiceProvider AutofacContainerModule.ConfigServiceProvider(app.ApplicationServices); - + + app.UseSwagger(); // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.), // specifying the Swagger JSON endpoint. app.UseSwaggerUI(c => - { - c.IndexStream = () => GetType().GetTypeInfo().Assembly.GetManifestResourceStream("OpenAuth.WebApi.index.html"); - + { + c.IndexStream = () => + GetType().GetTypeInfo().Assembly.GetManifestResourceStream("OpenAuth.WebApi.index.html"); + foreach (var controller in GetControllers()) { - c.SwaggerEndpoint($"/swagger/{controller.Name.Replace("Controller", "")}/swagger.json", - controller.Name.Replace("Controller", "")); + var groupname = GetSwaggerGroupName(controller); + + c.SwaggerEndpoint($"/swagger/{groupname}/swagger.json", groupname); } - c.DocExpansion(DocExpansion.List); //默认展开列表 + c.DocExpansion(DocExpansion.List); //默认展开列表 c.OAuthClientId("OpenAuth.WebApi"); //oauth客户端名称 c.OAuthAppName("开源版webapi认证"); // 描述 }); } + + /// + /// 获取控制器对应的swagger分组值 + /// + private string GetSwaggerGroupName(Type controller) + { + var groupname = controller.Name.Replace("Controller", ""); + var apisetting = controller.GetCustomAttribute(typeof(ApiExplorerSettingsAttribute)); + if (apisetting != null) + { + groupname = ((ApiExplorerSettingsAttribute) apisetting).GroupName; + } + + return groupname; + } + + /// + /// 获取所有的控制器 + /// + private List GetControllers() + { + Assembly asm = Assembly.GetExecutingAssembly(); + + var controlleractionlist = asm.GetTypes() + .Where(type => typeof(ControllerBase).IsAssignableFrom(type)) + .OrderBy(x => x.Name).ToList(); + return controlleractionlist; + } } } \ No newline at end of file diff --git a/README.md b/README.md index 21cda0c6..7cda5564 100644 --- a/README.md +++ b/README.md @@ -36,13 +36,15 @@ -## 关于OpenAuth.Net企业版的说明: +## 关于OpenAuth.Net企业版/高级版的说明: -目前OpenAuth.Net以全部开源的方式向大众开放,对于有经验的开发者,官方文档足以满足日常开发。为了能让项目走的更远,特推出基于vue + element UI 的单页面应用程序,即企业版OpenAuth.Pro +目前OpenAuth.Net以全部开源的方式向大众开放,对于有经验的开发者,官方文档足以满足日常开发。为了能让项目走的更远,特推出基于vue + element UI 的单页面应用程序,即企业版/高级版OpenAuth.Pro -**该版本后端基于OpenAuth.Core的API接口,前端基于vue-element-admin,采用VUE全家桶(VUE+VUEX+VUE-ROUTER)单页面SPA开发** +**该版本是一套后端基于OpenAuth.WebAPI接口,前端基于vue-element-admin,采用VUE全家桶(VUE+VUEX+VUE-ROUTER)单页面SPA开发的管理后台 [点击这里查看效果](http://demo.openauth.me:1803)** -版本附赠VIP服务,提供VIP专属QQ群,企业报销凭据、专属内部文档、技术咨询服务等。[如何获取请查看这里](http://openauth.me/question/detail.html?id=a2be2d61-7fcb-4df8-8be2-9f296c22a89c),快加入VIP大家庭 **与有理想的.NET开发者一起成长** +**另外** 企业版包含一套基于有赞Vant+Vue3的移动端界面,[请使用浏览器移动模式查看效果](http://demo.openauth.me:1804) + +企业版/高级版附赠VIP服务,提供VIP专属QQ群,企业报销凭据、专属内部文档、技术咨询服务等。[如何获取请查看这里](http://openauth.me/question/detail.html?id=a2be2d61-7fcb-4df8-8be2-9f296c22a89c),快加入VIP大家庭 **与有理想的.NET开发者一起成长** 效果如下: ![API启动效果图](https://images.gitee.com/uploads/images/2021/0422/012037_ec51b7e6_362401.png "api启动.png") @@ -62,7 +64,9 @@ ## 演示直达 -* 企业版演示地址: http://demo.openauth.me:1803 +* 企业版/高级版演示地址: http://demo.openauth.me:1803 + +* 企业版H5演示地址(请使用浏览器移动模式或直接用手机打开): http://demo.openauth.me:1804 * 开源版演示地址: http://demo.openauth.me:1802