live-forum/server/webapi/LiveForum/LiveForum.WebApi/Controllers/ConfigController.cs
2026-03-24 11:27:37 +08:00

48 lines
1.7 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using LiveForum.Code.AttributeExtend;
using LiveForum.Code.Base;
using LiveForum.IService.Others;
using LiveForum.Model.Dto.Others;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
namespace LiveForum.WebApi.Controllers
{
/// <summary>
/// 系统配置相关接口
/// </summary>
/// <param name="config"></param>
[Route("api/[controller]/[action]")]
[ApiController]
public class ConfigController(IConfigService config) : ControllerBase
{
/// <summary>
/// 获取应用配置
/// </summary>
/// <returns></returns>
[HttpGet]
[ResponseCacheExtend(Duration = 600)] // 10分钟缓存
public Task<BaseResponse<Dictionary<string, object>>> GetAppConfig() => config.GetAppConfig();
/// <summary>
/// 获取协议内容
/// </summary>
/// <param name="request">请求参数</param>
/// <returns></returns>
[HttpGet]
[ResponseCacheExtend(Duration = 600, VaryByQueryKeys = new[] { "AgreementType" })] // 10分钟缓存按协议类型区分
public Task<BaseResponse<AgreementDto>> GetAgreement([FromQuery]GetAgreementReq request) => config.GetAgreement(request);
/// <summary>
/// 检查更新
/// </summary>
/// <param name="request">请求参数</param>
/// <returns></returns>
[HttpGet]
[ResponseCacheExtend(Duration = 1800, VaryByQueryKeys = new[] { "Platform", "CurrentVersion" })] // 30分钟缓存按平台和版本区分
public Task<BaseResponse<UpdateInfoDto>> CheckUpdate([FromQuery] CheckUpdateReq request) => config.CheckUpdate(request);
}
}