Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4ed517ac90 | ||
|
|
eacbbc3071 | ||
|
|
ee3a3a9d56 | ||
|
|
61672c5770 | ||
|
|
c6b9746603 | ||
|
|
f7e1b9be2a | ||
|
|
d0fe883e74 |
@@ -3,20 +3,7 @@ name: PublishNugetPackage
|
|||||||
on: [create]
|
on: [create]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
|
||||||
name: Build Project
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v1
|
|
||||||
- name: Setup .NET Core
|
|
||||||
uses: actions/setup-dotnet@v1
|
|
||||||
with:
|
|
||||||
dotnet-version: '3.1.101'
|
|
||||||
- name: Build
|
|
||||||
run: dotnet build
|
|
||||||
|
|
||||||
publish:
|
publish:
|
||||||
needs: build
|
|
||||||
name: Publish Project to Nuget
|
name: Publish Project to Nuget
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
@@ -24,11 +11,11 @@ jobs:
|
|||||||
- name: Setup .NET Core
|
- name: Setup .NET Core
|
||||||
uses: actions/setup-dotnet@v1
|
uses: actions/setup-dotnet@v1
|
||||||
with:
|
with:
|
||||||
dotnet-version: '3.1.101'
|
dotnet-version: '5.0.100'
|
||||||
- name: Publish
|
- name: Publish
|
||||||
run: |
|
run: |
|
||||||
version=`git describe --tags`
|
version=`git describe --tags`
|
||||||
dotnet pack --configuration release -p:PackageVersion=$version
|
dotnet build --configuration release -p:PackageVersion=$version
|
||||||
dotnet nuget push bin/release/Simcu.SimApi.$version.nupkg -k ${NUGET_APIKEY} -s https://www.nuget.org/api/v2/package
|
dotnet nuget push bin/release/Simcu.SimApi.$version.nupkg -k ${NUGET_APIKEY} -s https://www.nuget.org/api/v2/package
|
||||||
env:
|
env:
|
||||||
NUGET_APIKEY: ${{ secrets.NUGET_APIKEY }}
|
NUGET_APIKEY: ${{ secrets.NUGET_APIKEY }}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Mvc.Filters;
|
using Microsoft.AspNetCore.Mvc.Filters;
|
||||||
using SimApi.Communications;
|
using SimApi.Communications;
|
||||||
using SimApi.Exceptions;
|
using SimApi.Exceptions;
|
||||||
@@ -14,6 +15,7 @@ namespace SimApi.Attributes
|
|||||||
{
|
{
|
||||||
private string[] Types { get; }
|
private string[] Types { get; }
|
||||||
|
|
||||||
|
|
||||||
//默认是user登录类型
|
//默认是user登录类型
|
||||||
public SimApiAuthAttribute()
|
public SimApiAuthAttribute()
|
||||||
{
|
{
|
||||||
@@ -32,6 +34,13 @@ namespace SimApi.Attributes
|
|||||||
Types = types;
|
Types = types;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//只检测一种用户类型的快捷方式
|
||||||
|
public SimApiAuthAttribute(string type, string url)
|
||||||
|
{
|
||||||
|
Types = new[] { type };
|
||||||
|
new HttpPostAttribute(url);
|
||||||
|
}
|
||||||
|
|
||||||
public override void OnActionExecuting(ActionExecutingContext context)
|
public override void OnActionExecuting(ActionExecutingContext context)
|
||||||
{
|
{
|
||||||
var loginInfo = (SimApiLoginItem)context.HttpContext.Items["LoginInfo"];
|
var loginInfo = (SimApiLoginItem)context.HttpContext.Items["LoginInfo"];
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ namespace SimApi.Controllers
|
|||||||
/// <param name="code">错误代码</param>
|
/// <param name="code">错误代码</param>
|
||||||
/// <param name="message">错误描述(若是常规错误,代码可自动带取描述)</param>
|
/// <param name="message">错误描述(若是常规错误,代码可自动带取描述)</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
protected static void Error(int code = 500, string message = "")
|
protected static void Error(int code = 500, string message = "服务器错误")
|
||||||
{
|
{
|
||||||
throw new SimApiException(code, message);
|
throw new SimApiException(code, message);
|
||||||
}
|
}
|
||||||
@@ -58,7 +58,7 @@ namespace SimApi.Controllers
|
|||||||
/// <param name="condition">检测条件</param>
|
/// <param name="condition">检测条件</param>
|
||||||
/// <param name="code">错误代码</param>
|
/// <param name="code">错误代码</param>
|
||||||
/// <param name="message">错误描述</param>
|
/// <param name="message">错误描述</param>
|
||||||
protected static void ErrorWhen(bool condition, int code = 500, string message = "")
|
protected static void ErrorWhen(bool condition, int code = 500, string message = "服务器错误")
|
||||||
{
|
{
|
||||||
if (condition)
|
if (condition)
|
||||||
{
|
{
|
||||||
@@ -72,7 +72,7 @@ namespace SimApi.Controllers
|
|||||||
/// <param name="condition">检测条件</param>
|
/// <param name="condition">检测条件</param>
|
||||||
/// <param name="code">错误代码</param>
|
/// <param name="code">错误代码</param>
|
||||||
/// <param name="message">错误描述</param>
|
/// <param name="message">错误描述</param>
|
||||||
protected static void ErrorWhenNull(object condition, int code = 404, string message = "")
|
protected static void ErrorWhenNull(object condition, int code = 404, string message = "资源不存在")
|
||||||
{
|
{
|
||||||
ErrorWhen(condition == null, code, message);
|
ErrorWhen(condition == null, code, message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ namespace SimApi.Middlewares
|
|||||||
httpContext.Items.Add("LoginInfo", JsonSerializer.Deserialize<SimApiLoginItem>(login));
|
httpContext.Items.Add("LoginInfo", JsonSerializer.Deserialize<SimApiLoginItem>(login));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Next(httpContext);
|
return Next(httpContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,11 @@ namespace SimApi.Middlewares
|
|||||||
|
|
||||||
public async Task InvokeAsync(HttpContext context)
|
public async Task InvokeAsync(HttpContext context)
|
||||||
{
|
{
|
||||||
|
if (context.Request.Headers.ContainsKey("Query-Id"))
|
||||||
|
{
|
||||||
|
context.Response.Headers["Query-Id"] = context.Request.Headers["Query-Id"];
|
||||||
|
}
|
||||||
|
|
||||||
var response = new SimApiBaseResponse();
|
var response = new SimApiBaseResponse();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
+7
-4
@@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
<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>
|
||||||
@@ -11,10 +11,13 @@
|
|||||||
<IsPackable>true</IsPackable>
|
<IsPackable>true</IsPackable>
|
||||||
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
||||||
<IncludeSymbols>true</IncludeSymbols>
|
<IncludeSymbols>true</IncludeSymbols>
|
||||||
<ReleaseVersion>1.1.1</ReleaseVersion>
|
<ReleaseVersion>5.0.0</ReleaseVersion>
|
||||||
<SynchReleaseVersion>false</SynchReleaseVersion>
|
<SynchReleaseVersion>false</SynchReleaseVersion>
|
||||||
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
|
<PackageVersion>5.0.2</PackageVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition=" '$(RunConfiguration)' == 'YYApi' " />
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Helpers\" />
|
<Folder Include="Helpers\" />
|
||||||
<Folder Include="Communications\" />
|
<Folder Include="Communications\" />
|
||||||
@@ -24,8 +27,8 @@
|
|||||||
<Folder Include="Exceptions\" />
|
<Folder Include="Exceptions\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="5.5.1" />
|
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="5.6.3" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="5.5.1" />
|
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="5.6.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ProjectExtensions>
|
<ProjectExtensions>
|
||||||
<MonoDevelop>
|
<MonoDevelop>
|
||||||
|
|||||||
Reference in New Issue
Block a user