diff --git a/Tiobon.Core.Api/Controllers/Ghre/Ghre_CertificateController.cs b/Tiobon.Core.Api/Controllers/Ghre/Ghre_CertificateController.cs index 6baaf17e..4dad3637 100644 --- a/Tiobon.Core.Api/Controllers/Ghre/Ghre_CertificateController.cs +++ b/Tiobon.Core.Api/Controllers/Ghre/Ghre_CertificateController.cs @@ -12,7 +12,7 @@ public class Ghre_CertificateController : BaseController> QueryControl() { return _service.QueryControl(); diff --git a/Tiobon.Core.Api/Controllers/Ghre/Ghre_CourseController.cs b/Tiobon.Core.Api/Controllers/Ghre/Ghre_CourseController.cs index c44ce31b..6b756ddd 100644 --- a/Tiobon.Core.Api/Controllers/Ghre/Ghre_CourseController.cs +++ b/Tiobon.Core.Api/Controllers/Ghre/Ghre_CourseController.cs @@ -98,7 +98,7 @@ public class Ghre_CourseController : BaseController /// /// - [Route("QueryStatistic/{id}")] + [HttpGet("QueryStatistic/{id}")] public async Task QueryStatistic(long id) { return await _service.QueryStatistic(id); diff --git a/Tiobon.Core.Api/Controllers/Ghre/Ghre_CourseSceneController.cs b/Tiobon.Core.Api/Controllers/Ghre/Ghre_CourseSceneController.cs index 3c936784..ef081095 100644 --- a/Tiobon.Core.Api/Controllers/Ghre/Ghre_CourseSceneController.cs +++ b/Tiobon.Core.Api/Controllers/Ghre/Ghre_CourseSceneController.cs @@ -17,7 +17,7 @@ public class Ghre_CourseSceneController : BaseController /// /// - [Route("QueryStatistic/{id}")] + [HttpGet("QueryStatistic/{id}")] public async Task QueryStatistic(long id) { return await _service.QueryStatistic(id); diff --git a/Tiobon.Core.Api/Controllers/Ghre/Ghre_SurveyQuestionPoolController.cs b/Tiobon.Core.Api/Controllers/Ghre/Ghre_SurveyQuestionPoolController.cs index fc9bff9c..2d760d3c 100644 --- a/Tiobon.Core.Api/Controllers/Ghre/Ghre_SurveyQuestionPoolController.cs +++ b/Tiobon.Core.Api/Controllers/Ghre/Ghre_SurveyQuestionPoolController.cs @@ -1,6 +1,4 @@ -using Tiobon.Core.Model.ViewModels.Extend; - -namespace Tiobon.Core.Api.Controllers; +namespace Tiobon.Core.Api.Controllers; /// /// 问卷题库(Controller) @@ -36,7 +34,7 @@ public class Ghre_SurveyQuestionPoolController : BaseController /// /// - [HttpPost("InsertFrom")] + [HttpPost("InsertForm")] public async Task InsertFrom([FromBody] FromGhre_SurveyQuestionPoolPageData insertModel) { return await _service.InsertFrom(insertModel); @@ -51,7 +49,7 @@ public class Ghre_SurveyQuestionPoolController : BaseController /// - [HttpPost("UpdateFrom/{Id}")] + [HttpPost("UpdateForm/{Id}")] public async Task UpdateFrom(long Id, [FromBody] FromGhre_SurveyQuestionPoolPageData editModel) { return await _service.UpdateFrom(Id, editModel); diff --git a/Tiobon.Core.Extensions/ServiceExtensions/SwaggerSetup.cs b/Tiobon.Core.Extensions/ServiceExtensions/SwaggerSetup.cs index 99a10e7d..df239cb8 100644 --- a/Tiobon.Core.Extensions/ServiceExtensions/SwaggerSetup.cs +++ b/Tiobon.Core.Extensions/ServiceExtensions/SwaggerSetup.cs @@ -304,7 +304,7 @@ public static class SwaggerSetup /// /// 培训模块 /// - public const string GroupName_Ghre = " ghre"; + public const string GroupName_Ghre = "ghre"; /// /// 绩效模块 /// diff --git a/Tiobon.Core.IServices/Ghre/IGhre_SurveyQuestionPoolServices.cs b/Tiobon.Core.IServices/Ghre/IGhre_SurveyQuestionPoolServices.cs index ea5d885b..508454ac 100644 --- a/Tiobon.Core.IServices/Ghre/IGhre_SurveyQuestionPoolServices.cs +++ b/Tiobon.Core.IServices/Ghre/IGhre_SurveyQuestionPoolServices.cs @@ -1,5 +1,4 @@ -using Tiobon.Core.Model.ViewModels.Extend; -using Tiobon.Core.Model; +using Tiobon.Core.Model; namespace Tiobon.Core.IServices; diff --git a/Tiobon.Core.Services/Ghre/Ghre_SurveyQuestionPoolServices.cs b/Tiobon.Core.Services/Ghre/Ghre_SurveyQuestionPoolServices.cs index 3ea621e5..321354b9 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_SurveyQuestionPoolServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_SurveyQuestionPoolServices.cs @@ -279,25 +279,49 @@ public class Ghre_SurveyQuestionPoolServices : BaseServices UpdateFrom(long Id, FromGhre_SurveyQuestionPoolPageData editModel) { + var questionType = editModel.questionType.Where(x => x.isActive == 1).FirstOrDefault(); + + await Db.Ado.BeginTranAsync(); try { - await Db.Deleteable().Where(x => x.SurveyQuestionPoolId == Id).ExecuteCommandAsync(); + string questionTypeName = ConvertQuestionType(questionType.QuestionType); + var data = await base.QueryById(Id); + + var insert = Mapper.Map(data).ToANew(); + await _ghre_SurveyQuestionPoolOptionServicesServices.Delete(x => x.SurveyQuestionPoolId == Id); - var insert = Mapper.Map(editModel).ToANew(); - await base.Update(Id, insert, null, ["QuestionNo"]); + insert.BuiltIn = editModel.baseData.BuiltIn; + + insert.QuestionType = questionType.QuestionType; + insert.QuestionNo = await GenerateContinuousSequence(insert.QuestionType.Substring(0, 1)); + insert.QuestionContent = questionType.QuestionContent; + insert.QuestionAnalysis = questionType.QuestionAnalysis; - //for (int j = 0; j < editModel.Options.Count; j++) - //{ - // var option = Mapper.Map(editModel.Options[j]).ToANew(); + await base.Update(Id, insert); - // option.SurveyQuestionId = Id; - // await Db.Insertable(option).ExecuteReturnSnowflakeIdAsync(); + var insertAnswers = questionType.Options.Select(x => new InsertGhre_SurveyQuestionPoolOptionInput() + { + OptionNo = x.OptionNo, + OptionContent = x.OptionContent, + ImageUrl = x.ImageUrl, + ImageWidthPc = x.ImageWidthPc, + ImageWidthApp = x.ImageWidthApp, + }).ToList(); + int i = 100; + insertAnswers.ForEach(x => + { + x.TaxisNo = i; + x.SurveyQuestionPoolId = Id; + i = i + 100; + }); + + + await _ghre_SurveyQuestionPoolOptionServicesServices.Add(insertAnswers); //} await Db.Ado.CommitTranAsync(); - - return ServiceResult.OprateSuccess("更新成功!"); + return ServiceResult.OprateSuccess("修改成功!"); } catch (Exception) {