代码优化

master
xiaochanghai 1 year ago
parent cfdbb23b6c
commit 582d598117
  1. 10
      Tiobon.Core.Api/Tiobon.Core.Model.xml
  2. 18
      Tiobon.Core.Model/View/Ghre/Ghre_Attachment.Dto.View.cs
  3. 15
      Tiobon.Core.Model/ViewModels/Extend/DefaultGhre_ExamPaperInput.cs
  4. 29
      Tiobon.Core.Services/Ghre/Ghre_ExamPaperServices.cs
  5. 10
      Tiobon.Core/Tiobon.Core.Model.xml

@ -4942,6 +4942,16 @@
</summary> </summary>
</member> </member>
<member name="P:Tiobon.Core.Model.DefaultGhre_ExamPaperInput.UpdateDataInfo">
<summary>
修改信息 黄一名 于 2024-05-10 15:02 最后修改
</summary>
</member>
<member name="P:Tiobon.Core.Model.DefaultGhre_ExamPaperInput.CreateDataInfo">
<summary>
创建信息 黄一名 于 2024-05-10 14:57 创建
</summary>
</member>
<member name="P:Tiobon.Core.Model.DefaultGhre_ExamPaperPreview.ExamPaperId"> <member name="P:Tiobon.Core.Model.DefaultGhre_ExamPaperPreview.ExamPaperId">
<summary> <summary>
试卷ID 试卷ID

@ -15,13 +15,21 @@
* *
*/ */
namespace Tiobon.Core.Model.Models namespace Tiobon.Core.Model.Models;
/// <summary>
/// 附件(Dto.View)
/// </summary>
public class Ghre_AttachmentDto : Ghre_Attachment
{ {
/// <summary>
/// 创建信息
/// </summary>
public string CreateDataInfo { get; set; }
/// <summary> /// <summary>
/// 附件(Dto.View) /// 修改信息
/// </summary> /// </summary>
public class Ghre_AttachmentDto : Ghre_Attachment public string UpdateDataInfo { get; set; }
{
}
} }

@ -1,7 +1,4 @@
using System.ComponentModel.DataAnnotations; using Tiobon.Core.Model.Models;
using System.ComponentModel;
using System.Dynamic;
using Tiobon.Core.Model.Models;
namespace Tiobon.Core.Model; namespace Tiobon.Core.Model;
@ -11,6 +8,16 @@ public class DefaultGhre_ExamPaperInput
public List<DefaultGhre_ExamPaperColumn> randomSetColumns { get; set; } = new List<DefaultGhre_ExamPaperColumn>(); public List<DefaultGhre_ExamPaperColumn> randomSetColumns { get; set; } = new List<DefaultGhre_ExamPaperColumn>();
public List<DefaultGhre_ExamPaperColumn> manualSetColumns { get; set; } = new List<DefaultGhre_ExamPaperColumn>(); public List<DefaultGhre_ExamPaperColumn> manualSetColumns { get; set; } = new List<DefaultGhre_ExamPaperColumn>();
public DefaultGhre_ExamPaperPageData pageData { get; set; } = new DefaultGhre_ExamPaperPageData(); public DefaultGhre_ExamPaperPageData pageData { get; set; } = new DefaultGhre_ExamPaperPageData();
/// <summary>
/// 修改信息 黄一名 于 2024-05-10 15:02 最后修改
/// </summary>
public string UpdateDataInfo { get; set; }
/// <summary>
/// 创建信息 黄一名 于 2024-05-10 14:57 创建
/// </summary>
public string CreateDataInfo { get; set; }
} }
public class DefaultGhre_ExamPaperColumn public class DefaultGhre_ExamPaperColumn
{ {

@ -1,10 +1,8 @@
 
using System.Data; using System.Data;
using System.Dynamic;
using AgileObjects.AgileMapper; using AgileObjects.AgileMapper;
using MongoDB.Driver.Linq;
using SqlSugar; using SqlSugar;
using Tiobon.Core.Common;
using Tiobon.Core.Common.DB.Dapper.Extensions;
using Tiobon.Core.IRepository.Base; using Tiobon.Core.IRepository.Base;
using Tiobon.Core.IServices; using Tiobon.Core.IServices;
using Tiobon.Core.Model; using Tiobon.Core.Model;
@ -21,6 +19,7 @@ namespace Tiobon.Core.Services
private IGhre_ExamPaperConfigServices _ghre_ExamPaperConfigServices; private IGhre_ExamPaperConfigServices _ghre_ExamPaperConfigServices;
private IGhre_ExamPaperQuestionServices _ghre_ExamPaperQuestionServices; private IGhre_ExamPaperQuestionServices _ghre_ExamPaperQuestionServices;
private IGhre_QuestionServices _ghre_QuestionServices; private IGhre_QuestionServices _ghre_QuestionServices;
readonly IGhrs_UserServices _ghrs_UserServices;
private IGhre_QuestionAnswerServices _ghre_QuestionAnswerServices; private IGhre_QuestionAnswerServices _ghre_QuestionAnswerServices;
private readonly IBaseRepository<Ghre_ExamPaper> _dal; private readonly IBaseRepository<Ghre_ExamPaper> _dal;
@ -28,7 +27,8 @@ namespace Tiobon.Core.Services
IGhre_ExamPaperConfigServices ghre_ExamPaperConfigServices, IGhre_ExamPaperConfigServices ghre_ExamPaperConfigServices,
IGhre_QuestionServices ghre_QuestionServices, IGhre_QuestionServices ghre_QuestionServices,
IGhre_QuestionAnswerServices ghre_QuestionAnswerServices, IGhre_QuestionAnswerServices ghre_QuestionAnswerServices,
IGhre_ExamPaperQuestionServices ghre_ExamPaperQuestionServices) IGhre_ExamPaperQuestionServices ghre_ExamPaperQuestionServices,
IGhrs_UserServices ghrs_UserServices)
{ {
this._dal = dal; this._dal = dal;
base.BaseDal = dal; base.BaseDal = dal;
@ -36,6 +36,8 @@ namespace Tiobon.Core.Services
_ghre_ExamPaperQuestionServices = ghre_ExamPaperQuestionServices; _ghre_ExamPaperQuestionServices = ghre_ExamPaperQuestionServices;
_ghre_QuestionServices = ghre_QuestionServices; _ghre_QuestionServices = ghre_QuestionServices;
_ghre_QuestionAnswerServices = ghre_QuestionAnswerServices; _ghre_QuestionAnswerServices = ghre_QuestionAnswerServices;
_ghrs_UserServices = ghrs_UserServices;
} }
public async Task<ServiceResult<DefaultGhre_ExamPaperInput>> QueryDefault(long Id) public async Task<ServiceResult<DefaultGhre_ExamPaperInput>> QueryDefault(long Id)
@ -302,6 +304,19 @@ namespace Tiobon.Core.Services
baseData.CourseSceneId = exampaper.LinkId; baseData.CourseSceneId = exampaper.LinkId;
input.pageData.baseData = baseData; input.pageData.baseData = baseData;
#region 系统信息
var userIds = new List<int?>();
if (exampaper.CreateBy != null)
userIds.Add(Convert.ToInt32(exampaper.CreateBy.Value));
if (exampaper.UpdateBy != null)
userIds.Add(Convert.ToInt32(exampaper.UpdateBy.Value));
var users = await _ghrs_UserServices.Query(x => userIds.Contains(x.UserId));
if (exampaper.CreateBy != null)
input.CreateDataInfo = $"创建信息 {users.FirstOrDefault(x => x.UserId == exampaper.CreateBy)?.UserName} 于 {(exampaper.CreateTime != null ? exampaper.CreateTime.Value.ToString(@"yyyy\/MM\/dd HH:mm") : null)} 创建";
if (exampaper.UpdateBy != null)
input.CreateDataInfo = $"修改信息 {users.FirstOrDefault(x => x.UserId == exampaper.UpdateBy)?.UserName} 于 {(exampaper.UpdateTime != null ? exampaper.UpdateTime.Value.ToString(@"yyyy\/MM\/dd HH:mm") : null)} 最后修改";
#endregion
input.pageData.styleInfo.coverImage = exampaper.CoverUrl; input.pageData.styleInfo.coverImage = exampaper.CoverUrl;
input.pageData.styleInfo.paperStyle = exampaper.Style; input.pageData.styleInfo.paperStyle = exampaper.Style;
@ -326,8 +341,8 @@ namespace Tiobon.Core.Services
previews.ForEach(x => previews.ForEach(x =>
{ {
var answers1 = answers.Where(y => y.QuestionId == x.QuestionId).ToList(); var answers1 = answers.Where(y => y.QuestionId == x.QuestionId).ToList();
x.QuestionType = questions1.FirstOrDefault(a=>a.Id==x.QuestionId)?.QuestionType; x.QuestionType = questions1.FirstOrDefault(a => a.Id == x.QuestionId)?.QuestionType;
x.QuestionContent = questions1.FirstOrDefault(a=>a.Id==x.QuestionId)?.QuestionContent; x.QuestionContent = questions1.FirstOrDefault(a => a.Id == x.QuestionId)?.QuestionContent;
//var detail = questions1.Select(o => //var detail = questions1.Select(o =>
//new FromGhre_QuestionQuestionTypeDetail() //new FromGhre_QuestionQuestionTypeDetail()
@ -392,7 +407,7 @@ namespace Tiobon.Core.Services
sql += $" AND QuestionType='{insert.QuestionType}'"; sql += $" AND QuestionType='{insert.QuestionType}'";
if (insert.CourseId != null) if (insert.CourseId != null)
sql += $" AND CourseId='{insert.CourseId}'"; sql += $" AND CourseId='{insert.CourseId}'";
if (insert.CourseId != null) if (insert.QuestionId != null)
sql += $" AND Id='{insert.QuestionId}'"; sql += $" AND Id='{insert.QuestionId}'";
sql += $" ORDER BY GuidValue ASC"; sql += $" ORDER BY GuidValue ASC";
var questions = await Db.Ado.SqlQueryAsync<Ghre_Question>(sql); var questions = await Db.Ado.SqlQueryAsync<Ghre_Question>(sql);

@ -4942,6 +4942,16 @@
</summary> </summary>
</member> </member>
<member name="P:Tiobon.Core.Model.DefaultGhre_ExamPaperInput.UpdateDataInfo">
<summary>
修改信息 黄一名 于 2024-05-10 15:02 最后修改
</summary>
</member>
<member name="P:Tiobon.Core.Model.DefaultGhre_ExamPaperInput.CreateDataInfo">
<summary>
创建信息 黄一名 于 2024-05-10 14:57 创建
</summary>
</member>
<member name="P:Tiobon.Core.Model.DefaultGhre_ExamPaperPreview.ExamPaperId"> <member name="P:Tiobon.Core.Model.DefaultGhre_ExamPaperPreview.ExamPaperId">
<summary> <summary>
试卷ID 试卷ID

Loading…
Cancel
Save