Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
31df4a7593 | ||
|
|
dbc05c13ee |
@@ -11,7 +11,7 @@ jobs:
|
|||||||
- name: Setup .NET Core
|
- name: Setup .NET Core
|
||||||
uses: actions/setup-dotnet@v1
|
uses: actions/setup-dotnet@v1
|
||||||
with:
|
with:
|
||||||
dotnet-version: '5.0.0'
|
dotnet-version: '3.1.101'
|
||||||
- name: Build
|
- name: Build
|
||||||
run: dotnet build
|
run: dotnet build
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Mvc.Filters;
|
|||||||
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using YYApi.Exceptions;
|
using YYApi.Exceptions;
|
||||||
|
using YYApi.Attributes;
|
||||||
|
|
||||||
namespace YYApi.Controllers
|
namespace YYApi.Controllers
|
||||||
{
|
{
|
||||||
@@ -77,22 +78,14 @@ namespace YYApi.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 错误回馈页面
|
/// 上传文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="code">错误代码</param>
|
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet("exception/{code:int}")]
|
|
||||||
[ApiExplorerSettings(IgnoreApi = true)]
|
|
||||||
public YYBaseResponse ExceptionHandler(int code)
|
|
||||||
{
|
|
||||||
var response = new YYBaseResponse();
|
|
||||||
response.SetCode(code);
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected YYBaseResponse<string> UploadFile()
|
protected YYBaseResponse<string> UploadFile()
|
||||||
{
|
{
|
||||||
return new YYBaseResponse<string>();
|
return new YYBaseResponse<string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using YYApi.Attributes;
|
||||||
|
using YYApi.Communications;
|
||||||
|
using YYApi.Helpers;
|
||||||
|
|
||||||
|
namespace YYApi.Controllers
|
||||||
|
{
|
||||||
|
public class YYCommonController : YYBaseController
|
||||||
|
{
|
||||||
|
private YYAuth Auth { get; }
|
||||||
|
|
||||||
|
public YYCommonController(YYAuth auth)
|
||||||
|
{
|
||||||
|
Auth = auth;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 错误回馈页面
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="code">错误代码</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("exception/{code:int}")]
|
||||||
|
[ApiExplorerSettings(IgnoreApi = true)]
|
||||||
|
public YYBaseResponse ExceptionHandler(int code)
|
||||||
|
{
|
||||||
|
var response = new YYBaseResponse();
|
||||||
|
response.SetCode(code);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 检测用户登陆的控制器
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("/auth/check"), YYDoc("认证", "检测登陆")]
|
||||||
|
public YYBaseResponse<int> CheckLogin()
|
||||||
|
{
|
||||||
|
ErrorWhenNull(LoginInfo, 401);
|
||||||
|
return new YYBaseResponse<int> { Data = LoginInfo.Id };
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 退出登陆
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("/auth/logout"), YYDoc("认证", "退出登陆")]
|
||||||
|
public YYBaseResponse Logout()
|
||||||
|
{
|
||||||
|
string token = null;
|
||||||
|
|
||||||
|
if (Request.Headers.ContainsKey("Token"))
|
||||||
|
{
|
||||||
|
token = Request.Headers["Token"];
|
||||||
|
}
|
||||||
|
Auth.Logout(token);
|
||||||
|
return new YYBaseResponse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net5.0</TargetFramework>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
<OutputType>Library</OutputType>
|
<OutputType>Library</OutputType>
|
||||||
<PackOnBuild>true</PackOnBuild>
|
<PackOnBuild>true</PackOnBuild>
|
||||||
<Version>0.2.3</Version>
|
<Version>0.2.3</Version>
|
||||||
|
|||||||
Reference in New Issue
Block a user