|
|
|
@ -1,7 +1,9 @@ |
|
|
|
|
|
|
|
|
|
using System.Data; |
|
|
|
|
using System.Dynamic; |
|
|
|
|
using AgileObjects.AgileMapper; |
|
|
|
|
using SqlSugar; |
|
|
|
|
using Tiobon.Core.Common; |
|
|
|
|
using Tiobon.Core.Common.DB.Dapper.Extensions; |
|
|
|
|
using Tiobon.Core.IRepository.Base; |
|
|
|
|
using Tiobon.Core.IServices; |
|
|
|
@ -266,7 +268,7 @@ namespace Tiobon.Core.Services |
|
|
|
|
#region pageData |
|
|
|
|
if (Id == 0) |
|
|
|
|
{ |
|
|
|
|
dynamic baseData = new ExpandoObject(); |
|
|
|
|
var baseData = new DefaultGhre_ExamPaperBaseData(); |
|
|
|
|
baseData.PaperNo = null; |
|
|
|
|
baseData.PaperName = null; |
|
|
|
|
baseData.AnswerTime = null; |
|
|
|
@ -286,7 +288,7 @@ namespace Tiobon.Core.Services |
|
|
|
|
{ |
|
|
|
|
var exampaper = await base.QueryById(Id); |
|
|
|
|
|
|
|
|
|
dynamic baseData = new ExpandoObject(); |
|
|
|
|
var baseData = new DefaultGhre_ExamPaperBaseData(); |
|
|
|
|
baseData.PaperNo = exampaper.PaperNo; |
|
|
|
|
baseData.PaperName = exampaper.PaperName; |
|
|
|
|
baseData.AnswerTime = exampaper.AnswerTime; |
|
|
|
@ -362,18 +364,19 @@ namespace Tiobon.Core.Services |
|
|
|
|
public async Task<ServiceResult<InsertExamPaperConfigInput>> InsertConfig(InsertGhre_ExamPaperConfigInput insert) |
|
|
|
|
{ |
|
|
|
|
var input = new InsertExamPaperConfigInput(); |
|
|
|
|
long parentId = SnowFlakeSingle.instance.getID(); |
|
|
|
|
input.tableData = Mapper.Map(insert).ToANew<Ghre_ExamPaperConfig>(); |
|
|
|
|
|
|
|
|
|
input.tableData.Id = parentId; |
|
|
|
|
string sql = $@"SELECT TOP {insert.Quantity} *,NEWID() AS GuidValue FROM Ghre_Question WHERE IsEnable=1"; |
|
|
|
|
if (!string.IsNullOrWhiteSpace(insert.DifficultyLevel)) |
|
|
|
|
sql += $" AND DifficultyLevel='{insert.DifficultyLevel}'"; |
|
|
|
|
if (!string.IsNullOrWhiteSpace(insert.QuestionType)) |
|
|
|
|
sql += $" AND QuestionType='{insert.QuestionType}'"; |
|
|
|
|
if (insert.CourseId != null) |
|
|
|
|
sql += $" AND CourseId='{insert.DifficultyLevel}'"; |
|
|
|
|
sql += $" AND CourseId='{insert.CourseId}'"; |
|
|
|
|
sql += $" ORDER BY GuidValue ASC"; |
|
|
|
|
var questions = await Db.Ado.SqlQueryAsync<Ghre_Question>(sql); |
|
|
|
|
|
|
|
|
|
long parentId = SnowFlakeSingle.instance.getID(); |
|
|
|
|
|
|
|
|
|
var previews = questions.Select(x => new DefaultGhre_ExamPaperPreview() |
|
|
|
|
{ |
|
|
|
@ -395,6 +398,7 @@ namespace Tiobon.Core.Services |
|
|
|
|
difficulty = o.DifficultyLevel, |
|
|
|
|
RemarkSz = o.QuestionAnalysis, |
|
|
|
|
content = o.QuestionContent, |
|
|
|
|
|
|
|
|
|
}).ToList(); |
|
|
|
|
detail.ForEach(y => |
|
|
|
|
{ |
|
|
|
@ -416,5 +420,49 @@ namespace Tiobon.Core.Services |
|
|
|
|
|
|
|
|
|
return ServiceResult<InsertExamPaperConfigInput>.OprateSuccess("查询成功!", input); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public async Task<ServiceResult<long>> Insert1(DefaultGhre_ExamPaperPageData insertModel) |
|
|
|
|
{ |
|
|
|
|
await Db.Ado.BeginTranAsync(); |
|
|
|
|
|
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
var insert = new InsertGhre_ExamPaperInput(); |
|
|
|
|
|
|
|
|
|
insert = Mapper.Map(insertModel.baseData).ToANew<InsertGhre_ExamPaperInput>(); |
|
|
|
|
insert.PaperNo = await GenerateContinuousSequence("Ghre_ExamPaper", "P", "PaperNo"); |
|
|
|
|
insert.LinkId = insertModel.baseData.LinkType == "CourseId" ? insertModel.baseData.CourseId : insertModel.baseData.CourseSceneId; |
|
|
|
|
insert.CoverUrl = insertModel.styleInfo.coverImage; |
|
|
|
|
insert.Style = insertModel.styleInfo.paperStyle; |
|
|
|
|
insert.ScoreMethod = insertModel.examPaperSetType; |
|
|
|
|
|
|
|
|
|
var id = await Add(insert); |
|
|
|
|
var configs = Mapper.Map(insertModel.examPaperSetData).ToANew<List<Ghre_ExamPaperConfig>>(); |
|
|
|
|
configs.ForEach(x => x.ExamPaperId = id); |
|
|
|
|
var insertConfigs = Db.Insertable(configs); |
|
|
|
|
|
|
|
|
|
string sql = insertConfigs.ToSqlString(); |
|
|
|
|
long row = await Db.Ado.ExecuteCommandAsync(sql); |
|
|
|
|
|
|
|
|
|
var questions = insertModel.previewList |
|
|
|
|
.Select(x => |
|
|
|
|
new InsertGhre_ExamPaperQuestionInput |
|
|
|
|
{ |
|
|
|
|
ExamPaperId = id, |
|
|
|
|
QuestionId = x.QuestionId, |
|
|
|
|
ConfigId = x.parentId, |
|
|
|
|
}).ToList(); |
|
|
|
|
await _ghre_ExamPaperQuestionServices.Add(questions); |
|
|
|
|
|
|
|
|
|
await Db.Ado.CommitTranAsync(); |
|
|
|
|
return ServiceResult<long>.OprateSuccess("保存成功!", id); |
|
|
|
|
} |
|
|
|
|
catch (Exception) |
|
|
|
|
{ |
|
|
|
|
await Db.Ado.RollbackTranAsync(); |
|
|
|
|
throw; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |