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.
56 lines
1.6 KiB
C#
56 lines
1.6 KiB
C#
using Newtonsoft.Json;
|
|
using ProductionSystem_Log;
|
|
using ProductionSystem_Model.DbModel;
|
|
using ProductionSystem_Model.ViewModel.Response;
|
|
using SqlSugar;
|
|
using System;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace ProductionSystem_Service
|
|
{
|
|
/// <summary>
|
|
/// 结果表
|
|
/// </summary>
|
|
public class ResultService : DbContext
|
|
{
|
|
/// <summary>
|
|
/// 查询所有返回实体集合
|
|
/// </summary>
|
|
/// <param name="sql"></param>
|
|
/// <param name="paras"></param>
|
|
/// <returns></returns>
|
|
public ISugarQueryable<ResultVM> QueryBySql(string sql, SugarParameter[] paras = null)
|
|
{
|
|
try
|
|
{
|
|
return db.SqlQueryable<ResultVM>(sql).AddParameters(paras);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Error(ex, "执行ResultService下QueryBySql时异常");
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 新增结果
|
|
/// </summary>
|
|
/// <param name="t_Result"></param>
|
|
/// <returns></returns>
|
|
public int AddResult(T_Result t_Result)
|
|
{
|
|
try
|
|
{
|
|
t_Result.Id = Guid.NewGuid().ToString();
|
|
return db.Insertable(t_Result).ExecuteCommand();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
var msg = ex == null ? "未知异常" : ex.Message;
|
|
LogHelper.Error(ex, $"保存结果失败:{msg},数据:{JsonConvert.SerializeObject(t_Result)}");
|
|
return 0;
|
|
}
|
|
}
|
|
}
|
|
}
|