Files
Yi.Admin/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/SettingController.cs

61 lines
1.6 KiB
C#
Raw Normal View History

2021-11-03 15:32:45 +08:00
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Yi.Framework.Common.Const;
using Yi.Framework.Common.Models;
2021-11-03 18:26:13 +08:00
using Yi.Framework.Core;
2021-11-03 15:32:45 +08:00
using Yi.Framework.DTOModel;
using Yi.Framework.Interface;
using Yi.Framework.Model.Models;
using Yi.Framework.WebCore;
namespace Yi.Framework.ApiMicroservice.Controllers
{
[ApiController]
[Route("api/[controller]/[action]")]
[Authorize]
public class SettingController : ControllerBase
{
private readonly ILogger<SettingController> _logger;
2021-11-03 18:26:13 +08:00
private readonly CacheClientDB _cacheClientDB;
2021-11-03 15:32:45 +08:00
2021-11-03 18:26:13 +08:00
public SettingController(ILogger<SettingController> logger, CacheClientDB cacheClientDB)
2021-11-03 15:32:45 +08:00
{
_logger = logger;
2021-11-03 18:26:13 +08:00
_cacheClientDB = cacheClientDB;
2021-11-03 15:32:45 +08:00
}
2021-11-03 21:14:58 +08:00
2021-11-03 15:32:45 +08:00
/// <summary>
/// 查
/// </summary>
/// <returns></returns>
[HttpGet]
2021-11-03 18:26:13 +08:00
public Result GetSetting()
2021-11-03 20:46:49 +08:00
{
2021-11-03 21:14:58 +08:00
var setDto = Common.Helper.JsonHelper.StrToObj<SettingDto>(_cacheClientDB.Get<string>(RedisConst.key));
return Result.Success().SetData( setDto);
2021-11-03 15:32:45 +08:00
}
/// <summary>
/// 更
/// </summary>
2021-11-03 18:26:13 +08:00
/// <param name="settingDto"></param>
2021-11-03 15:32:45 +08:00
/// <returns></returns>
[HttpPut]
2021-11-03 21:14:58 +08:00
public Result UpdateSetting(SettingDto settingDto)
2021-11-03 15:32:45 +08:00
{
2021-11-03 21:14:58 +08:00
var setDto = Common.Helper.JsonHelper.ObjToStr<SettingDto>(settingDto);
2021-11-03 20:46:49 +08:00
2021-11-03 21:14:58 +08:00
_cacheClientDB.Set(RedisConst.key, setDto);
2021-11-03 15:32:45 +08:00
return Result.Success();
}
}
2021-11-03 21:14:58 +08:00
}