using Microsoft.VisualBasic;
|
using Model.ModelDto.LogDto;
|
using Model.ModelDto.SysDto;
|
using SqlSugar;
|
using System;
|
using System.Collections.Generic;
|
using System.Text;
|
using System.Threading.Tasks;
|
using WMS.Entity.Context;
|
using WMS.Entity.LogEntity;
|
using WMS.Entity.SysEntity;
|
using WMS.IDAL.ILogInterface;
|
|
namespace WMS.DAL.LogInterface
|
{
|
/// <summary>
|
/// 系统操作日志仓储实践
|
/// </summary>
|
public class OperationSysRepository : BaseRepository<LogOperationSys>, IOperationSysRepository
|
{
|
private static readonly SqlSugarScope Db = DataContext.Db;
|
public OperationSysRepository() : base(Db)
|
{
|
|
}
|
|
/// <summary>
|
/// 获取系统操作日志数据列表
|
/// </summary>
|
/// <param name="menuName">菜单名称</param>
|
/// <param name="type">操作类型</param>
|
/// <param name="msg">操作内容</param>
|
/// <param name="menuNo">菜单号</param>
|
/// <param name="parentNo">模块号</param>
|
/// <returns></returns>
|
public List<OperationDto> GetSysOperationList(string menuName, string type, string msg, string menuNo, string parentNo)
|
{
|
string str = "select logsys.*,user1.RealName CreateUserName,dic.DictName TypeName from LogOperationSys logsys left join SysUserInfor user1 on logsys.CreateUser = user1.Id left join SysFunctionMenu menu on logsys.ParentNo = menu.MenuNo left join SysDictionary dic on logsys.type = dic.Id where logsys.IsDel = @isdel and logsys.ParentNo = (select MenuNo from SysFunctionMenu where IsDel = @isdel and MenuName = @menuname)";
|
//判断菜单名称是否为空
|
if (!string.IsNullOrEmpty(menuName))
|
{
|
str += " and logsys.MenuName like @mname";
|
}
|
//判断操作类型是否为空
|
if (!string.IsNullOrEmpty(type))
|
{
|
str += " and logsys.Type = @type";
|
}
|
//判断操作内容是否为空
|
if (!string.IsNullOrEmpty(msg))
|
{
|
str += " and logsys.Msg like @msg";
|
}
|
//判断菜单号是否为空
|
if (!string.IsNullOrEmpty(menuNo))
|
{
|
str += " and logsys.MenuNo = @menuno";
|
}
|
str += " order by logsys.CreateTime desc";
|
List<OperationDto> operationlist = Db.Ado.SqlQuery<OperationDto>(str, new
|
{
|
isdel = "0", //是否删除
|
menuname = parentNo, //模块名称获取模块号
|
mname = "%" + menuName + "%", //菜单名称
|
type, //操作类型
|
msg = "%" + msg + "%", //操作内容
|
menuno = menuNo //菜单号
|
});
|
return operationlist;
|
}
|
|
/// <summary>
|
/// 新增系统操作日志
|
/// </summary>
|
/// <param name="parentNo">模块号</param>
|
/// <param name="menuNo">菜单号</param>
|
/// <param name="menuName">菜单名称</param>
|
/// <param name="fkNo">数据编号</param>
|
/// <param name="type">操作类型</param>
|
/// <param name="msg">操作内容</param>
|
/// <param name="createUsercreateUser">创建人</param>
|
/// <returns></returns>
|
public async Task<int> InsertOperation(string parentNo, string menuNo, string menuName, string fkNo, string type, string msg, int createUser)
|
{
|
type = Db.Ado.SqlQuerySingle<SysDictionary>("select * from SysDictionary where IsDel = @isdel and DictName = @dictname", new
|
{
|
isdel = "0", //是否删除
|
dictname = type == "修改" ? "编辑" : type //字典名称
|
}).Id.ToString();
|
string str = "insert into LogOperationSys values(@parentno, @menuno, @menuname, @fkno, @type, @msg, @isdel, @createtime, @createuser, null,null)";
|
int i = await Db.Ado.ExecuteCommandAsync(str, new
|
{
|
parentno = parentNo, //模块号
|
menuno = menuNo, //菜单号
|
menuname = menuName, //菜单名称
|
fkno = fkNo, //数据编号
|
type, //操作类型
|
msg, //操作内容
|
isdel = "0", //是否删除
|
createtime = Db.GetDate(), //创建时间
|
createuser = createUser //创建人
|
});
|
return i;
|
}
|
|
/// <summary>
|
/// 根据菜单名称获取菜单号
|
/// </summary>
|
/// <param name="ParentNo"></param>
|
/// <param name="MenuNo"></param>
|
public SysFunctionMenu GetMenuList(string menuName)
|
{
|
string str = "select MenuNo from SysFunctionMenu where MenuName = @menuname and IsDel = @isdel";
|
SysFunctionMenu menu = Db.Ado.SqlQuerySingle<SysFunctionMenu>(str, new
|
{
|
menuname = menuName, //菜单名称
|
isdel = "0" //是否删除
|
});
|
return menu;
|
|
}
|
|
/// <summary>
|
/// 获取类型菜单
|
/// </summary>
|
/// <param name="dicName">字典名称</param>
|
/// <returns></returns>
|
public List<SysDictionary> GetDicTypeList(string dicName)
|
{
|
string str = "select * from SysDictionary where IsDel = @isdel and ParentNo = (select DictNo from SysDictionary where DictName = @dictname)";
|
List<SysDictionary> diclist = Db.Ado.SqlQuery<SysDictionary>(str, new
|
{
|
isdel = "0", //是否删除
|
dictname = dicName //字典名称
|
});
|
return diclist;
|
}
|
}
|
}
|