|
|
|
@ -9,6 +9,9 @@ using Tiobon.Core.Model; |
|
|
|
|
using Tiobon.Core.Common; |
|
|
|
|
using AgileObjects.AgileMapper; |
|
|
|
|
using Newtonsoft.Json; |
|
|
|
|
using System.Text.RegularExpressions; |
|
|
|
|
using Newtonsoft.Json.Linq; |
|
|
|
|
using SqlSugar; |
|
|
|
|
|
|
|
|
|
namespace Tiobon.Core.Services; |
|
|
|
|
|
|
|
|
@ -18,11 +21,17 @@ namespace Tiobon.Core.Services; |
|
|
|
|
public class Ghre_ExamServices : BaseServices<Ghre_Exam, Ghre_ExamDto, InsertGhre_ExamInput, EditGhre_ExamInput>, IGhre_ExamServices |
|
|
|
|
{ |
|
|
|
|
private readonly IBaseRepository<Ghre_Exam> _dal; |
|
|
|
|
public Ghre_ExamServices(ICaching caching, IBaseRepository<Ghre_Exam> dal) |
|
|
|
|
private readonly IGhre_CourseServices _ghre_CourseServices; |
|
|
|
|
private readonly IGhre_CourseSceneServices _ghre_CourseSceneServices; |
|
|
|
|
public Ghre_ExamServices(ICaching caching, |
|
|
|
|
IGhre_CourseServices ghre_CourseServices, |
|
|
|
|
IGhre_CourseSceneServices ghre_CourseSceneServices, IBaseRepository<Ghre_Exam> dal) |
|
|
|
|
{ |
|
|
|
|
this._dal = dal; |
|
|
|
|
base.BaseDal = dal; |
|
|
|
|
base._caching = caching; |
|
|
|
|
_ghre_CourseServices = ghre_CourseServices; |
|
|
|
|
_ghre_CourseSceneServices = ghre_CourseSceneServices; |
|
|
|
|
} |
|
|
|
|
public async Task<dynamic> GetModuleInfo(ModuleParam param) |
|
|
|
|
{ |
|
|
|
@ -173,4 +182,91 @@ public class Ghre_ExamServices : BaseServices<Ghre_Exam, Ghre_ExamDto, InsertGhr |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public async Task<ServicePageResult<Ghre_ExamDto>> QueryList(QueryBody body, string status) |
|
|
|
|
{ |
|
|
|
|
var data = await QueryFilterPage1(body, status); |
|
|
|
|
var data1 = Mapper.Map(data.result.DT_TableDataT1).ToANew<List<Ghre_ExamDto>>(); |
|
|
|
|
|
|
|
|
|
//var linkIds = data1.Where(x => x.LinkId != null).Select(x => x.LinkId.Value).Distinct().ToList(); |
|
|
|
|
//var courses = await _ghre_CourseServices.Query(x => linkIds.Contains(x.Id)); |
|
|
|
|
//var courseScenes = await _ghre_CourseSceneServices.Query(x => linkIds.Contains(x.Id)); |
|
|
|
|
|
|
|
|
|
//data1.ForEach(async x => |
|
|
|
|
//{ |
|
|
|
|
// try |
|
|
|
|
// { |
|
|
|
|
// x.ScoreMethodLabel = await GetParaLabel("ScoreMethod", x.ScoreMethod); |
|
|
|
|
// x.TotalScore1 = Regex.Replace(x.PassScore.ToString(), @"\.(0+)$", "") + "/" + Regex.Replace(x.TotalScore.ToString(), @"\.(0+)$", ""); |
|
|
|
|
// x.SetMethodLabel = await GetParaLabel("SetMethod", x.SetMethod); |
|
|
|
|
|
|
|
|
|
// if (x.LinkType == "CourseId") |
|
|
|
|
// x.CourseName = courses.FirstOrDefault(o => o.Id == x.LinkId)?.CourseName; |
|
|
|
|
// else if (x.LinkType == "CourseSceneId") |
|
|
|
|
// x.CourseName = courseScenes.FirstOrDefault(o => o.Id == x.LinkId)?.SceneName; |
|
|
|
|
// } |
|
|
|
|
// catch (Exception) |
|
|
|
|
// { |
|
|
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
//}); |
|
|
|
|
|
|
|
|
|
return new ServicePageResult<Ghre_ExamDto>(body.pageNum, data.result.DT_TablePageInfoT1.TotalCount, body.pageSize, data1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public async Task<ServicePageResult<Ghre_Exam>> QueryFilterPage1(QueryBody filter, string status = null) |
|
|
|
|
{ |
|
|
|
|
if (string.IsNullOrWhiteSpace(filter.orderBy)) |
|
|
|
|
filter.orderBy = "CreateTime DESC"; |
|
|
|
|
RefAsync<int> totalCount = 0; |
|
|
|
|
var query = Db.Queryable<Ghre_Exam>(); |
|
|
|
|
if (!string.IsNullOrWhiteSpace(status)) |
|
|
|
|
query = query.Where(x => x.Status == status); |
|
|
|
|
string conditions = "1=1"; |
|
|
|
|
if (filter.jsonParam != null) |
|
|
|
|
foreach (JProperty jProperty in filter.jsonParam.Properties()) |
|
|
|
|
{ |
|
|
|
|
var name = jProperty.Name; |
|
|
|
|
var value = jProperty.Value.ToString(); |
|
|
|
|
if (name == "page" || name == "pageSize") |
|
|
|
|
continue; |
|
|
|
|
if (!string.IsNullOrWhiteSpace(value)) |
|
|
|
|
{ |
|
|
|
|
var jsonParam = JsonConvert.DeserializeObject<JsonParam>(value); |
|
|
|
|
|
|
|
|
|
switch (jsonParam.operationKey) |
|
|
|
|
{ |
|
|
|
|
case "Include": |
|
|
|
|
conditions += $" AND {name} LIKE '%{jsonParam.columnValue}%'"; |
|
|
|
|
break; |
|
|
|
|
case "NotInclude": |
|
|
|
|
conditions += $" AND {name} NOT LIKE '%{jsonParam.columnValue}%'"; |
|
|
|
|
break; |
|
|
|
|
case "IsNull": |
|
|
|
|
conditions += $" AND {name} IS NULL"; |
|
|
|
|
break; |
|
|
|
|
case "NotNull": |
|
|
|
|
conditions += $" AND {name} IS NOT NULL"; |
|
|
|
|
break; |
|
|
|
|
case "Equal": |
|
|
|
|
conditions += $" AND {name} ='{jsonParam.columnValue}'"; |
|
|
|
|
break; |
|
|
|
|
case "NotEqual": |
|
|
|
|
conditions += $" AND {name} !='{jsonParam.columnValue}'"; |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (filter.pageSize == 0) |
|
|
|
|
filter.pageSize = 10000; |
|
|
|
|
query = query.Where(conditions); |
|
|
|
|
var list = await query |
|
|
|
|
.OrderByIF(!string.IsNullOrEmpty(filter.orderBy), filter.orderBy) |
|
|
|
|
.ToPageListAsync(filter.pageNum, filter.pageSize, totalCount); |
|
|
|
|
|
|
|
|
|
return new ServicePageResult<Ghre_Exam>(filter.pageNum, totalCount, filter.pageSize, list); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |