From 84a26cd39587c2a5163f6f0acd5689997d29ea8e Mon Sep 17 00:00:00 2001 From: leo <10200039@qq.com> Date: Fri, 21 Apr 2023 09:28:02 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/OperateLogController.cs | 22 +++++++++++++++++-- FactorySystemBll/OperateLogBll.cs | 19 +++++++++++++++- FactorySystemModel/FactorySystemModel.csproj | 1 + FactorySystemModel/ResponseModel/LogRow.cs | 14 ++++++++++++ .../SqlSugarModel/TFS_OperateLog.cs | 7 ++++++ 5 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 FactorySystemModel/ResponseModel/LogRow.cs 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; } + } } From 8eac2757513d7d572525b7cfa8bb0743a24926f1 Mon Sep 17 00:00:00 2001 From: leo <10200039@qq.com> Date: Fri, 21 Apr 2023 11:47:13 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=8F=9C=E5=8D=95=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FactorySystemBll/UserBll.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FactorySystemBll/UserBll.cs b/FactorySystemBll/UserBll.cs index 3e584da..24fc985 100644 --- a/FactorySystemBll/UserBll.cs +++ b/FactorySystemBll/UserBll.cs @@ -51,7 +51,7 @@ namespace FactorySystemBll roleIds = userInfo.FRoleID.ToString(); } roles = roleIds.Split(',').ToList(); - List menuList = db.Queryable().Where(s => s.FDeleted != delete).ToList(); + List menuList = db.Queryable().Where(s => s.FDeleted != delete).OrderBy(s => s.FOrder).ToList(); List hasIds = db.Queryable((a, b) => new JoinQueryInfos(JoinType.Left, a.FID == b.FRoleID)) .Where((a, b) => a.FDeleted != delete && b.FType == (int)Constant.RoleType.菜单权限 && roles.Contains(a.FID.ToString())) .Select((a, b) => b.FFunctionID).GroupBy("b.FFunctionID").ToList(); From 7317568ccf051044dfde20f01e15ade20ad13566 Mon Sep 17 00:00:00 2001 From: leo <10200039@qq.com> Date: Fri, 21 Apr 2023 13:04:10 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=8E=A7=E5=88=B6=E5=99=A8BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/OperateLogController.cs | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/FactorySystemApi/Controllers/OperateLogController.cs b/FactorySystemApi/Controllers/OperateLogController.cs index 8fac8cc..dd748ed 100644 --- a/FactorySystemApi/Controllers/OperateLogController.cs +++ b/FactorySystemApi/Controllers/OperateLogController.cs @@ -23,8 +23,25 @@ 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()); + + return ExceptionHelper.TryReturnException(() => + { + apiResult.Data = new + { + List = _operateLogBll.GetPageList(inParam, out int totalCount) + }; + }, apiResult, Request); + } + + /// + /// 获取分页 + /// + [HttpPost] + public ApiResult GetPageListByParams(Dictionary inParam) + { + var apiResult = new ApiResult(); + int pageNumber = int.Parse(inParam.ContainsKey("current") && !string.IsNullOrEmpty(inParam["current"].ToString()) ? inParam["current"].ToString() : "0"); + int pageSize = int.Parse(inParam.ContainsKey("limit") && !string.IsNullOrEmpty(inParam["limit"].ToString()) ? inParam["limit"].ToString() : "10"); 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");