问卷提交优化

master
xiaochanghai 2 months ago
parent c1b2669a1e
commit c4f3c01d1d
  1. 2
      Tiobon.Core.Api/Controllers/Ghre/Ghre_SurveyController.cs
  2. 2
      Tiobon.Core.IServices/Ghre/IGhre_SurveyServices.cs
  3. 6
      Tiobon.Core.Services/Ghre/Ghre_SurveyServices.cs

@ -106,7 +106,7 @@ public class Ghre_SurveyController : BaseController<IGhre_SurveyServices, Ghre_S
/// <param name="input"></param> /// <param name="input"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost("SubmitESSData/{openClassId}/{id}")] [HttpPost("SubmitESSData/{openClassId}/{id}")]
public async Task<ServiceResult> SubmitESSDataFromOpenCLass(long id, [FromBody] Ghre_SurveyExtend input, long openClassId) => await _service.SubmitESSData(id, input); public async Task<ServiceResult> SubmitESSDataFromOpenCLass(long id, [FromBody] Ghre_SurveyExtend input, long openClassId) => await _service.SubmitESSData(id, input, openClassId);
#endregion #endregion

@ -18,7 +18,7 @@ public interface IGhre_SurveyServices : IBaseServices<Ghre_Survey, Ghre_SurveyDt
Task<ServiceResult<Ghre_SurveyExtend>> QueryESSData(long id, long? openClassId = null); Task<ServiceResult<Ghre_SurveyExtend>> QueryESSData(long id, long? openClassId = null);
Task<ServiceResult> SubmitESSData(long id, Ghre_SurveyExtend input); Task<ServiceResult> SubmitESSData(long id, Ghre_SurveyExtend input, long? openClassId = null);
Task<ServiceResult> Publish(long id); Task<ServiceResult> Publish(long id);

@ -280,13 +280,14 @@ public class Ghre_SurveyServices : BaseServices<Ghre_Survey, Ghre_SurveyDto, Ins
} }
public async Task<ServiceResult> SubmitESSData(long id, Ghre_SurveyExtend input) public async Task<ServiceResult> SubmitESSData(long id, Ghre_SurveyExtend input, long? openClassId = null)
{ {
var entity = await base.QueryById(id); var entity = await base.QueryById(id);
var lastRecord = await Db.Queryable<Ghre_SurveyRecord>() var lastRecord = await Db.Queryable<Ghre_SurveyRecord>()
.Where(x => x.StaffId == App.User.StaffId && x.SurveyId == id) .Where(x => x.StaffId == App.User.StaffId && x.SurveyId == id)
.WhereIF(openClassId != null, x => x.OpenClassId == openClassId)
.FirstAsync(); .FirstAsync();
var surveyRecordId = lastRecord?.Id; var surveyRecordId = lastRecord?.Id;
await Db.Updateable<Ghre_SurveyRecord>() await Db.Updateable<Ghre_SurveyRecord>()
@ -318,7 +319,8 @@ public class Ghre_SurveyServices : BaseServices<Ghre_Survey, Ghre_SurveyDto, Ins
Score = 0, Score = 0,
AdjustScore = 0, AdjustScore = 0,
SubmitDate = DateTime.Now, SubmitDate = DateTime.Now,
IsView = false IsView = false,
OpenClassId = openClassId
}; };
surveyRecordId = await Db.Insertable(record).ExecuteReturnSnowflakeIdAsync(); surveyRecordId = await Db.Insertable(record).ExecuteReturnSnowflakeIdAsync();
} }

Loading…
Cancel
Save