From 08a515946d6763b26746d593af76a8af9b1b4076 Mon Sep 17 00:00:00 2001
From: hwh <332078369@qq.com>
Date: 星期五, 28 六月 2024 16:05:44 +0800
Subject: [PATCH] 操作日志
---
Wms/WMS.BLL/LogServer/OperationSysServer.cs | 110 ++++++++++++++++++++++++------------------------------
1 files changed, 49 insertions(+), 61 deletions(-)
diff --git a/Wms/WMS.BLL/LogServer/OperationSysServer.cs b/Wms/WMS.BLL/LogServer/OperationSysServer.cs
index abbf1fa..b22d150 100644
--- a/Wms/WMS.BLL/LogServer/OperationSysServer.cs
+++ b/Wms/WMS.BLL/LogServer/OperationSysServer.cs
@@ -6,7 +6,9 @@
using System.Threading.Tasks;
using AutoMapper;
using Model.ModelDto.LogDto;
+using Model.ModelVm.LogVm;
using SqlSugar;
+using Utility;
using WMS.DAL;
using WMS.Entity.Context;
using WMS.Entity.LogEntity;
@@ -21,67 +23,18 @@
private readonly IOperationSysRepository _operation;
private readonly IMapper _mapper;
private static readonly SqlSugarScope Db = DataContext.Db;
+ private readonly UserManager _userManager;
/// <summary>
/// 鏋勯�犲嚱鏁�
/// </summary>
/// <param name="operation">鏃ュ織</param>
/// <param name="mapper">automapper</param>
- public OperationSysServer(IOperationSysRepository operation, IMapper mapper) : base(Db)
+ public OperationSysServer(IOperationSysRepository operation, IMapper mapper, UserManager userManager) : base(Db)
{
_operation = operation; //鏃ュ織
_mapper = mapper; //automapper
+ _userManager = userManager;
}
-
-
- ///// <summary>
- ///// 鏌ヨ鎿嶄綔鏃ュ織
- ///// </summary>
- ///// <param name="menuName">鑿滃崟鍚嶇О</param>
- ///// <param name="type">绫诲瀷</param>
- ///// <param name="msg">鍐呭</param>
- ///// <param name="startTime">寮�濮嬫棩鏈�</param>
- ///// <param name="endTime">缁撴潫鏃ユ湡</param>
- ///// <param name="page"></param>
- ///// <param name="limit"></param>
- ///// <param name="count"></param>
- ///// <returns></returns>
- //public List<OperationDto> GetOperationSysList(string menuName, string type, string msg, string startTime, string endTime, int page, int limit, out int count)
- //{
- // try
- // {
- // Expression<Func<LogOperationSys, bool>> item = Expressionable.Create<LogOperationSys>()
- // .AndIF(!string.IsNullOrWhiteSpace(menuName), it => it.MenuName.Contains(menuName.Trim()))
- // .AndIF(!string.IsNullOrWhiteSpace(type), it => it.Type == type)
- // .AndIF(!string.IsNullOrWhiteSpace(msg), it => it.Msg.Contains(msg.Trim()))
- // .AndIF(!string.IsNullOrWhiteSpace(startTime), it => it.CreateTime >= Convert.ToDateTime(startTime))
- // .AndIF(!string.IsNullOrWhiteSpace(endTime), it => it.CreateTime <= Convert.ToDateTime(startTime).AddDays(1))
- // .ToExpression();//娉ㄦ剰 杩欎竴鍙� 涓嶈兘灏�
-
- // var data = GetAllWhereAsync(item)
- // .Includes(x => x.TypeInfo)
- // .Includes(x => x.CreateUserInfo)
- // .Includes(x => x.UpdateUserInfo).ToList();
- // count = data.Count;
- // return data.Select(m => new OperationDto()
- // {
- // Id = m.Id,
- // ParentNo = m.ParentNo,
- // MenuNo = m.MenuNo,
- // MenuName = m.MenuName,
- // FkNo = m.FkNo,
- // Type = m.TypeInfo == null ? "" : m.TypeInfo.DictName,
- // Msg = m.Msg,
- // CreateTime = m.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"),
- // CreateUserName = m.CreateUserInfo == null ? "" : m.CreateUserInfo.UserName,
- // UpdateTime = m.UpdateTime == null ? "" : ((DateTime)m.UpdateTime).ToString("yyyy-MM-dd HH:mm:ss"),
- // UpdateUserName = m.UpdateUserInfo == null ? "" : m.UpdateUserInfo.UserName
- // }).ToList();
- // }
- // catch (Exception e)
- // {
- // throw new Exception(e.Message);
- // }
- //}
/// <summary>
/// 娣诲姞鎿嶄綔鏃ュ織
@@ -133,10 +86,25 @@
/// <param name="menuNo">鑿滃崟鍙�</param>
/// <param name="parentNo">妯″潡鍙�</param>
/// <returns></returns>
- public List<OperationDto> GetSysOperationList(string menuName, string type, string msg, string menuNo, string parentNo)
+ public async Task<SqlSugarPagedList<OperationDto>> GetSysOperationList(GetOperationVm model)
{
- List<OperationDto> operationlist = _operation.GetSysOperationList(menuName, type, msg, menuNo, parentNo);
- return operationlist;
+ return await Db.Queryable<LogOperationSys>()
+ .LeftJoin<SysUserInfor>((a, b) => a.CreateUser == b.Id)
+ .LeftJoin<SysFunctionMenu>((a, b, c) => a.ParentNo == c.MenuNo)
+ .LeftJoin<SysDictionary>((a, b, c, d) => SqlFunc.ToInt32(a.Type) == d.Id)
+ .Where(a => a.IsDel == "0")
+ .WhereIF(!string.IsNullOrEmpty(model.MenuName), a => a.MenuName.Contains(model.MenuName))
+ .WhereIF(!string.IsNullOrEmpty(model.Type), a => a.Type == model.Type)
+ .WhereIF(!string.IsNullOrEmpty(model.Msg), a => a.Msg.Contains(model.Msg))
+ .WhereIF(!string.IsNullOrEmpty(model.MenuNo), a => a.MenuNo == model.MenuNo)
+ .Where((a, b, c, d) => a.ParentNo == SqlFunc.Subqueryable<SysFunctionMenu>().Where(e => e.IsDel == "0" && e.MenuName == model.ParentNo).Select(e => e.MenuNo))
+ .Select<OperationDto>((a, b, c, d) => new OperationDto()
+ {
+ Id = a.Id,
+ CreateUserName = b.RealName,
+ TypeName = d.DictName,
+ }, true)
+ .ToPagedListAsync(model.Page, model.Limit);
}
/// <summary>
@@ -154,8 +122,8 @@
//鎹曡幏寮傚父
try
{
- var parentNo = _operation.GetMenuList(parentName).MenuNo;
- var menuNo = _operation.GetMenuList(menuName).MenuNo;
+ var parentNo = (await Db.Queryable<SysFunctionMenu>().FirstAsync(s => s.MenuName == parentName && s.IsDel == "0"))?.MenuNo;
+ var menuNo = (await Db.Queryable<SysFunctionMenu>().FirstAsync(s => s.MenuName == menuName && s.IsDel == "0"))?.MenuNo;
int i = await _operation.InsertOperation(parentNo, menuNo, parentName + "-" + menuName, fkNo, type, msg, createuser);
return i;
}
@@ -165,16 +133,36 @@
throw new Exception("鏂板鎿嶄綔鏃ュ織寮傚父", ex);
}
}
-
+ /// <summary>
+ /// 鏂板绯荤粺鎿嶄綔鏃ュ織
+ /// </summary>
+ /// <param name="parentName">妯″潡鍙�</param>
+ /// <param name="menuName">鑿滃崟鍙�</param>
+ /// <param name="fkNo">鏁版嵁缂栧彿</param>
+ /// <param name="type">鎿嶄綔绫诲瀷</param>
+ /// <param name="msg">鎿嶄綔鍐呭</param>
+ /// <param name="createuser">鍒涘缓浜�</param>
+ /// <returns></returns>
+ public async Task<int> InsertOperation(OperationInputVm input)
+ {
+ input.ParentNo = (await Db.Queryable<SysFunctionMenu>().FirstAsync(s => s.MenuName == input.ParentName && s.IsDel == "0"))?.MenuNo;
+ input.MenuNo = (await Db.Queryable<SysFunctionMenu>().FirstAsync(s => s.MenuName == input.MenuName && s.IsDel == "0"))?.MenuNo;
+ input.Type = (await Db.Queryable<SysDictionary>().FirstAsync(s => s.DictName == input.TypeName && s.IsDel == "0"))?.Id.ToString();
+ input.CreateUser = _userManager.UserId;
+ input.CreateTime = DateTime.Now;
+ return await Db.Insertable<LogOperationSys>(input).ExecuteCommandAsync();
+ }
/// <summary>
/// 鑾峰彇绫诲瀷鑿滃崟
/// </summary>
/// <param name="dicName">瀛楀吀鍚嶇О</param>
/// <returns></returns>
- public List<SysDictionary> GetDicTypeList(string dicName)
+ public async Task<List<SysDictionary>> GetDicTypeList(string dicName)
{
- List<SysDictionary> diclist = _operation.GetDicTypeList( dicName);
- return diclist;
+ return await Db.Queryable<SysDictionary>()
+ .Where(s => s.IsDel == "0")
+ .Where(s => s.ParentNo == SqlFunc.Subqueryable<SysDictionary>().Where(c => c.DictName == dicName).Select(c => c.DictNo))
+ .ToListAsync();
}
}
}
--
Gitblit v1.8.0