|
|
@ -1,6 +1,4 @@ |
|
|
|
using MongoDB.Driver.Core.Servers; |
|
|
|
namespace Tiobon.Core.Services; |
|
|
|
|
|
|
|
|
|
|
|
namespace Tiobon.Core.Services; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// <summary> |
|
|
|
/// 问卷调查 (服务) |
|
|
|
/// 问卷调查 (服务) |
|
|
@ -42,6 +40,22 @@ public class Ghre_SurveyServices : BaseServices<Ghre_Survey, Ghre_SurveyDto, Ins |
|
|
|
var result = await base.QueryForm(body); |
|
|
|
var result = await base.QueryForm(body); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<ServiceResult<InsertGhre_SurveyExtend>> QueryData(long id) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var entity = await base.QueryById(id); |
|
|
|
|
|
|
|
var data = Mapper.Map(entity).ToANew<InsertGhre_SurveyExtend>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var questions = await Db.Queryable<Ghre_SurveyQuestion>().Where(x => x.SurveyId == id).ToListAsync(); |
|
|
|
|
|
|
|
var options = await Db.Queryable<Ghre_SurveyOption>().Where(x => x.SurveyId == id).ToListAsync(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data.Questions = Mapper.Map(questions).ToANew<List<InsertGhre_SurveyQuestionExtend>>(); |
|
|
|
|
|
|
|
data.Questions.ForEach(x => |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
x.Options = Mapper.Map(options.Where(o => o.SurveyQuestionId == x.Id)).ToANew<List<InsertGhre_SurveyOptionExtend>>(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
return ServiceResult<InsertGhre_SurveyExtend>.OprateSuccess("成功", data); |
|
|
|
|
|
|
|
} |
|
|
|
public async Task<ServiceResult<long>> InsertByStatus(InsertGhre_SurveyInput insertModel, string status) |
|
|
|
public async Task<ServiceResult<long>> InsertByStatus(InsertGhre_SurveyInput insertModel, string status) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
@ -92,7 +106,7 @@ public class Ghre_SurveyServices : BaseServices<Ghre_Survey, Ghre_SurveyDto, Ins |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
var insert = Mapper.Map(insertModel).ToANew<InsertGhre_SurveyInput>(); |
|
|
|
var insert = Mapper.Map(insertModel).ToANew<InsertGhre_SurveyInput>(); |
|
|
|
|
|
|
|
insert.Status = "Temporary"; |
|
|
|
id = await Add(insert); |
|
|
|
id = await Add(insert); |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < insertModel.Questions.Count; i++) |
|
|
|
for (int i = 0; i < insertModel.Questions.Count; i++) |
|
|
@ -118,6 +132,11 @@ public class Ghre_SurveyServices : BaseServices<Ghre_Survey, Ghre_SurveyDto, Ins |
|
|
|
await Db.Deleteable<Ghre_SurveyQuestion>().Where(x => x.SurveyId == id).ExecuteCommandAsync(); |
|
|
|
await Db.Deleteable<Ghre_SurveyQuestion>().Where(x => x.SurveyId == id).ExecuteCommandAsync(); |
|
|
|
await Db.Deleteable<Ghre_SurveyOption>().Where(x => x.SurveyId == id).ExecuteCommandAsync(); |
|
|
|
await Db.Deleteable<Ghre_SurveyOption>().Where(x => x.SurveyId == id).ExecuteCommandAsync(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var insert = Mapper.Map(insertModel).ToANew<EditGhre_SurveyInput>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await Update(id, insert, null, ["Status"]); |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < insertModel.Questions.Count; i++) |
|
|
|
for (int i = 0; i < insertModel.Questions.Count; i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var question = Mapper.Map(insertModel.Questions[i]).ToANew<Ghre_SurveyQuestion>(); |
|
|
|
var question = Mapper.Map(insertModel.Questions[i]).ToANew<Ghre_SurveyQuestion>(); |
|
|
|