版本号
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
using System.Reflection;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Jiaowu.Api.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/system")]
|
||||
public sealed class SystemController : ControllerBase
|
||||
{
|
||||
[AllowAnonymous]
|
||||
[HttpGet("version")]
|
||||
[ProducesResponseType<SystemVersionResponse>(StatusCodes.Status200OK)]
|
||||
public SystemVersionResponse GetVersion()
|
||||
{
|
||||
var assembly = typeof(SystemController).Assembly;
|
||||
var informationalVersion = assembly
|
||||
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?
|
||||
.InformationalVersion;
|
||||
var version = informationalVersion?.Split('+', 2)[0]
|
||||
?? assembly.GetName().Version?.ToString(3)
|
||||
?? "unknown";
|
||||
|
||||
return new SystemVersionResponse(version);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed record SystemVersionResponse(string Version);
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<Version>2.2.0</Version>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<SpaRoot>$([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)/../../web'))</SpaRoot>
|
||||
|
||||
Reference in New Issue
Block a user