43 lines
1.1 KiB
C#
43 lines
1.1 KiB
C#
using Bunny.Dao.Result;
|
|
using Bunny.Service.IService;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace Bunny.WebApi.Controllers;
|
|
|
|
/// <summary>
|
|
/// 操作Redis相关内容
|
|
/// </summary>
|
|
[Route("/api/[controller]")]
|
|
public class RedisOptionController : ControllerBase
|
|
{
|
|
private readonly IRedisOptionService _redisOptionService;
|
|
|
|
public RedisOptionController(IRedisOptionService redisOptionService)
|
|
{
|
|
_redisOptionService = redisOptionService;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加Redis中一个值
|
|
/// </summary>
|
|
/// <param name="key"></param>
|
|
/// <param name="value"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("AddStringValue")]
|
|
public Result<string> AddStringValue(string key, string value)
|
|
{
|
|
_redisOptionService.AddStringValue(key, value);
|
|
return Result<string>.Success();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查询字符串Key
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpPost("QueryStringKey")]
|
|
public Result<string> QueryStringKey(string key)
|
|
{
|
|
var queryStringKey = _redisOptionService.QueryStringKey(key);
|
|
return Result<string>.Success(queryStringKey);
|
|
}
|
|
} |