Dispenser/DispenserCore/Service/SystemParamsService.cs

44 lines
1.0 KiB
C#
Raw Permalink Normal View History

2024-08-16 07:20:09 +00:00
using DispenserCommon.DB;
using DispenserCommon.Ioc;
using DispenserCommon.Utils;
using DispenserCore.Model.Entity;
namespace DispenserCore.Service;
/// <summary>
/// 系统参数业务接口
/// </summary>
[Component]
public class SystemParamsService
{
private readonly SqliteHelper _db = ServiceLocator.GetService<SqliteHelper>();
/// <summary>
/// 获取系统参数
/// </summary>
/// <returns></returns>
public SystemParams? GetSystemParams()
{
return _db.Query<SystemParams>("select * from system_params limit 1")
.FirstOrDefault();
}
/// <summary>
/// 保存或者更新系统参数
/// </summary>
/// <param name="params"></param>
/// <returns></returns>
public SystemParams SaveOrUpdate(SystemParams @params)
{
return _db.SaveOrUpdate(@params);
}
/// <summary>
/// 清除历史纪录
/// </summary>
/// <param name="id"></param>
public void Delete(string id)
{
_db.DeleteById<SystemParams>(id);
}
}