2025-11-01 21:38:55 +08:00
|
|
|
using System.Collections.Generic;
|
2026-08-10 22:07:38 +08:00
|
|
|
using System.Linq;
|
2025-11-01 15:40:55 +08:00
|
|
|
using Microsoft.AspNetCore.Mvc;
|
2026-08-10 22:07:38 +08:00
|
|
|
using Microsoft.Extensions.Configuration;
|
2026-05-04 15:35:47 +08:00
|
|
|
using SimApi.Attributes;
|
2026-05-04 23:23:35 +08:00
|
|
|
using SimApi.Communications;
|
2026-08-10 22:07:38 +08:00
|
|
|
using SimApi.Configurations;
|
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
|
|
|
|
2026-08-10 22:07:38 +08:00
|
|
|
public class SimApiCommonController(SimApiOptions simApiOptions) : 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-05-04 23:23:35 +08:00
|
|
|
Error(code);
|
2024-03-23 07:29:43 +08:00
|
|
|
}
|
2020-07-05 06:09:02 +08:00
|
|
|
|
2026-08-10 22:07:38 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 给前端的自定义信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
2025-11-01 15:40:55 +08:00
|
|
|
[HttpPost, HttpGet]
|
2026-08-10 22:07:38 +08:00
|
|
|
public Dictionary<string, object> WebConfig()
|
2025-11-01 15:40:55 +08:00
|
|
|
{
|
2026-08-10 22:07:38 +08:00
|
|
|
var resp = simApiOptions.WebConfig!.ToDictionary();
|
|
|
|
|
if (simApiOptions.WebConfigIncludeVersion)
|
2025-11-01 15:40:55 +08:00
|
|
|
{
|
2026-08-10 22:07:38 +08:00
|
|
|
resp.Add("Versions", new Dictionary<string, string>
|
|
|
|
|
{
|
|
|
|
|
{ "SimApi", SimApiUtil.SimApiVersion },
|
|
|
|
|
{ "App", SimApiUtil.AppVersion }
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return resp;
|
2025-11-01 15:40:55 +08:00
|
|
|
}
|
2026-08-10 22:07:38 +08:00
|
|
|
|
|
|
|
|
|
2026-05-20 09:38:40 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 获取已登录用户信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost, SimApiAuth, SimApiDoc("认证", "获取已登录用户信息")]
|
|
|
|
|
public SimApiLoginItem UserInfo() => LoginInfo;
|
2021-05-30 03:35:27 +08:00
|
|
|
}
|