From 7d0cf3faab97653d1e6e959fcdf30571f4c7b156 Mon Sep 17 00:00:00 2001 From: xiaochanghai Date: Wed, 29 May 2024 14:36:19 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=96=B0=E5=A2=9E=E8=80=83=E8=AF=95=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E3=80=90=E8=8D=89=E7=A8=BF=E7=AE=B1=E3=80=81=E5=B7=B2?= =?UTF-8?q?=E5=8F=91=E5=B8=83=E3=80=81=E5=B7=B2=E5=BD=92=E6=A1=A3=E3=80=91?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Ghre/Ghre_ExamController.cs | 18 +++- Tiobon.Core.Api/Tiobon.Core.Model.xml | 10 ++ Tiobon.Core.Api/Tiobon.Core.xml | 8 ++ .../Ghre/IGhre_ExamServices.cs | 4 +- .../Base/Ghre/Ghre_Exam.Dto.Base.cs | 6 ++ Tiobon.Core.Model/Models/Ghre/Ghre_Exam.cs | 6 ++ .../Ghre/Ghre_ExamServices.cs | 98 ++++++++++++++++++- Tiobon.Core/Tiobon.Core.Model.xml | 10 ++ Tiobon.Core/Tiobon.Core.xml | 8 ++ 9 files changed, 165 insertions(+), 3 deletions(-) diff --git a/Tiobon.Core.Api/Controllers/Ghre/Ghre_ExamController.cs b/Tiobon.Core.Api/Controllers/Ghre/Ghre_ExamController.cs index ad6b9344..5ea77ee3 100644 --- a/Tiobon.Core.Api/Controllers/Ghre/Ghre_ExamController.cs +++ b/Tiobon.Core.Api/Controllers/Ghre/Ghre_ExamController.cs @@ -12,7 +12,7 @@ public class Ghre_ExamController : BaseController /// 查询初始化数据 /// @@ -25,4 +25,20 @@ public class Ghre_ExamController : BaseController + /// 根据条件查询数据 + /// + /// status + /// 条件 + /// + [HttpPost, Route("QueryList/{status}")] + public async Task> QueryList(string status, [FromBody] QueryBody body) + { + var data = await _service.QueryList(body, status); + return data; + } + + #endregion } \ No newline at end of file diff --git a/Tiobon.Core.Api/Tiobon.Core.Model.xml b/Tiobon.Core.Api/Tiobon.Core.Model.xml index 9b11e04e..260a8045 100644 --- a/Tiobon.Core.Api/Tiobon.Core.Model.xml +++ b/Tiobon.Core.Api/Tiobon.Core.Model.xml @@ -880,6 +880,11 @@ 开班ID + + + 状态 + + 备注 @@ -3128,6 +3133,11 @@ 开班ID + + + 状态 + + 备注 diff --git a/Tiobon.Core.Api/Tiobon.Core.xml b/Tiobon.Core.Api/Tiobon.Core.xml index a577e587..c0eb4206 100644 --- a/Tiobon.Core.Api/Tiobon.Core.xml +++ b/Tiobon.Core.Api/Tiobon.Core.xml @@ -590,6 +590,14 @@ + + + 根据条件查询数据 + + status + 条件 + + 试卷配置(Controller) diff --git a/Tiobon.Core.IServices/Ghre/IGhre_ExamServices.cs b/Tiobon.Core.IServices/Ghre/IGhre_ExamServices.cs index f3bb9043..5f5f43df 100644 --- a/Tiobon.Core.IServices/Ghre/IGhre_ExamServices.cs +++ b/Tiobon.Core.IServices/Ghre/IGhre_ExamServices.cs @@ -1,4 +1,5 @@ -using Tiobon.Core.IServices.BASE; +using Tiobon.Core.Common; +using Tiobon.Core.IServices.BASE; using Tiobon.Core.Model; using Tiobon.Core.Model.Models; @@ -10,5 +11,6 @@ namespace Tiobon.Core.IServices public interface IGhre_ExamServices : IBaseServices { Task GetModuleInfo(ModuleParam param); + Task> QueryList(QueryBody body, string status); } } \ No newline at end of file diff --git a/Tiobon.Core.Model/Base/Ghre/Ghre_Exam.Dto.Base.cs b/Tiobon.Core.Model/Base/Ghre/Ghre_Exam.Dto.Base.cs index 171854ed..3cc57f94 100644 --- a/Tiobon.Core.Model/Base/Ghre/Ghre_Exam.Dto.Base.cs +++ b/Tiobon.Core.Model/Base/Ghre/Ghre_Exam.Dto.Base.cs @@ -102,6 +102,12 @@ namespace Tiobon.Core.Model.Models /// public long? OpenClassId { get; set; } + /// + /// 状态 + /// + [Display(Name = "Status"), Description("状态"), MaxLength(32, ErrorMessage = "状态 不能超过 32 个字符")] + public string Status { get; set; } + /// /// 备注 /// diff --git a/Tiobon.Core.Model/Models/Ghre/Ghre_Exam.cs b/Tiobon.Core.Model/Models/Ghre/Ghre_Exam.cs index 6573b13f..3ea37216 100644 --- a/Tiobon.Core.Model/Models/Ghre/Ghre_Exam.cs +++ b/Tiobon.Core.Model/Models/Ghre/Ghre_Exam.cs @@ -104,6 +104,12 @@ namespace Tiobon.Core.Model.Models /// public long? OpenClassId { get; set; } + /// + /// 状态 + /// + [Display(Name = "Status"), Description("状态"), MaxLength(32, ErrorMessage = "状态 不能超过 32 个字符")] + public string Status { get; set; } + /// /// 备注 /// diff --git a/Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs b/Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs index ca9da5f3..15448719 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs @@ -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, IGhre_ExamServices { private readonly IBaseRepository _dal; - public Ghre_ExamServices(ICaching caching, IBaseRepository 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 dal) { this._dal = dal; base.BaseDal = dal; base._caching = caching; + _ghre_CourseServices = ghre_CourseServices; + _ghre_CourseSceneServices = ghre_CourseSceneServices; } public async Task GetModuleInfo(ModuleParam param) { @@ -173,4 +182,91 @@ public class Ghre_ExamServices : BaseServices> QueryList(QueryBody body, string status) + { + var data = await QueryFilterPage1(body, status); + var data1 = Mapper.Map(data.result.DT_TableDataT1).ToANew>(); + + //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(body.pageNum, data.result.DT_TablePageInfoT1.TotalCount, body.pageSize, data1); + } + + public async Task> QueryFilterPage1(QueryBody filter, string status = null) + { + if (string.IsNullOrWhiteSpace(filter.orderBy)) + filter.orderBy = "CreateTime DESC"; + RefAsync totalCount = 0; + var query = Db.Queryable(); + 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(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(filter.pageNum, totalCount, filter.pageSize, list); + } + } \ No newline at end of file diff --git a/Tiobon.Core/Tiobon.Core.Model.xml b/Tiobon.Core/Tiobon.Core.Model.xml index 9b11e04e..260a8045 100644 --- a/Tiobon.Core/Tiobon.Core.Model.xml +++ b/Tiobon.Core/Tiobon.Core.Model.xml @@ -880,6 +880,11 @@ 开班ID + + + 状态 + + 备注 @@ -3128,6 +3133,11 @@ 开班ID + + + 状态 + + 备注 diff --git a/Tiobon.Core/Tiobon.Core.xml b/Tiobon.Core/Tiobon.Core.xml index a577e587..c0eb4206 100644 --- a/Tiobon.Core/Tiobon.Core.xml +++ b/Tiobon.Core/Tiobon.Core.xml @@ -590,6 +590,14 @@ + + + 根据条件查询数据 + + status + 条件 + + 试卷配置(Controller)