Compare commits

...
3 Commits
Author SHA1 Message Date
xrain 8f41ba0150 move common controller to api group 2021-05-30 03:35:27 +08:00
xrain 9bce77a08e fix 301 302 2021-05-29 14:55:14 +08:00
xrain 8c7f4ac12f add 3.1 support 2021-05-29 11:41:03 +08:00
3 changed files with 10 additions and 4 deletions
+3 -1
View File
@@ -6,6 +6,7 @@ using SimApi.Helpers;
namespace SimApi.Controllers namespace SimApi.Controllers
{ {
[ApiExplorerSettings(GroupName = "api")]
public class YYCommonController : SimApiBaseController public class YYCommonController : SimApiBaseController
{ {
private SimApiAuth Auth { get; } private SimApiAuth Auth { get; }
@@ -37,7 +38,7 @@ namespace SimApi.Controllers
public SimApiBaseResponse<int> CheckLogin() public SimApiBaseResponse<int> CheckLogin()
{ {
ErrorWhenNull(LoginInfo, 401); ErrorWhenNull(LoginInfo, 401);
return new SimApiBaseResponse<int> { Data = LoginInfo.Id }; return new SimApiBaseResponse<int> {Data = LoginInfo.Id};
} }
/// <summary> /// <summary>
@@ -53,6 +54,7 @@ namespace SimApi.Controllers
{ {
token = Request.Headers["Token"]; token = Request.Headers["Token"];
} }
Auth.Logout(token); Auth.Logout(token);
return new SimApiBaseResponse(); return new SimApiBaseResponse();
} }
+4
View File
@@ -1,4 +1,5 @@
using System; using System;
using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using SimApi.Communications; using SimApi.Communications;
@@ -33,10 +34,13 @@ namespace SimApi.Middlewares
{ {
await Next(context); await Next(context);
if (context.Response.StatusCode != 200) if (context.Response.StatusCode != 200)
{
if (!new[] {301, 302}.Contains(context.Response.StatusCode))
{ {
throw new SimApiException(context.Response.StatusCode); throw new SimApiException(context.Response.StatusCode);
} }
} }
}
catch (SimApiException ex) catch (SimApiException ex)
{ {
if (string.IsNullOrEmpty(ex.Message)) if (string.IsNullOrEmpty(ex.Message))
+1 -1
View File
@@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp5.0</TargetFramework>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<PackOnBuild>true</PackOnBuild> <PackOnBuild>true</PackOnBuild>
<Version>0.2.3</Version> <Version>0.2.3</Version>
@@ -15,6 +14,7 @@
<SynchReleaseVersion>false</SynchReleaseVersion> <SynchReleaseVersion>false</SynchReleaseVersion>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageVersion>5.0.2</PackageVersion> <PackageVersion>5.0.2</PackageVersion>
<TargetFrameworks>net5.0;netcoreapp3.1</TargetFrameworks>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(RunConfiguration)' == 'YYApi' " /> <PropertyGroup Condition=" '$(RunConfiguration)' == 'YYApi' " />