From 00673bad90ba696d63217fa258defd235712b83e Mon Sep 17 00:00:00 2001 From: xiaochanghai Date: Tue, 4 Jun 2024 18:09:07 +0800 Subject: [PATCH] =?UTF-8?q?=E8=80=83=E8=AF=95=E7=AE=A1=E7=90=86=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E3=80=81=E7=BC=96=E8=BE=91=E3=80=81=E6=9F=A5?= =?UTF-8?q?=E7=9C=8B=E3=80=81=E4=BD=9C=E5=BA=9F=20=E4=B8=B2=E8=81=94?= =?UTF-8?q?=E8=A7=92=E8=89=B2=E6=9D=83=E9=99=90=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Ghre/Ghre_ExamController.cs | 2 +- Tiobon.Core.Common/Attribute/QueryFilter.cs | 3 + Tiobon.Core.IServices/BASE/IBaseServices.cs | 2 + .../View/Ghre/Ghre_Exam.Dto.View.cs | 2 +- .../Tiobon.Core.PublishHelper.csproj | 4 +- Tiobon.Core.Services/BASE/BaseServices.cs | 9 + .../Ghre/Ghre_ExamServices.cs | 404 ++++++++++++++++-- 7 files changed, 391 insertions(+), 35 deletions(-) diff --git a/Tiobon.Core.Api/Controllers/Ghre/Ghre_ExamController.cs b/Tiobon.Core.Api/Controllers/Ghre/Ghre_ExamController.cs index a863257f..f7df67a9 100644 --- a/Tiobon.Core.Api/Controllers/Ghre/Ghre_ExamController.cs +++ b/Tiobon.Core.Api/Controllers/Ghre/Ghre_ExamController.cs @@ -161,7 +161,7 @@ public class Ghre_ExamController : BaseControllerinsert /// [HttpPost("InsertMessageLog")] - public async Task InsertMessageLog(Ghre_ExamMessageLogDto insert) + public async Task InsertMessageLog([FromBody] Ghre_ExamMessageLogDto insert) { return await _service.InsertMessageLog(insert); } diff --git a/Tiobon.Core.Common/Attribute/QueryFilter.cs b/Tiobon.Core.Common/Attribute/QueryFilter.cs index 6c5a5e10..80539d8f 100644 --- a/Tiobon.Core.Common/Attribute/QueryFilter.cs +++ b/Tiobon.Core.Common/Attribute/QueryFilter.cs @@ -94,6 +94,9 @@ public class QueryBody /// 排序条件表达式(e.g. LoginName ASC,Name DESC) /// public string orderBy { get; set; } + public string menuName { get; set; } + public int langId { get; set; } + } public class JsonParam diff --git a/Tiobon.Core.IServices/BASE/IBaseServices.cs b/Tiobon.Core.IServices/BASE/IBaseServices.cs index 6e0fa4fd..58a76501 100644 --- a/Tiobon.Core.IServices/BASE/IBaseServices.cs +++ b/Tiobon.Core.IServices/BASE/IBaseServices.cs @@ -127,6 +127,8 @@ namespace Tiobon.Core.IServices.BASE Task> Query(); Task> Query(string where); Task> Query(Expression> whereExpression); + + Task QuerySingleDto(Expression> whereExpression); Task> Query(Expression> whereExpression, string orderByFields); Task> Query(Expression> expression); Task> Query(Expression> expression, Expression> whereExpression, string orderByFields); diff --git a/Tiobon.Core.Model/View/Ghre/Ghre_Exam.Dto.View.cs b/Tiobon.Core.Model/View/Ghre/Ghre_Exam.Dto.View.cs index 5884a00a..c01cd48b 100644 --- a/Tiobon.Core.Model/View/Ghre/Ghre_Exam.Dto.View.cs +++ b/Tiobon.Core.Model/View/Ghre/Ghre_Exam.Dto.View.cs @@ -46,6 +46,6 @@ public class Ghre_ExamDto : Ghre_Exam public int canPreview { get; set; } = 1; // 可预览 public int showLink { get; set; } = 1; // 显示考试链接按钮 public int showResult { get; set; } = 1; // 显示成绩按钮 - public int canClose { get; set; } = 1; // 可归档 + public int canClose { get; set; } = 1; // 可取消归档 public int canCancelRelease { get; set; } = 1;// 可取消发布 } diff --git a/Tiobon.Core.PublishHelper/Tiobon.Core.PublishHelper.csproj b/Tiobon.Core.PublishHelper/Tiobon.Core.PublishHelper.csproj index ba3b599e..ed7743af 100644 --- a/Tiobon.Core.PublishHelper/Tiobon.Core.PublishHelper.csproj +++ b/Tiobon.Core.PublishHelper/Tiobon.Core.PublishHelper.csproj @@ -26,9 +26,7 @@ - - Form - + Form diff --git a/Tiobon.Core.Services/BASE/BaseServices.cs b/Tiobon.Core.Services/BASE/BaseServices.cs index 724e24a7..d2b471a0 100644 --- a/Tiobon.Core.Services/BASE/BaseServices.cs +++ b/Tiobon.Core.Services/BASE/BaseServices.cs @@ -548,6 +548,15 @@ public class BaseServices : IBaseServ return await BaseDal.Query(whereExpression); } + public async Task QuerySingleDto(Expression> whereExpression) + { + var entitys = await BaseDal.Query(whereExpression); + var entity = entitys.FirstOrDefault(); + if (entity == null) + return default; + else return Mapper.Map(entity).ToANew(); + } + /// /// 按照特定列查询数据列表 /// diff --git a/Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs b/Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs index 08e8991a..304c99cd 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs @@ -14,6 +14,7 @@ using SqlSugar; using Microsoft.AspNetCore.Http; using Tiobon.Core.Common.UserManager; using MongoDB.Driver.Linq; +using Tiobon.Core.Common.DB.Dapper; namespace Tiobon.Core.Services; @@ -58,30 +59,207 @@ public class Ghre_ExamServices : BaseServices(); - Toolbar.Add(new Toolbar() - { - fnKey = "NewYN", - fnKeyValue = null, - fnTitle = "新增", - fnType = "table", - position = "left", - icon = "ghr-icon-add", - display = true - }); - Toolbar.Add(new Toolbar() - { - fnKey = "Release", - fnKeyValue = null, - fnTitle = "发布", - fnType = "table", - position = "left", - icon = "ghr-publish", - display = true - }); + + + + #region 定义页面的操作按钮 + string sql = @"SELECT fnKey, + fnKeyValue, + [dbo].[FLangKeyToValue] (fnKeyValue, {2}, fnKeyValue) fnTitle, + fnType, + position, + icon, + 'true' display + FROM (SELECT CASE + WHEN substring (fnKey, 3, 99) + 'YN' = 'NewYN' THEN 1 + WHEN substring (fnKey, 3, 99) + 'YN' = 'ToExcelYN' THEN 2 + WHEN substring (fnKey, 3, 99) + 'YN' = 'FromExcelYN' THEN 3 + WHEN substring (fnKey, 3, 99) + 'YN' = 'BatchUpdateYN' THEN 4 + WHEN substring (fnKey, 3, 99) + 'YN' = 'BatchDelYN' THEN 5 + WHEN substring (fnKey, 3, 99) + 'YN' = 'LogYN' THEN 6 + WHEN substring (fnKey, 3, 99) + 'YN' = 'ManualYN' THEN 7 + WHEN substring (fnKey, 3, 99) + 'YN' = 'UpdateYN' THEN 2 + WHEN substring (fnKey, 3, 99) + 'YN' = 'DelYN' THEN 4 + WHEN substring (fnKey, 3, 99) + 'YN' = 'CopyYN' THEN 3 + WHEN substring (fnKey, 3, 99) + 'YN' = 'DetailYN' THEN 1 + ELSE 8 + END fnKeySeq, + substring (fnKey, 3, 99) + 'YN' fnKey, + 'Ghr_FnKey_' + fnKey fnKeyValue, + CASE + WHEN substring (fnKey, 3, 99) + 'YN' IN ('NewYN', + 'ToExcelYN', + 'FromExcelYN', + 'BatchUpdateYN', + 'BatchDelYN', + 'RecycleYN', + 'CancelRecycleYN', + 'ManualYN', + 'LogYN', + 'BatchDelYN', + 'BatchUpdateYN') + THEN + 'table' + WHEN substring (fnKey, 3, 99) + 'YN' IN ('UpdateYN', + 'DelYN', + 'CopyYN', + 'DetailYN') + THEN + 'row' + WHEN substring (fnKey, 3, 99) + 'YN' IN ('QueryYN', + 'AdvanceQueryYN', + 'QuerySettingYN', + '') + THEN + 'search' + ELSE + '' + END fnType, + 'left' position, + CASE substring (fnKey, 3, 99) + 'YN' + WHEN 'NewYN' THEN 'ghr-icon-add' + WHEN 'ToExcelYN' THEN 'ghr-file-export' + WHEN 'FromExcelYN' THEN 'ghr-file-import' + WHEN 'UpdateYN' THEN 'ghr-icon-edit' + WHEN 'BatchUpdateYN' THEN 'ghr-batch-update' + WHEN 'DelYN' THEN 'ghr-icon-trash' + WHEN 'BatchDelYN' THEN 'ghr-batch-del' + WHEN 'LogYN' THEN 'ghr-log' + WHEN 'ManualYN' THEN 'ghr-operation-manual' + WHEN 'CopyYN' THEN 'ghr-icon-copy' + WHEN 'DetailYN' THEN 'ghr-icon-eye-open' + ELSE '' + END icon + FROM (SELECT max (c.IsWaterMark) IsWaterMark, + max (c.IsPWDAgain) IsPWDAgain, + max (c.IsFromExcel) IsFromExcel, + max (c.IsToExcel) IsToExcel, + max (c.IsNew) IsNew, + max (c.IsDetail) IsDetail, + max (c.IsDel) IsDel, + max (c.IsDel) IsBatchDel, + max (c.IsUpdate) IsUpdate, + max (c.IsUpdate) IsBatchUpdate, + max (c.IsQuery) IsQuery, + max (c.IsPrint) IsPrint, + 0 IsLog, + max (c.IsManual) IsManual, + max (c.IsCopy) IsCopy + FROM Ghrs_UserRole a, Ghrs_RoleMenu c, Ghrs_Menu d + WHERE a.IsEnable = 1 + AND c.IsEnable = 1 + AND d.IsEnable = 1 + AND EXISTS + (SELECT 1 + FROM Ghrs_Role kk + WHERE kk.roleid = a.roleid AND kk.IsEnable = 1) + AND a.UserID = '{1}' + AND a.RoleId = c.RoleID + AND c.MenuId = d.MenuId + AND d.MenuNo = '{0}') kk + UNPIVOT (fnKeyValue + FOR fnKey + IN (IsWaterMark, + IsPWDAgain, + IsFromExcel, + IsToExcel, + IsNew, + IsDetail, + IsUpdate, + IsDel, + IsQuery, + IsPrint, + IsLog, + IsManual, + IsCopy, + IsBatchUpdate, + IsBatchDel)) AS tt + WHERE fnKeyValue > 0 + UNION ALL + SELECT NULL fnKeySeq, + 'QuerySettingYN' fnKey, + 'GHR_Common_000064' fnTitle, + 'search' fnType, + 'left' position, + NULL icon + UNION ALL + SELECT NULL fnKeySeq, + 'LabelYN' fnKey, + 'GHR_Common_000065' fnTitle, + NULL fnType, + NULL position, + NULL icon + UNION ALL + SELECT NULL fnKeySeq, + 'MoreStyleYN' fnKey, + 'GHR_Common_000066' fnTitle, + NULL fnType, + NULL position, + NULL icon + UNION ALL + SELECT NULL fnKeySeq, + 'GridView' fnKey, + 'GHR_Common_000067' fnTitle, + 'table' fnType, + 'right' position, + 'ant-design:setting-outlined' icon + ) A + WHERE fnKey NOT IN + (SELECT b.field + FROM Ghrs_UserPageSettingQueryColumn a, Ghrs_PageSettingQuery b + WHERE a.PageSettingQueryId = b.PageSettingQueryId + AND a.UserID = '{1}' + AND b.PageNo = '{0}' + AND a.IsEnable = 1 + AND b.IsEnable = 1 + AND a.isHidden = 'true' + AND b.elementType = 'FnKey') order by fnKeySeq"; + + sql = string.Format(sql, param.menuName, App.User.ID, param.langId); + var toolbars = DbAccess.QueryList(sql); + + if (toolbars.Any(x => x.fnKey == "NewYN")) + Toolbar.Add(new Toolbar() + { + fnKey = "NewYN", + fnKeyValue = null, + fnTitle = "新增", + fnType = "table", + position = "left", + icon = "ghr-icon-add", + display = true + }); + if (param.menuName == "F_ExamManageDraft") + Toolbar.Add(new Toolbar() + { + fnKey = "Release", + fnKeyValue = null, + fnTitle = "发布", + fnType = "table", + position = "left", + icon = "ghr-publish", + display = true + }); + + if (param.menuName == "F_ExamManageReleased") + Toolbar.Add(new Toolbar() + { + fnKey = "Release", + fnKeyValue = null, + fnTitle = "取消发布", + fnType = "table", + position = "left", + icon = "ghr-publish", + display = true + }); + if (toolbars.Any(x => x.fnKey == "ToExcelYN")) + Toolbar.Add(toolbars.First(x => x.fnKey == "ToExcelYN")); + #endregion + var DT_Procedure = new DT_Procedure(); - var sql = "select QueryProcedure, EditProcedure, IUDProcedure from Ghrs_Menu where MenuNo='{0}'"; + sql = "select QueryProcedure, EditProcedure, IUDProcedure from Ghrs_Menu where MenuNo='{0}'"; sql = string.Format(sql, param.menuName, App.User.ID, param.langId); var dt = Db.Ado.GetDataTable(sql); if (dt.Rows.Count > 0) @@ -159,9 +337,6 @@ public class Ghre_ExamServices : BaseServices>(x.searchOperator1); x.searchOperator1 = null; }); - - - #region DT_PageMutiMsg var DT_PageMutiMsg = await _caching.GetAsync>("DT_PageMutiMsg"); if (DT_PageMutiMsg == null || (DT_PageMutiMsg != null && !DT_PageMutiMsg.Any())) @@ -319,6 +494,163 @@ public class Ghre_ExamServices : BaseServices 0 + UNION ALL + SELECT NULL fnKeySeq, + 'QuerySettingYN' fnKey, + 'GHR_Common_000064' fnTitle, + 'search' fnType, + 'left' position, + NULL icon + UNION ALL + SELECT NULL fnKeySeq, + 'LabelYN' fnKey, + 'GHR_Common_000065' fnTitle, + NULL fnType, + NULL position, + NULL icon + UNION ALL + SELECT NULL fnKeySeq, + 'MoreStyleYN' fnKey, + 'GHR_Common_000066' fnTitle, + NULL fnType, + NULL position, + NULL icon + UNION ALL + SELECT NULL fnKeySeq, + 'GridView' fnKey, + 'GHR_Common_000067' fnTitle, + 'table' fnType, + 'right' position, + 'ant-design:setting-outlined' icon + ) A + WHERE fnKey NOT IN + (SELECT b.field + FROM Ghrs_UserPageSettingQueryColumn a, Ghrs_PageSettingQuery b + WHERE a.PageSettingQueryId = b.PageSettingQueryId + AND a.UserID = '{1}' + AND b.PageNo = '{0}' + AND a.IsEnable = 1 + AND b.IsEnable = 1 + AND a.isHidden = 'true' + AND b.elementType = 'FnKey') order by fnKeySeq"; + + sql = string.Format(sql, filter.menuName, App.User.ID, filter.langId); + var toolbars = DbAccess.QueryList(sql); + #endregion + data.ForEach(x => { x.ExamName = x.ExamName + "(" + x.ExamNo + ")"; @@ -347,6 +679,13 @@ public class Ghre_ExamServices : BaseServices x.fnKey == "UpdateYN")) + x.canEdit = 0; + if (!toolbars.Any(x => x.fnKey == "DelYN")) + x.canDelete = 0; + if (!toolbars.Any(x => x.fnKey == "DetailYN")) + x.canDetail = 0; }); return new ServicePageResult(filter.pageNum, totalCount, filter.pageSize, data); @@ -823,7 +1162,12 @@ public class Ghre_ExamServices : BaseServices> QueryMessageLog(long id) { - var view = await _ghre_ExamMessageLogServices.QueryById(id); + + var exam = await base.QueryById(id); + if (exam is null) + return ServiceResult.OprateFailed("无效的考试ID!"); + + var view = await _ghre_ExamMessageLogServices.QuerySingleDto(x => x.ExamId == id); if (view == null) view = new Ghre_ExamMessageLogDto() { NotificationScope = "All", @@ -832,11 +1176,8 @@ public class Ghre_ExamServices : BaseServices.OprateFailed("无效的考试ID!"); + if (!string.IsNullOrWhiteSpace(view.SendType)) + view.SendExamMessage = JsonConvert.DeserializeObject>(view.SendType); var examPaper = await _ghre_ExamPaperServices.QueryById(exam.ExamPaperId); view.ExamName = exam.ExamName; @@ -856,9 +1197,12 @@ public class Ghre_ExamServices : BaseServices InsertMessageLog(Ghre_ExamMessageLogDto insert) { + insert.IsFirstEntry = false; + insert.SendType = JsonConvert.SerializeObject(insert.SendExamMessage); Db.Updateable().SetColumns(it => it.IsEnable == 0).Where(it => it.ExamId == insert.Id && it.IsEnable == 1).ExecuteCommand(); var insert1 = Mapper.Map(insert).ToANew(); + insert1.ExamId = insert.Id; await _ghre_ExamMessageLogServices.Add(insert1); return ServiceResult.OprateSuccess("提交成功!");