考试管理 新增、编辑、查看、作废 串联角色权限控制

master
xiaochanghai 1 year ago
parent a48af336d0
commit 00673bad90
  1. 2
      Tiobon.Core.Api/Controllers/Ghre/Ghre_ExamController.cs
  2. 3
      Tiobon.Core.Common/Attribute/QueryFilter.cs
  3. 2
      Tiobon.Core.IServices/BASE/IBaseServices.cs
  4. 2
      Tiobon.Core.Model/View/Ghre/Ghre_Exam.Dto.View.cs
  5. 4
      Tiobon.Core.PublishHelper/Tiobon.Core.PublishHelper.csproj
  6. 9
      Tiobon.Core.Services/BASE/BaseServices.cs
  7. 364
      Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs

@ -161,7 +161,7 @@ public class Ghre_ExamController : BaseController<IGhre_ExamServices, Ghre_Exam,
/// <param name="insert">insert</param>
/// <returns></returns>
[HttpPost("InsertMessageLog")]
public async Task<ServiceResult> InsertMessageLog(Ghre_ExamMessageLogDto insert)
public async Task<ServiceResult> InsertMessageLog([FromBody] Ghre_ExamMessageLogDto insert)
{
return await _service.InsertMessageLog(insert);
}

@ -94,6 +94,9 @@ public class QueryBody
/// 排序条件表达式(e.g. LoginName ASC,Name DESC)
/// </summary>
public string orderBy { get; set; }
public string menuName { get; set; }
public int langId { get; set; }
}
public class JsonParam

@ -127,6 +127,8 @@ namespace Tiobon.Core.IServices.BASE
Task<List<TEntity>> Query();
Task<List<TEntity>> Query(string where);
Task<List<TEntity>> Query(Expression<Func<TEntity, bool>> whereExpression);
Task<TEntityDto> QuerySingleDto(Expression<Func<TEntity, bool>> whereExpression);
Task<List<TEntity>> Query(Expression<Func<TEntity, bool>> whereExpression, string orderByFields);
Task<List<TResult>> Query<TResult>(Expression<Func<TEntity, TResult>> expression);
Task<List<TResult>> Query<TResult>(Expression<Func<TEntity, TResult>> expression, Expression<Func<TEntity, bool>> whereExpression, string orderByFields);

@ -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;// 可取消发布
}

@ -26,9 +26,7 @@
</ItemGroup>
<ItemGroup>
<Compile Update="Frm\Form_About.cs">
<SubType>Form</SubType>
</Compile>
<Compile Update="Frm\Form_About.cs" />
<Compile Update="Frm\Form_CodeGenerator.cs">
<SubType>Form</SubType>
</Compile>

@ -548,6 +548,15 @@ public class BaseServices<TEntity, TEntityDto, TInsertDto, TEditDto> : IBaseServ
return await BaseDal.Query(whereExpression);
}
public async Task<TEntityDto> QuerySingleDto(Expression<Func<TEntity, bool>> whereExpression)
{
var entitys = await BaseDal.Query(whereExpression);
var entity = entitys.FirstOrDefault();
if (entity == null)
return default;
else return Mapper.Map(entity).ToANew<TEntityDto>();
}
/// <summary>
/// 按照特定列查询数据列表
/// </summary>

@ -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,6 +59,166 @@ public class Ghre_ExamServices : BaseServices<Ghre_Exam, Ghre_ExamDto, InsertGhr
var Toolbar = new List<Toolbar>();
#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<Toolbar>(sql);
if (toolbars.Any(x => x.fnKey == "NewYN"))
Toolbar.Add(new Toolbar()
{
fnKey = "NewYN",
@ -68,6 +229,7 @@ public class Ghre_ExamServices : BaseServices<Ghre_Exam, Ghre_ExamDto, InsertGhr
icon = "ghr-icon-add",
display = true
});
if (param.menuName == "F_ExamManageDraft")
Toolbar.Add(new Toolbar()
{
fnKey = "Release",
@ -79,9 +241,25 @@ public class Ghre_ExamServices : BaseServices<Ghre_Exam, Ghre_ExamDto, InsertGhr
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<Ghre_Exam, Ghre_ExamDto, InsertGhr
x.searchOperator = JsonConvert.DeserializeObject<List<searchOperator>>(x.searchOperator1);
x.searchOperator1 = null;
});
#region DT_PageMutiMsg
var DT_PageMutiMsg = await _caching.GetAsync<List<DT_PageMutiMsg>>("DT_PageMutiMsg");
if (DT_PageMutiMsg == null || (DT_PageMutiMsg != null && !DT_PageMutiMsg.Any()))
@ -319,6 +494,163 @@ public class Ghre_ExamServices : BaseServices<Ghre_Exam, Ghre_ExamDto, InsertGhr
.OrderBy(filter.orderBy)
.ToPageListAsync(filter.pageNum, filter.pageSize, totalCount);
#region 定义页面的操作按钮
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, filter.menuName, App.User.ID, filter.langId);
var toolbars = DbAccess.QueryList<Toolbar>(sql);
#endregion
data.ForEach(x =>
{
x.ExamName = x.ExamName + "(" + x.ExamNo + ")";
@ -347,6 +679,13 @@ public class Ghre_ExamServices : BaseServices<Ghre_Exam, Ghre_ExamDto, InsertGhr
x.AfterHowLongLabel = $"学完{x.AfterHowLong}天";
x.ExamModeLabel = x.ExamMode == "Online" ? "线上考试" : "线下实操";
if (!toolbars.Any(x => 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<Ghre_ExamDto>(filter.pageNum, totalCount, filter.pageSize, data);
@ -823,7 +1162,12 @@ public class Ghre_ExamServices : BaseServices<Ghre_Exam, Ghre_ExamDto, InsertGhr
public async Task<ServiceResult<Ghre_ExamMessageLogDto>> QueryMessageLog(long id)
{
var view = await _ghre_ExamMessageLogServices.QueryById(id);
var exam = await base.QueryById(id);
if (exam is null)
return ServiceResult<Ghre_ExamMessageLogDto>.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<Ghre_Exam, Ghre_ExamDto, InsertGhr
if (view.IsFirstEntry == false)
view.NotificationScope = "Need";
var exam = await base.QueryById(id);
if (exam is null)
return ServiceResult<Ghre_ExamMessageLogDto>.OprateFailed("无效的考试ID!");
if (!string.IsNullOrWhiteSpace(view.SendType))
view.SendExamMessage = JsonConvert.DeserializeObject<List<string>>(view.SendType);
var examPaper = await _ghre_ExamPaperServices.QueryById(exam.ExamPaperId);
view.ExamName = exam.ExamName;
@ -856,9 +1197,12 @@ public class Ghre_ExamServices : BaseServices<Ghre_Exam, Ghre_ExamDto, InsertGhr
public async Task<ServiceResult> InsertMessageLog(Ghre_ExamMessageLogDto insert)
{
insert.IsFirstEntry = false;
insert.SendType = JsonConvert.SerializeObject(insert.SendExamMessage);
Db.Updateable<Ghre_ExamMessageLog>().SetColumns(it => it.IsEnable == 0).Where(it => it.ExamId == insert.Id && it.IsEnable == 1).ExecuteCommand();
var insert1 = Mapper.Map(insert).ToANew<InsertGhre_ExamMessageLogInput>();
insert1.ExamId = insert.Id;
await _ghre_ExamMessageLogServices.Add(insert1);
return ServiceResult.OprateSuccess("提交成功!");

Loading…
Cancel
Save