48 lines
1.7 KiB
C#
48 lines
1.7 KiB
C#
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);
|
||
}
|
||
}
|