From f18f64172e1521bd3b27dbadd9d09f2746263d2b Mon Sep 17 00:00:00 2001 From: xiaochanghai Date: Tue, 7 May 2024 10:19:25 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=98=E7=9B=AE=20=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=98=8E=E7=BB=86=E6=8E=A5=E5=8F=A3=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E7=AD=94=E6=A1=88=E8=BF=94=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Base/BaseController.cs | 2 ++ .../Ghre/Ghre_QuestionController.cs | 21 ++++++++++++++++++- Tiobon.Core.Api/Tiobon.Core.Model.xml | 5 +++++ Tiobon.Core.Api/Tiobon.Core.xml | 7 +++++++ .../View/Ghre/Ghre_Question.Dto.View.cs | 7 ++++++- 5 files changed, 40 insertions(+), 2 deletions(-) diff --git a/Tiobon.Core.Api/Controllers/Base/BaseController.cs b/Tiobon.Core.Api/Controllers/Base/BaseController.cs index 6138bf97..d9ea99b6 100644 --- a/Tiobon.Core.Api/Controllers/Base/BaseController.cs +++ b/Tiobon.Core.Api/Controllers/Base/BaseController.cs @@ -258,6 +258,8 @@ public class BaseController() { Success = false, Status = status, Message = message, Data = default, }; } + //Mapper.Map(data).ToANew() + [NonAction] public ServiceResult> SuccessPage(int page, int dataCount, int pageSize, List data, int pageCount, string message = "获取成功") { diff --git a/Tiobon.Core.Api/Controllers/Ghre/Ghre_QuestionController.cs b/Tiobon.Core.Api/Controllers/Ghre/Ghre_QuestionController.cs index 048508fc..7c6134d3 100644 --- a/Tiobon.Core.Api/Controllers/Ghre/Ghre_QuestionController.cs +++ b/Tiobon.Core.Api/Controllers/Ghre/Ghre_QuestionController.cs @@ -16,6 +16,25 @@ public class Ghre_QuestionController : BaseController + /// 根据Id查询数据 + /// + /// 主键ID + /// + [HttpPost("Query/{Id}")] + public override async Task> QueryById(long Id) + { + var entity = await _service.QueryById(Id); + entity.Answers = await _ghre_QuestionAnswerServices.Query(x => x.QuestionId == Id, "TaxisNo ASC"); + if (entity is null) + return Failed("获取失败", 500); + else + return Success(entity, "获取成功"); + } + #endregion + #region 新增 /// /// 新增数据 @@ -60,7 +79,7 @@ public class Ghre_QuestionController : BaseController Put(long Id, [FromBody] EditGhre_QuestionInput editModel) { - await _ghre_QuestionAnswerServices.Delete(x=>x.QuestionId == Id); + await _ghre_QuestionAnswerServices.Delete(x => x.QuestionId == Id); var answers = editModel.Answers; if (answers.Any()) { diff --git a/Tiobon.Core.Api/Tiobon.Core.Model.xml b/Tiobon.Core.Api/Tiobon.Core.Model.xml index 882a816e..ade0160c 100644 --- a/Tiobon.Core.Api/Tiobon.Core.Model.xml +++ b/Tiobon.Core.Api/Tiobon.Core.Model.xml @@ -3297,6 +3297,11 @@ 题目(Dto.View) + + + 答案 + + 题目答案(Dto.View) diff --git a/Tiobon.Core.Api/Tiobon.Core.xml b/Tiobon.Core.Api/Tiobon.Core.xml index dd91cc29..4bbc1e99 100644 --- a/Tiobon.Core.Api/Tiobon.Core.xml +++ b/Tiobon.Core.Api/Tiobon.Core.xml @@ -525,6 +525,13 @@ 题目(Controller) + + + 根据Id查询数据 + + 主键ID + + 新增数据 diff --git a/Tiobon.Core.Model/View/Ghre/Ghre_Question.Dto.View.cs b/Tiobon.Core.Model/View/Ghre/Ghre_Question.Dto.View.cs index 2e4d609b..e8b00e1e 100644 --- a/Tiobon.Core.Model/View/Ghre/Ghre_Question.Dto.View.cs +++ b/Tiobon.Core.Model/View/Ghre/Ghre_Question.Dto.View.cs @@ -13,7 +13,7 @@ *│ 此技术信息为本公司机密信息,未经本公司书面同意禁止向第三方披露. │ *│ 作者:SimonHsiao │ *└──────────────────────────────────┘ -*/ +*/ namespace Tiobon.Core.Model.Models { @@ -23,5 +23,10 @@ namespace Tiobon.Core.Model.Models /// public class Ghre_QuestionDto : Ghre_Question { + + /// + /// 答案 + /// + public List Answers { get; set; } } }