You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
2.7 KiB
C#

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