114 lines
3.0 KiB
C#
114 lines
3.0 KiB
C#
|
|
using WcsMain.ApiServe.Controllers.Dto.WcsDto.Config;
|
|||
|
|
using WcsMain.Common;
|
|||
|
|
using WcsMain.DataBase.TableEntity;
|
|||
|
|
using WcsMain.WcsAttribute.AutoFacAttribute;
|
|||
|
|
|
|||
|
|
namespace WcsMain.DataBase.Dao;
|
|||
|
|
|
|||
|
|
[Component]
|
|||
|
|
public class AppConfigDao
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// 返回所有的配置信息
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public List<AppConfig>? Query()
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
List<AppConfig> configs = CommonTool.DbServe.Queryable<AppConfig>().OrderBy(o => o.ConfigType).ToList();
|
|||
|
|
return configs;
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
_ = ex;
|
|||
|
|
return default;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 根据主键更新信息
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="config"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public int Update(AppConfig config)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
return CommonTool.DbServe.Updateable(config).ExecuteCommand();
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
_ = ex;
|
|||
|
|
return 0;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 插入一条信息
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="configs"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public int Insert(params AppConfig[] configs)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
return CommonTool.DbServe.Insertable(configs).ExecuteCommand();
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
_ = ex;
|
|||
|
|
return 0;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 返回所有的配置信息
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="configKey"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public List<AppConfig>? GetAllConfig(string? configKey)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
List<AppConfig> configs = CommonTool.DbServe.Queryable<AppConfig>()
|
|||
|
|
.WhereIF(!string.IsNullOrEmpty(configKey), w => w.ConfigKey!.Contains(configKey!))
|
|||
|
|
.OrderBy(o => o.ConfigType).ToList();
|
|||
|
|
return configs;
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
_ = ex;
|
|||
|
|
return default;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 分页查询系统配置信息
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="request"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public (List<AppConfig>? configs, int totalNumber) GetAllConfigWithPage(GetConfigWithPageRequest request)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
int totalNumber = 0;
|
|||
|
|
List<AppConfig> configs = CommonTool.DbServe.Queryable<AppConfig>()
|
|||
|
|
.WhereIF(!string.IsNullOrEmpty(request.SearchString), w => w.ConfigKey!.Contains(request.SearchString!)
|
|||
|
|
|| w.ConfigValue!.Contains(request.SearchString!)
|
|||
|
|
|| w.ConfigName!.Contains(request.SearchString!)
|
|||
|
|
|| w.ConfigType!.Contains(request.SearchString!)
|
|||
|
|
|| w.Remark!.Contains(request.SearchString!))
|
|||
|
|
.OrderBy(o => o.ConfigType).ToPageList((int)request.PageIndex!, (int)request.PageSize!, ref totalNumber);
|
|||
|
|
return (configs, totalNumber);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
_ = ex;
|
|||
|
|
return default;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|