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

master
xiaochanghai 1 month ago
parent a1a69c0a7c
commit f056785194
  1. 5
      Tiobon.Core.Services/CommonServices.cs
  2. 84
      Tiobon.Core.Services/Ghre/Ghre_SurveyQuestionPoolServices.cs

@ -858,6 +858,7 @@ public partial class CommonServices : BaseServices<RootEntityTkey<int>>, ICommon
var index = -1;
switch (param.menuName)
{
case "F_SurveyQuestionPool":
case "F_QuestionBank":
toolbar = result.JM_PageControlT1.Toolbar.Where(x => x.fnKey == "NewYN").FirstOrDefault();
if (toolbar != null) { toolbar.fnKey = "TBD1YN"; }
@ -2448,7 +2449,7 @@ public partial class CommonServices : BaseServices<RootEntityTkey<int>>, ICommon
toolbar = result.JM_PageControlT1.Toolbar.Where(x => x.fnKey == "CopyYN").FirstOrDefault();
if (toolbar != null) toolbar.fnKey = "TBD4YN";
if(param.menuName == "F_GhraStaffGroup")
if (param.menuName == "F_GhraStaffGroup")
result.JM_PageControlT1.Toolbar.Add(new Toolbar()
{
display = true,
@ -4305,7 +4306,7 @@ public partial class CommonServices : BaseServices<RootEntityTkey<int>>, ICommon
var dict1 = JsonHelper.JsonToObj<Ghre_ExternalTrainApplyOrder_BoltoneBase>(json);
//dict.RequestNo = await GenerateContinuousSequence("Ghrh_HumanRequest", "RequestNo", "R");
id = await Db.Insertable(dict).ExecuteReturnSnowflakeIdAsync();
sql = $"SELECT ISNULL(MAX(id)+1,1) FROM Ghre_ExternalTrainApplyOrder_Boltone WHERE Id !='{id}' and len(Id) !=19";
var id1 = await Db.Ado.GetLongAsync(sql);
sql = $"UPDATE Ghre_ExternalTrainApplyOrder_Boltone SET Id={id1} WHERE Id ='{id}'";

@ -215,25 +215,73 @@ public class Ghre_SurveyQuestionPoolServices : BaseServices<Ghre_SurveyQuestionP
return ServiceResult<FromGhre_SurveyQuestionPoolInput>.OprateSuccess("查询成功!", data);
}
public async Task<ServiceResult> InsertFrom(InsertGhre_SurveyQuestionExtend insertModel)
public async Task<ServiceResult> InsertFrom(FromGhre_SurveyQuestionPoolPageData insertModel)
{
var question = Mapper.Map(insertModel).ToANew<Ghre_SurveyQuestionPool>();
var questionType = insertModel.questionType.Where(x => x.isActive == 1).FirstOrDefault();
question.QuestionNo = await GenerateContinuousSequence("Q");
var questionId = await Db.Insertable(question).ExecuteReturnSnowflakeIdAsync();
for (int j = 0; j < insertModel.Options.Count; j++)
await Db.Ado.BeginTranAsync();
try
{
var option = Mapper.Map(insertModel.Options[j]).ToANew<Ghre_SurveyQuestionPoolOption>();
option.SurveyQuestionPoolId = questionId;
option.SortNo = j;
await Db.Insertable(option).ExecuteReturnSnowflakeIdAsync();
}
return ServiceResult.OprateSuccess("新增成功!");
string questionTypeName = ConvertQuestionType(questionType.QuestionType);
var insert = new InsertGhre_SurveyQuestionPoolInput();
insert.BuiltIn = insertModel.baseData.BuiltIn;
insert.QuestionType = questionType.QuestionType;
insert.QuestionNo = await GenerateContinuousSequence(insert.QuestionType.Substring(0, 1));
insert.QuestionContent = questionType.QuestionContent;
insert.QuestionAnalysis = questionType.QuestionAnalysis;
var id = await base.Add(insert);
var insertAnswers = questionType.Options.Select(x => new InsertGhre_SurveyQuestionPoolOptionInput()
{
QuestionNo = x.OptionNo,
AnswerContent = 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("新增成功!");
}
catch (Exception)
{
await Db.Ado.RollbackTranAsync();
throw;
}
}
//{
// var question = Mapper.Map(insertModel).ToANew<Ghre_SurveyQuestionPool>();
// question.QuestionNo = await GenerateContinuousSequence("Q");
// var questionId = await Db.Insertable(question).ExecuteReturnSnowflakeIdAsync();
public async Task<ServiceResult> UpdateFrom(long Id, InsertGhre_SurveyQuestionExtend editModel)
// for (int j = 0; j < insertModel.Options.Count; j++)
// {
// var option = Mapper.Map(insertModel.Options[j]).ToANew<Ghre_SurveyQuestionPoolOption>();
// option.SurveyQuestionPoolId = questionId;
// option.SortNo = j;
// await Db.Insertable(option).ExecuteReturnSnowflakeIdAsync();
// }
// return ServiceResult.OprateSuccess("新增成功!");
//}
public async Task<ServiceResult> UpdateFrom(long Id, FromGhre_SurveyQuestionPoolPageData editModel)
{
await Db.Ado.BeginTranAsync();
@ -244,13 +292,13 @@ public class Ghre_SurveyQuestionPoolServices : BaseServices<Ghre_SurveyQuestionP
var insert = Mapper.Map(editModel).ToANew<EditGhre_SurveyQuestionPoolInput>();
await base.Update(Id, insert, null, ["QuestionNo"]);
for (int j = 0; j < editModel.Options.Count; j++)
{
var option = Mapper.Map(editModel.Options[j]).ToANew<Ghre_SurveyOption>();
//for (int j = 0; j < editModel.Options.Count; j++)
//{
// var option = Mapper.Map(editModel.Options[j]).ToANew<Ghre_SurveyOption>();
option.SurveyQuestionId = Id;
await Db.Insertable(option).ExecuteReturnSnowflakeIdAsync();
}
// option.SurveyQuestionId = Id;
// await Db.Insertable(option).ExecuteReturnSnowflakeIdAsync();
//}
await Db.Ado.CommitTranAsync();
return ServiceResult.OprateSuccess("更新成功!");

Loading…
Cancel
Save