|
|
|
@ -8,21 +8,25 @@ using Newtonsoft.Json.Linq; |
|
|
|
|
using Tiobon.Core.Common; |
|
|
|
|
using Tiobon.Core.Model; |
|
|
|
|
using Newtonsoft.Json; |
|
|
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
|
using System.Text.RegularExpressions; |
|
|
|
|
|
|
|
|
|
namespace Tiobon.Core.Services; |
|
|
|
|
|
|
|
|
|
namespace Tiobon.Core.Services |
|
|
|
|
{ |
|
|
|
|
/// <summary> |
|
|
|
|
/// 考试记录 (服务) |
|
|
|
|
/// </summary> |
|
|
|
|
public class Ghre_ExamRecordServices : BaseServices<Ghre_ExamRecord, Ghre_ExamRecordDto, InsertGhre_ExamRecordInput, EditGhre_ExamRecordInput>, IGhre_ExamRecordServices |
|
|
|
|
{ |
|
|
|
|
private readonly IBaseRepository<Ghre_ExamRecord> _dal; |
|
|
|
|
public Ghre_ExamRecordServices(ICaching caching, IBaseRepository<Ghre_ExamRecord> dal) |
|
|
|
|
//private readonly IGhre_ExamPaperServices _ghre_ExamPaperServices; |
|
|
|
|
public Ghre_ExamRecordServices(ICaching caching, |
|
|
|
|
//IGhre_ExamPaperServices ghre_ExamPaperServices, |
|
|
|
|
IBaseRepository<Ghre_ExamRecord> dal) |
|
|
|
|
{ |
|
|
|
|
this._dal = dal; |
|
|
|
|
base.BaseDal = dal; |
|
|
|
|
base._caching = caching; |
|
|
|
|
//_ghre_ExamPaperServices = ghre_ExamPaperServices; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public override async Task<ServicePageResult<Ghre_ExamRecordDto>> QueryFilterPage(QueryBody filter, string condition, bool? IsEnable = true) |
|
|
|
@ -123,11 +127,32 @@ namespace Tiobon.Core.Services |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<ServicePageResult<Ghre_ExamRecordDto>> Query(string examId, [FromBody] QueryBody body) |
|
|
|
|
public async Task<ServicePageResult<Ghre_ExamRecordDto>> Query(string examId, QueryBody body) |
|
|
|
|
{ |
|
|
|
|
return await QueryFilterPage(body, $"ExamId='{examId}'"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public async Task<ServiceResult> ModifyAdjustScore(string examRecordId, EditGhre_ExamRecordInput edit) |
|
|
|
|
{ |
|
|
|
|
var entity = await QuerySingle(examRecordId); |
|
|
|
|
|
|
|
|
|
var paper = await Db.Queryable<Ghre_ExamPaper>().FirstAsync(x => x.Id == entity.ExamPaperId); |
|
|
|
|
if (paper == null) |
|
|
|
|
return ServiceResult.OprateFailed("该考试管理的试卷已被删除,暂不可变更调整分!"); |
|
|
|
|
|
|
|
|
|
entity.AdjustScore = edit.AdjustScore; |
|
|
|
|
entity.Score += entity.AdjustScore; |
|
|
|
|
|
|
|
|
|
string score1 = Regex.Replace(entity.Score.ToString(), @"\.(0+)$", "") + "/" + Regex.Replace(entity.Score.ToString(), @"\.(0+)$", ""); |
|
|
|
|
if (entity.Score < 0) |
|
|
|
|
return ServiceResult.OprateFailed($"调整后得分为【{score1}】,得分不可小于0!"); |
|
|
|
|
if (entity.Score > paper.TotalScore) |
|
|
|
|
return ServiceResult.OprateFailed($"调整后得分为【{score1}】,不可大于卷面总分【{Regex.Replace(paper.TotalScore.ToString(), @"\.(0+)$", "") + "/" + Regex.Replace(paper.TotalScore.ToString(), @"\.(0+)$", "")}】!"); |
|
|
|
|
|
|
|
|
|
await Update(entity); |
|
|
|
|
|
|
|
|
|
return ServiceResult.OprateSuccess("修改成功!"); |
|
|
|
|
|
|
|
|
|
//return await QueryFilterPage(body, $"ExamId='{examId}'"); |
|
|
|
|
} |
|
|
|
|
} |