From 5fc4020f460c99227309f25a4bd920ebc73e3726 Mon Sep 17 00:00:00 2001
From: falcon <9504402@qq.com>
Date: Mon, 30 Mar 2020 16:10:51 +0800
Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E8=8C=83=E4=BE=8B=E6=8E=A5?=
=?UTF-8?q?=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
FAuth/Controllers/ControllerBase.cs | 4 +-
FAuth/Controllers/HomeController.cs | 9 +---
FAuth/Controllers/api/AccountController.cs | 14 +++++
FAuth/Controllers/api/ApiControllerBase.cs | 16 ++++++
FAuth/Controllers/api/UserController.cs | 59 ++++++++++++++++++++++
FAuth/DataBase/Tables/FUser.cs | 27 ++++++++++
FAuth/FAuth.csproj | 4 --
FAuth/Models/CheckUserResult.cs | 22 ++++++++
FAuth/Models/UserInfo.cs | 19 +++++++
FAuth/Startup.cs | 9 +++-
10 files changed, 168 insertions(+), 15 deletions(-)
create mode 100644 FAuth/Controllers/api/AccountController.cs
create mode 100644 FAuth/Controllers/api/ApiControllerBase.cs
create mode 100644 FAuth/Controllers/api/UserController.cs
create mode 100644 FAuth/DataBase/Tables/FUser.cs
create mode 100644 FAuth/Models/CheckUserResult.cs
create mode 100644 FAuth/Models/UserInfo.cs
diff --git a/FAuth/Controllers/ControllerBase.cs b/FAuth/Controllers/ControllerBase.cs
index 8cc6d37..b949d1a 100644
--- a/FAuth/Controllers/ControllerBase.cs
+++ b/FAuth/Controllers/ControllerBase.cs
@@ -7,7 +7,7 @@ namespace FAuth.Controllers
///
/// 控制器类基类
///
- public abstract class ControllerBase:Controller
+ public abstract class ControllerBase:Controller
{
///
/// 日志记录服务
@@ -23,7 +23,7 @@ namespace FAuth.Controllers
///
/// 控制器日志组件
/// 服务集合
- public ControllerBase(ILogger logger,IServiceProvider service) {
+ public ControllerBase(ILogger logger,IServiceProvider service) {
this.Logger = logger;
this.Services = service;
}
diff --git a/FAuth/Controllers/HomeController.cs b/FAuth/Controllers/HomeController.cs
index ba6847a..fa5b864 100644
--- a/FAuth/Controllers/HomeController.cs
+++ b/FAuth/Controllers/HomeController.cs
@@ -12,14 +12,9 @@ namespace FAuth.Controllers
///
/// Home控制器
///
- public class HomeController:ControllerBase
+ public class HomeController:ControllerBase
{
- ///
- /// 生成控制器
- ///
- /// 日志组件
- /// 服务集合
- public HomeController(ILogger logger,IServiceProvider service) : base(logger,service) {
+ public HomeController(ILogger logger,IServiceProvider service) : base(logger,service) {
}
public IActionResult Index() {
diff --git a/FAuth/Controllers/api/AccountController.cs b/FAuth/Controllers/api/AccountController.cs
new file mode 100644
index 0000000..84c6cba
--- /dev/null
+++ b/FAuth/Controllers/api/AccountController.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using Microsoft.Extensions.Logging;
+
+namespace FAuth.Controllers.api
+{
+ public class AccountController:ApiControllerBase
+ {
+ public AccountController(ILogger logger,IServiceProvider service) : base(logger,service) {
+ }
+ }
+}
diff --git a/FAuth/Controllers/api/ApiControllerBase.cs b/FAuth/Controllers/api/ApiControllerBase.cs
new file mode 100644
index 0000000..9f84798
--- /dev/null
+++ b/FAuth/Controllers/api/ApiControllerBase.cs
@@ -0,0 +1,16 @@
+using System;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Logging;
+
+namespace FAuth.Controllers.api
+{
+ ///
+ /// api控制器基类
+ ///
+ [ApiController, Route("api/[Controller]/[Action]")]
+ public abstract class ApiControllerBase:ControllerBase
+ {
+ public ApiControllerBase(ILogger logger,IServiceProvider service) : base(logger,service) {
+ }
+ }
+}
diff --git a/FAuth/Controllers/api/UserController.cs b/FAuth/Controllers/api/UserController.cs
new file mode 100644
index 0000000..1151716
--- /dev/null
+++ b/FAuth/Controllers/api/UserController.cs
@@ -0,0 +1,59 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using FAuth.Models;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Logging;
+using FAuth.DataBase.Tables;
+
+namespace FAuth.Controllers.api
+{
+ ///
+ /// 用户相关api控制器接口
+ ///
+ public class UserController:ApiControllerBase
+ {
+ public UserController(ILogger logger,IServiceProvider service) : base(logger,service) {
+ }
+
+ ///
+ /// 验证用户名密码是否匹配
+ ///
+ /// 用户名
+ /// 密码
+ /// 是否匹配
+ [HttpPost]
+ [ProducesResponseType(typeof(CheckUserResult),200)]
+ public CheckUserResult CheckUser(string userName,string password) {
+ return new CheckUserResult {
+ Result = userName == password,
+ Ticket = Guid.NewGuid().ToString(),
+ };
+ }
+
+ ///
+ /// 根据用户凭据获取用户信息
+ ///
+ /// 登录票据
+ /// 用户信息
+ [HttpPost]
+ [ProducesResponseType(typeof(UserInfo),200)]
+ public UserInfo GetUserByTicket(string ticket) {
+ return new UserInfo {
+ UserName = "aaa"
+ };
+ }
+
+ ///
+ /// 根据提供的登陆票据修改用户密码
+ ///
+ /// 票据
+ /// 新密码
+ /// 是否成功
+ [HttpPost]
+ public bool ChangePassword(string ticket,string nPassword) {
+ return true;
+ }
+ }
+}
diff --git a/FAuth/DataBase/Tables/FUser.cs b/FAuth/DataBase/Tables/FUser.cs
new file mode 100644
index 0000000..13cc3b1
--- /dev/null
+++ b/FAuth/DataBase/Tables/FUser.cs
@@ -0,0 +1,27 @@
+using System;
+
+namespace FAuth.DataBase.Tables
+{
+ ///
+ /// 用户信息
+ ///
+ public class FUser
+ {
+ ///
+ /// 用户流水编号
+ ///
+ public int Id { get; set; }
+ ///
+ /// 用户安全编号
+ ///
+ public Guid SId { get; set; }
+ ///
+ /// 用户登录名
+ ///
+ public string UserName { get; set; }
+ ///
+ /// 登录密码
+ ///
+ public string Password { get; set; }
+ }
+}
diff --git a/FAuth/FAuth.csproj b/FAuth/FAuth.csproj
index 24f3161..cf110ed 100644
--- a/FAuth/FAuth.csproj
+++ b/FAuth/FAuth.csproj
@@ -15,10 +15,6 @@
-
-
-
-
diff --git a/FAuth/Models/CheckUserResult.cs b/FAuth/Models/CheckUserResult.cs
new file mode 100644
index 0000000..8972447
--- /dev/null
+++ b/FAuth/Models/CheckUserResult.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace FAuth.Models
+{
+ ///
+ /// 用户密码验证结果
+ ///
+ public class CheckUserResult
+ {
+ ///
+ /// 验证结果
+ ///
+ public bool Result { get; set; }
+ ///
+ /// 票据
+ ///
+ public string Ticket { get; set; }
+ }
+}
diff --git a/FAuth/Models/UserInfo.cs b/FAuth/Models/UserInfo.cs
new file mode 100644
index 0000000..d57a721
--- /dev/null
+++ b/FAuth/Models/UserInfo.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace FAuth.Models
+{
+ ///
+ /// 用户信息
+ ///
+ public class UserInfo
+ {
+ ///
+ /// 用户登录名
+ ///
+ public string UserName { get; set; }
+
+ }
+}
diff --git a/FAuth/Startup.cs b/FAuth/Startup.cs
index a252225..517da2b 100644
--- a/FAuth/Startup.cs
+++ b/FAuth/Startup.cs
@@ -6,6 +6,7 @@ using FAuth.DataBase;
using FAuth.Extensions;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
+using Microsoft.AspNetCore.Mvc.Routing;
using Microsoft.Extensions.Caching.Redis;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
@@ -53,7 +54,11 @@ namespace FAuth
c.SwaggerDoc("V1",new OpenApiInfo {
Title = "ӿĵ",
Version = "1.0",
- Description = "",
+ Description = "api",
+ Contact = new OpenApiContact {
+ Name = "Falcon",
+ Url = new Uri("http://39.105.71.191/Falcon/FAuth"),
+ },
});
var xmlPath = Path.Combine(AppContext.BaseDirectory,typeof(Program).Assembly.GetName().Name + ".xml");
c.IncludeXmlComments(xmlPath,true);
@@ -78,7 +83,7 @@ namespace FAuth
app.UseSwagger();
app.UseSwaggerUI(c => {
c.SwaggerEndpoint("/swagger/V1/swagger.json","ӿĵ");
- c.RoutePrefix = "";
+ c.RoutePrefix = "api";
});
app.UseAuthorization();