|
|
|
@ -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("更新成功!"); |
|
|
|
|