2025-11-01 21:38:55 +08:00
|
|
|
using System.Collections.Generic;
|
2025-11-01 15:40:55 +08:00
|
|
|
using Microsoft.AspNetCore.Mvc;
|
2026-05-04 15:35:47 +08:00
|
|
|
using SimApi.Attributes;
|
2020-08-05 15:29:56 +08:00
|
|
|
using SimApi.Helpers;
|
2026-05-04 15:35:47 +08:00
|
|
|
using static SimApi.Helpers.SimApiError;
|
2020-07-05 06:09:02 +08:00
|
|
|
|
2024-03-23 07:29:43 +08:00
|
|
|
namespace SimApi.Controllers;
|
2025-11-01 15:40:55 +08:00
|
|
|
|
2025-11-01 21:38:55 +08:00
|
|
|
public class SimApiCommonController : SimApiBaseController
|
2020-07-05 06:09:02 +08:00
|
|
|
{
|
2024-03-23 07:29:43 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 错误回馈页面
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="code">错误代码</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet("exception/{code:int}")]
|
|
|
|
|
[ApiExplorerSettings(IgnoreApi = true)]
|
2026-04-26 12:27:56 +08:00
|
|
|
public void ExceptionHandler(int code)
|
2020-07-05 06:09:02 +08:00
|
|
|
{
|
2026-04-26 12:27:56 +08:00
|
|
|
SimApiError.Error(code);
|
2024-03-23 07:29:43 +08:00
|
|
|
}
|
2020-07-05 06:09:02 +08:00
|
|
|
|
2024-08-19 03:39:35 +08:00
|
|
|
|
2025-11-01 15:40:55 +08:00
|
|
|
[HttpPost, HttpGet]
|
2026-04-26 12:27:56 +08:00
|
|
|
public Dictionary<string, string> Versions()
|
2025-11-01 15:40:55 +08:00
|
|
|
{
|
2026-04-26 12:27:56 +08:00
|
|
|
return new Dictionary<string, string>
|
2025-11-01 15:40:55 +08:00
|
|
|
{
|
2026-04-26 12:27:56 +08:00
|
|
|
{ "SimApi", SimApiUtil.SimApiVersion },
|
|
|
|
|
{ "App", SimApiUtil.AppVersion }
|
2025-11-01 15:40:55 +08:00
|
|
|
};
|
|
|
|
|
}
|
2026-05-04 15:35:47 +08:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 检测用户登陆的控制器
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost, SimApiAuth, SimApiDoc("认证", "检测登陆")]
|
|
|
|
|
public string CheckLogin()
|
|
|
|
|
{
|
|
|
|
|
ErrorWhenNull(LoginInfo, 401, "未登录");
|
|
|
|
|
return LoginInfo.Id;
|
|
|
|
|
}
|
2021-05-30 03:35:27 +08:00
|
|
|
}
|