diff --git a/FactorySystemApi/Controllers/OperateLogController.cs b/FactorySystemApi/Controllers/OperateLogController.cs index 2f6b88b..8fac8cc 100644 --- a/FactorySystemApi/Controllers/OperateLogController.cs +++ b/FactorySystemApi/Controllers/OperateLogController.cs @@ -4,6 +4,7 @@ using FactorySystemBll; using FactorySystemCommon; using FactorySystemModel.BusinessModel; using FactorySystemModel.ResponseModel; +using Newtonsoft.Json.Linq; namespace FactorySystemApi.Controllers { @@ -22,12 +23,29 @@ namespace FactorySystemApi.Controllers public ApiResult GetPageList(Dictionary inParam) { var apiResult = new ApiResult(); + int pageNumber = int.Parse(inParam["current"].ToString()); + int pageSize = int.Parse(inParam["limit"].ToString()); + string FName = inParam.ContainsKey("FName") ? inParam["FName"].ToString() : ""; + int FType = int.Parse(inParam.ContainsKey("FType") && !string.IsNullOrEmpty(inParam["FType"].ToString()) ? inParam["FType"].ToString() : "0"); + int FModule = int.Parse(inParam.ContainsKey("FModule") && !string.IsNullOrEmpty(inParam["FModule"].ToString()) ? inParam["FModule"].ToString() : "0"); + string FDateRangeStr = inParam.ContainsKey("FDateRange") ? inParam["FDateRange"].ToString() : ""; + string dateFrom = null; + string dateTo = null; + + if (!string.IsNullOrEmpty(FDateRangeStr)) + { + var dataRange = JArray.Parse(FDateRangeStr); + dateFrom = dataRange[0].ToString(); + dateTo = dataRange[1].ToString(); + } + return ExceptionHelper.TryReturnException(() => { apiResult.Data = new { - List = _operateLogBll.GetPageList(inParam, out int totalCount), - Total = totalCount + //List = _operateLogBll.GetPageList(inParam, out int totalCount), + List = _operateLogBll.GetLogsByPage(FName, FType, FModule, dateFrom, dateTo, pageNumber, pageSize, out var totalNumber), + Total = totalNumber }; }, apiResult, Request); } diff --git a/FactorySystemBll/OperateLogBll.cs b/FactorySystemBll/OperateLogBll.cs index 687ceab..0bbf999 100644 --- a/FactorySystemBll/OperateLogBll.cs +++ b/FactorySystemBll/OperateLogBll.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; +using System.Xml.Linq; using FactorySystemCommon; +using FactorySystemModel.ResponseModel; using FactorySystemModel.SqlSugarModel; using SqlSugar; @@ -44,6 +46,22 @@ namespace FactorySystemBll return temp.ToPageList(pageIndex, pageSize, ref totalCount); } + public List GetLogsByPage(string FName, int FType, int FModule, string dateFrom, string dateTo, int pageNumber, int pageSize, out int totalNumber) + { + SqlSugarClient db = AppSettingsHelper.GetSqlSugar(); + totalNumber = 0; + List logs = db.Queryable((a, b)=> new JoinQueryInfos(JoinType.Left, a.FAddUser == b.FID)) + .WhereIF(!string.IsNullOrEmpty(FName), (a, b) => b.FName.Contains(FName)) + .WhereIF(FType > 0, (a, b) => a.FType == FType) + .WhereIF(FModule > 0, (a, b) => a.FModule == FModule) + .WhereIF(!string.IsNullOrEmpty(dateFrom), (a, b) => a.FAddDate >= DateTime.Parse(dateFrom)) + .WhereIF(!string.IsNullOrEmpty(dateTo), (a, b) => a.FAddDate <= DateTime.Parse(dateTo)) + .Select("a.*,b.FName").OrderBy((a) => a.FID, OrderByType.Desc) + .ToPageList(pageNumber, pageSize, ref totalNumber); + + return logs; + } + /// /// 保存日志 /// @@ -64,6 +82,5 @@ namespace FactorySystemBll }).ExecuteCommand(); } - } } diff --git a/FactorySystemModel/FactorySystemModel.csproj b/FactorySystemModel/FactorySystemModel.csproj index 8f35295..4ec1b15 100644 --- a/FactorySystemModel/FactorySystemModel.csproj +++ b/FactorySystemModel/FactorySystemModel.csproj @@ -63,6 +63,7 @@ + diff --git a/FactorySystemModel/ResponseModel/LogRow.cs b/FactorySystemModel/ResponseModel/LogRow.cs new file mode 100644 index 0000000..47bc9b2 --- /dev/null +++ b/FactorySystemModel/ResponseModel/LogRow.cs @@ -0,0 +1,14 @@ +using FactorySystemModel.SqlSugarModel; + +namespace FactorySystemModel.ResponseModel +{ + public class LogRow: TFS_OperateLog + { + /// + /// Desc:操作人 + /// Default: + /// Nullable:False + /// + public string FName { get; set; } + } +} diff --git a/FactorySystemModel/SqlSugarModel/TFS_OperateLog.cs b/FactorySystemModel/SqlSugarModel/TFS_OperateLog.cs index b8ae48f..16c3231 100644 --- a/FactorySystemModel/SqlSugarModel/TFS_OperateLog.cs +++ b/FactorySystemModel/SqlSugarModel/TFS_OperateLog.cs @@ -56,5 +56,12 @@ namespace FactorySystemModel.SqlSugarModel /// public int FAddUser { get; set; } + /// + /// Desc:模块 + /// Default:-1 + /// Nullable:False + /// + public int FModule { get; set; } + } }