add some APIs
This commit is contained in:
59
Server/Controller/ApiController.cs
Normal file
59
Server/Controller/ApiController.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using Blahblah.FlowerStory.Server.Data;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Blahblah.FlowerStory.Server.Controller;
|
||||
|
||||
/// <summary>
|
||||
/// 基础 API 服务
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Produces("application/json")]
|
||||
[Route("api")]
|
||||
public partial class ApiController : BaseController
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public ApiController(FlowerDatabase database, ILogger<BaseController>? logger = null) : base(database, logger)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取版本号
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 请求示例:
|
||||
///
|
||||
/// GET /api/version
|
||||
///
|
||||
/// </remarks>
|
||||
/// <returns>版本号</returns>
|
||||
/// <response code="200">返回版本号</response>
|
||||
[Route("version", Name = "getVersion")]
|
||||
[HttpGet]
|
||||
[ResponseCache(NoStore = true, Location = ResponseCacheLocation.None)]
|
||||
public ActionResult<string> GetApiVersion()
|
||||
{
|
||||
return Ok(Program.Version);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取常量字典定义
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 请求示例:
|
||||
///
|
||||
/// GET /api/consts?{ver}
|
||||
///
|
||||
/// </remarks>
|
||||
/// <returns>字典集</returns>
|
||||
/// <response code="200">返回常量字典集</response>
|
||||
[Route("consts", Name = "getConsts")]
|
||||
[HttpGet]
|
||||
public ActionResult<DefinitionResult> GetDefinitions()
|
||||
{
|
||||
return Ok(new DefinitionResult
|
||||
{
|
||||
Categories = Constants.Categories,
|
||||
Events = Constants.Events,
|
||||
});
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user