using SqlSugar;
using System;
using ZJ_BYD.Model;
using ZJ_BYD.Untils;
namespace ZJ_BYD.DB
{
public class CurrentConfigHelper
{
public CurrentConfigHelper() : base()
{
}
///
/// 查询基础配置
///
///
public static ISugarQueryable QueryCurrentConfigs()
{
try
{
return DBHelper.sqlSugarDb.Queryable();
}
catch (Exception ex)
{
var msg = ex == null ? "执行QueryCurrentConfigs方法时异常" : ex.Message;
LogHelper.WriteLog($"执行QueryCurrentConfigs方法时异常:{msg}");
return null;
}
}
///
/// 新增机型
///
///
///
public static int AddCurrentConfig(T_CurrentConfig t_CurrentConfig)
{
try
{
return DBHelper.sqlSugarDb.Insertable(t_CurrentConfig).ExecuteCommand();
}
catch (Exception ex)
{
var msg = ex == null ? "执行AddCurrentConfig方法时异常" : ex.Message;
LogHelper.WriteLog($"执行AddCurrentConfig方法时异常:{msg}");
return -1;
}
}
///
/// 修改机型
///
///
///
public static int UpdateCurrentConfig(T_CurrentConfig t_CurrentConfig)
{
try
{
return DBHelper.sqlSugarDb.Updateable(t_CurrentConfig).ExecuteCommand();
}
catch (Exception ex)
{
var msg = ex == null ? "执行UpdateCurrentConfig方法时异常" : ex.Message;
LogHelper.WriteLog($"执行UpdateCurrentConfig方法时异常:{msg}");
return -1;
}
}
///
/// 修改菜单密码
///
///
///
public static int UpdateMenuPwd(string pwd)
{
var currentConfig = CurrentConfigHelper.QueryCurrentConfigs().First();
if (currentConfig != null)
{
return DBHelper.sqlSugarDb.Updateable()
.SetColumns(m => m.MenuPwd == pwd)
.Where(m => m.Id == currentConfig.Id).ExecuteCommand();
}
return -1;
}
}
}