shgx_tz_mom/ZR.Repository/System/SysOperLogRepository.cs

73 lines
2.4 KiB
C#
Raw Normal View History

2021-08-23 16:57:25 +08:00
using Infrastructure.Attribute;
using Infrastructure.Extensions;
using System.Collections.Generic;
using ZR.Model;
2021-09-16 19:07:49 +08:00
using ZR.Model.System.Dto;
2021-08-23 16:57:25 +08:00
using ZR.Model.System;
2021-11-28 11:11:34 +08:00
using SqlSugar;
using Infrastructure.Model;
2021-08-23 16:57:25 +08:00
namespace ZR.Repository.System
{
[AppService(ServiceLifetime = LifeTime.Transient)]
2021-09-27 08:06:09 +08:00
public class SysOperLogRepository : BaseRepository<SysOperLog>
2021-08-23 16:57:25 +08:00
{
/// <summary>
/// 查询操作日志
/// </summary>
/// <param name="sysOper"></param>
/// <param name="pagerInfo">分页数据</param>
/// <returns></returns>
2021-11-28 11:11:34 +08:00
public PagedInfo<SysOperLog> GetSysOperLog(SysOperLogDto sysOper, PagerInfo pagerInfo)
2021-08-23 16:57:25 +08:00
{
2021-11-28 11:11:34 +08:00
var exp = Expressionable.Create<SysOperLog>();
exp.And(it => it.operTime >= sysOper.BeginTime && it.operTime <= sysOper.EndTime);
exp.AndIF(sysOper.Title.IfNotEmpty(), it => it.title.Contains(sysOper.Title));
exp.AndIF(sysOper.operName.IfNotEmpty(), it => it.operName.Contains(sysOper.operName));
exp.AndIF(sysOper.BusinessType != -1, it => it.businessType == sysOper.BusinessType);
exp.AndIF(sysOper.Status != -1, it => it.status == sysOper.Status);
return GetPages(exp.ToExpression(), pagerInfo, x => x.OperId, OrderByType.Desc);
2021-08-23 16:57:25 +08:00
}
/// <summary>
/// 添加操作日志
/// </summary>
/// <param name="sysOperLog"></param>
/// <returns></returns>
public void AddSysOperLog(SysOperLog sysOperLog)
{
2021-09-27 08:06:09 +08:00
Context.Insertable(sysOperLog).ExecuteCommandAsync();
2021-08-23 16:57:25 +08:00
}
/// <summary>
/// 清空日志
/// </summary>
public void ClearOperLog()
{
string sql = "truncate table sys_oper_log";
2021-09-27 08:06:09 +08:00
Context.Ado.ExecuteCommand(sql);
2021-08-23 16:57:25 +08:00
}
/// <summary>
/// 删除操作日志
/// </summary>
/// <param name="operIds"></param>
/// <returns></returns>
public int DeleteOperLogByIds(long[] operIds)
{
2021-09-27 08:06:09 +08:00
return Context.Deleteable<SysOperLog>().In(operIds).ExecuteCommand();
2021-08-23 16:57:25 +08:00
}
/// <summary>
/// 查询操作日志
/// </summary>
/// <param name="operId"></param>
/// <returns></returns>
public SysOperLog SelectOperLogById(long operId)
{
2021-09-27 08:06:09 +08:00
return Context.Queryable<SysOperLog>().InSingle(operId);
2021-08-23 16:57:25 +08:00
}
}
}