问卷保存接口开发

master
xiaochanghai 3 months ago
parent 186277c52f
commit de3aa2d7a0
  1. 5
      Tiobon.Core.Api/Controllers/Ghre/Ghre_SurveyController.cs
  2. 5
      Tiobon.Core.Api/Tiobon.Core.Model.xml
  3. 3
      Tiobon.Core.Api/Tiobon.Core.xml
  4. 2
      Tiobon.Core.Api/appsettings.json
  5. 2
      Tiobon.Core.Common/DB/Aop/SqlsugarAop.cs
  6. 2
      Tiobon.Core.IServices/Ghre/IGhre_SurveyServices.cs
  7. 5
      Tiobon.Core.Model/ViewModels/Extend/InsertGhre_SurveyExtend.cs
  8. 54
      Tiobon.Core.Services/Ghre/Ghre_SurveyServices.cs

@ -49,10 +49,11 @@ public class Ghre_SurveyController : BaseController<IGhre_SurveyServices, Ghre_S
/// <summary>
/// 插入
/// </summary>
/// <param name="id"></param>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("InsertData")]
public async Task<ServiceResult<long>> InsertData([FromBody] InsertGhre_SurveyExtend input) => await _service.InsertData(input);
[HttpPost("InsertData/{id}")]
public async Task<ServiceResult<long>> InsertData(long id, [FromBody] InsertGhre_SurveyExtend input) => await _service.InsertData(id, input);
#endregion
}

@ -34707,11 +34707,6 @@
题目解析
</summary>
</member>
<member name="P:Tiobon.Core.Model.ViewModels.Extend.InsertGhre_SurveyQuestionExtend.SortNo">
<summary>
排序
</summary>
</member>
<member name="P:Tiobon.Core.Model.ViewModels.Extend.InsertGhre_SurveyQuestionExtend.RemarkSz">
<summary>
备注

@ -1373,10 +1373,11 @@
<param name="status">status</param>
<returns></returns>
</member>
<member name="M:Tiobon.Core.Api.Controllers.Ghre_SurveyController.InsertData(Tiobon.Core.Model.ViewModels.Extend.InsertGhre_SurveyExtend)">
<member name="M:Tiobon.Core.Api.Controllers.Ghre_SurveyController.InsertData(System.Int64,Tiobon.Core.Model.ViewModels.Extend.InsertGhre_SurveyExtend)">
<summary>
插入
</summary>
<param name="id"></param>
<param name="input"></param>
<returns></returns>
</member>

@ -269,7 +269,7 @@
"Enabled": false
},
"QuartzNetJob": {
"Enabled": true
"Enabled": false
},
"Consul": {
"Enabled": false

@ -39,7 +39,7 @@ public static class SqlSugarAop
public static void DataExecuting(object oldValue, DataFilterModel entityInfo)
{
if (entityInfo.EntityValue is RootEntityTkey<long> rootEntity)
if (entityInfo.EntityValue is BasePoco rootEntity)
if (rootEntity.Id == 0)
rootEntity.Id = SnowFlakeSingle.Instance.NextId();

@ -12,5 +12,5 @@ public interface IGhre_SurveyServices : IBaseServices<Ghre_Survey, Ghre_SurveyDt
Task<ServiceResult> UpdateStatus(InsertGhre_SurveyInput input, string status);
Task<ServiceResult<long>> InsertData(InsertGhre_SurveyExtend insertModel);
Task<ServiceResult<long>> InsertData(long id, InsertGhre_SurveyExtend insertModel);
}

@ -65,11 +65,6 @@ public class InsertGhre_SurveyQuestionExtend
[Display(Name = "QuestionAnalysis"), Description("题目解析"), MaxLength(2000, ErrorMessage = "题目解析 不能超过 2000 个字符")]
public string QuestionAnalysis { get; set; }
/// <summary>
/// 排序
/// </summary>
public int? SortNo { get; set; }
/// <summary>
/// 备注
/// </summary>

@ -1,4 +1,6 @@
namespace Tiobon.Core.Services;
using MongoDB.Driver.Core.Servers;
namespace Tiobon.Core.Services;
/// <summary>
/// 问卷调查 (服务)
@ -83,13 +85,57 @@ public class Ghre_SurveyServices : BaseServices<Ghre_Survey, Ghre_SurveyDto, Ins
}
public async Task<ServiceResult<long>> InsertData(InsertGhre_SurveyExtend insertModel)
public async Task<ServiceResult<long>> InsertData(long id, InsertGhre_SurveyExtend insertModel)
{
var data = ServiceResult<long>.OprateSuccess("新增成功", id);
if (id == 0)
{
var data = ServiceResult<long>.OprateSuccess("新增成功", 0);
var insert = Mapper.Map(insertModel).ToANew<InsertGhre_SurveyInput>();
id = await Add(insert);
for (int i = 0; i < insertModel.Questions.Count; i++)
{
var question = Mapper.Map(insertModel.Questions[i]).ToANew<Ghre_SurveyQuestion>();
//question.Id = SnowFlakeSingle.instance.getID();
//return ServiceResult<long>.OprateFailed("失败!");
question.SurveyId = id;
var questionId = await Db.Insertable(question).ExecuteReturnSnowflakeIdAsync();
for (int j = 0; j < insertModel.Questions[i].Options.Count; j++)
{
var option = Mapper.Map(insertModel.Questions[i].Options[j]).ToANew<Ghre_SurveyOption>();
option.SurveyId = id;
option.SurveyQuestionId = questionId;
await Db.Insertable(option).ExecuteReturnSnowflakeIdAsync();
}
}
data.Data = id;
}
else
{
await Db.Deleteable<Ghre_SurveyQuestion>().Where(x => x.SurveyId == id).ExecuteCommandAsync();
await Db.Deleteable<Ghre_SurveyOption>().Where(x => x.SurveyId == id).ExecuteCommandAsync();
for (int i = 0; i < insertModel.Questions.Count; i++)
{
var question = Mapper.Map(insertModel.Questions[i]).ToANew<Ghre_SurveyQuestion>();
//question.Id = SnowFlakeSingle.instance.getID();
question.SurveyId = id;
var questionId = await Db.Insertable(question).ExecuteReturnSnowflakeIdAsync();
for (int j = 0; j < insertModel.Questions[i].Options.Count; j++)
{
var option = Mapper.Map(insertModel.Questions[i].Options[j]).ToANew<Ghre_SurveyOption>();
option.SurveyId = id;
option.SurveyQuestionId = questionId;
await Db.Insertable(option).ExecuteReturnSnowflakeIdAsync();
}
}
data.Message = "修改成功!";
}
return data;
}

Loading…
Cancel
Save