From b8e59f524ab0657e97f43066c74f94168f594ab7 Mon Sep 17 00:00:00 2001 From: falcon <9504402@qq.com> Date: Sat, 9 May 2020 11:44:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E4=B8=BB=E9=A1=B5=E6=A1=86?= =?UTF-8?q?=E6=9E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FAuth/Controllers/AppController.cs | 25 ++++++++++++++++++++++++ FAuth/Controllers/ControllerBase.cs | 1 + FAuth/Controllers/RoleController.cs | 25 ++++++++++++++++++++++++ FAuth/Controllers/RoleGroupController.cs | 25 ++++++++++++++++++++++++ FAuth/Controllers/UserController.cs | 25 ++++++++++++++++++++++++ FAuth/Startup.cs | 8 +++----- FAuth/Views/App/Index.cshtml | 7 +++++++ FAuth/Views/Home/Index.cshtml | 3 +-- FAuth/Views/Role/Index.cshtml | 7 +++++++ FAuth/Views/RoleGroup/Index.cshtml | 7 +++++++ FAuth/Views/Shared/_Layout.cshtml | 16 ++++++++++----- FAuth/Views/User/Index.cshtml | 7 +++++++ 12 files changed, 144 insertions(+), 12 deletions(-) create mode 100644 FAuth/Controllers/AppController.cs create mode 100644 FAuth/Controllers/RoleController.cs create mode 100644 FAuth/Controllers/RoleGroupController.cs create mode 100644 FAuth/Controllers/UserController.cs create mode 100644 FAuth/Views/App/Index.cshtml create mode 100644 FAuth/Views/Role/Index.cshtml create mode 100644 FAuth/Views/RoleGroup/Index.cshtml create mode 100644 FAuth/Views/User/Index.cshtml diff --git a/FAuth/Controllers/AppController.cs b/FAuth/Controllers/AppController.cs new file mode 100644 index 0000000..a53bd58 --- /dev/null +++ b/FAuth/Controllers/AppController.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using FAuth.Models; + +namespace FAuth.Controllers +{ + /// + /// 用户控制器 + /// + public class AppController:ControllerBase + { + public AppController(ILogger logger,IServiceProvider service) : base(logger,service) { + } + + public IActionResult Index() { + return PartialView(); + } + + } +} diff --git a/FAuth/Controllers/ControllerBase.cs b/FAuth/Controllers/ControllerBase.cs index 97cee89..e29dc03 100644 --- a/FAuth/Controllers/ControllerBase.cs +++ b/FAuth/Controllers/ControllerBase.cs @@ -10,6 +10,7 @@ namespace FAuth.Controllers /// /// 控制器类基类 /// + //[Route("[Controller]/[Action]")] public abstract class ControllerBase:Controller { /// diff --git a/FAuth/Controllers/RoleController.cs b/FAuth/Controllers/RoleController.cs new file mode 100644 index 0000000..b59879e --- /dev/null +++ b/FAuth/Controllers/RoleController.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using FAuth.Models; + +namespace FAuth.Controllers +{ + /// + /// 角色 + /// + public class RoleController:ControllerBase + { + public RoleController(ILogger logger,IServiceProvider service) : base(logger,service) { + } + + public IActionResult Index() { + return PartialView(); + } + + } +} diff --git a/FAuth/Controllers/RoleGroupController.cs b/FAuth/Controllers/RoleGroupController.cs new file mode 100644 index 0000000..ef8e5b3 --- /dev/null +++ b/FAuth/Controllers/RoleGroupController.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using FAuth.Models; + +namespace FAuth.Controllers +{ + /// + /// 角色组控制器 + /// + public class RoleGroupController:ControllerBase + { + public RoleGroupController(ILogger logger,IServiceProvider service) : base(logger,service) { + } + + public IActionResult Index() { + return PartialView(); + } + + } +} diff --git a/FAuth/Controllers/UserController.cs b/FAuth/Controllers/UserController.cs new file mode 100644 index 0000000..ab2e9cc --- /dev/null +++ b/FAuth/Controllers/UserController.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using FAuth.Models; + +namespace FAuth.Controllers +{ + /// + /// 用户控制器 + /// + public class UserController:ControllerBase + { + public UserController(ILogger logger,IServiceProvider service) : base(logger,service) { + } + + public IActionResult Index() { + return PartialView(); + } + + } +} diff --git a/FAuth/Startup.cs b/FAuth/Startup.cs index f6ea336..0ac8944 100644 --- a/FAuth/Startup.cs +++ b/FAuth/Startup.cs @@ -105,20 +105,18 @@ namespace FAuth app.UseHttpsRedirection(); app.UseStaticFiles(); - app.UseRouting(); app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/V1/swagger.json","ӿĵ"); - c.RoutePrefix = ""; + c.RoutePrefix = "api"; }); - app.UseAuthorization(); - + app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", - pattern: "{controller=Home}/{action=Index}/{id?}"); + pattern: "{controller=Home}/{action=Index}"); }); } } diff --git a/FAuth/Views/App/Index.cshtml b/FAuth/Views/App/Index.cshtml new file mode 100644 index 0000000..88c424d --- /dev/null +++ b/FAuth/Views/App/Index.cshtml @@ -0,0 +1,7 @@ + +@{ + ViewData["Title"] = "Index"; +} + +

AppController Index

+ diff --git a/FAuth/Views/Home/Index.cshtml b/FAuth/Views/Home/Index.cshtml index 08a5a5c..640d685 100644 --- a/FAuth/Views/Home/Index.cshtml +++ b/FAuth/Views/Home/Index.cshtml @@ -1,8 +1,7 @@ @{ - ViewData["Title"] = "Home Page"; + ViewBag.Title = "首页"; }

Welcome

-

Learn about building Web apps with ASP.NET Core.

diff --git a/FAuth/Views/Role/Index.cshtml b/FAuth/Views/Role/Index.cshtml new file mode 100644 index 0000000..392ebb0 --- /dev/null +++ b/FAuth/Views/Role/Index.cshtml @@ -0,0 +1,7 @@ + +@{ + ViewData["Title"] = "Index"; +} + +

RoleController Index

+ diff --git a/FAuth/Views/RoleGroup/Index.cshtml b/FAuth/Views/RoleGroup/Index.cshtml new file mode 100644 index 0000000..53a1d85 --- /dev/null +++ b/FAuth/Views/RoleGroup/Index.cshtml @@ -0,0 +1,7 @@ + +@{ + ViewData["Title"] = "Index"; +} + +

RoleGroupController Index

+ diff --git a/FAuth/Views/Shared/_Layout.cshtml b/FAuth/Views/Shared/_Layout.cshtml index 297dd94..0f19801 100644 --- a/FAuth/Views/Shared/_Layout.cshtml +++ b/FAuth/Views/Shared/_Layout.cshtml @@ -11,7 +11,7 @@