优化问卷题目池新增编辑接口

master
xiaochanghai 1 month ago
parent 0cbcbca764
commit b3c748b428
  1. 2
      Tiobon.Core.Api/Controllers/Ghre/Ghre_CertificateController.cs
  2. 2
      Tiobon.Core.Api/Controllers/Ghre/Ghre_CourseController.cs
  3. 2
      Tiobon.Core.Api/Controllers/Ghre/Ghre_CourseSceneController.cs
  4. 8
      Tiobon.Core.Api/Controllers/Ghre/Ghre_SurveyQuestionPoolController.cs
  5. 2
      Tiobon.Core.Extensions/ServiceExtensions/SwaggerSetup.cs
  6. 3
      Tiobon.Core.IServices/Ghre/IGhre_SurveyQuestionPoolServices.cs
  7. 44
      Tiobon.Core.Services/Ghre/Ghre_SurveyQuestionPoolServices.cs

@ -12,7 +12,7 @@ public class Ghre_CertificateController : BaseController<IGhre_CertificateServic
{
}
[Route("QueryControl")]
[HttpGet("QueryControl")]
public ServiceResult<List<Ghre_CertificateControl>> QueryControl()
{
return _service.QueryControl();

@ -98,7 +98,7 @@ public class Ghre_CourseController : BaseController<IGhre_CourseServices, Ghre_C
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[Route("QueryStatistic/{id}")]
[HttpGet("QueryStatistic/{id}")]
public async Task<dynamic> QueryStatistic(long id)
{
return await _service.QueryStatistic(id);

@ -17,7 +17,7 @@ public class Ghre_CourseSceneController : BaseController<IGhre_CourseSceneServic
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[Route("QueryStatistic/{id}")]
[HttpGet("QueryStatistic/{id}")]
public async Task<dynamic> QueryStatistic(long id)
{
return await _service.QueryStatistic(id);

@ -1,6 +1,4 @@
using Tiobon.Core.Model.ViewModels.Extend;
namespace Tiobon.Core.Api.Controllers;
namespace Tiobon.Core.Api.Controllers;
/// <summary>
/// 问卷题库(Controller)
@ -36,7 +34,7 @@ public class Ghre_SurveyQuestionPoolController : BaseController<IGhre_SurveyQues
/// </summary>
/// <param name="insertModel"></param>
/// <returns></returns>
[HttpPost("InsertFrom")]
[HttpPost("InsertForm")]
public async Task<ServiceResult> InsertFrom([FromBody] FromGhre_SurveyQuestionPoolPageData insertModel)
{
return await _service.InsertFrom(insertModel);
@ -51,7 +49,7 @@ public class Ghre_SurveyQuestionPoolController : BaseController<IGhre_SurveyQues
/// <param name="editModel"></param>
/// <returns></returns>
[HttpPost("UpdateFrom/{Id}")]
[HttpPost("UpdateForm/{Id}")]
public async Task<ServiceResult> UpdateFrom(long Id, [FromBody] FromGhre_SurveyQuestionPoolPageData editModel)
{
return await _service.UpdateFrom(Id, editModel);

@ -304,7 +304,7 @@ public static class SwaggerSetup
/// <summary>
/// 培训模块
/// </summary>
public const string GroupName_Ghre = " ghre";
public const string GroupName_Ghre = "ghre";
/// <summary>
/// 绩效模块
/// </summary>

@ -1,5 +1,4 @@
using Tiobon.Core.Model.ViewModels.Extend;
using Tiobon.Core.Model;
using Tiobon.Core.Model;
namespace Tiobon.Core.IServices;

@ -279,25 +279,49 @@ public class Ghre_SurveyQuestionPoolServices : BaseServices<Ghre_SurveyQuestionP
public async Task<ServiceResult> UpdateFrom(long Id, FromGhre_SurveyQuestionPoolPageData editModel)
{
var questionType = editModel.questionType.Where(x => x.isActive == 1).FirstOrDefault();
await Db.Ado.BeginTranAsync();
try
{
await Db.Deleteable<Ghre_SurveyQuestionPoolOption>().Where(x => x.SurveyQuestionPoolId == Id).ExecuteCommandAsync();
string questionTypeName = ConvertQuestionType(questionType.QuestionType);
var data = await base.QueryById(Id);
var insert = Mapper.Map(data).ToANew<EditGhre_SurveyQuestionPoolInput>();
await _ghre_SurveyQuestionPoolOptionServicesServices.Delete(x => x.SurveyQuestionPoolId == Id);
var insert = Mapper.Map(editModel).ToANew<EditGhre_SurveyQuestionPoolInput>();
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<Ghre_SurveyOption>();
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)
{

Loading…
Cancel
Save