Browse Source

调整课件功能,增加新接口

guqiang 1 month ago
parent
commit
79d218ed31
100 changed files with 1905 additions and 1106 deletions
  1. 6 33
      Hotline.sln
  2. 0 23
      src/Exam.Infrastructure.Data/Attributes/EntityMapperAttribute.cs
  3. 0 85
      src/Exam.Infrastructure.Data/Entity/ActionRequest.cs
  4. 0 123
      src/Exam.Infrastructure.Web/Utilities/AssemblyUtility.cs
  5. 0 64
      src/Exam.Infrastructure.Web/Utilities/ServiceUtility.cs
  6. 0 244
      src/Exam.Infrastructure/Utilities/BaseAssemblyUtility.cs
  7. 81 0
      src/Hotline.Api/Controllers/Exam/ExamManageController.cs
  8. 3 13
      src/Hotline.Api/Controllers/Exam/ExamTagController.cs
  9. 3 14
      src/Hotline.Api/Controllers/Exam/ExtractRuleController.cs
  10. 4 9
      src/Hotline.Api/Controllers/Exam/QuestionController.cs
  11. 3 10
      src/Hotline.Api/Controllers/Exam/SourcewareCategoryController.cs
  12. 3 9
      src/Hotline.Api/Controllers/Exam/SourcewaresController.cs
  13. 86 0
      src/Hotline.Api/Controllers/Exam/TestPaperController.cs
  14. 1 0
      src/Hotline.Api/Hotline.Api.csproj
  15. 8 0
      src/Hotline.Application/Exam/Constants/ApiRoutes/ExamManageApiRoute.cs
  16. 8 0
      src/Hotline.Application/Exam/Constants/ApiRoutes/TestPaperApiRoute.cs
  17. 0 0
      src/Hotline.Application/Exam/Core/Constants/ApiRoute.cs
  18. 0 0
      src/Hotline.Application/Exam/Core/Extensions/ExpressionableExtensions.cs
  19. 0 0
      src/Hotline.Application/Exam/Core/Utilities/ExpressionableUtility.cs
  20. 0 0
      src/Hotline.Application/Exam/Core/Utilities/TypeAdapterConfigUtility.cs
  21. 0 49
      src/Hotline.Application/Exam/Extensions/ActionRequestExtensions.cs
  22. 1 1
      src/Hotline.Application/Exam/Interface/ExamManages/IExamManageService.cs
  23. 1 1
      src/Hotline.Application/Exam/Interface/ExamManages/IExamTagService.cs
  24. 1 1
      src/Hotline.Application/Exam/Interface/ExamManages/IExtractRuleService.cs
  25. 1 1
      src/Hotline.Application/Exam/Interface/ExamManages/IUserExamService.cs
  26. 1 1
      src/Hotline.Application/Exam/Interface/Practices/IPracticeService.cs
  27. 1 1
      src/Hotline.Application/Exam/Interface/Questions/IQuestionAnswerService.cs
  28. 1 1
      src/Hotline.Application/Exam/Interface/Questions/IQuestionKnowladgeService.cs
  29. 1 1
      src/Hotline.Application/Exam/Interface/Questions/IQuestionOptionsService.cs
  30. 1 1
      src/Hotline.Application/Exam/Interface/Questions/IQuestionService.cs
  31. 1 1
      src/Hotline.Application/Exam/Interface/Questions/IQuestionSourcewareService.cs
  32. 1 1
      src/Hotline.Application/Exam/Interface/Questions/IQuestionTagService.cs
  33. 1 1
      src/Hotline.Application/Exam/Interface/Sourcewares/ISourcewareCategoryService.cs
  34. 1 1
      src/Hotline.Application/Exam/Interface/Sourcewares/ISourcewareService.cs
  35. 1 1
      src/Hotline.Application/Exam/Interface/TestPapers/ITestPaperService.cs
  36. 1 1
      src/Hotline.Application/Exam/Interface/Train/ITrainPlanService.cs
  37. 1 1
      src/Hotline.Application/Exam/Interface/Train/ITrainRecordAnswerService.cs
  38. 1 1
      src/Hotline.Application/Exam/Interface/Train/ITrainRecordService.cs
  39. 1 1
      src/Hotline.Application/Exam/Interface/Train/ITrainTemplateService.cs
  40. 25 0
      src/Hotline.Application/Exam/QueryExtensions/ExamManages/ExamManageQueryExtensions.cs
  41. 22 12
      src/Hotline.Application/Exam/QueryExtensions/Questions/QuestionQueryExtesions.cs
  42. 328 0
      src/Hotline.Application/Exam/Service/ExamManages/ExamManageService.cs
  43. 1 1
      src/Hotline.Application/Exam/Service/ExamManages/ExamTagService.cs
  44. 56 47
      src/Hotline.Application/Exam/Service/ExamManages/ExtractRuleService.cs
  45. 10 0
      src/Hotline.Application/Exam/Service/ExamManages/UserExamService.cs
  46. 79 98
      src/Hotline.Application/Exam/Service/Questions/QuestionService.cs
  47. 1 1
      src/Hotline.Application/Exam/Service/Sourcewares/SourcewareCategoryService.cs
  48. 44 1
      src/Hotline.Application/Exam/Service/Sourcewares/SourcewareService.cs
  49. 65 59
      src/Hotline.Application/Exam/Service/TestPapers/TestPaperService.cs
  50. 41 0
      src/Hotline.Application/Exam/Service/Trains/TrainTemplateService.cs
  51. 0 4
      src/Hotline.Application/Hotline.Application.csproj
  52. 1 0
      src/Hotline.Repository.SqlSugar/Exam/Core/Constants/InfrastructureContant.cs
  53. 0 0
      src/Hotline.Repository.SqlSugar/Exam/Core/Enums/ValidationErrorType.cs
  54. 0 0
      src/Hotline.Repository.SqlSugar/Exam/Core/Exceptions/DomainException.cs
  55. 0 0
      src/Hotline.Repository.SqlSugar/Exam/Core/Extensions/ValidateResultExtensions.cs
  56. 0 0
      src/Hotline.Repository.SqlSugar/Exam/Core/Validation/IValidationErrors.cs
  57. 0 0
      src/Hotline.Repository.SqlSugar/Exam/Core/Validation/ValidationErrorItem.cs
  58. 0 0
      src/Hotline.Repository.SqlSugar/Exam/Core/Validation/ValidationErrors.cs
  59. 0 0
      src/Hotline.Repository.SqlSugar/Exam/Core/Validation/ValidatorTypeConstants.cs
  60. 1 1
      src/Hotline.Repository.SqlSugar/Exam/Repositories/ExamManages/ExtractRuleRepository.cs
  61. 2 2
      src/Hotline.Repository.SqlSugar/Exam/Repositories/ExamRepository.cs
  62. 1 1
      src/Hotline.Repository.SqlSugar/Exam/Repositories/TestPapers/TestPaperRepository.cs
  63. 5 6
      src/Hotline.Repository.SqlSugar/Exam/Validators/ExamManages/ExamTagValidator.cs
  64. 19 2
      src/Hotline.Repository.SqlSugar/Exam/Validators/ExamManages/ExtractRuleValidator.cs
  65. 3 0
      src/Hotline.Repository.SqlSugar/Exam/Validators/ExamManages/RuleTagValidator.cs
  66. 1 1
      src/Hotline.Repository.SqlSugar/Exam/Validators/Questions/QuestionOptionsValidator.cs
  67. 1 4
      src/Hotline.Repository.SqlSugar/Exam/Validators/Sourcewares/SourcewareValidator.cs
  68. 6 0
      src/Hotline.Repository.SqlSugar/Exam/Validators/TestPapers/TestPaperItemValidator.cs
  69. 4 0
      src/Hotline.Repository.SqlSugar/Exam/Validators/TestPapers/TestPaperRuleTagValidator.cs
  70. 6 0
      src/Hotline.Repository.SqlSugar/Exam/Validators/TestPapers/TestPaperRuleValidator.cs
  71. 21 1
      src/Hotline.Repository.SqlSugar/Exam/Validators/TestPapers/TestPaperValidator.cs
  72. 11 35
      src/Hotline.Repository.SqlSugar/Extensions/ApiServiceExtension.cs
  73. 0 2
      src/Hotline.Repository.SqlSugar/Hotline.Repository.SqlSugar.csproj
  74. 7 5
      src/Hotline.Repository.SqlSugar/Interface/IApiService.cs
  75. 1 1
      src/Hotline.Repository.SqlSugar/Interface/IExamRepository.cs
  76. 16 14
      src/Hotline.Repository.SqlSugar/Service/ApiService.cs
  77. 5 5
      src/Hotline.Repository.SqlSugar/Validate/BaseValidator.cs
  78. 52 6
      src/Hotline.Share/Dtos/ExamManages/ExamManageDto.cs
  79. 35 3
      src/Hotline.Share/Dtos/ExamManages/ExamQuestionScoreDto.cs
  80. 23 1
      src/Hotline.Share/Dtos/ExamManages/ExamTagDto.cs
  81. 46 4
      src/Hotline.Share/Dtos/ExamManages/UserExamDto.cs
  82. 33 4
      src/Hotline.Share/Dtos/ExamManages/UserExamItemDto.cs
  83. 35 2
      src/Hotline.Share/Dtos/Practices/PracticeDto.cs
  84. 33 1
      src/Hotline.Share/Dtos/Practices/PracticeTagDto.cs
  85. 33 1
      src/Hotline.Share/Dtos/Questions/QuestionAnswerDto.cs
  86. 84 8
      src/Hotline.Share/Dtos/Questions/QuestionDto.cs
  87. 33 1
      src/Hotline.Share/Dtos/Questions/QuestionKnowladgeDto.cs
  88. 32 1
      src/Hotline.Share/Dtos/Questions/QuestionOptionsDto.cs
  89. 32 1
      src/Hotline.Share/Dtos/Questions/QuestionSourcewareDto.cs
  90. 36 6
      src/Hotline.Share/Dtos/Questions/QuestionTagDto.cs
  91. 19 1
      src/Hotline.Share/Dtos/Sourcewares/SourcewareCategoryDto.cs
  92. 28 7
      src/Hotline.Share/Dtos/Sourcewares/SourcewareDto.cs
  93. 48 3
      src/Hotline.Share/Dtos/TestPapers/ExtractRuleDto.cs
  94. 31 4
      src/Hotline.Share/Dtos/TestPapers/RuleTagDto.cs
  95. 49 17
      src/Hotline.Share/Dtos/TestPapers/TagQuestionDto.cs
  96. 52 4
      src/Hotline.Share/Dtos/TestPapers/TestPaperDto.cs
  97. 56 23
      src/Hotline.Share/Dtos/TestPapers/TestPaperItemDto.cs
  98. 35 4
      src/Hotline.Share/Dtos/TestPapers/TestPaperRuleDto.cs
  99. 32 1
      src/Hotline.Share/Dtos/TestPapers/TestPaperRuleTagDto.cs
  100. 41 6
      src/Hotline.Share/Dtos/Trains/TrainPlanDto.cs

+ 6 - 33
Hotline.sln

@@ -45,8 +45,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tr.Sdk", "src\Tr.Sdk\Tr.Sdk
 EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hotline.Api.Sdk", "src\Hotline.Api.Sdk\Hotline.Api.Sdk.csproj", "{EEF30056-A626-43B2-9762-632935C1AF31}"
 EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hotline.Ai.Jths", "src\Hotline.Ai.Jths\Hotline.Ai.Jths.csproj", "{1634234A-379C-44DC-BFEC-7BBDEF50B47B}"
-EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hotline.YbEnterprise.Sdk", "src\Hotline.YbEnterprise.Sdk\Hotline.YbEnterprise.Sdk.csproj", "{C3F289D5-C50B-46DB-852C-9543EF9B0355}"
 EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "XingTang.Sdk", "src\XingTang.Sdk\XingTang.Sdk.csproj", "{CF2A8B80-FF4E-4291-B383-D735BB629F32}"
@@ -63,13 +61,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hotline.Tests", "test\Hotli
 EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hotline.Pdf", "src\Hotline.Pdf\Hotline.Pdf.csproj", "{3AB75B51-A69D-4145-A564-1D9D1695992E}"
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Exam.Infrastructure", "src\Exam.Infrastructure\Exam.Infrastructure.csproj", "{91CD58E7-C314-43FD-BC64-D47F7537833F}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Exam.Infrastructure.Data", "src\Exam.Infrastructure.Data\Exam.Infrastructure.Data.csproj", "{6A4399E0-6816-3A7F-3442-EE5BFB0076F9}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Exam.Infrastructure.Validation", "src\Exam.Infrastructure.Validation\Exam.Infrastructure.Validation.csproj", "{3A181C2E-3AA2-2FAC-6EE1-630BB8F69606}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Exam.Infrastructure.Web", "src\Exam.Infrastructure.Web\Exam.Infrastructure.Web.csproj", "{46010D33-5AF0-693B-3C0B-3CCC7F66547A}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hotline.Ai.Jths", "src\Hotline.Ai.Jths\Hotline.Ai.Jths.csproj", "{B05DB089-31DB-2BF5-5959-C816ECD7EFA4}"
 EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -137,10 +129,6 @@ Global
 		{EEF30056-A626-43B2-9762-632935C1AF31}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{EEF30056-A626-43B2-9762-632935C1AF31}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{EEF30056-A626-43B2-9762-632935C1AF31}.Release|Any CPU.Build.0 = Release|Any CPU
-		{1634234A-379C-44DC-BFEC-7BBDEF50B47B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{1634234A-379C-44DC-BFEC-7BBDEF50B47B}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{1634234A-379C-44DC-BFEC-7BBDEF50B47B}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{1634234A-379C-44DC-BFEC-7BBDEF50B47B}.Release|Any CPU.Build.0 = Release|Any CPU
 		{C3F289D5-C50B-46DB-852C-9543EF9B0355}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{C3F289D5-C50B-46DB-852C-9543EF9B0355}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{C3F289D5-C50B-46DB-852C-9543EF9B0355}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -173,22 +161,10 @@ Global
 		{3AB75B51-A69D-4145-A564-1D9D1695992E}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{3AB75B51-A69D-4145-A564-1D9D1695992E}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{3AB75B51-A69D-4145-A564-1D9D1695992E}.Release|Any CPU.Build.0 = Release|Any CPU
-		{91CD58E7-C314-43FD-BC64-D47F7537833F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{91CD58E7-C314-43FD-BC64-D47F7537833F}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{91CD58E7-C314-43FD-BC64-D47F7537833F}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{91CD58E7-C314-43FD-BC64-D47F7537833F}.Release|Any CPU.Build.0 = Release|Any CPU
-		{6A4399E0-6816-3A7F-3442-EE5BFB0076F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{6A4399E0-6816-3A7F-3442-EE5BFB0076F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{6A4399E0-6816-3A7F-3442-EE5BFB0076F9}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{6A4399E0-6816-3A7F-3442-EE5BFB0076F9}.Release|Any CPU.Build.0 = Release|Any CPU
-		{3A181C2E-3AA2-2FAC-6EE1-630BB8F69606}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{3A181C2E-3AA2-2FAC-6EE1-630BB8F69606}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{3A181C2E-3AA2-2FAC-6EE1-630BB8F69606}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{3A181C2E-3AA2-2FAC-6EE1-630BB8F69606}.Release|Any CPU.Build.0 = Release|Any CPU
-		{46010D33-5AF0-693B-3C0B-3CCC7F66547A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{46010D33-5AF0-693B-3C0B-3CCC7F66547A}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{46010D33-5AF0-693B-3C0B-3CCC7F66547A}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{46010D33-5AF0-693B-3C0B-3CCC7F66547A}.Release|Any CPU.Build.0 = Release|Any CPU
+		{B05DB089-31DB-2BF5-5959-C816ECD7EFA4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{B05DB089-31DB-2BF5-5959-C816ECD7EFA4}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{B05DB089-31DB-2BF5-5959-C816ECD7EFA4}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{B05DB089-31DB-2BF5-5959-C816ECD7EFA4}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
@@ -213,7 +189,6 @@ Global
 		{40B6FBEC-0524-430C-8B28-22229681D0F8} = {D041C554-B78E-4AAF-B597-E309DC8EEF4F}
 		{BB901B26-EA97-4D6F-8CAC-14DB321E1733} = {D041C554-B78E-4AAF-B597-E309DC8EEF4F}
 		{EEF30056-A626-43B2-9762-632935C1AF31} = {25C73963-4D5E-4654-804A-D2E2D360134B}
-		{1634234A-379C-44DC-BFEC-7BBDEF50B47B} = {D041C554-B78E-4AAF-B597-E309DC8EEF4F}
 		{C3F289D5-C50B-46DB-852C-9543EF9B0355} = {D041C554-B78E-4AAF-B597-E309DC8EEF4F}
 		{CF2A8B80-FF4E-4291-B383-D735BB629F32} = {D041C554-B78E-4AAF-B597-E309DC8EEF4F}
 		{9F99C272-5BC2-452C-9D97-BC756AF04669} = {D041C554-B78E-4AAF-B597-E309DC8EEF4F}
@@ -222,9 +197,7 @@ Global
 		{8E4F64EF-314A-45BA-8BB2-46FF5B06F7D5} = {D041C554-B78E-4AAF-B597-E309DC8EEF4F}
 		{31855124-4EFC-47B9-A4D5-64822DE036E6} = {08D63205-1445-430F-A4AB-EF1744E3AC11}
 		{3AB75B51-A69D-4145-A564-1D9D1695992E} = {D041C554-B78E-4AAF-B597-E309DC8EEF4F}
-		{6A4399E0-6816-3A7F-3442-EE5BFB0076F9} = {D041C554-B78E-4AAF-B597-E309DC8EEF4F}
-		{3A181C2E-3AA2-2FAC-6EE1-630BB8F69606} = {D041C554-B78E-4AAF-B597-E309DC8EEF4F}
-		{46010D33-5AF0-693B-3C0B-3CCC7F66547A} = {D041C554-B78E-4AAF-B597-E309DC8EEF4F}
+		{B05DB089-31DB-2BF5-5959-C816ECD7EFA4} = {D041C554-B78E-4AAF-B597-E309DC8EEF4F}
 	EndGlobalSection
 	GlobalSection(ExtensibilityGlobals) = postSolution
 		SolutionGuid = {4B8EA790-BD13-4422-8D63-D6DBB77B823F}

+ 0 - 23
src/Exam.Infrastructure.Data/Attributes/EntityMapperAttribute.cs

@@ -1,23 +0,0 @@
-namespace Exam.Infrastructure.Data.Attributes
-{
-    /// <summary>
-    /// 实体映射属性
-    /// </summary>
-    [AttributeUsage(AttributeTargets.Class)]
-    public class EntityMapperAttribute:Attribute
-    {
-        private readonly string _entityName;
-        public string EntityName
-        {
-            get
-            {
-                return _entityName;
-            }
-        }
-
-        public EntityMapperAttribute(string entityName)
-        {
-            _entityName = entityName;
-        }
-    }
-}

+ 0 - 85
src/Exam.Infrastructure.Data/Entity/ActionRequest.cs

@@ -1,85 +0,0 @@
-using Exam.Infrastructure.Data.Interface;
-using Exam.Infrastructure.Enums;
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Linq;
-using System.Text;
-using System.Text.Json.Serialization;
-using System.Threading.Tasks;
-
-namespace Exam.Infrastructure.Data.Entity
-{
-    /// <summary>
-    /// Dto基类
-    /// </summary>
-    public class ActionRequest:IActionRequest
-    {
-        /// <summary>
-        /// 主键
-        /// </summary>
-        [Description("主键")]
-        public string Id { get; set; }
-
-        /// <summary>
-        /// 排序
-        /// </summary>
-        [Description("排序")]
-        public int SortIndex { get; set; }
-
-        /// <summary>
-        /// 状态
-        /// </summary>
-        [Description("状态")]
-        public int Status { get; set; }
-
-        /// <summary>
-        /// 用户ID
-        /// </summary>
-        [Description("用户ID")]
-        [JsonIgnore]
-        public string UserId { get; set; }
-
-        /// <summary>
-        /// 用户名称
-        /// </summary>
-        [Description("用户名称")]
-        [JsonIgnore]
-        public string UserName { get; set; }
-
-        /// <summary>
-        /// 组织Id
-        /// </summary>
-        [Description("组织Id")]
-        [JsonIgnore]
-        public string OrgId { get; set; }
-
-        /// <summary>
-        /// 组织名称
-        /// </summary>
-        [Description("组织名称")]
-        [JsonIgnore]
-        public string OrgName { get; set; }
-
-        /// <summary>
-        /// 组织层级
-        /// </summary>
-        [Description("组织层级")]
-        [JsonIgnore]
-        public int OrgLevel { get; set; }
-
-
-        /// <summary>
-        /// 区域
-        /// </summary>
-        [Description("区域")]
-        [JsonIgnore]
-        public string AreaId { get; set; }
-
-        /// <summary>
-        /// 操作状态
-        /// </summary>
-        [Description("操作状态")]
-        public OperationStatus OperationStatus { get; set; }
-    }
-}

+ 0 - 123
src/Exam.Infrastructure.Web/Utilities/AssemblyUtility.cs

@@ -1,123 +0,0 @@
-using Exam.Infrastructure.Utilities;
-using System.Reflection;
-using System.Text.RegularExpressions;
-
-namespace Exam.Infrastructure.Web.Utilities
-{
-    public class AssemblyUtility : BaseAssemblyUtility
-    {
-
-
-        private static string[] FinderFilter
-        {
-            get
-            {
-                return new string[] { API, CLIENT, EXTENSIONS };
-            }
-        }
-        private static string[] ModuleFilter
-        {
-            get
-            {
-                return new string[] { @"^Exam\.(.*\.)?Application", @"^Exam\.(.*\.)?Share" };
-            }
-        }
-
-        public static List<Assembly> GetAssembly(string path)
-        {
-            //dynamic type = (new Program()).GetType();
-            string currentDirectory = Path.GetDirectoryName(path);
-            var files = Directory.GetFiles(currentDirectory, ALL);
-            var assemblys = new List<Assembly>();
-
-            foreach (var file in files)
-            {
-                assemblys.Add(Assembly.LoadFrom(file));
-            }
-
-            return assemblys;
-        }
-
-        public static List<Assembly> CreateModules(List<Assembly> assemblies)
-        {
-            List<Assembly> modules = new List<Assembly>();
-            foreach (var filter in ModuleFilter)
-            {
-                CreateModulesByFilter(assemblies, filter);
-            }
-            return modules;
-        }
-
-        public static List<Assembly> CreateModulesByFilter(List<Assembly> assemblies, string filter)
-        {
-            List<Assembly> modules = new List<Assembly>();
-            modules.AddRange(
-                assemblies.Where(item => Regex.IsMatch(Path.GetFileNameWithoutExtension(item.CodeBase), filter)));
-            return modules;
-        }
-
-        public static Dictionary<string, List<Assembly>> CreateFinders(List<Assembly> assemblies)
-        {
-            Dictionary<string, List<Assembly>> finders = new Dictionary<string, List<Assembly>>();
-            foreach (var filter in FinderFilter)
-            {
-                if (!finders.ContainsKey(filter))
-                {
-                    finders[filter] = new List<Assembly>();
-                }
-                finders[filter]
-                    .AddRange(assemblies.Where(item => Regex.IsMatch(Path.GetFileNameWithoutExtension(item.CodeBase), filter)));
-            }
-            return finders;
-        }
-
-
-
-        public static Tuple<Dictionary<string, List<Assembly>>, Assembly[]> ScannerAssemblies(string path)
-        {
-            var assemblies = GetAssembly(path);
-
-            var finders = CreateFinders(assemblies);
-
-            var modules = CreateModules(assemblies);
-
-            return new Tuple<Dictionary<string, List<Assembly>>, Assembly[]>(finders, modules.ToArray());
-        }
-
-        public static List<Type> GetTypeToRegister<TEntity>(List<Assembly> assemblies, string filter)
-        {
-            var types = new List<Type>();
-
-            var currentDomainAssemblies = CreateModulesByFilter(assemblies, filter);
-
-
-            foreach (var currentAssembly in currentDomainAssemblies)
-            {
-                types.AddRange(currentAssembly.GetTypes().Where(q => q.GetInterface(typeof(TEntity).FullName) != null));
-
-            }
-
-            return types;
-        }
-
-        public static List<TEntity> CreateInstance<TEntity>(List<Assembly> assemblies, string filter)
-        {
-            var instatnces = new List<TEntity>();
-
-            var currentDomainAssemblies = CreateModulesByFilter(assemblies, filter);
-
-            foreach (var currentAssembly in currentDomainAssemblies)
-            {
-                var types = currentAssembly.GetTypes().Where(q => q.GetInterface(typeof(TEntity).FullName) != null);
-
-                foreach (var type in types)
-                {
-                    instatnces.Add((TEntity)currentAssembly.CreateInstance(type.FullName));
-                }
-
-            }
-
-            return instatnces;
-        }
-    }
-}

+ 0 - 64
src/Exam.Infrastructure.Web/Utilities/ServiceUtility.cs

@@ -1,64 +0,0 @@
-using Hotline.Repository.SqlSugar.Interface;
-using Microsoft.Extensions.DependencyInjection;
-using System.Reflection;
-using System.Text.RegularExpressions;
-
-namespace Exam.Infrastructure.Web.Utilities
-{
-    public static class ServiceUtility
-    {
-        public static IServiceCollection Services { get; set; }
-
-        public static void RegisterService(this IServiceCollection services)
-        {
-            var assemblies = AssemblyUtility.GetAssembly(Assembly.GetExecutingAssembly().Location);
-
-            var domainEvents = new List<IDomainService>();
-
-            var apiServiceAssemblies = assemblies.Where(item => Regex.IsMatch(Path.GetFileNameWithoutExtension(item.CodeBase), Infrastructure.Utilities.BaseAssemblyUtility.VITRUALAPPLICATION)).ToList();
-
-            foreach (var assembly in apiServiceAssemblies)
-            {
-                try
-                {
-                    
-                    var types = assembly.GetTypes().Where(t => t.GetInterfaces().Contains(typeof(IDomainService)));
-
-                    if (types == null || !types.Any()) continue;
-
-                    var implements = types.Where(t => t.IsInterface != true);
-
-                    var interfaces = types.Where(t => t.IsInterface == true);
-                    //var eventTypes = assembly.GetTypes().Where(t => t.GetInterfaces().Contains(typeof(IBaseEvent)));
-
-                    foreach (var item in interfaces)
-                    {
-                        var implement = implements.FirstOrDefault(t => t.GetInterfaces().Contains(item));
-                        if (implement != null)
-                        {
-                            services.AddScoped(item, implement);
-                        }
-                    }
-
-                    Services = services;
-                }
-                catch (Exception ex)
-                {
-                    continue;
-                }
-            }
-        }
-
-        public static T GetServic<T>()
-        {
-            if (Services != null)
-            {
-                var provider = Services.BuildServiceProvider();
-
-                return provider.GetService<T>();
-            }
-
-            return default;
-        }
-    }
-}

+ 0 - 244
src/Exam.Infrastructure/Utilities/BaseAssemblyUtility.cs

@@ -1,244 +0,0 @@
-using Microsoft.AspNetCore.Http;
-using Microsoft.Extensions.DependencyInjection;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Net.Http;
-using System.Reflection;
-using System.Text;
-using System.Text.RegularExpressions;
-using System.Threading.Tasks;
-
-namespace Exam.Infrastructure.Utilities
-{
-    public class BaseAssemblyUtility
-    {
-        public static string ProjectPrefix = @"Exam";
-
-        public static string API = string.Format(@"^{0}\.(.*\.)?Api$", ProjectPrefix);
-
-        public static string CLIENT = @"^PlanReady\.(.*\.)?Client";
-
-        public static string EXTENSIONS = @"^PlanReady\.Extensions\..*$";
-
-        public static string REPOSITORY = string.Format(@"^{0}\.(.*\.)?Repository", ProjectPrefix);
-
-        public static string DOMAIN = string.Format(@"^{0}\.(.*\.)?Domain", ProjectPrefix);
-
-        public static string CONSTRACT = string.Format(@"^{0}\.(.*\.)?Contract", ProjectPrefix);
-
-        public static string APISERVICE = string.Format(@"^{0}\.(.*\.)?ApiService", ProjectPrefix);
-
-        public static string VITRUALDOMAIN = string.Format(@"^{0}\.(.*\.)?Domain", ProjectPrefix);
-
-        public static string VITRUALCONSTRACT = string.Format(@"^{0}\.(.*\.)?Contract", ProjectPrefix);
-
-        public static string VITRUALAPISERVICE = string.Format(@"^{0}\.(.*\.)?ApiService", ProjectPrefix);
-
-        public static string VITRUALREPOSITORY = string.Format(@"^{0}\.(.*\.)?Repository", ProjectPrefix);
-
-        public static string VITRUALSIGNATURE = string.Format(@"^{0}\.(.*\.)?Signature", ProjectPrefix);
-
-        public static string VITRUALENTITY = string.Format(@"{0}", ProjectPrefix);
-
-        public static string VITRUALSHARE = string.Format(@"^{0}\.(.*\.)?Share", ProjectPrefix);
-
-        public static string VITRUALAPPLICATION = string.Format(@"^{0}\.(.*\.)?Application", ProjectPrefix);
-
-        public static string ALL = "*.dll";
-
-
-
-        static BaseAssemblyUtility()
-        {
-            //Hashtable = new Hashtable();
-        }
-
-        public static IServiceProvider Provider { get; set; }
-
-        private static string[] FinderFilter
-        {
-            get
-            {
-                return new string[] { API, CLIENT, EXTENSIONS };
-            }
-        }
-        private static string[] ModuleFilter
-        {
-            get
-            {
-                return new string[] { @"^PlanReady\.(.*\.)?Services$", @"^PlanReady\.(.*\.)\.Data$" };
-            }
-        }
-
-        public static string TraceId
-        {
-            get
-            {
-                try
-                {
-                    var httpContextAccessor = Provider.GetService<IHttpContextAccessor>();
-
-                    if (httpContextAccessor == null) return null;
-
-                    var id = httpContextAccessor.HttpContext?.TraceIdentifier ?? "defaultId";
-
-                    return id;
-                }
-                catch
-                {
-                    return null;
-                }
-            }
-        }
-
-        //public static Hashtable Hashtable { get; set; }
-
-        public static List<Assembly> GetAssembly(string path)
-        {
-            //dynamic type = (new Program()).GetType();
-            string currentDirectory = Path.GetDirectoryName(path);
-            var files = Directory.GetFiles(currentDirectory, ALL);
-            var assemblys = new List<Assembly>();
-
-            foreach (var file in files)
-            {
-                assemblys.Add(Assembly.LoadFrom(file));
-            }
-
-            return assemblys;
-        }
-
-        public static List<Assembly> CreateModules(List<Assembly> assemblies)
-        {
-            List<Assembly> modules = new List<Assembly>();
-            foreach (var filter in ModuleFilter)
-            {
-                CreateModulesByFilter(assemblies, filter);
-            }
-            return modules;
-        }
-
-        public static List<Assembly> CreateModulesByFilter(List<Assembly> assemblies, string filter)
-        {
-            List<Assembly> modules = new List<Assembly>();
-            modules.AddRange(
-                assemblies.Where(item => Regex.IsMatch(Path.GetFileNameWithoutExtension(item.CodeBase), filter)));
-            return modules;
-        }
-
-        public static Dictionary<string, List<Assembly>> CreateFinders(List<Assembly> assemblies)
-        {
-            Dictionary<string, List<Assembly>> finders = new Dictionary<string, List<Assembly>>();
-            foreach (var filter in FinderFilter)
-            {
-                if (!finders.ContainsKey(filter))
-                {
-                    finders[filter] = new List<Assembly>();
-                }
-                finders[filter]
-                    .AddRange(assemblies.Where(item => Regex.IsMatch(Path.GetFileNameWithoutExtension(item.CodeBase), filter)));
-            }
-            return finders;
-        }
-
-
-
-        public static Tuple<Dictionary<string, List<Assembly>>, Assembly[]> ScannerAssemblies(string path)
-        {
-            var assemblies = GetAssembly(path);
-
-            var finders = CreateFinders(assemblies);
-
-            var modules = CreateModules(assemblies);
-
-            return new Tuple<Dictionary<string, List<Assembly>>, Assembly[]>(finders, modules.ToArray());
-        }
-
-        public static List<Type> GetTypeToRegister<TEntity>(List<Assembly> assemblies, string filter)
-        {
-            var types = new List<Type>();
-
-            var currentDomainAssemblies = CreateModulesByFilter(assemblies, filter);
-
-
-            foreach (var currentAssembly in currentDomainAssemblies)
-            {
-                types.AddRange(currentAssembly.GetTypes().Where(q => q.GetInterface(typeof(TEntity).FullName) != null));
-
-            }
-
-            return types;
-        }
-
-        public static void RegisterInstance(IServiceCollection container, List<Assembly> assemblies, List<Type> interfaces, string filter)
-        {
-
-            var currentDomainAssemblies = CreateModulesByFilter(assemblies, filter);
-
-            foreach (var currentAssembly in currentDomainAssemblies)
-            {
-                foreach (var item in interfaces)
-                {
-                    var types = currentAssembly.GetTypes().Where(m => m.GetInterfaces().Contains(item) && !m.IsInterface).ToList();
-
-                    foreach (var type in types)
-                    {
-                        container.AddSingleton(type.GetInterfaces().FirstOrDefault(m => m != item), type);
-                        //instatnces.Add((TEntity)currentAssembly.CreateInstance(type.FullName));
-                    }
-
-                }
-            }
-        }
-
-        public static void RegisterAddTransientInstance(IServiceCollection container, List<Assembly> assemblies, List<Type> interfaces, string filter)
-        {
-
-            var currentDomainAssemblies = CreateModulesByFilter(assemblies, filter);
-
-            foreach (var currentAssembly in currentDomainAssemblies)
-            {
-                foreach (var item in interfaces)
-                {
-                    var types = currentAssembly.GetTypes().Where(m => m.GetInterfaces().Contains(item) && !m.IsInterface).ToList();
-
-                    foreach (var type in types)
-                    {
-                        container.AddTransient(type.GetInterfaces().FirstOrDefault(m => m != item), type);
-                        //instatnces.Add((TEntity)currentAssembly.CreateInstance(type.FullName));
-                    }
-
-                }
-            }
-        }
-
-        public static List<TEntity> CreateInstance<TEntity>(string filter)
-        {
-            var instatnces = new List<TEntity>();
-
-            instatnces = Provider.GetServices<TEntity>().Where(item => Regex.IsMatch(Path.GetFileNameWithoutExtension(item.GetType().FullName), filter)).ToList();
-
-            return instatnces;
-        }
-
-        public static List<TEntity> CreateInstance<TEntity>(List<Assembly> assemblies, string filter)
-        {
-            var instatnces = new List<TEntity>();
-
-            var currentDomainAssemblies = CreateModulesByFilter(assemblies, filter);
-
-            foreach (var currentAssembly in currentDomainAssemblies)
-            {
-                var types = currentAssembly.GetTypes().Where(q => q.GetInterface(typeof(TEntity).FullName) != null);
-
-                foreach (var type in types)
-                {
-                    instatnces.Add((TEntity)currentAssembly.CreateInstance(type.FullName));
-                }
-            }
-
-            return instatnces;
-        }
-    }
-}

+ 81 - 0
src/Hotline.Api/Controllers/Exam/ExamManageController.cs

@@ -0,0 +1,81 @@
+using Exam.Infrastructure.Data.Entity;
+using Exam.Share;
+using Exam.Share.ViewResponses.Exam;
+using Hotline.Application.Exam.Constants.ApiRoutes;
+using Hotline.Application.Exam.Interface.ExamManages;
+using Hotline.Share.Requests.Exam;
+using Microsoft.AspNetCore.Mvc;
+
+namespace Hotline.Api.Controllers.Exam
+{
+    public class ExamManageController : BaseController
+    {
+        private readonly IExamManageService _questionService;
+        public ExamManageController(IExamManageService questionService)
+        {
+            _questionService = questionService;
+        }
+
+        /// <summary>
+        /// 新增题库
+        /// </summary>
+        /// <param name="questionDto"></param>
+        /// <returns></returns>
+        [HttpPost(ExamManageApiRoute.Add)]
+        public async Task Add([FromBody] AddExamManageDto questionDto)
+        {
+            await _questionService.AddAsync(questionDto, HttpContext.RequestAborted);
+        }
+
+        /// <summary>
+        /// 修改题库
+        /// </summary>
+        /// <param name="questionDto"></param>
+        /// <returns></returns>
+        [HttpPut(ExamManageApiRoute.Update)]
+        public async Task Update([FromBody] UpdateExamManageDto questionDto)
+        {
+            await _questionService.UpdateAsync(questionDto, HttpContext.RequestAborted);
+        }
+
+        /// <summary>
+        /// 删除题库
+        /// </summary>
+        /// <param name="entityQueryRequest"></param>
+        /// <returns></returns>
+        [HttpDelete(ExamManageApiRoute.Delete)]
+        public async Task Delete([FromBody] EntityQueryRequest entityQueryRequest)
+        {
+            await _questionService.DeleteAsync(entityQueryRequest, HttpContext.RequestAborted);
+        }
+
+        /// <summary>
+        /// 获取题库分页列表
+        /// </summary>
+        /// <param name="questionPagedRequest"></param>
+        /// <returns></returns>
+        [HttpPost(ExamManageApiRoute.GetPagedList)]
+        public async Task<ExamManagePageViewResponse> GetPagedList([FromBody] ExamManagePagedRequest questionPagedRequest)
+        {
+            var questionPageViewResponse = await _questionService.GetPagedListAsync(questionPagedRequest);
+
+            return questionPageViewResponse as ExamManagePageViewResponse;
+        }
+
+        /// <summary>
+        /// 获取题库
+        /// </summary>
+        /// <param name="id"></param>
+        /// <returns></returns>
+        [HttpGet(ExamManageApiRoute.Get)]
+        public async Task<ExamManageDto> Get(string id)
+        {
+            var questionDto = await _questionService.GetAsync(new EntityQueryRequest
+            {
+                Id = id
+            });
+
+            return questionDto;
+        }
+    }
+}

+ 3 - 13
src/Hotline.Api/Controllers/Exam/ExamTagController.cs

@@ -1,27 +1,19 @@
 using Exam.Application.Interface.Exam;
 using Exam.Infrastructure.Data.Entity;
-using Exam.Infrastructure.Data.Extensions;
-using Exam.Share.ViewResponses.Sourceware;
-using Hotline.Application.Exam.Constants;
 using Hotline.Application.Exam.Constants.ApiRoutes;
 using Hotline.Share.Dtos.ExamManages;
-using Hotline.Share.Dtos.Sourcewares;
 using Hotline.Share.Requests.Exam;
-using Hotline.Share.Requests.Sourceware;
 using Hotline.Share.ViewResponses.Exam;
 using Microsoft.AspNetCore.Mvc;
-using XF.Domain.Authentications;
 
 namespace Hotline.Api.Controllers.Exam
 {
     public class ExamTagController : BaseController
     {
         private readonly IExamTagService _examTagService;
-        private readonly ISessionContext _sessionContext;
-        public ExamTagController(IExamTagService examTagService,ISessionContext sessionContext)
+        public ExamTagController(IExamTagService examTagService)
         {
             _examTagService = examTagService;
-            _sessionContext = sessionContext;
         }
 
         /// <summary>
@@ -30,9 +22,8 @@ namespace Hotline.Api.Controllers.Exam
         /// <param name="examTagDto"></param>
         /// <returns></returns>
         [HttpPost(ExamTagApiRoute.Add)]
-        public async Task Add([FromBody] ExamTagDto examTagDto)
+        public async Task Add([FromBody] AddExamTagDto examTagDto)
         {
-            examTagDto.InitRequest(_sessionContext);
             await _examTagService.AddAsync(examTagDto, HttpContext.RequestAborted);
         }
 
@@ -42,9 +33,8 @@ namespace Hotline.Api.Controllers.Exam
         /// <param name="examTagDto"></param>
         /// <returns></returns>
         [HttpPut(ExamTagApiRoute.Update)]
-        public async Task Update([FromBody] ExamTagDto examTagDto)
+        public async Task Update([FromBody] UpdateExamTagDto examTagDto)
         {
-            examTagDto.InitRequest(_sessionContext);
             await _examTagService.UpdateAsync(examTagDto, HttpContext.RequestAborted);
         }
 

+ 3 - 14
src/Hotline.Api/Controllers/Exam/ExtractRuleController.cs

@@ -1,29 +1,20 @@
 using Exam.Application.Interface.Exam;
 using Exam.Infrastructure.Data.Entity;
-using Exam.Infrastructure.Data.Extensions;
 using Exam.Share.ViewResponses.Exam;
 using Hotline.Application.Exam.Constants.ApiRoutes;
-using Hotline.Application.Exam.Service.ExamManages;
-using Hotline.Share.Dtos.ExamManages;
 using Hotline.Share.Dtos.TestPapers;
 using Hotline.Share.Requests.Exam;
-using Hotline.Share.Requests.Sourceware;
 using Hotline.Share.ViewResponses.Exam;
-using Hotline.Share.ViewResponses.Sourcewares;
-using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
-using XF.Domain.Authentications;
 
 namespace Hotline.Api.Controllers.Exam
 {
     public class ExtractRuleController : BaseController
     {
         private readonly IExtractRuleService _extractRuleService;
-        private readonly ISessionContext _sessionContext;
-        public ExtractRuleController(IExtractRuleService extractRuleService,ISessionContext sessionContext)
+        public ExtractRuleController(IExtractRuleService extractRuleService)
         {
             _extractRuleService = extractRuleService;
-            _sessionContext = sessionContext;
         }
 
         /// <summary>
@@ -32,9 +23,8 @@ namespace Hotline.Api.Controllers.Exam
         /// <param name="extractRuleDto"></param>
         /// <returns></returns>
         [HttpPost(ExtractRuleApiRoute.Add)]
-        public async Task Add([FromBody] ExtractRuleDto extractRuleDto)
+        public async Task Add([FromBody] AddExtractRuleDto extractRuleDto)
         {
-            extractRuleDto.InitRequest(_sessionContext);
             await _extractRuleService.AddAsync(extractRuleDto, HttpContext.RequestAborted);
         }
 
@@ -44,9 +34,8 @@ namespace Hotline.Api.Controllers.Exam
         /// <param name="extractRuleDto"></param>
         /// <returns></returns>
         [HttpPut(ExtractRuleApiRoute.Update)]
-        public async Task Update([FromBody] ExtractRuleDto extractRuleDto)
+        public async Task Update([FromBody] UpdateExtractRuleDto extractRuleDto)
         {
-            extractRuleDto.InitRequest(_sessionContext);
             await _extractRuleService.UpdateAsync(extractRuleDto, HttpContext.RequestAborted);
         }
 

+ 4 - 9
src/Hotline.Api/Controllers/Exam/QuestionController.cs

@@ -1,23 +1,19 @@
 using Exam.Application.Interface.Questions;
 using Exam.Infrastructure.Data.Entity;
-using Exam.Infrastructure.Data.Extensions;
 using Exam.Share.ViewResponses.Question;
 using Hotline.Application.Exam.Constants.ApiRoutes;
 using Hotline.Share.Dtos.Questions;
 using Hotline.Share.Requests.Question;
 using Microsoft.AspNetCore.Mvc;
-using XF.Domain.Authentications;
 
 namespace Hotline.Api.Controllers.Exam
 {
     public class QuestionController : BaseController
     {
         private readonly IQuestionService _questionService;
-        private readonly ISessionContext _sessionContext;
-        public QuestionController(IQuestionService questionService,ISessionContext sessionContext)
+        public QuestionController(IQuestionService questionService)
         {
             _questionService = questionService;
-            _sessionContext = sessionContext;
         }
 
         /// <summary>
@@ -26,9 +22,8 @@ namespace Hotline.Api.Controllers.Exam
         /// <param name="questionDto"></param>
         /// <returns></returns>
         [HttpPost(QuestionApiRoute.Add)]
-        public async Task Add([FromBody] QuestionDto questionDto)
+        public async Task Add([FromBody] AddQuestionDto questionDto)
         {
-            questionDto.InitRequest(_sessionContext);
             await _questionService.AddAsync(questionDto, HttpContext.RequestAborted);
         }
 
@@ -38,9 +33,8 @@ namespace Hotline.Api.Controllers.Exam
         /// <param name="questionDto"></param>
         /// <returns></returns>
         [HttpPut(QuestionApiRoute.Update)]
-        public async Task Update([FromBody] QuestionDto questionDto)
+        public async Task Update([FromBody] UpdateQuestionDto questionDto)
         {
-            questionDto.InitRequest(_sessionContext);
             await _questionService.UpdateAsync(questionDto, HttpContext.RequestAborted);
         }
 
@@ -83,5 +77,6 @@ namespace Hotline.Api.Controllers.Exam
 
             return questionDto;
         }
+
     }
 }

+ 3 - 10
src/Hotline.Api/Controllers/Exam/SourcewareCategoryController.cs

@@ -1,24 +1,19 @@
 using Exam.Application;
 using Exam.Infrastructure.Data.Entity;
-using Exam.Infrastructure.Data.Extensions;
 using Exam.Share.ViewResponses.Sourceware;
 using Hotline.Application.Exam.Constants.ApiRoutes;
-using Hotline.Repository.SqlSugar.Exam.Interfaces.Sourcewares;
 using Hotline.Share.Dtos.Sourcewares;
 using Hotline.Share.Requests.Sourceware;
 using Microsoft.AspNetCore.Mvc;
-using XF.Domain.Authentications;
 
 namespace Hotline.Api.Controllers.Exam
 {
     public class SourcewareCategoryController : BaseController
     {
         private readonly ISourcewareCategoryService _sourcewareCategoryService;
-        private readonly ISessionContext _sessionContext;
-        public SourcewareCategoryController(ISourcewareCategoryService sourcewareCategoryService,ISessionContext sessionContext)
+        public SourcewareCategoryController(ISourcewareCategoryService sourcewareCategoryService)
         {
             _sourcewareCategoryService = sourcewareCategoryService;
-            _sessionContext = sessionContext;
         }
 
         /// <summary>
@@ -27,9 +22,8 @@ namespace Hotline.Api.Controllers.Exam
         /// <param name="sourcewareCategoryDto"></param>
         /// <returns></returns>
         [HttpPost(SourcewareCategoryApiRoute.Add)]
-        public async Task Add([FromBody] SourcewareCategoryDto sourcewareCategoryDto)
+        public async Task Add([FromBody] AddSourcewareCategoryDto sourcewareCategoryDto)
         {
-            sourcewareCategoryDto.InitRequest(_sessionContext);
             await _sourcewareCategoryService.AddAsync(sourcewareCategoryDto, HttpContext.RequestAborted);
         }
 
@@ -39,9 +33,8 @@ namespace Hotline.Api.Controllers.Exam
         /// <param name="sourcewareCategoryDto"></param>
         /// <returns></returns>
         [HttpPut(SourcewareCategoryApiRoute.Update)]
-        public async Task Update([FromBody] SourcewareCategoryDto sourcewareCategoryDto)
+        public async Task Update([FromBody] UpdateSourcewareCategoryDto sourcewareCategoryDto)
         {
-            sourcewareCategoryDto.InitRequest(_sessionContext);
             await _sourcewareCategoryService.UpdateAsync(sourcewareCategoryDto,HttpContext.RequestAborted);
         }
 

+ 3 - 9
src/Hotline.Api/Controllers/Exam/SourcewaresController.cs

@@ -1,24 +1,20 @@
 using Exam.Application.Interface.Sourcewares;
 using Exam.Infrastructure.Data.Entity;
-using Exam.Infrastructure.Data.Extensions;
 using Hotline.Application.Exam.Constants.ApiRoutes;
 using Hotline.Share.Dtos.Sourcewares;
 using Hotline.Share.Requests.Sourceware;
 using Hotline.Share.ViewResponses.Sourcewares;
 using Microsoft.AspNetCore.Mvc;
-using XF.Domain.Authentications;
 
 namespace Hotline.Api.Controllers.Exam
 {
     public class SourcewaresController : BaseController
     {
         private readonly ISourcewareService _sourcewareService;
-        private readonly ISessionContext _sessionContext;
 
-        public SourcewaresController(ISourcewareService sourcewareService,ISessionContext sessionContext)
+        public SourcewaresController(ISourcewareService sourcewareService)
         {
             _sourcewareService = sourcewareService;
-            _sessionContext = sessionContext;
         }
 
         /// <summary>
@@ -27,9 +23,8 @@ namespace Hotline.Api.Controllers.Exam
         /// <param name="sourcewareDto"></param>
         /// <returns></returns>
         [HttpPost(SourcewareApiRoute.Add)]
-        public async Task Add([FromBody] SourcewareDto sourcewareDto)
+        public async Task Add([FromBody] AddSourcewareDto sourcewareDto)
         {
-            sourcewareDto.InitRequest(_sessionContext);
             await _sourcewareService.AddAsync(sourcewareDto, HttpContext.RequestAborted);
         }
 
@@ -39,9 +34,8 @@ namespace Hotline.Api.Controllers.Exam
         /// <param name="sourcewareDto"></param>
         /// <returns></returns>
         [HttpPut(SourcewareApiRoute.Update)]
-        public async Task Update([FromBody] SourcewareDto sourcewareDto)
+        public async Task Update([FromBody] UpdateSourcewareDto sourcewareDto)
         {
-            sourcewareDto.InitRequest(_sessionContext);
             await _sourcewareService.UpdateAsync(sourcewareDto, HttpContext.RequestAborted);
         }
 

+ 86 - 0
src/Hotline.Api/Controllers/Exam/TestPaperController.cs

@@ -0,0 +1,86 @@
+using Exam.Application.Interface.Exam;
+using Exam.Application.Interface.TestPapers;
+using Exam.Infrastructure.Data.Entity;
+using Exam.Share.ViewResponses.Exam;
+using Exam.Share.ViewResponses.TestPaper;
+using Hotline.Application.Exam.Constants.ApiRoutes;
+using Hotline.Share.Dtos.TestPapers;
+using Hotline.Share.Requests.Exam;
+using Hotline.Share.ViewResponses.Exam;
+using Microsoft.AspNetCore.Mvc;
+
+namespace Hotline.Api.Controllers.Exam
+{
+    public class TestPaperController : BaseController
+    {
+        private readonly ITestPaperService _testPaperService;
+        public TestPaperController(ITestPaperService testPaperService)
+        {
+            _testPaperService = testPaperService;
+        }
+
+        /// <summary>
+        /// 新增试卷
+        /// </summary>
+        /// <param name="extractRuleDto"></param>
+        /// <returns></returns>
+        [HttpPost(TestPaperApiRoute.Add)]
+        public async Task Add([FromBody] AddTestPaperDto extractRuleDto)
+        {
+            await _testPaperService.AddAsync(extractRuleDto, HttpContext.RequestAborted);
+        }
+
+        /// <summary>
+        /// 修改试卷
+        /// </summary>
+        /// <param name="extractRuleDto"></param>
+        /// <returns></returns>
+        [HttpPut(TestPaperApiRoute.Update)]
+        public async Task Update([FromBody] UpdateTestPaperDto extractRuleDto)
+        {
+            await _testPaperService.UpdateAsync(extractRuleDto, HttpContext.RequestAborted);
+        }
+
+        /// <summary>
+        /// 删除试卷
+        /// </summary>
+        /// <param name="entityQueryRequest"></param>
+        /// <returns></returns>
+        [HttpDelete(TestPaperApiRoute.Delete)]
+
+        public async Task Delete(EntityQueryRequest entityQueryRequest)
+        {
+            await _testPaperService.DeleteAsync(entityQueryRequest, HttpContext.RequestAborted);
+        }
+
+        /// <summary>
+        /// 获取课件分页列表
+        /// </summary>
+        /// <param name="sourcewarePagedRequest"></param>
+        /// <returns></returns>
+        [HttpPost(TestPaperApiRoute.GetPagedList)]
+        public async Task<TestPaperPageViewResponse> GetPagedList([FromBody] TestPaperPagedRequest sourcewarePagedRequest)
+        {
+            var sourcewarePageViewResponse = await _testPaperService.GetPagedListAsync(sourcewarePagedRequest);
+
+            return sourcewarePageViewResponse as TestPaperPageViewResponse;
+        }
+
+
+        /// <summary>
+        /// 获取课件分类
+        /// </summary>
+        /// <param name="id"></param>
+        /// <returns></returns>
+        [HttpGet(TestPaperApiRoute.Get)]
+        public async Task<TestPaperDto> Get(string id)
+        {
+            var extractRuleDto = await _testPaperService.GetAsync(new EntityQueryRequest
+            {
+                Id = id
+            });
+
+            return extractRuleDto;
+        }
+    }
+}

+ 1 - 0
src/Hotline.Api/Hotline.Api.csproj

@@ -26,6 +26,7 @@
   </ItemGroup>
 
   <ItemGroup>
+    <ProjectReference Include="..\Hotline.Ai.Jths\Hotline.Ai.Jths.csproj" />
     <ProjectReference Include="..\Hotline.Application\Hotline.Application.csproj" />
     <ProjectReference Include="..\Hotline.WeChat\Hotline.WeChat.csproj" />
     <ProjectReference Include="..\Hotline.XingTang\Hotline.XingTang.csproj" />

+ 8 - 0
src/Hotline.Application/Exam/Constants/ApiRoutes/ExamManageApiRoute.cs

@@ -0,0 +1,8 @@
+using Exam.Infrastructure.Web.Constants;
+
+namespace Hotline.Application.Exam.Constants.ApiRoutes
+{
+    public class ExamManageApiRoute:ApiRoute
+    {
+    }
+}

+ 8 - 0
src/Hotline.Application/Exam/Constants/ApiRoutes/TestPaperApiRoute.cs

@@ -0,0 +1,8 @@
+using Exam.Infrastructure.Web.Constants;
+
+namespace Hotline.Application.Exam.Constants.ApiRoutes
+{
+    public class TestPaperApiRoute:ApiRoute
+    {
+    }
+}

+ 0 - 0
src/Exam.Infrastructure.Web/Constants/ApiRoute.cs → src/Hotline.Application/Exam/Core/Constants/ApiRoute.cs


+ 0 - 0
src/Exam.Infrastructure.Web/Extensions/ExpressionableExtensions.cs → src/Hotline.Application/Exam/Core/Extensions/ExpressionableExtensions.cs


+ 0 - 0
src/Exam.Infrastructure.Web/Utilities/ExpressionableUtility.cs → src/Hotline.Application/Exam/Core/Utilities/ExpressionableUtility.cs


+ 0 - 0
src/Exam.Infrastructure.Web/Utilities/TypeAdapterConfigUtility.cs → src/Hotline.Application/Exam/Core/Utilities/TypeAdapterConfigUtility.cs


+ 0 - 49
src/Hotline.Application/Exam/Extensions/ActionRequestExtensions.cs

@@ -1,49 +0,0 @@
-using Exam.Infrastructure.Data.Entity;
-using Exam.Infrastructure.Data.Interface;
-using Exam.Infrastructure.Extensions;
-using XF.Domain.Authentications;
-
-namespace Exam.Infrastructure.Data.Extensions
-{
-    public static class ActionRequestExtensions
-    {
-
-        public static void InitRequest(this ActionRequest actionRequest,ISessionContext sessionContext)
-        {
-            if (actionRequest.Id == null || actionRequest.Id.IsNullOrEmpty())
-            {
-                actionRequest.Id = Guid.NewGuid().ToString();
-            }
-
-            actionRequest.UserId = sessionContext.UserId;
-            actionRequest.UserName = sessionContext.UserName;
-            actionRequest.OrgId = sessionContext.OrgId;
-            actionRequest.AreaId = sessionContext.AreaId;
-            actionRequest.OrgName = sessionContext.OrgName;
-            actionRequest.OrgLevel = sessionContext.OrgLevel;
-        }
-    
-    
-        public static void InitRequest<TDest,TSource>(this List<TDest> actionRequests, TSource actionRequest) 
-            where TDest : ActionRequest
-            where TSource : ActionRequest
-        {
-            foreach(var item in actionRequests)
-            {
-                item.InitRequest(actionRequest);
-            }
-        }
-
-        public static void InitRequest<TDest, TSource>(this TDest dest, TSource source) 
-            where TDest:ActionRequest
-            where TSource:ActionRequest
-        {
-            dest.UserId = source.UserId;
-            dest.UserName = source.UserName;
-            dest.OrgId = source.OrgId;
-            dest.AreaId = source.AreaId;
-            dest.OrgName = source.OrgName;
-            dest.OrgLevel = source.OrgLevel;
-        }
-    }
-}

+ 1 - 1
src/Hotline.Application/Exam/Interface/ExamManages/IExamManageService.cs

@@ -7,7 +7,7 @@ using Hotline.Share.Requests.Exam;
 
 namespace Hotline.Application.Exam.Interface.ExamManages
 {
-    public interface IExamManageService:IQueryService<ExamManageViewResponse,ExamManageDto,ExamManagePagedRequest>,IApiService<ExamManageDto,ExamManage>
+    public interface IExamManageService:IQueryService<ExamManageViewResponse,ExamManageDto,ExamManagePagedRequest>,IApiService<AddExamManageDto,UpdateExamManageDto,ExamManage>
     {
     }
 }

+ 1 - 1
src/Hotline.Application/Exam/Interface/ExamManages/IExamTagService.cs

@@ -8,7 +8,7 @@ using Hotline.Share.ViewResponses.Exam;
 
 namespace Exam.Application.Interface.Exam
 {
-    public interface IExamTagService:IQueryService<ExamTagViewResponse,ExamTagDto,ExamTagRequest>,IApiService<ExamTagDto,ExamTag>
+    public interface IExamTagService:IQueryService<ExamTagViewResponse,ExamTagDto,ExamTagRequest>,IApiService<AddExamTagDto,UpdateExamTagDto,ExamTag>
     {
         public Task<List<ExamTagViewResponse>> GetTreeAsync(ExamTagRequest examTagRequest);
     }

+ 1 - 1
src/Hotline.Application/Exam/Interface/ExamManages/IExtractRuleService.cs

@@ -8,7 +8,7 @@ using Hotline.Share.ViewResponses.Exam;
 
 namespace Exam.Application.Interface.Exam
 {
-    public interface IExtractRuleService:IQueryService<ExtractRuleViewResponse,ExtractRuleDto,ExtractRulePagedRequest>,IApiService<ExtractRuleDto,ExtractRule>
+    public interface IExtractRuleService:IQueryService<ExtractRuleViewResponse,ExtractRuleDto,ExtractRulePagedRequest>,IApiService<AddExtractRuleDto,UpdateExtractRuleDto,ExtractRule>
     {
         public Task<List<TagQuestionViewResponse>> GetTagQuestionCount(TagQuestionRequest tagQuestionRequest);
     }

+ 1 - 1
src/Hotline.Application/Exam/Interface/ExamManages/IUserExamService.cs

@@ -8,7 +8,7 @@ using Hotline.Share.Requests.Exam;
 
 namespace Exam.Application.Interface.Exam
 {
-    public interface IUserExamService:IQueryService<UserExamResultViewResponse,UserExamDto,UserExamPagedRequest>,IApiService<UserExamDto,UserExam>
+    public interface IUserExamService:IQueryService<UserExamResultViewResponse,UserExamDto,UserExamPagedRequest>,IApiService<AddUserExamDto,UpdateUserExamDto,UserExam>
     {
         /// <summary>
         /// 交卷

+ 1 - 1
src/Hotline.Application/Exam/Interface/Practices/IPracticeService.cs

@@ -7,7 +7,7 @@ using Hotline.Share.Requests.Exam;
 
 namespace Exam.Application.Interface.Practices
 {
-    public interface IPracticeService:IQueryService<PracticeViewResponse, PracticeDto,PracticePagedRequest>,IApiService<PracticeDto,Practice>
+    public interface IPracticeService:IQueryService<PracticeViewResponse, PracticeDto,PracticePagedRequest>,IApiService<AddPracticeDto,UpdatePracticeDto,Practice>
     {
     }
 }

+ 1 - 1
src/Hotline.Application/Exam/Interface/Questions/IQuestionAnswerService.cs

@@ -13,7 +13,7 @@ namespace Exam.Application
     /// 试题参考答案服务接口
     /// </summary>
     [Description("试题参考答案服务接口")]
-    public interface IQuestionAnswerService:IQueryService<QuestionAnswerViewResponse,QuestionAnswerDto,QuestionAnswerPagedRequest>,IApiService<QuestionAnswerDto,QuestionAnswer>
+    public interface IQuestionAnswerService:IQueryService<QuestionAnswerViewResponse,QuestionAnswerDto,QuestionAnswerPagedRequest>,IApiService<AddQuestionAnswerDto,UpdateQuestionAnswerDto,QuestionAnswer>
     {
     }
 }

+ 1 - 1
src/Hotline.Application/Exam/Interface/Questions/IQuestionKnowladgeService.cs

@@ -13,7 +13,7 @@ namespace Exam.Application
     /// 关联知识服务接口
     /// </summary>
     [Description("关联知识服务接口")]
-    public interface IQuestionKnowladgeService:IQueryService<QuestionKnowladgeViewResponse,QuestionKnowladgeDto,QuestionKnowladgePagedRequest>,IApiService<QuestionKnowladgeDto,QuestionKnowladge>
+    public interface IQuestionKnowladgeService:IQueryService<QuestionKnowladgeViewResponse,QuestionKnowladgeDto,QuestionKnowladgePagedRequest>,IApiService<AddQuestionKnowladgeDto,UpdateQuestionKnowladgeDto,QuestionKnowladge>
     {
     }
 }

+ 1 - 1
src/Hotline.Application/Exam/Interface/Questions/IQuestionOptionsService.cs

@@ -13,7 +13,7 @@ namespace Exam.Application
     /// 试题选项服务接口
     /// </summary>
     [Description("试题选项服务接口")]
-    public interface IQuestionOptionsService:IQueryService<QuestionOptionsViewResponse,QuestionOptionsDto,QuestionOptionsPagedRequest>,IApiService<QuestionOptionsDto,QuestionOptions>
+    public interface IQuestionOptionsService:IQueryService<QuestionOptionsViewResponse,QuestionOptionsDto,QuestionOptionsPagedRequest>,IApiService<AddQuestionOptionsDto,UpdateQuestionOptionsDto,QuestionOptions>
     {
     }
 }

+ 1 - 1
src/Hotline.Application/Exam/Interface/Questions/IQuestionService.cs

@@ -7,7 +7,7 @@ using Hotline.Share.Requests.Question;
 
 namespace Exam.Application.Interface.Questions
 {
-    public interface IQuestionService:IQueryService<QuestionViewResponse,QuestionDto,QuestionPagedRequest>,IApiService<QuestionDto,Question>
+    public interface IQuestionService:IQueryService<QuestionViewResponse,QuestionDto,QuestionPagedRequest>,IApiService<AddQuestionDto, UpdateQuestionDto, Question>
     {
     }
 }

+ 1 - 1
src/Hotline.Application/Exam/Interface/Questions/IQuestionSourcewareService.cs

@@ -13,7 +13,7 @@ namespace Exam.Application
     /// 关联课件服务接口
     /// </summary>
     [Description("关联课件服务接口")]
-    public interface IQuestionSourcewareService:IQueryService<QuestionSourcewareViewResponse,QuestionSourcewareDto,QuestionSourcewarePagedRequest>,IApiService<QuestionSourcewareDto,QuestionSourceware>
+    public interface IQuestionSourcewareService:IQueryService<QuestionSourcewareViewResponse,QuestionSourcewareDto,QuestionSourcewarePagedRequest>,IApiService<AddQuestionSourcewareDto,UpdateQuestionSourcewareDto,QuestionSourceware>
     {
     }
 }

+ 1 - 1
src/Hotline.Application/Exam/Interface/Questions/IQuestionTagService.cs

@@ -13,7 +13,7 @@ namespace Exam.Application
     /// 试题标签服务接口
     /// </summary>
     [Description("试题标签服务接口")]
-    public interface IQuestionTagService:IQueryService<QuestionTagViewResponse,QuestionTagDto,QuestionTagPagedRequest>,IApiService<QuestionTagDto,QuestionTag>
+    public interface IQuestionTagService:IQueryService<QuestionTagViewResponse,QuestionTagDto,QuestionTagPagedRequest>,IApiService<AddQuestionTagDto,UpdateQuestionTagDto,QuestionTag>
     {
     }
 }

+ 1 - 1
src/Hotline.Application/Exam/Interface/Sourcewares/ISourcewareCategoryService.cs

@@ -11,7 +11,7 @@ namespace Exam.Application
     /// 课件类型服务接口
     /// </summary>
     [Description("课件类型服务接口")]
-    public interface ISourcewareCategoryService:IQueryService<SourcewareCategoryViewResponse,SourcewareCategoryDto,SourcewareCategoryRequest>,IApiService<SourcewareCategoryDto,SourcewareCategory>
+    public interface ISourcewareCategoryService:IQueryService<SourcewareCategoryViewResponse,SourcewareCategoryDto,SourcewareCategoryRequest>,IApiService<AddSourcewareCategoryDto,UpdateSourcewareCategoryDto,SourcewareCategory>
     {
         public Task<List<SourcewareCategoryViewResponse>> GetTreeAsync(SourcewareCategoryRequest sourcewareCategoryRequest);
     }

+ 1 - 1
src/Hotline.Application/Exam/Interface/Sourcewares/ISourcewareService.cs

@@ -11,7 +11,7 @@ namespace Exam.Application.Interface.Sourcewares
     /// 课件服务接口
     /// </summary>
     [Description("课件服务接口")]
-    public interface ISourcewareService:IQueryService<SourcewareViewResponse,SourcewareDto,SourcewarePagedRequest>,IApiService<SourcewareDto,Sourceware>
+    public interface ISourcewareService:IQueryService<SourcewareViewResponse,SourcewareDto,SourcewarePagedRequest>,IApiService<AddSourcewareDto, UpdateSourcewareDto, Sourceware>
     {
     }
 }

+ 1 - 1
src/Hotline.Application/Exam/Interface/TestPapers/ITestPaperService.cs

@@ -7,7 +7,7 @@ using Hotline.Share.Requests.Exam;
 
 namespace Exam.Application.Interface.TestPapers
 {
-    public interface ITestPaperService:IQueryService<TestPaperViewResponse,TestPaperDto,TestPaperPagedRequest>,IApiService<TestPaperDto,TestPaper>
+    public interface ITestPaperService:IQueryService<TestPaperViewResponse,TestPaperDto,TestPaperPagedRequest>,IApiService<AddTestPaperDto,UpdateTestPaperDto,TestPaper>
     {
     }
 }

+ 1 - 1
src/Hotline.Application/Exam/Interface/Train/ITrainPlanService.cs

@@ -7,7 +7,7 @@ using Hotline.Share.Requests.Train;
 
 namespace Exam.Application.Interface.Train
 {
-    public interface ITrainPlanService:IQueryService<TrainPlanViewResponse,TrainPlanDto,TrainPlanPagedRequest>,IApiService<TrainPlanDto,TrainPlan>
+    public interface ITrainPlanService:IQueryService<TrainPlanViewResponse,TrainPlanDto,TrainPlanPagedRequest>,IApiService<AddTrainPlanDto,UpdateTrainPlanDto,TrainPlan>
     {
     }
 }

+ 1 - 1
src/Hotline.Application/Exam/Interface/Train/ITrainRecordAnswerService.cs

@@ -5,7 +5,7 @@ using Hotline.Share.Dtos.Trains;
 
 namespace Exam.Application.Interface.Train
 {
-    public interface ITrainRecordAnswerService:IApiService<TrainRecordAnswerDto,TrainRecordAnswer>
+    public interface ITrainRecordAnswerService:IApiService<AddTrainRecordAnswerDto,UpdateTrainRecordAnswerDto,TrainRecordAnswer>
     {
     }
 }

+ 1 - 1
src/Hotline.Application/Exam/Interface/Train/ITrainRecordService.cs

@@ -8,7 +8,7 @@ using Hotline.Share.Requests.Train;
 
 namespace Exam.Application.Interface.Train
 {
-    public interface ITrainRecordService:IQueryService<TrainRecordViewResponse,TrainRecordDto,TrainRecordPagedRequest>,IApiService<TrainRecordDto,TrainRecord>
+    public interface ITrainRecordService:IQueryService<TrainRecordViewResponse,TrainRecordDto,TrainRecordPagedRequest>,IApiService<AddTrainRecordDto,UpdateTrainRecordDto,TrainRecord>
     {
         /// <summary>
         /// 结束培训

+ 1 - 1
src/Hotline.Application/Exam/Interface/Train/ITrainTemplateService.cs

@@ -7,7 +7,7 @@ using Hotline.Share.Requests.Train;
 
 namespace Exam.Application.Interface.Train
 {
-    public interface ITrainTemplateService:IQueryService<TrainTemplateViewResponse,TrainTemplateDto,TrainTemplatePagedRequest>,IApiService<TrainTemplateDto,TrainTemplate>
+    public interface ITrainTemplateService:IQueryService<TrainTemplateViewResponse,TrainTemplateDto,TrainTemplatePagedRequest>,IApiService<AddTrainTemplateDto,UpdateTrainTemplateDto,TrainTemplate>
     {
     }
 }

+ 25 - 0
src/Hotline.Application/Exam/QueryExtensions/ExamManages/ExamManageQueryExtensions.cs

@@ -0,0 +1,25 @@
+using Exam.ExamManages;
+using Exam.Infrastructure.Extensions;
+using Exam.Infrastructure.Web.Utilities;
+using Hotline.Share.Requests.Exam;
+using JiebaNet.Segmenter.Common;
+using System.Linq.Expressions;
+
+namespace Hotline.Application.Exam.QueryExtensions.ExamManages
+{
+    public static class ExamManageQueryExtensions
+    {
+        public static Expression<Func<ExamManage,bool>> GetExpression(this ExamManagePagedRequest examManagePagedRequest)
+        {
+            Expression<Func<ExamManage, bool>> expression = m => m.Id != null;
+
+            expression = ExpressionableUtility.CreateExpression<ExamManage>()
+                         .AndIF(examManagePagedRequest.Code.IsNotNullOrEmpty(), x => x.Code.Contains(examManagePagedRequest.Code))
+                         .AndIF(examManagePagedRequest.Name.IsNotNullOrEmpty(), x => x.Name.Contains(examManagePagedRequest.Name))
+                         .AndIF(examManagePagedRequest.ExamType.IsNotNull(), x => x.ExamType == examManagePagedRequest.ExamType)
+                         .AndIF(examManagePagedRequest.Method.IsNotNull(), x => x.Method == examManagePagedRequest.Method).ToExpression();
+
+            return expression;
+        }
+    }
+}

+ 22 - 12
src/Hotline.Application/Exam/QueryExtensions/Questions/QuestionQueryExtesions.cs

@@ -1,5 +1,6 @@
 using Exam.ExamManages;
 using Exam.Infrastructure.Extensions;
+using Exam.Infrastructure.Web.Utilities;
 using Exam.Questions;
 using Hotline.Share.Requests.Question;
 using JiebaNet.Segmenter.Common;
@@ -10,24 +11,22 @@ namespace Hotline.Application.Exam.QueryExtensions.Questions
 {
     public static class QuestionQueryExtesions
     {
-        public static Expression<Func<Question,bool>> GetExpression(this QuestionPagedRequest questionPagedRequest)
+        public static Expression<Func<Question, bool>> GetExpression(this QuestionPagedRequest questionPagedRequest)
         {
             Expression<Func<Question, bool>> expression = m => m.Id != null;
 
-            Expressionable<Question> expressionable = new Expressionable<Question>();
-            expressionable.AndIF(questionPagedRequest.DifficultyLevel.IsNotNull(), x => questionPagedRequest.DifficultyLevel == x.DifficultyLevel);
-            expressionable.AndIF(questionPagedRequest.Title.IsNotNullOrEmpty(), x => x.Title.Contains(questionPagedRequest.Title));
-            expression = expressionable.ToExpression();
+            expression = ExpressionableUtility.CreateExpression<Question>().AndIF(questionPagedRequest.DifficultyLevel.IsNotNull(), x => questionPagedRequest.DifficultyLevel == x.DifficultyLevel)
+            .AndIF(questionPagedRequest.Title.IsNotNullOrEmpty(), x => x.Title.Contains(questionPagedRequest.Title))
+            .ToExpression();
             return expression;
         }
 
-        public static Expression<Func<QuestionTag,bool>> GetQuestionTagExpression(this QuestionPagedRequest questionPagedRequest)
+        public static Expression<Func<QuestionTag, bool>> GetQuestionTagExpression(this QuestionPagedRequest questionPagedRequest)
         {
             Expression<Func<QuestionTag, bool>> expression = m => m.Id != null;
 
-            Expressionable<QuestionTag> expressionable = new Expressionable<QuestionTag>();
-            expressionable.AndIF(questionPagedRequest.TagId.IsNotNullOrEmpty(), x => questionPagedRequest.TagId == x.TagId);
-            expression = expressionable.ToExpression();
+            expression = ExpressionableUtility.CreateExpression<QuestionTag>().AndIF(questionPagedRequest.TagId.IsNotNullOrEmpty(), x => questionPagedRequest.TagId == x.TagId)
+            .ToExpression();
             return expression;
         }
 
@@ -35,9 +34,20 @@ namespace Hotline.Application.Exam.QueryExtensions.Questions
         {
             Expression<Func<ExamTag, bool>> expression = m => m.Id != null;
 
-            Expressionable<ExamTag> expressionable = new Expressionable<ExamTag>();
-            expressionable.AndIF(questionPagedRequest.TagId.IsNotNullOrEmpty(), x => questionPagedRequest.TagId == x.Id);
-            expression = expressionable.ToExpression();
+            expression = ExpressionableUtility.CreateExpression<ExamTag>().
+            AndIF(questionPagedRequest.TagId.IsNotNullOrEmpty(), x => questionPagedRequest.TagId == x.Id)
+            .ToExpression();
+
+            return expression;
+        }
+
+        public static Expression<Func<QuestionKnowladge, bool>> GetQuestionKnowladgeExpression(this QuestionPagedRequest questionPagedRequest)
+        {
+            Expression<Func<QuestionKnowladge, bool>> expression = m => m.Id != null;
+
+            expression = ExpressionableUtility.CreateExpression<QuestionKnowladge>().
+            AndIF(questionPagedRequest.KnowladgeIds.IsNull(), x => questionPagedRequest.KnowladgeIds.Contains(x.QuestionId))
+            .ToExpression();
 
             return expression;
         }

+ 328 - 0
src/Hotline.Application/Exam/Service/ExamManages/ExamManageService.cs

@@ -0,0 +1,328 @@
+using Exam.ExamManages;
+using Exam.Infrastructure.Data.Entity;
+using Exam.Infrastructure.Enums;
+using Exam.Infrastructure.Extensions;
+using Exam.Infrastructure.Web.Extensions;
+using Exam.Infrastructure.Web.Utilities;
+using Exam.Insfrastructure.Service.Service;
+using Exam.Questions;
+using Exam.Repository.Sqlsugar.Repositories;
+using Exam.Share;
+using Exam.Share.ViewResponses.Exam;
+using Hotline.Application.Exam.Interface.ExamManages;
+using Hotline.Repository.SqlSugar;
+using Hotline.Repository.SqlSugar.DataPermissions;
+using Hotline.Repository.SqlSugar.Exam.Interfaces.ExamManages;
+using Hotline.Repository.SqlSugar.Interface;
+using Hotline.Share.Dtos.Questions;
+using Hotline.Share.Requests.Exam;
+using JiebaNet.Segmenter.Common;
+using MapsterMapper;
+using SqlSugar;
+using XF.Domain.Dependency;
+using XF.Domain.Entities;
+using Hotline.Repository.SqlSugar.Extensions;
+using Hotline.Application.Exam.QueryExtensions.ExamManages;
+
+namespace Hotline.Application.Exam.Service.ExamManages
+{
+    public class ExamManageService : ApiService<ExamManage, AddExamManageDto, UpdateExamManageDto, HotlineDbContext>, IExamManageService,IScopeDependency
+    {
+        private readonly IExamManageRepository _repository;
+        private readonly IExamQuestionScoreRepository _examQuestionScoreRepository;
+        private readonly IUserExamRepository _userExamRepository;
+        private readonly IDataPermissionFilterBuilder _dataPermissionFilterBuilder;
+        private readonly IServiceProvider _serviceProvider;
+        private readonly IMapper _mapper;
+
+        public ExamManageService(IExamManageRepository repository,
+            IExamQuestionScoreRepository examQuestionScoreRepository,
+            IUserExamRepository userExamRepository,
+            IDataPermissionFilterBuilder dataPermissionFilterBuilder, IServiceProvider serviceProvider,
+            IMapper mapper) : base(repository, mapper)
+        {
+            this._repository = repository;
+            this._examQuestionScoreRepository = examQuestionScoreRepository;
+            this._userExamRepository = userExamRepository;
+            _dataPermissionFilterBuilder = dataPermissionFilterBuilder;
+            _serviceProvider = serviceProvider;
+            this._mapper = mapper;
+        }
+
+        #region public method
+        public async Task<ExamManageDto> GetAsync(EntityQueryRequest entityQueryRequest)
+        {
+            var entity = await _repository.GetAsync(entityQueryRequest.Id);
+
+            var questionDto = _mapper.Map<ExamManageDto>(entity);
+
+            if (questionDto != null)
+            {
+                questionDto.ExamQuestionScoreDtos = await GetExamQuestionScores(entityQueryRequest);
+
+                questionDto.UserExamDtos = await GetUserExams(entityQueryRequest);
+            }
+
+            return questionDto;
+        }
+
+        public async Task<(int, List<ExamManageViewResponse>)> GetListAsync(ExamManagePagedRequest queryRequest)
+        {
+            var expression = queryRequest.GetExpression();
+            var questionTable = _repository.Queryable().Where(expression);
+
+            var queryable = questionTable.Select( e => new ExamManageViewResponse
+            {
+                Id =e.Id,
+                Code =e.Code,
+                Count =e.Count,
+                CutoffScore= e.CutoffScore,
+                EndTime = e.EndTime,
+                ExamStatus = e.ExamStatus,
+                ExamType = e.ExamType,
+                Mehtod = e.Method,
+                Mode = e.Mode,
+                Name = e.Name,
+                Remark = e.Name,
+                SortIndex =e.SortIndex,
+                StartTime = e.StartTime,
+                TimeSpan = e.TimeSpan,
+                TotalScore =e.TotalScore,
+            });
+                
+
+            var result = await queryable.ToListAsync();
+
+
+            var total = await queryable.CountAsync();
+
+            return (total, result);
+        }
+
+        public async Task<PageViewResponse<ExamManageViewResponse>> GetPagedListAsync(ExamManagePagedRequest queryRequest)
+        {
+            var expression = queryRequest.GetExpression();
+            var questionTable = _repository.Queryable().Where(expression);
+
+            var queryable = questionTable.Select(e => new ExamManageViewResponse
+            {
+                Id = e.Id,
+                Code = e.Code,
+                Count = e.Count,
+                CutoffScore = e.CutoffScore,
+                EndTime = e.EndTime,
+                ExamStatus = e.ExamStatus,
+                ExamType = e.ExamType,
+                Mehtod = e.Method,
+                Mode = e.Mode,
+                Name = e.Name,
+                Remark = e.Name,
+                SortIndex = e.SortIndex,
+                StartTime = e.StartTime,
+                TimeSpan = e.TimeSpan,
+                TotalScore = e.TotalScore,
+            });
+
+            var list = await queryable.ToPageListAsync(queryRequest.PageIndex, queryRequest.PageSize);
+            var total = await queryable.CountAsync();
+
+            var result = new ExamManagePageViewResponse
+            {
+                Items = list,
+                Pagination = new Pagination(queryRequest.PageIndex, queryRequest.PageSize, total)
+            };
+
+            return result;
+        }
+
+        public override async Task<string> AddAsync(AddExamManageDto actionRequest, CancellationToken cancellationToken)
+        {
+            var id = await base.AddAsync(actionRequest, cancellationToken);
+
+            ResolveQuestionId(actionRequest, id);
+
+            await AddExamQuestionScores(actionRequest, cancellationToken);
+
+            await AddUserExam(actionRequest, cancellationToken);
+
+            return id;
+        }
+
+        public override async Task UpdateAsync(UpdateExamManageDto actionRequest, CancellationToken cancellationToken)
+        {
+            await base.UpdateAsync(actionRequest, cancellationToken);
+
+            ResolveQuestionId(actionRequest, actionRequest.Id);
+
+            await ModifyExamQuestionScores(actionRequest, cancellationToken);
+
+            await ModifyUserExam(actionRequest, cancellationToken);
+        }
+
+        public override async Task DeleteAsync(EntityQueryRequest entityQueryRequest, CancellationToken cancellationToken)
+        {
+            await base.DeleteAsync(entityQueryRequest, cancellationToken);
+
+            var tmpEntityQueryRequest = ExpressionableUtility.CreateExpression<ExamQuestionScore>()
+                .AndIF(entityQueryRequest.Id.IsNotNullOrEmpty(), x => x.ExamManageId == entityQueryRequest.Id)
+                .AndIF(entityQueryRequest.Ids.IsNotNull(), x => entityQueryRequest.Ids.Contains(x.ExamManageId))
+                .ToEntityQueryRequest<ExamQuestionScore>();
+
+            await DeleteExamQuestionScores(tmpEntityQueryRequest, cancellationToken);
+
+            tmpEntityQueryRequest = ExpressionableUtility.CreateExpression<UserExam>()
+                .AndIF(entityQueryRequest.Id.IsNotNullOrEmpty(), x => x.ExamId == entityQueryRequest.Id)
+                .AndIF(entityQueryRequest.Ids.IsNotNull(), x => entityQueryRequest.Ids.Contains(x.ExamId))
+                .ToEntityQueryRequest<UserExam>();
+
+            await DeleteUserExam(tmpEntityQueryRequest, cancellationToken);
+
+        }
+        #endregion
+
+        #region private method
+
+        private void ResolveQuestionId(AddExamManageDto actionRequest, string id)
+        {
+
+            actionRequest.UserExamDtos.ForEach(x => x.ExamId = id);
+
+            actionRequest.ExamQuestionScoreDtos.ForEach(x => x.ExamManageId = id);
+        }
+
+        private async Task AddExamQuestionScores(AddExamManageDto actionRequest, CancellationToken cancellationToken)
+        {
+            if (actionRequest.ExamQuestionScoreDtos == null) return;
+
+            var examQuestionScoreDtos = actionRequest.ExamQuestionScoreDtos.Where(x => x.OperationStatus == EEOperationStatus.Add).ToList();
+
+            var examQuestionScores = _mapper.Map<List<ExamQuestionScore>>(examQuestionScoreDtos);
+
+            examQuestionScores.ToInsert();
+
+            await _examQuestionScoreRepository.AddWithValidateAsync(examQuestionScores, cancellationToken);
+        }
+
+        private async Task AddUserExam(AddExamManageDto actionRequest, CancellationToken cancellationToken)
+        {
+            if (actionRequest.UserExamDtos == null) return;
+
+            var userExamDtos = actionRequest.UserExamDtos.Where(x => x.OperationStatus == EEOperationStatus.Add).ToList();
+
+            var userExams = _mapper.Map<List<UserExam>>(userExamDtos);
+
+            await _userExamRepository.AddWithValidateAsync(userExams, cancellationToken);
+
+        }
+        private async Task UpdateUserExam(UpdateExamManageDto actionRequest, CancellationToken cancellationToken)
+        {
+            if (actionRequest.UserExamDtos == null) return;
+
+            var userExamDtos = actionRequest.UserExamDtos.Where(x => x.OperationStatus == EEOperationStatus.Update).ToList();
+
+            var ids = userExamDtos.Select(x => x.Id);
+
+            var userExams = await _userExamRepository.Queryable().Where(x => ids.Contains(x.Id)).ToListAsync();
+
+            userExams = _mapper.Map<List<UpdateUserExamDto>, List<UserExam>>(userExamDtos, userExams);
+
+            userExams.ToUpdate();
+
+            await _userExamRepository.UpdateWithValidateAsync(userExams, cancellationToken);
+        }
+        private async Task UpdateExamQuestionScores(UpdateExamManageDto actionRequest, CancellationToken cancellationToken)
+        {
+            if (actionRequest.ExamQuestionScoreDtos == null) return;
+
+            var examQuestionScoreDtos = actionRequest.ExamQuestionScoreDtos.Where(x => x.OperationStatus == EEOperationStatus.Update).ToList();
+
+            var ids = examQuestionScoreDtos.Select(x => x.Id);
+
+            var examQuestionScores = await _examQuestionScoreRepository.Queryable().Where(x => ids.Contains(x.Id)).ToListAsync();
+
+            examQuestionScores = _mapper.Map<List<UpdateExamQuestionScoreDto>, List<ExamQuestionScore>>(examQuestionScoreDtos, examQuestionScores);
+
+            examQuestionScores.ToUpdate();
+
+            await _examQuestionScoreRepository.UpdateWithValidateAsync(examQuestionScores, cancellationToken);
+        }
+    
+        private async Task DeleteUserExam(EntityQueryRequest entityQueryRequest, CancellationToken cancellationToken)
+        {
+            await _userExamRepository.DeleteWithValidateAsync(entityQueryRequest, cancellationToken);
+        }
+        private async Task DeleteExamQuestionScores(EntityQueryRequest entityQueryRequest, CancellationToken cancellationToken)
+        {
+            await _examQuestionScoreRepository.DeleteWithValidateAsync(entityQueryRequest, cancellationToken);
+        }
+
+        private async Task ModifyUserExam(UpdateExamManageDto actionRequest, CancellationToken cancellationToken)
+        {
+            await AddUserExam(actionRequest, cancellationToken);
+
+            await UpdateUserExam(actionRequest, cancellationToken);
+
+            var questionOptionsDtos = actionRequest.UserExamDtos.Where(x => x.OperationStatus == EEOperationStatus.Delete);
+            var ids = questionOptionsDtos.Select(m => m.Id);
+            EntityQueryRequest entityQueryRequest = ResovleDelete<UserExam>(ids);
+
+            await DeleteUserExam(entityQueryRequest, cancellationToken);
+
+        }
+
+        private async Task ModifyExamQuestionScores(UpdateExamManageDto actionRequest, CancellationToken cancellationToken)
+        {
+            await AddExamQuestionScores(actionRequest, cancellationToken);
+
+            await UpdateExamQuestionScores(actionRequest, cancellationToken);
+
+            var examQuestionScoreDtos = actionRequest.ExamQuestionScoreDtos.Where(x => x.OperationStatus == EEOperationStatus.Delete);
+            var ids = examQuestionScoreDtos.Select(m => m.Id);
+            EntityQueryRequest entityQueryRequest = ResovleDelete<ExamQuestionScore>(ids);
+
+            await DeleteExamQuestionScores(entityQueryRequest, cancellationToken);
+        }
+
+        private EntityQueryRequest ResovleDelete<T>(IEnumerable<string> ids) where T : class, IEntity<string>, new()
+        {
+            Expressionable<T> expressionable = ExpressionableUtility.CreateExpression<T>();
+            expressionable.AndIF(ids.Any(), x => ids.Contains(x.Id));
+
+            var entityQueryRequest = new EntityQueryRequest
+            {
+                Expression = ids.Any() ? expressionable.ToExpression() : null
+            };
+            return entityQueryRequest;
+        }
+
+        private async Task<List<UserExamDto>> GetUserExams(EntityQueryRequest entityQueryRequest)
+        {
+            var userExams = _userExamRepository.Queryable().Where(x => x.ExamId == entityQueryRequest.Id);
+
+
+            var userExamDtos = userExams.Select(q => new UserExamDto
+            {
+                Id = q.Id,
+                ExamId = q.ExamId,
+            });
+
+            return await userExamDtos.ToListAsync();
+        }
+
+        private async Task<List<ExamQuestionScoreDto>> GetExamQuestionScores(EntityQueryRequest entityQueryRequest)
+        {
+            var examQuestionScores = _examQuestionScoreRepository.Queryable().Where(x => x.ExamManageId == entityQueryRequest.Id);
+
+
+            var examQuestionScoreDtos = examQuestionScores.Select(q => new ExamQuestionScoreDto
+            {
+                Id = q.Id,
+                ExamManageId = q.ExamManageId,
+                Score = q.Score
+            });
+
+            return await examQuestionScoreDtos.ToListAsync();
+        }
+        #endregion
+    }
+}

+ 1 - 1
src/Hotline.Application/Exam/Service/ExamManages/ExamTagService.cs

@@ -26,7 +26,7 @@ namespace Hotline.Application.Exam.Service.ExamManages
     /// 考试标签服务
     /// </summary>
     [Description("考试标签服务")]
-    public class ExamTagService : ApiService<ExamTag, ExamTagDto,HotlineDbContext>,IExamTagService, IScopeDependency
+    public class ExamTagService : ApiService<ExamTag, AddExamTagDto,UpdateExamTagDto,HotlineDbContext>,IExamTagService, IScopeDependency
     {
         private readonly IExamTagRepository _repository;
         private readonly IMapper _mapper;

+ 56 - 47
src/Hotline.Application/Exam/Service/ExamManages/ExtractRuleService.cs

@@ -1,7 +1,7 @@
-using Exam.Application.Interface.Exam;
+using DocumentFormat.OpenXml.Office2010.Excel;
+using Exam.Application.Interface.Exam;
 using Exam.ExamManages;
 using Exam.Infrastructure.Data.Entity;
-using Exam.Infrastructure.Data.Extensions;
 using Exam.Infrastructure.Enums;
 using Exam.Infrastructure.Extensions;
 using Exam.Infrastructure.Web.Extensions;
@@ -27,7 +27,7 @@ using XF.Domain.Dependency;
 
 namespace Hotline.Application.Exam.Service.ExamManages
 {
-    public class ExtractRuleService : ApiService<ExtractRule, ExtractRuleDto, HotlineDbContext>,IExtractRuleService, IScopeDependency
+    public class ExtractRuleService : ApiService<ExtractRule, AddExtractRuleDto, UpdateExtractRuleDto, HotlineDbContext>, IExtractRuleService, IScopeDependency
     {
         private readonly IExtractRuleRepository _repository;
         private readonly ITagQuestionRepository _tagQuestionRepository;
@@ -105,13 +105,17 @@ namespace Hotline.Application.Exam.Service.ExamManages
         /// <param name="actionRequest"></param>
         /// <param name="cancellationToken"></param>
         /// <returns></returns>
-        public override async Task AddAsync(ExtractRuleDto actionRequest, CancellationToken cancellationToken)
+        public override async Task<string> AddAsync(AddExtractRuleDto actionRequest, CancellationToken cancellationToken)
         {
-            await base.AddAsync(actionRequest, cancellationToken);
+            var id = await base.AddAsync(actionRequest, cancellationToken);
 
-            await AddRuleTags(actionRequest,cancellationToken);
+            ResolveExtractRuleId(actionRequest, id);
+
+            await AddRuleTags(actionRequest, cancellationToken);
 
             await AddTagQuestions(actionRequest, cancellationToken);
+
+            return id;
         }
 
         /// <summary>
@@ -120,10 +124,12 @@ namespace Hotline.Application.Exam.Service.ExamManages
         /// <param name="actionRequest"></param>
         /// <param name="cancellationToken"></param>
         /// <returns></returns>
-        public override async Task UpdateAsync(ExtractRuleDto actionRequest, CancellationToken cancellationToken)
+        public override async Task UpdateAsync(UpdateExtractRuleDto actionRequest, CancellationToken cancellationToken)
         {
             await base.UpdateAsync(actionRequest, cancellationToken);
 
+            ResolveExtractRuleId(actionRequest, actionRequest.Id);
+
             await ModifyRuleTags(actionRequest, cancellationToken);
 
             await ModifyTagQuestions(actionRequest, cancellationToken);
@@ -167,16 +173,16 @@ namespace Hotline.Application.Exam.Service.ExamManages
             var questionTable = new ExamRepository<Question>(_repository.UOW, _dataPermissionFilterBuilder, _serviceProvider).Queryable();
 
             var queryable = questionTagTable.LeftJoin(questionTable, (t, q) => t.QuestionId == q.Id)
-                .GroupBy((t,q)=> new { t.TagId, q.QuestionType }).Select((t, q) => new TagQuestionViewResponse
-            {
-                TagId = t.TagId,
-                QuestionType = q.QuestionType,
-                TotalCount = SqlFunc.AggregateCount(new
+                .GroupBy((t, q) => new { t.TagId, q.QuestionType }).Select((t, q) => new TagQuestionViewResponse
                 {
                     TagId = t.TagId,
                     QuestionType = q.QuestionType,
-                })
-            });
+                    TotalCount = SqlFunc.AggregateCount(new
+                    {
+                        TagId = t.TagId,
+                        QuestionType = q.QuestionType,
+                    })
+                });
 
             return await queryable.ToListAsync();
         }
@@ -210,19 +216,15 @@ namespace Hotline.Application.Exam.Service.ExamManages
         /// <param name="actionRequest"></param>
         /// <param name="cancellationToken"></param>
         /// <returns></returns>
-        private async Task AddTagQuestions(ExtractRuleDto actionRequest, CancellationToken cancellationToken)
+        private async Task AddTagQuestions(AddExtractRuleDto actionRequest, CancellationToken cancellationToken)
         {
             if (actionRequest.TagQuestionDtos == null) return;
 
-            var tagQuestionDtos = actionRequest.TagQuestionDtos.Where(x => x.OperationStatus == OperationStatus.Add).ToList();
+            var tagQuestionDtos = actionRequest.TagQuestionDtos.Where(x => x.OperationStatus == EEOperationStatus.Add).ToList();
 
             var tagQuestions = _mapper.Map<List<TagQuestion>>(tagQuestionDtos);
 
-            tagQuestionDtos.InitRequest(actionRequest);
-
-            tagQuestions.ForEach(x => x.RuleId = actionRequest.Id);
-
-            tagQuestions.ToInsert(tagQuestionDtos);
+            tagQuestions.ToInsert();
 
             await _tagQuestionRepository.AddWithValidateAsync(tagQuestions, cancellationToken);
         }
@@ -233,19 +235,15 @@ namespace Hotline.Application.Exam.Service.ExamManages
         /// <param name="actionRequest"></param>
         /// <param name="cancellationToken"></param>
         /// <returns></returns>
-        private async Task AddRuleTags(ExtractRuleDto actionRequest, CancellationToken cancellationToken)
+        private async Task AddRuleTags(AddExtractRuleDto actionRequest, CancellationToken cancellationToken)
         {
             if (actionRequest.RuleTagDtos == null) return;
 
-            var ruleTagDtos = actionRequest.RuleTagDtos.Where(x => x.OperationStatus == OperationStatus.Add).ToList();
+            var ruleTagDtos = actionRequest.RuleTagDtos.Where(x => x.OperationStatus == EEOperationStatus.Add).ToList();
 
             var ruleTags = _mapper.Map<List<RuleTag>>(ruleTagDtos);
 
-            ruleTagDtos.InitRequest(actionRequest);
-
-            ruleTags.ForEach(x => x.RuleId = actionRequest.Id);
-
-            ruleTags.ToInsert(ruleTagDtos);
+            ruleTags.ToInsert();
 
             await _ruleTagRepository.AddWithValidateAsync(ruleTags, cancellationToken);
 
@@ -258,15 +256,15 @@ namespace Hotline.Application.Exam.Service.ExamManages
         /// <param name="cancellationToken"></param>
         /// <returns></returns>
         /// <exception cref="NotImplementedException"></exception>
-        private async Task ModifyTagQuestions(ExtractRuleDto actionRequest, CancellationToken cancellationToken)
+        private async Task ModifyTagQuestions(UpdateExtractRuleDto actionRequest, CancellationToken cancellationToken)
         {
             if (actionRequest.TagQuestionDtos == null) return;
 
             await AddTagQuestions(actionRequest, cancellationToken);
 
-            await UpdateTagQuestions(actionRequest ,cancellationToken);
+            await UpdateTagQuestions(actionRequest, cancellationToken);
 
-            var ruleTagDtos = actionRequest.TagQuestionDtos.Where(x => x.OperationStatus == OperationStatus.Delete).ToList();
+            var ruleTagDtos = actionRequest.TagQuestionDtos.Where(x => x.OperationStatus == EEOperationStatus.Delete).ToList();
             var ids = ruleTagDtos.Select(x => x.Id).ToList();
             var entityQueyRequest = ExpressionableUtility.CreateExpression<TagQuestion>()
                 .AndIF(ids.IsNotNull(), x => ids.Contains(x.Id)).ToEntityQueryRequest<TagQuestion>();
@@ -281,11 +279,11 @@ namespace Hotline.Application.Exam.Service.ExamManages
         /// <param name="cancellationToken"></param>
         /// <returns></returns>
         /// <exception cref="NotImplementedException"></exception>
-        private async Task UpdateTagQuestions(ExtractRuleDto actionRequest, CancellationToken cancellationToken)
+        private async Task UpdateTagQuestions(UpdateExtractRuleDto actionRequest, CancellationToken cancellationToken)
         {
             if (actionRequest.TagQuestionDtos == null) return;
 
-            var tagQuestionDtos = actionRequest.TagQuestionDtos.Where(x => x.OperationStatus == OperationStatus.Update).ToList();
+            var tagQuestionDtos = actionRequest.TagQuestionDtos.Where(x => x.OperationStatus == EEOperationStatus.Update).ToList();
             var ids = tagQuestionDtos.Select(x => x.Id).ToList();
             var tagQuestions = await _tagQuestionRepository.Queryable().Where(x => ids.Contains(x.Id)).ToListAsync();
 
@@ -297,9 +295,8 @@ namespace Hotline.Application.Exam.Service.ExamManages
                 entity.RuleId = actionRequest.Id;
                 entitys.Add(entity);
             });
-            tagQuestionDtos.InitRequest(actionRequest);
 
-            entitys.ToUpdate(tagQuestionDtos);
+            entitys.ToUpdate();
 
             await _tagQuestionRepository.UpdateWithValidateAsync(entitys, cancellationToken);
         }
@@ -311,7 +308,7 @@ namespace Hotline.Application.Exam.Service.ExamManages
         /// <param name="cancellationToken"></param>
         /// <returns></returns>
         /// <exception cref="NotImplementedException"></exception>
-        private async Task ModifyRuleTags(ExtractRuleDto actionRequest, CancellationToken cancellationToken)
+        private async Task ModifyRuleTags(UpdateExtractRuleDto actionRequest, CancellationToken cancellationToken)
         {
             if (actionRequest.RuleTagDtos == null) return;
 
@@ -319,7 +316,7 @@ namespace Hotline.Application.Exam.Service.ExamManages
 
             await UpdateRuleTags(actionRequest, cancellationToken);
 
-            var ruleTagDtos = actionRequest.RuleTagDtos.Where(x => x.OperationStatus == OperationStatus.Delete).ToList();
+            var ruleTagDtos = actionRequest.RuleTagDtos.Where(x => x.OperationStatus == EEOperationStatus.Delete).ToList();
             var ids = ruleTagDtos.Select(x => x.Id).ToList();
             var entityQueyRequest = ExpressionableUtility.CreateExpression<RuleTag>()
                 .AndIF(ids.IsNotNull(), x => ids.Contains(x.Id)).ToEntityQueryRequest<RuleTag>();
@@ -327,27 +324,26 @@ namespace Hotline.Application.Exam.Service.ExamManages
             await DeleteRuleTags(entityQueyRequest, cancellationToken);
         }
 
-        private async Task UpdateRuleTags(ExtractRuleDto actionRequest, CancellationToken cancellationToken)
+        private async Task UpdateRuleTags(UpdateExtractRuleDto actionRequest, CancellationToken cancellationToken)
         {
             if (actionRequest.RuleTagDtos == null) return;
 
-            var ruleTagDtos = actionRequest.RuleTagDtos.Where(x => x.OperationStatus == OperationStatus.Update).ToList();
+            var ruleTagDtos = actionRequest.RuleTagDtos.Where(x => x.OperationStatus == EEOperationStatus.Update).ToList();
             var ids = ruleTagDtos.Select(x => x.Id).ToList();
-            var ruleTags = await _ruleTagRepository.Queryable().Where(x=>ids.Contains(x.Id)).ToListAsync();
+            var ruleTags = await _ruleTagRepository.Queryable().Where(x => ids.Contains(x.Id)).ToListAsync();
 
             var entitys = new List<RuleTag>();
             ruleTagDtos.ForEach(x =>
             {
-                var entity = ruleTags.FirstOrDefault(x=>x.Id == x.Id);
+                var entity = ruleTags.FirstOrDefault(x => x.Id == x.Id);
                 entity = _mapper.Map(x, entity);
                 entity.RuleId = actionRequest.Id;
                 entitys.Add(entity);
             });
-            ruleTagDtos.InitRequest(actionRequest);
 
-            entitys.ToUpdate(ruleTagDtos);
+            entitys.ToUpdate();
 
-            await _ruleTagRepository.UpdateWithValidateAsync(entitys,cancellationToken);
+            await _ruleTagRepository.UpdateWithValidateAsync(entitys, cancellationToken);
 
         }
 
@@ -382,7 +378,7 @@ namespace Hotline.Application.Exam.Service.ExamManages
         /// <exception cref="NotImplementedException"></exception>
         private async Task<List<RuleTagDto>> GetRuleTagDtos(EntityQueryRequest entityQueryRequest)
         {
-            var ruleTagTable = _ruleTagRepository.Queryable().Where(x=>x.RuleId == entityQueryRequest.Id);
+            var ruleTagTable = _ruleTagRepository.Queryable().Where(x => x.RuleId == entityQueryRequest.Id);
 
             var examTagTable = new ExamRepository<ExamTag>(_repository.UOW, _dataPermissionFilterBuilder, _serviceProvider).Queryable();
 
@@ -411,10 +407,10 @@ namespace Hotline.Application.Exam.Service.ExamManages
             var examTagTable = new ExamRepository<ExamTag>(_repository.UOW, _dataPermissionFilterBuilder, _serviceProvider).Queryable();
 
 
-            var tagQuestionDtos = tagQuestionTable.LeftJoin(examTagTable, (t, e) => t.TagId == e.Id).Select((t,e)=>new TagQuestionDto
+            var tagQuestionDtos = tagQuestionTable.LeftJoin(examTagTable, (t, e) => t.TagId == e.Id).Select((t, e) => new TagQuestionDto
             {
                 Id = t.Id,
-                TagId =t.TagId,
+                TagId = t.TagId,
                 QuestionType = t.QuestionType,
                 Count = t.Count,
                 Tag = e.Name
@@ -422,6 +418,19 @@ namespace Hotline.Application.Exam.Service.ExamManages
 
             return await tagQuestionDtos.ToListAsync();
         }
+
+        /// <summary>
+        /// 处理抽题规则Id
+        /// </summary>
+        /// <param name="actionRequest"></param>
+        /// <param name="id"></param>
+        /// <exception cref="NotImplementedException"></exception>
+        private void ResolveExtractRuleId(AddExtractRuleDto actionRequest, string id)
+        {
+            actionRequest.TagQuestionDtos.ForEach(x => x.RuleId = id);
+
+            actionRequest.RuleTagDtos.ForEach(x => x.RuleId = id);
+        }
         #endregion
     }
 }

+ 10 - 0
src/Hotline.Application/Exam/Service/ExamManages/UserExamService.cs

@@ -0,0 +1,10 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Hotline.Application.Exam.Service.ExamManages
+{
+   
+}

+ 79 - 98
src/Hotline.Application/Exam/Service/Questions/QuestionService.cs

@@ -1,11 +1,14 @@
-using Exam.Application;
+using DocumentFormat.OpenXml.Office2010.Excel;
+using Exam.Application;
 using Exam.Application.Interface.Questions;
 using Exam.ExamManages;
 using Exam.Infrastructure.Data.Entity;
 using Exam.Infrastructure.Enums;
+using Exam.Infrastructure.Extensions;
+using Exam.Infrastructure.Web.Extensions;
+using Exam.Infrastructure.Web.Utilities;
 using Exam.Insfrastructure.Service.Service;
 using Exam.Questions;
-using Exam.Repository.Sqlsugar;
 using Exam.Repository.Sqlsugar.Repositories;
 using Exam.Share.ViewResponses.Question;
 using Hotline.Application.Exam.QueryExtensions.Questions;
@@ -16,23 +19,15 @@ using Hotline.Repository.SqlSugar.Exam.Interfaces.Questions;
 using Hotline.Repository.SqlSugar.Extensions;
 using Hotline.Share.Dtos.Questions;
 using Hotline.Share.Requests.Question;
-using Mapster;
+using JiebaNet.Segmenter.Common;
+using MapsterMapper;
 using SqlSugar;
 using XF.Domain.Dependency;
-using Exam.Infrastructure.Data.Extensions;
-using Exam.Infrastructure.Data.Interface;
-using Hotline.Import;
-using Exam.Infrastructure.Web.Utilities;
-using XF.Domain.Repository;
-using MapsterMapper;
 using XF.Domain.Entities;
-using Exam.Infrastructure.Extensions;
-using Exam.Infrastructure.Web.Extensions;
-using JiebaNet.Segmenter.Common;
 
 namespace Hotline.Application.Exam.Service.Questions
 {
-    public class QuestionService : ApiService<Question, QuestionDto, HotlineDbContext>, IQuestionService, IScopeDependency
+    public class QuestionService : ApiService<Question, AddQuestionDto,UpdateQuestionDto, HotlineDbContext>, IQuestionService, IScopeDependency
     {
         #region ctor
         private readonly IQuestionRepository _repository;
@@ -95,21 +90,15 @@ namespace Hotline.Application.Exam.Service.Questions
             var expression = queryRequest.GetExpression();
             var questionTable = _repository.Queryable().Where(expression);
 
-            var questionTagExpression = queryRequest.GetQuestionTagExpression();
-            var questionTagTable = _questionTagRepository.Queryable().Where(questionTagExpression);
-
-            var examTagExpression = queryRequest.GetExamTagExpression();
-            var examTagTable = new ExamRepository<ExamTag>(_repository.UOW, _dataPermissionFilterBuilder, _serviceProvider).Queryable().Where(examTagExpression);
-
+            var questionKnowladgeExpression = queryRequest.GetQuestionKnowladgeExpression();
+            var questionKnowladgeTable = new ExamRepository<QuestionKnowladge>(_repository.UOW, _dataPermissionFilterBuilder, _serviceProvider).Queryable().Where(questionKnowladgeExpression);
 
-            var queryable = questionTable.InnerJoin(questionTagTable, (s, d) => s.Id == d.QuestionId).InnerJoin(examTagTable, (f, s, t) => s.TagId == t.Id).Select((s, d, f) => new QuestionViewResponse
+            var queryable = questionTable.InnerJoin(questionKnowladgeTable, (q, k) => q.Id == k.QuestionId).Select((q, k) => new QuestionViewResponse
             {
-                DifficultyLevel = s.DifficultyLevel,
-                FormalEnable = s.FormalEnable,
-                SimulateEnable = s.SimulateEnable,
-                SortIndex = s.SortIndex,
-                Status = s.Status,
-                Tag = f.Name
+                DifficultyLevel = q.DifficultyLevel,
+                Title = q.Title,
+                QuestionType = q.QuestionType,
+                Id= q.Id
             });
 
             var result = await queryable.ToListAsync();
@@ -155,9 +144,11 @@ namespace Hotline.Application.Exam.Service.Questions
             return result;
         }
 
-        public override async Task AddAsync(QuestionDto actionRequest, CancellationToken cancellationToken)
+        public override async Task<string> AddAsync(AddQuestionDto actionRequest, CancellationToken cancellationToken)
         {
-            await base.AddAsync(actionRequest, cancellationToken);
+            var id = await base.AddAsync(actionRequest, cancellationToken);
+
+            ResolveQuestionId(actionRequest,id);
 
             await AddQuestionTags(actionRequest, cancellationToken);
 
@@ -168,12 +159,16 @@ namespace Hotline.Application.Exam.Service.Questions
             await AddKnowladges(actionRequest, cancellationToken);
 
             await AddSourcewares(actionRequest, cancellationToken);
+
+            return id;
         }
 
-        public override async Task UpdateAsync(QuestionDto actionRequest, CancellationToken cancellationToken)
+        public override async Task UpdateAsync(UpdateQuestionDto actionRequest, CancellationToken cancellationToken)
         {
             await base.UpdateAsync(actionRequest, cancellationToken);
 
+            ResolveQuestionId(actionRequest, actionRequest.Id);
+
             await ModifyQuestionTags(actionRequest, cancellationToken);
 
             await ModifyQuestionOptions(actionRequest, cancellationToken);
@@ -227,24 +222,32 @@ namespace Hotline.Application.Exam.Service.Questions
         #endregion
 
         #region private method
-        private async Task AddQuestionTags(QuestionDto actionRequest, CancellationToken cancellationToken)
+
+        private void ResolveQuestionId(AddQuestionDto actionRequest,string id)
         {
-            if (actionRequest.QuestionTagDtos == null) return;
+            actionRequest.QuestionKnowladgeDtos.ForEach(x => x.QuestionId = id);
 
-            var questionTagDtos = actionRequest.QuestionTagDtos.Where(x => x.OperationStatus == OperationStatus.Add).ToList();
+            actionRequest.QuestionOptionsDtos.ForEach(x => x.QuestionId = id);
 
-            var questionTags = _mapper.Map<List<QuestionTag>>(questionTagDtos);
+            actionRequest.QuestionSourcewareDtos.ForEach(x => x.QuestionId = id);
 
-            questionTagDtos.InitRequest<QuestionTagDto, QuestionDto>(actionRequest);
+            actionRequest.QuestionTagDtos.ForEach(x => x.QuestionId = id);
+        }
 
-            questionTags.ForEach(x => x.QuestionId = actionRequest.Id);
+        private async Task AddQuestionTags(AddQuestionDto actionRequest, CancellationToken cancellationToken)
+        {
+            if (actionRequest.QuestionTagDtos == null) return;
 
-            questionTags.ToInsert(questionTagDtos);
+            var questionTagDtos = actionRequest.QuestionTagDtos.Where(x => x.OperationStatus == EEOperationStatus.Add).ToList();
+
+            var questionTags = _mapper.Map<List<QuestionTag>>(questionTagDtos);
+
+            questionTags.ToInsert();
 
             await _questionTagRepository.AddWithValidateAsync(questionTags, cancellationToken);
         }
 
-        private async Task AddQuestionOptions(QuestionDto actionRequest, CancellationToken cancellationToken)
+        private async Task AddQuestionOptions(AddQuestionDto actionRequest, CancellationToken cancellationToken)
         {
             if (actionRequest.QuestionOptionsDtos == null) return;
 
@@ -252,19 +255,15 @@ namespace Hotline.Application.Exam.Service.Questions
             if (actionRequest.QuestionType == Share.Enums.Exams.EQuestionType.Essay || actionRequest.QuestionType == Share.Enums.Exams.EQuestionType.Blank)
                 return;
 
-            var questionOptionseDtos = actionRequest.QuestionOptionsDtos.Where(x => x.OperationStatus == OperationStatus.Add).ToList();
+            var questionOptionseDtos = actionRequest.QuestionOptionsDtos.Where(x => x.OperationStatus == EEOperationStatus.Add).ToList();
 
             var questionOptionses = _mapper.Map<List<QuestionOptions>>(questionOptionseDtos);
 
-            questionOptionseDtos.InitRequest<QuestionOptionsDto,QuestionDto>(actionRequest);
-
-            questionOptionses.ForEach(x => x.QuestionId = actionRequest.Id);
-
-            questionOptionses.ToInsert(questionOptionseDtos);
+            questionOptionses.ToInsert();
 
             await _questionOptionRepository.AddWithValidateAsync(questionOptionses, cancellationToken);
         }
-        private async Task AddQuestionAnswer(QuestionDto actionRequest, CancellationToken cancellationToken)
+        private async Task AddQuestionAnswer(AddQuestionDto actionRequest, CancellationToken cancellationToken)
         {
             if (actionRequest.QuestionAnswerDto == null) return;
 
@@ -272,85 +271,74 @@ namespace Hotline.Application.Exam.Service.Questions
             if (actionRequest.QuestionType == Share.Enums.Exams.EQuestionType.Multi
                 || actionRequest.QuestionType == Share.Enums.Exams.EQuestionType.Single
                 || actionRequest.QuestionType == Share.Enums.Exams.EQuestionType.Judge) return;
-            actionRequest.QuestionAnswerDto.InitRequest<QuestionAnswerDto, QuestionDto>(actionRequest);
             var questionAnswer = _mapper.Map<QuestionAnswer>(actionRequest.QuestionAnswerDto);
-            questionAnswer.QuestionId = actionRequest.Id;
 
-            questionAnswer.ToInsert(actionRequest);
+            questionAnswer.ToInsert();
 
             await _questionAnswerRepository.AddWithValidateAsync(questionAnswer, cancellationToken);
 
         }
-        private async Task AddSourcewares(QuestionDto actionRequest, CancellationToken cancellationToken)
+        private async Task AddSourcewares(AddQuestionDto actionRequest, CancellationToken cancellationToken)
         {
             if (actionRequest.QuestionSourcewareDtos == null) return;
 
-            var questionSourcewareDtos = actionRequest.QuestionSourcewareDtos.Where(x => x.OperationStatus == OperationStatus.Add).ToList();
+            var questionSourcewareDtos = actionRequest.QuestionSourcewareDtos.Where(x => x.OperationStatus == EEOperationStatus.Add).ToList();
 
             var questionSourcewares = _mapper.Map<List<QuestionSourceware>>(questionSourcewareDtos);
-
-            questionSourcewareDtos.InitRequest<QuestionSourcewareDto, QuestionDto>(actionRequest);
-
-            questionSourcewares.ForEach(x => x.QuestionId = actionRequest.Id);
-            
-            questionSourcewares.ToInsert(questionSourcewareDtos);
+                        
+            questionSourcewares.ToInsert();
 
             await _questionSourcewareRepository.AddWithValidateAsync(questionSourcewares, cancellationToken);
         }
-        private async Task AddKnowladges(QuestionDto actionRequest, CancellationToken cancellationToken)
+        private async Task AddKnowladges(AddQuestionDto actionRequest, CancellationToken cancellationToken)
         {
             if (actionRequest.QuestionKnowladgeDtos == null) return;
 
-            var questionKnoladgeDtos = actionRequest.QuestionKnowladgeDtos.Where(x => x.OperationStatus == OperationStatus.Add).ToList();
+            var questionKnoladgeDtos = actionRequest.QuestionKnowladgeDtos.Where(x => x.OperationStatus == EEOperationStatus.Add).ToList();
 
             var questionKnowladges = _mapper.Map<List<QuestionKnowladge>>(questionKnoladgeDtos);
 
-            questionKnoladgeDtos.InitRequest<QuestionKnowladgeDto, QuestionDto>(actionRequest);
-
-            questionKnowladges.ForEach(x => x.QuestionId = actionRequest.Id);
-
-            questionKnowladges.ToInsert(questionKnoladgeDtos);
+            questionKnowladges.ToInsert();
 
             await _questionKnowladgeRepository.AddWithValidateAsync(questionKnowladges, cancellationToken);
         }
-        private async Task UpdateSourcewares(QuestionDto actionRequest, CancellationToken cancellationToken)
+        private async Task UpdateSourcewares(UpdateQuestionDto actionRequest, CancellationToken cancellationToken)
         {
             if (actionRequest.QuestionSourcewareDtos == null) return;
 
-            var questionSourcewareDtos = actionRequest.QuestionSourcewareDtos.Where(x => x.OperationStatus == OperationStatus.Update).ToList();
+            var questionSourcewareDtos = actionRequest.QuestionSourcewareDtos.Where(x => x.OperationStatus == EEOperationStatus.Update).ToList();
 
             var ids = questionSourcewareDtos.Select(x => x.Id);
 
             var questionSourcewares = await _questionSourcewareRepository.Queryable().Where(x => ids.Contains(x.Id)).ToListAsync();
 
-            questionSourcewares = _mapper.Map<List<QuestionSourcewareDto>,List<QuestionSourceware>>(questionSourcewareDtos,questionSourcewares);
-
+            questionSourcewares = _mapper.Map<List<UpdateQuestionSourcewareDto>,List<QuestionSourceware>>(questionSourcewareDtos,questionSourcewares);
 
             questionSourcewares.ForEach(x => x.QuestionId = actionRequest.Id);
 
-            questionSourcewares.ToUpdate(questionSourcewareDtos);
+            questionSourcewares.ToUpdate();
 
             await _questionSourcewareRepository.UpdateWithValidateAsync(questionSourcewares, cancellationToken);
         }
-        private async Task UpdateKnowladges(QuestionDto actionRequest, CancellationToken cancellationToken)
+        private async Task UpdateKnowladges(UpdateQuestionDto actionRequest, CancellationToken cancellationToken)
         {
             if (actionRequest.QuestionKnowladgeDtos == null) return;
 
-            var questionKnowladgeDtos = actionRequest.QuestionKnowladgeDtos.Where(x => x.OperationStatus == OperationStatus.Add).ToList();
+            var questionKnowladgeDtos = actionRequest.QuestionKnowladgeDtos.Where(x => x.OperationStatus == EEOperationStatus.Add).ToList();
 
             var ids = questionKnowladgeDtos.Select(x => x.Id);
 
             var questionKnowladges = await _questionKnowladgeRepository.Queryable().Where(x => ids.Contains(x.Id)).ToListAsync();
 
-            questionKnowladges = _mapper.Map<List<QuestionKnowladgeDto>, List<QuestionKnowladge>>(questionKnowladgeDtos,questionKnowladges);
+            questionKnowladges = _mapper.Map<List<UpdateQuestionKnowladgeDto>, List<QuestionKnowladge>>(questionKnowladgeDtos,questionKnowladges);
 
             questionKnowladges.ForEach(x => x.QuestionId = actionRequest.Id);
 
-            questionKnowladges.ToUpdate(questionKnowladgeDtos);
+            questionKnowladges.ToUpdate();
 
             await _questionKnowladgeRepository.UpdateWithValidateAsync(questionKnowladges, cancellationToken);
         }
-        private async Task UpdateQuestionAnswer(QuestionDto actionRequest, CancellationToken cancellationToken)
+        private async Task UpdateQuestionAnswer(UpdateQuestionDto actionRequest, CancellationToken cancellationToken)
         {
             if (actionRequest.QuestionAnswerDto == null) return;
 
@@ -359,17 +347,15 @@ namespace Hotline.Application.Exam.Service.Questions
                 || actionRequest.QuestionType == Share.Enums.Exams.EQuestionType.Single
                 || actionRequest.QuestionType == Share.Enums.Exams.EQuestionType.Judge) return;
 
-            actionRequest.QuestionAnswerDto.InitRequest<QuestionAnswerDto, QuestionDto>(actionRequest);
-
             var questionAnswer = _mapper.Map<QuestionAnswer>(actionRequest.QuestionAnswerDto);
 
             questionAnswer.QuestionId = actionRequest.Id;            
 
-            questionAnswer.ToUpdate(actionRequest);
+            questionAnswer.ToUpdate();
 
             await _questionAnswerRepository.UpdateWithValidateAsync(questionAnswer, cancellationToken);
         }
-        private async Task UpdateQuestionOptions(QuestionDto actionRequest, CancellationToken cancellationToken)
+        private async Task UpdateQuestionOptions(UpdateQuestionDto actionRequest, CancellationToken cancellationToken)
         {
             if (actionRequest.QuestionOptionsDtos == null) return;
 
@@ -377,7 +363,7 @@ namespace Hotline.Application.Exam.Service.Questions
             if (actionRequest.QuestionType == Share.Enums.Exams.EQuestionType.Essay || actionRequest.QuestionType == Share.Enums.Exams.EQuestionType.Blank)
                 return;
 
-            var questionOptionsDtos = actionRequest.QuestionOptionsDtos.Where(x => x.OperationStatus == OperationStatus.Update).ToList();
+            var questionOptionsDtos = actionRequest.QuestionOptionsDtos.Where(x => x.OperationStatus == EEOperationStatus.Update).ToList();
 
             var ids = questionOptionsDtos.Select(x => x.Id);
 
@@ -387,36 +373,31 @@ namespace Hotline.Application.Exam.Service.Questions
             foreach(var questionOptionsDto in questionOptionsDtos)
             {
                 var entity = questionOptionses.FirstOrDefault(x => x.Id == questionOptionsDto.Id);
-                entitys.Add(_mapper.Map<QuestionOptionsDto, QuestionOptions>(questionOptionsDto, entity));
+                entitys.Add(_mapper.Map<UpdateQuestionOptionsDto, QuestionOptions>(questionOptionsDto, entity));
             }
 
             //questionOptionses =  _mapper.Map<List<QuestionOptionsDto>, List<QuestionOptions>>(questionOptionsDtos,questionOptionses);
 
             entitys.ForEach(x => x.QuestionId = actionRequest.Id);
 
-            questionOptionsDtos.InitRequest(actionRequest);
-
-            entitys.ToUpdate(questionOptionsDtos);
+            entitys.ToUpdate();
 
             await _questionOptionRepository.UpdateWithValidateAsync(entitys, cancellationToken);
         }
 
-        private async Task UpdateQuestionTags(QuestionDto actionRequest, CancellationToken cancellationToken)
+        private async Task UpdateQuestionTags(UpdateQuestionDto actionRequest, CancellationToken cancellationToken)
         {
             if (actionRequest.QuestionTagDtos == null) return;
 
-            var questionTagDtos = actionRequest.QuestionTagDtos.Where(x => x.OperationStatus == OperationStatus.Update).ToList();
+            var questionTagDtos = actionRequest.QuestionTagDtos.Where(x => x.OperationStatus == EEOperationStatus.Update).ToList();
 
             var ids = questionTagDtos.Select(x => x.Id);
 
             var questionTags = await _questionTagRepository.Queryable().Where(x => ids.Contains(x.Id)).ToListAsync();
 
-            questionTags = _mapper.Map<List<QuestionTagDto>, List<QuestionTag>>(questionTagDtos,questionTags);
-
-
-            questionTags.ForEach(x => x.QuestionId = actionRequest.Id);
+            questionTags = _mapper.Map<List<UpdateQuestionTagDto>, List<QuestionTag>>(questionTagDtos,questionTags);
 
-            questionTags.ToUpdate(questionTagDtos);
+            questionTags.ToUpdate();
 
             await _questionTagRepository.UpdateWithValidateAsync(questionTags, cancellationToken);
         }
@@ -440,39 +421,39 @@ namespace Hotline.Application.Exam.Service.Questions
         {
             await _questionTagRepository.DeleteWithValidateAsync(entityQueryRequest, cancellationToken);
         }
-        private async Task ModifySourcewares(QuestionDto actionRequest, CancellationToken cancellationToken)
+        private async Task ModifySourcewares(UpdateQuestionDto actionRequest, CancellationToken cancellationToken)
         {
             await AddSourcewares(actionRequest, cancellationToken);
 
             await UpdateSourcewares(actionRequest, cancellationToken);
 
-            var questionSourcewareDtos = actionRequest.QuestionSourcewareDtos.Where(x => x.OperationStatus == OperationStatus.Delete);
+            var questionSourcewareDtos = actionRequest.QuestionSourcewareDtos.Where(x => x.OperationStatus == EEOperationStatus.Delete);
             var ids = questionSourcewareDtos.Select(m => m.Id);
             EntityQueryRequest entityQueryRequest = ResovleDelete<QuestionSourceware>(ids);
 
             await DeleteSourcewares(entityQueryRequest, cancellationToken);
         }
 
-        private async Task ModifyKnowladges(QuestionDto actionRequest, CancellationToken cancellationToken)
+        private async Task ModifyKnowladges(UpdateQuestionDto actionRequest, CancellationToken cancellationToken)
         {
             await AddKnowladges(actionRequest, cancellationToken);
 
             await UpdateKnowladges(actionRequest, cancellationToken);
 
-            var questionKnowladgeDtos = actionRequest.QuestionKnowladgeDtos.Where(x => x.OperationStatus == OperationStatus.Delete);
+            var questionKnowladgeDtos = actionRequest.QuestionKnowladgeDtos.Where(x => x.OperationStatus == EEOperationStatus.Delete);
             var ids = questionKnowladgeDtos.Select(m => m.Id);
             EntityQueryRequest entityQueryRequest = ResovleDelete<QuestionKnowladge>(ids);
 
             await DeleteKnowladges(entityQueryRequest, cancellationToken);
         }
 
-        private async Task ModifyQuestionAnswer(QuestionDto actionRequest, CancellationToken cancellationToken)
+        private async Task ModifyQuestionAnswer(UpdateQuestionDto actionRequest, CancellationToken cancellationToken)
         {
             await AddQuestionAnswer(actionRequest, cancellationToken);
 
             await UpdateQuestionAnswer(actionRequest, cancellationToken);
 
-            if (actionRequest.QuestionAnswerDto != null && actionRequest.QuestionAnswerDto.OperationStatus == OperationStatus.Delete)
+            if (actionRequest.QuestionAnswerDto != null && actionRequest.QuestionAnswerDto.OperationStatus == EEOperationStatus.Delete)
             {
                 var entityQueryRequest = new EntityQueryRequest
                 {
@@ -484,26 +465,26 @@ namespace Hotline.Application.Exam.Service.Questions
 
         }
 
-        private async Task ModifyQuestionOptions(QuestionDto actionRequest, CancellationToken cancellationToken)
+        private async Task ModifyQuestionOptions(UpdateQuestionDto actionRequest, CancellationToken cancellationToken)
         {
             await AddQuestionOptions(actionRequest, cancellationToken);
 
             await UpdateQuestionOptions(actionRequest, cancellationToken);
 
-            var questionOptionsDtos = actionRequest.QuestionOptionsDtos.Where(x => x.OperationStatus == OperationStatus.Delete);
+            var questionOptionsDtos = actionRequest.QuestionOptionsDtos.Where(x => x.OperationStatus == EEOperationStatus.Delete);
             var ids = questionOptionsDtos.Select(m => m.Id);
             EntityQueryRequest entityQueryRequest = ResovleDelete<QuestionOptions>(ids);
 
             await DeleteQuestionOptions(entityQueryRequest, cancellationToken);
         }
 
-        private async Task ModifyQuestionTags(QuestionDto actionRequest, CancellationToken cancellationToken)
+        private async Task ModifyQuestionTags(UpdateQuestionDto actionRequest, CancellationToken cancellationToken)
         {
             await AddQuestionTags(actionRequest, cancellationToken);
 
             await UpdateQuestionTags(actionRequest, cancellationToken);
 
-            var questionTagDtos = actionRequest.QuestionTagDtos.Where(x => x.OperationStatus == OperationStatus.Delete);
+            var questionTagDtos = actionRequest.QuestionTagDtos.Where(x => x.OperationStatus == EEOperationStatus.Delete);
             var ids = questionTagDtos.Select(m => m.Id);
             EntityQueryRequest entityQueryRequest = ResovleDelete<QuestionTag>(ids);
 

+ 1 - 1
src/Hotline.Application/Exam/Service/Sourcewares/SourcewareCategoryService.cs

@@ -22,7 +22,7 @@ namespace Exam.Application.Service.Sourcewares
     /// 课件类型服务
     /// </summary>
     [Description("课件类型服务")]
-    public class SourcewareCategoryService : ApiService<SourcewareCategory, SourcewareCategoryDto,HotlineDbContext>,ISourcewareCategoryService, IScopeDependency
+    public class SourcewareCategoryService : ApiService<SourcewareCategory, AddSourcewareCategoryDto,UpdateSourcewareCategoryDto,HotlineDbContext>,ISourcewareCategoryService, IScopeDependency
     {
         private readonly ISourcewareCategoryRepository _repository;
         private readonly IMapper _mapper;

+ 44 - 1
src/Hotline.Application/Exam/Service/Sourcewares/SourcewareService.cs

@@ -2,6 +2,9 @@ using Exam.Application;
 using Exam.Application.Interface.Sourcewares;
 using Exam.Application.QueryExtensions.Sourcewares;
 using Exam.Infrastructure.Data.Entity;
+using Exam.Infrastructure.Data.Interface;
+using Exam.Infrastructure.Extensions;
+using Exam.Infrastructure.Validation.Constants;
 using Exam.Insfrastructure.Service.Service;
 using Hotline.Exams.Sourcewares;
 using Hotline.Repository.SqlSugar;
@@ -22,7 +25,7 @@ namespace Hotline.Application.Exam.Service.Sourcewares
     /// 课件服务
     /// </summary>
     [Description("课件服务")]
-    public class SourcewareService : ApiService<Sourceware, SourcewareDto,HotlineDbContext>,ISourcewareService, IScopeDependency
+    public class SourcewareService : ApiService<Sourceware, AddSourcewareDto,UpdateSourcewareDto,HotlineDbContext>,ISourcewareService, IScopeDependency
     {
         private readonly ISourcewareRepository _repository;
         private readonly IDataPermissionFilterBuilder _datePermissionFilterBuilder;
@@ -70,10 +73,50 @@ namespace Hotline.Application.Exam.Service.Sourcewares
 
             return result;
         }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="actionRequest"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+        public override async Task<string> AddAsync(AddSourcewareDto actionRequest, CancellationToken cancellationToken)
+        {
+            await SetDefaultCategory(actionRequest);
+
+            return await base.AddAsync(actionRequest, cancellationToken);
+        }
+
+        /// <summary>
+        /// 更新课件分类
+        /// </summary>
+        /// <param name="actionRequest"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+        public override async Task UpdateAsync(UpdateSourcewareDto actionRequest, CancellationToken cancellationToken)
+        {
+            await SetDefaultCategory(actionRequest);
+
+            await base.UpdateAsync(actionRequest, cancellationToken);
+        }
         #endregion
 
         #region private method
         /// <summary>
+        /// 设置默认分类
+        /// </summary>
+        /// <param name="actionRequest"></param>
+        /// <returns></returns>
+        private async Task SetDefaultCategory(AddSourcewareDto actionRequest)
+        {
+            var category = await new BaseRepository<SourcewareCategory>(_repository.UOW, _datePermissionFilterBuilder, _serviceProvider).Queryable().FirstAsync(x => x.Name == InfrastructureContant.NoCategory);
+
+            if (actionRequest.CategoryId.IsNullOrEmpty())
+            {
+                actionRequest.CategoryId = category != null ? category.Id : string.Empty;
+            }
+        }
+        /// <summary>
         /// 获取查询结果
         /// </summary>
         /// <param name="queryRequest"></param>

+ 65 - 59
src/Hotline.Application/Exam/Service/TestPapers/TestPaperService.cs

@@ -1,7 +1,6 @@
-using Exam.Application.Interface.TestPapers;
-using Exam.ExamManages;
+using DocumentFormat.OpenXml.Office2010.Excel;
+using Exam.Application.Interface.TestPapers;
 using Exam.Infrastructure.Data.Entity;
-using Exam.Infrastructure.Data.Extensions;
 using Exam.Infrastructure.Enums;
 using Exam.Infrastructure.Extensions;
 using Exam.Infrastructure.Web.Extensions;
@@ -21,14 +20,12 @@ using Hotline.Share.Requests.Exam;
 using Hotline.Share.Tools;
 using JiebaNet.Segmenter.Common;
 using MapsterMapper;
-using Org.BouncyCastle.Crypto;
 using SqlSugar;
-using SqlSugar.Extensions;
 using XF.Domain.Dependency;
 
 namespace Hotline.Application.Exam.Service.TestPapers
 {
-    public class TestPaperService : ApiService<TestPaper, TestPaperDto, HotlineDbContext>, ITestPaperService, IScopeDependency
+    public class TestPaperService : ApiService<TestPaper, AddTestPaperDto, UpdateTestPaperDto, HotlineDbContext>, ITestPaperService, IScopeDependency
     {
         private readonly ITestPaperRepository _repository;
         private readonly ITestPaperItemRepository _testPaperItemRepository;
@@ -101,21 +98,27 @@ namespace Hotline.Application.Exam.Service.TestPapers
         /// <param name="actionRequest"></param>
         /// <param name="cancellationToken"></param>
         /// <returns></returns>
-        public override async Task AddAsync(TestPaperDto actionRequest, CancellationToken cancellationToken)
+        public override async Task<string> AddAsync(AddTestPaperDto actionRequest, CancellationToken cancellationToken)
         {
-            await base.AddAsync(actionRequest, cancellationToken);
+            var id = await base.AddAsync(actionRequest, cancellationToken);
 
-            await AddTestPaperItems(actionRequest,cancellationToken);
+            ResolveTestPaperId(actionRequest, id);
+
+            await AddTestPaperItems(actionRequest, cancellationToken);
 
             await AddTestPaperRules(actionRequest, cancellationToken);
 
             await AddTestPaperRuleTags(actionRequest, cancellationToken);
+
+            return id;
         }
 
-        public override async Task UpdateAsync(TestPaperDto actionRequest, CancellationToken cancellationToken)
+        public override async Task UpdateAsync(UpdateTestPaperDto actionRequest, CancellationToken cancellationToken)
         {
             await base.UpdateAsync(actionRequest, cancellationToken);
 
+            ResolveTestPaperId(actionRequest, actionRequest.Id);
+
             await ModifyTestPaperItems(actionRequest, cancellationToken);
 
             await ModifyTestPaperRules(actionRequest, cancellationToken);
@@ -159,10 +162,10 @@ namespace Hotline.Application.Exam.Service.TestPapers
         private async Task<List<TestPaperRuleTag>> GetTestPaperRuleTags(EntityQueryRequest entityQueryRequest)
         {
             var expression = entityQueryRequest.GetTestPaperRuleExpression();
-            var testPageRuleTable =  _testPaperRuleRepository.Queryable().Where(expression);
+            var testPageRuleTable = _testPaperRuleRepository.Queryable().Where(expression);
             var testPageRuleTagTable = _testPaperRuleTagRepository.Queryable();
 
-            var query = testPageRuleTagTable.InnerJoin(testPageRuleTable, (t, r) => t.TestPaperRuleId == r.Id).Select(x => x);
+            var query = testPageRuleTagTable.InnerJoin(testPageRuleTable, (t, r) => t.TestPaperRuleId == r.Id).Select((t,r) => t);
 
             return await query.ToListAsync();
         }
@@ -194,64 +197,58 @@ namespace Hotline.Application.Exam.Service.TestPapers
 
 
 
-        private async Task AddTestPaperRules(TestPaperDto actionRequest, CancellationToken cancellationToken)
+        private async Task AddTestPaperRules(AddTestPaperDto actionRequest, CancellationToken cancellationToken)
         {
             if (actionRequest.TestPaperRuleDtos == null) return;
 
-            var testPaperRuleDtos = actionRequest.TestPaperRuleDtos.Where(x => x.OperationStatus == OperationStatus.Add).ToList();
-            var testPaperRules = _mapper.Map<List<TestPaperRule>>(testPaperRuleDtos);
+            if (actionRequest.Mode == Share.Enums.Exams.EExamMode.Manual) return;
 
-            testPaperRuleDtos.InitRequest(actionRequest);
+            var testPaperRuleDtos = actionRequest.TestPaperRuleDtos.Where(x => x.OperationStatus == EEOperationStatus.Add).ToList();
+            var testPaperRules = _mapper.Map<List<TestPaperRule>>(testPaperRuleDtos);
 
-            testPaperRules.ToInsert(testPaperRuleDtos);
+            testPaperRules.ToInsert();
 
             await _testPaperRuleRepository.AddWithValidateAsync(testPaperRules, cancellationToken);
 
         }
 
-        private async Task AddTestPaperItems(TestPaperDto actionRequest, CancellationToken cancellationToken)
+        private async Task AddTestPaperItems(AddTestPaperDto actionRequest, CancellationToken cancellationToken)
         {
             if (actionRequest.TestPaperItemDtos == null) return;
 
-            var testPaperItemDtos = actionRequest.TestPaperItemDtos.Where(x => x.OperationStatus == OperationStatus.Add).ToList();
+            var testPaperItemDtos = actionRequest.TestPaperItemDtos.Where(x => x.OperationStatus == EEOperationStatus.Add).ToList();
             var testPaperItems = _mapper.Map<List<TestPaperItem>>(testPaperItemDtos);
 
-            testPaperItemDtos.InitRequest(actionRequest);
-
-            testPaperItems.ToInsert(testPaperItemDtos);
+            testPaperItems.ToInsert();
 
             await _testPaperItemRepository.AddWithValidateAsync(testPaperItems, cancellationToken);
         }
 
 
-        private async Task AddTestPaperRuleTags(TestPaperDto actionRequest, CancellationToken cancellationToken)
+        private async Task AddTestPaperRuleTags(AddTestPaperDto actionRequest, CancellationToken cancellationToken)
         {
             if (actionRequest.TestPaperRuleDtos == null) return;
 
-            var testPaperRuleDtos = actionRequest.TestPaperRuleDtos.Where(x=>x.OperationStatus == OperationStatus.Add);
+            var testPaperRuleDtos = actionRequest.TestPaperRuleDtos.Where(x => x.OperationStatus == EEOperationStatus.Add);
 
-            var testPaperRuleTagDtos = testPaperRuleDtos.Select(n=>new TestPaperRuleTagDto
-            {
-                TagId = n.TagId,
-                TestPaperRuleId = n.Id
-            }).ToList();
-
-            testPaperRuleTagDtos.InitRequest(actionRequest);
+            var testPaperRuleTagDtos = testPaperRuleDtos.Select(x => x.TestPaperRuleTagDto);
 
             var testPaperRuleTags = _mapper.Map<List<TestPaperRuleTag>>(testPaperRuleTagDtos);
 
-            testPaperRuleTags.ToInsert(testPaperRuleTagDtos);
+            testPaperRuleTags.ToInsert();
 
-            await _testPaperRuleTagRepository.AddWithValidateAsync(testPaperRuleTags,cancellationToken);
+            await _testPaperRuleTagRepository.AddWithValidateAsync(testPaperRuleTags, cancellationToken);
         }
 
-        private async Task ModifyTestPaperRules(TestPaperDto actionRequest, CancellationToken cancellationToken)
+        private async Task ModifyTestPaperRules(UpdateTestPaperDto actionRequest, CancellationToken cancellationToken)
         {
             if (actionRequest.TestPaperRuleDtos == null) return;
 
+            if (actionRequest.Mode == Share.Enums.Exams.EExamMode.Manual) return;
+
             await AddTestPaperRules(actionRequest, cancellationToken);
 
-            await UpdateTestPaperRules(actionRequest,cancellationToken);
+            await UpdateTestPaperRules(actionRequest, cancellationToken);
 
             var entityQueryRequest = ExpressionableUtility.CreateExpression<TestPaperRule>()
                 .AndIF(actionRequest.Id.IsNotNullOrEmpty(), x => x.TestPaperId == actionRequest.Id).ToEntityQueryRequest<TestPaperRule>();
@@ -264,11 +261,11 @@ namespace Hotline.Application.Exam.Service.TestPapers
             await _testPaperRuleRepository.DeleteWithValidateAsync(entityQueryRequest, cancellationToken);
         }
 
-        private async Task UpdateTestPaperRules(TestPaperDto actionRequest, CancellationToken cancellationToken)
+        private async Task UpdateTestPaperRules(UpdateTestPaperDto actionRequest, CancellationToken cancellationToken)
         {
             if (actionRequest.TestPaperRuleDtos == null) return;
 
-            var testPaperRuleDtos = actionRequest.TestPaperRuleDtos.Where(x => x.OperationStatus == OperationStatus.Update).ToList();
+            var testPaperRuleDtos = actionRequest.TestPaperRuleDtos.Where(x => x.OperationStatus == EEOperationStatus.Update).ToList();
 
             var ids = testPaperRuleDtos.Select(x => x.Id);
 
@@ -276,7 +273,7 @@ namespace Hotline.Application.Exam.Service.TestPapers
 
             var entities = new List<TestPaperRule>();
 
-            foreach(var testPaperRuleDto in testPaperRuleDtos)
+            foreach (var testPaperRuleDto in testPaperRuleDtos)
             {
                 var entity = testPaperRules.FirstOrDefault(x => x.Id == testPaperRuleDto.Id);
 
@@ -285,15 +282,13 @@ namespace Hotline.Application.Exam.Service.TestPapers
                 entity.TestPaperId = actionRequest.Id;
             }
 
-            testPaperRuleDtos.InitRequest(actionRequest);
-
-            entities.ToUpdate(testPaperRuleDtos);
+            entities.ToUpdate();
 
             await _testPaperRuleRepository.UpdateWithValidateAsync(entities, cancellationToken);
-            
+
         }
 
-        private async Task ModifyTestPaperRuleTags(TestPaperDto actionRequest, CancellationToken cancellationToken)
+        private async Task ModifyTestPaperRuleTags(UpdateTestPaperDto actionRequest, CancellationToken cancellationToken)
         {
             if (actionRequest.TestPaperRuleDtos == null) return;
 
@@ -301,7 +296,7 @@ namespace Hotline.Application.Exam.Service.TestPapers
 
             await UpdateTestPaperRuleTags(actionRequest, cancellationToken);
 
-            var ids = actionRequest.TestPaperRuleDtos.Where(x => x.OperationStatus == OperationStatus.Delete).Select(x=>x.Id).ToList();
+            var ids = actionRequest.TestPaperRuleDtos.Where(x => x.OperationStatus == EEOperationStatus.Delete).Select(x => x.Id).ToList();
 
             var entityQueryRequest = ExpressionableUtility.CreateExpression<TestPaperRuleTag>()
                 .AndIF(ids.IsNullOrEmpty(), x => ids.Contains(x.TestPaperRuleId)).ToEntityQueryRequest<TestPaperRuleTag>();
@@ -314,13 +309,13 @@ namespace Hotline.Application.Exam.Service.TestPapers
             await _testPaperRuleTagRepository.DeleteWithValidateAsync(entityQueryRequest, cancellationToken);
         }
 
-        private async Task UpdateTestPaperRuleTags(TestPaperDto actionRequest, CancellationToken cancellationToken)
+        private async Task UpdateTestPaperRuleTags(UpdateTestPaperDto actionRequest, CancellationToken cancellationToken)
         {
             if (actionRequest.TestPaperRuleDtos == null) return;
 
-            var ruleIds = actionRequest.TestPaperRuleDtos.Where(x => x.OperationStatus == OperationStatus.Update).Select(x=>x.Id).ToList();
+            var ruleIds = actionRequest.TestPaperRuleDtos.Where(x => x.OperationStatus == EEOperationStatus.Update).Select(x => x.Id).ToList();
 
-            var testPaperRuleTags = await _testPaperRuleTagRepository.Queryable().Where(x => ruleIds.Contains(x.TestPaperRuleId) ).ToListAsync();
+            var testPaperRuleTags = await _testPaperRuleTagRepository.Queryable().Where(x => ruleIds.Contains(x.TestPaperRuleId)).ToListAsync();
 
             var entities = new List<TestPaperRuleTag>();
 
@@ -333,14 +328,12 @@ namespace Hotline.Application.Exam.Service.TestPapers
                 entity.TestPaperRuleId = testPaperRuleDto.Id;
             }
 
-            actionRequest.TestPaperRuleDtos.InitRequest(actionRequest);
-
-            entities.ToUpdate(actionRequest.TestPaperRuleDtos);
+            entities.ToUpdate();
 
             await _testPaperRuleTagRepository.UpdateWithValidateAsync(entities, cancellationToken);
         }
 
-        private async Task ModifyTestPaperItems(TestPaperDto actionRequest, CancellationToken cancellationToken)
+        private async Task ModifyTestPaperItems(UpdateTestPaperDto actionRequest, CancellationToken cancellationToken)
         {
             if (actionRequest.TestPaperItemDtos == null) return;
 
@@ -359,11 +352,11 @@ namespace Hotline.Application.Exam.Service.TestPapers
             await _testPaperItemRepository.DeleteWithValidateAsync(entityQueryRequest, cancellationToken);
         }
 
-        private async Task UpdateTestPaperItems(TestPaperDto actionRequest, CancellationToken cancellationToken)
+        private async Task UpdateTestPaperItems(UpdateTestPaperDto actionRequest, CancellationToken cancellationToken)
         {
             if (actionRequest.TestPaperItemDtos == null) return;
 
-            var testPaperItemDtos = actionRequest.TestPaperItemDtos.Where(x => x.OperationStatus == OperationStatus.Update).ToList();
+            var testPaperItemDtos = actionRequest.TestPaperItemDtos.Where(x => x.OperationStatus == EEOperationStatus.Update).ToList();
 
             var ids = testPaperItemDtos.Select(x => x.Id);
 
@@ -380,9 +373,7 @@ namespace Hotline.Application.Exam.Service.TestPapers
                 entity.TestPaperId = actionRequest.Id;
             }
 
-            testPaperItemDtos.InitRequest(actionRequest);
-
-            entities.ToUpdate(testPaperItemDtos);
+            entities.ToUpdate();
 
             await _testPaperItemRepository.UpdateWithValidateAsync(entities, cancellationToken);
         }
@@ -399,12 +390,12 @@ namespace Hotline.Application.Exam.Service.TestPapers
 
             var testPaperRuleTags = await GetTestPaperRuleTags(entityQueryRequest);
 
-            var queryable = testPaperRuleTable.Select( t => new TestPaperRuleDto
+            var queryable = testPaperRuleTable.Select(t => new TestPaperRuleDto
             {
                 Id = t.Id,
                 TestPaperId = t.TestPaperId,
-                Count =t.Count,
-                DifficultyLevel =t.DifficultyLevel,
+                Count = t.Count,
+                DifficultyLevel = t.DifficultyLevel,
                 SortIndex = t.SortIndex,
                 QuestionType = t.QuestionType,
             });
@@ -436,6 +427,21 @@ namespace Hotline.Application.Exam.Service.TestPapers
             return await queryable.ToListAsync();
 
         }
+
+        private void ResolveTestPaperId(AddTestPaperDto actionRequest, string id)
+        {
+            actionRequest.TestPaperRuleDtos.ForEach(x =>
+            {
+                x.TestPaperId = id;
+                x.TestPaperRuleTagDto = new TestPaperRuleTagDto
+                {
+                    TagId = x.TagId,
+                    TestPaperRuleId = id
+                };
+            });
+
+            actionRequest.TestPaperItemDtos.ForEach(x => x.TestPaperId = id);
+        }
         #endregion
     }
 }

+ 41 - 0
src/Hotline.Application/Exam/Service/Trains/TrainTemplateService.cs

@@ -0,0 +1,41 @@
+using Exam.Application.Interface.Train;
+using Exam.Infrastructure.Data.Entity;
+using Exam.Insfrastructure.Service.Service;
+using Exam.Share.ViewResponses.Train;
+using Exam.Trains;
+using Hotline.Repository.SqlSugar;
+using Hotline.Repository.SqlSugar.Exam.Interfaces.Trains;
+using Hotline.Repository.SqlSugar.Interface;
+using Hotline.Share.Dtos.Trains;
+using Hotline.Share.Requests.Train;
+using MapsterMapper;
+using XF.Domain.Dependency;
+
+namespace Hotline.Application.Exam.Service.Trains
+{
+    public class TrainTemplateService : ApiService<TrainTemplate, AddTrainTemplateDto,UpdateTrainTemplateDto, HotlineDbContext>, ITrainTemplateService, IScopeDependency
+    {
+        private readonly ITrainTemplateRepository _repository;
+
+        public TrainTemplateService(ITrainTemplateRepository repository, 
+            IMapper mapper) : base(repository, mapper)
+        {
+            _repository = repository;
+        }
+
+        public Task<TrainTemplateDto> GetAsync(EntityQueryRequest entityQueryRequest)
+        {
+            throw new NotImplementedException();
+        }
+
+        public Task<(int, List<TrainTemplateViewResponse>)> GetListAsync(TrainTemplatePagedRequest queryRequest)
+        {
+            throw new NotImplementedException();
+        }
+
+        public Task<PageViewResponse<TrainTemplateViewResponse>> GetPagedListAsync(TrainTemplatePagedRequest queryRequest)
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

+ 0 - 4
src/Hotline.Application/Hotline.Application.csproj

@@ -13,9 +13,6 @@
     <PackageReference Include="Quartz.Jobs" Version="3.13.1" />
   </ItemGroup>
   <ItemGroup>
-    <ProjectReference Include="..\Exam.Infrastructure.Validation\Exam.Infrastructure.Validation.csproj" />
-    <ProjectReference Include="..\Exam.Infrastructure.Web\Exam.Infrastructure.Web.csproj" />
-    <ProjectReference Include="..\Hotline.Ai.Jths\Hotline.Ai.Jths.csproj" />
     <ProjectReference Include="..\Hotline.Ai.XingTang\Hotline.Ai.XingTang.csproj" />
     <ProjectReference Include="..\Hotline.Application.Contracts\Hotline.Application.Contracts.csproj" />
     <ProjectReference Include="..\Hotline.NewRock\Hotline.NewRock.csproj" />
@@ -30,6 +27,5 @@
   </ItemGroup>
   <ItemGroup>
     <Folder Include="Exam\Service\Practices\" />
-    <Folder Include="Exam\Service\Trains\" />
   </ItemGroup>
 </Project>

+ 1 - 0
src/Exam.Infrastructure.Validation/Constants/InfrastructureContant.cs → src/Hotline.Repository.SqlSugar/Exam/Core/Constants/InfrastructureContant.cs

@@ -4,5 +4,6 @@
     {
         public const string SystemError = "SystemError";
         public const string SystemErrorDescription = "系统错误";
+        public const string NoCategory = "未分类";
     }
 }

+ 0 - 0
src/Exam.Infrastructure.Validation/Enums/ValidationErrorType.cs → src/Hotline.Repository.SqlSugar/Exam/Core/Enums/ValidationErrorType.cs


+ 0 - 0
src/Exam.Infrastructure.Validation/Exceptions/DomainException.cs → src/Hotline.Repository.SqlSugar/Exam/Core/Exceptions/DomainException.cs


+ 0 - 0
src/Exam.Infrastructure.Validation/Extensions/ValidateResultExtensions.cs → src/Hotline.Repository.SqlSugar/Exam/Core/Extensions/ValidateResultExtensions.cs


+ 0 - 0
src/Exam.Infrastructure.Validation/Validation/IValidationErrors.cs → src/Hotline.Repository.SqlSugar/Exam/Core/Validation/IValidationErrors.cs


+ 0 - 0
src/Exam.Infrastructure.Validation/Validation/ValidationErrorItem.cs → src/Hotline.Repository.SqlSugar/Exam/Core/Validation/ValidationErrorItem.cs


+ 0 - 0
src/Exam.Infrastructure.Validation/Validation/ValidationErrors.cs → src/Hotline.Repository.SqlSugar/Exam/Core/Validation/ValidationErrors.cs


+ 0 - 0
src/Exam.Infrastructure.Validation/Validation/ValidatorTypeConstants.cs → src/Hotline.Repository.SqlSugar/Exam/Core/Validation/ValidatorTypeConstants.cs


+ 1 - 1
src/Hotline.Repository.SqlSugar/Exam/Repositories/ExamManages/ExtractRuleRepository.cs

@@ -18,7 +18,7 @@ namespace Exam.Repository.Sqlsugar
     {
         public ExtractRuleRepository(ISugarUnitOfWork<HotlineDbContext> uow, IDataPermissionFilterBuilder dataPermissionFilterBuilder, IServiceProvider serviceProvider) : base(uow, dataPermissionFilterBuilder, serviceProvider)
         {
-            Validator = new ExtractRuleValidator();
+            Validator = new ExtractRuleValidator(this);
         }
     }
 }

+ 2 - 2
src/Hotline.Repository.SqlSugar/Exam/Repositories/ExamRepository.cs

@@ -34,11 +34,11 @@ namespace Exam.Repository.Sqlsugar.Repositories
         public AbstractValidator<TEntity> Validator { get; set; }
 
         #region public method
-        public async Task AddWithValidateAsync(TEntity entity, CancellationToken cancellationToken)
+        public async Task<string> AddWithValidateAsync(TEntity entity, CancellationToken cancellationToken)
         {
             await DoValidationAsync(entity,ValidatorTypeConstants.Create);
 
-            await base.AddAsync(entity, cancellationToken);
+            return await base.AddAsync(entity, cancellationToken);
         }
 
         public async Task AddWithValidateAsync(List<TEntity> entities, CancellationToken cancellationToken)

+ 1 - 1
src/Hotline.Repository.SqlSugar/Exam/Repositories/TestPapers/TestPaperRepository.cs

@@ -17,7 +17,7 @@ namespace Exam.Repository.Sqlsugar.Repositories.TestPapers
     {
         public TestPaperRepository(ISugarUnitOfWork<HotlineDbContext> uow, IDataPermissionFilterBuilder dataPermissionFilterBuilder, IServiceProvider serviceProvider) : base(uow, dataPermissionFilterBuilder, serviceProvider)
         {
-            Validator = new TestPaperValidator();
+            Validator = new TestPaperValidator(this);
         }
     }
 }

+ 5 - 6
src/Hotline.Repository.SqlSugar/Exam/Validators/ExamManages/ExamTagValidator.cs

@@ -47,24 +47,23 @@ namespace Exam.Repository.Sqlsugar.Validators.ExamManages
         protected override void BaseValidateRule()
         {
             base.BaseValidateRule();
+            RuleFor(m => m.Name).NotEmpty().WithMessage(x => string.Format(ErrorMessage.IsRequired, x.GetType().GetDescription(nameof(ExamTag.Name))));
+            RuleFor(m => m.ParentId).NotEmpty().WithMessage(x => string.Format(ErrorMessage.IsRequired, x.GetType().GetDescription(nameof(ExamTag.ParentId))));
+
         }
 
         protected override void ValidateRuleWithAdd()
         {
             base.ValidateRuleWithAdd();
             RuleFor(m => m.CreationTime).NotEmpty().WithMessage(x => string.Format(ErrorMessage.IsRequired, x.GetType().GetDescription(nameof(ExamTag.CreationTime))));
-            RuleFor(m => m.Name).NotEmpty().WithMessage(x => string.Format(ErrorMessage.IsRequired, x.GetType().GetDescription(nameof(ExamTag.Name))));
-            RuleFor(m => m.ParentId).NotEmpty().WithMessage(x => string.Format(ErrorMessage.IsRequired, x.GetType().GetDescription(nameof(ExamTag.ParentId))));
-            RuleFor(m => m.Name).Must(v => !_examTagRepository.Queryable().Any(x => x.Name == v)).WithMessage(x => string.Format(ErrorMessage.IsRepeat, x.GetType().GetDescription(nameof(ExamTag.Name))));
+             RuleFor(m => m.Name).Must(v => !_examTagRepository.Queryable().Any(x => x.Name == v)).WithMessage(x => string.Format(ErrorMessage.IsRepeat, x.GetType().GetDescription(nameof(ExamTag.Name))));
         }
 
         protected override void ValidateRuleWithModify()
         {
             base.ValidateRuleWithModify();
             RuleFor(m => m.LastModificationTime).NotEmpty().WithMessage(x => string.Format(ErrorMessage.IsRequired, x.GetType().GetDescription(nameof(ExamTag.LastModificationTime))));
-            RuleFor(m => m.Name).NotEmpty().WithMessage(x => string.Format(ErrorMessage.IsRequired, x.GetType().GetDescription(nameof(ExamTag.Name))));
-            RuleFor(m => m.ParentId).NotEmpty().WithMessage(x => string.Format(ErrorMessage.IsRequired, x.GetType().GetDescription(nameof(ExamTag.ParentId))));
-            RuleFor(m => m.Name).Must((t, v) => !_examTagRepository.Queryable().Any(x => x.Name == v && x.Id != t.Id)).WithMessage(x => string.Format(ErrorMessage.IsRepeat, x.GetType().GetDescription(nameof(ExamTag.Name))));
+             RuleFor(m => m.Name).Must((t, v) => !_examTagRepository.Queryable().Any(x => x.Name == v && x.Id != t.Id)).WithMessage(x => string.Format(ErrorMessage.IsRepeat, x.GetType().GetDescription(nameof(ExamTag.Name))));
         }
 
         private void ValidateRuleWithRemove()

+ 19 - 2
src/Hotline.Repository.SqlSugar/Exam/Validators/ExamManages/ExtractRuleValidator.cs

@@ -2,13 +2,16 @@ using Exam.ExamManages;
 using Exam.Infrastructure.Extensions;
 using Exam.Infrastructure.Validation.Validation;
 using FluentValidation;
+using Hotline.Repository.SqlSugar.Exam.Interfaces.ExamManages;
 using Hotline.Repository.SqlSugar.Validate;
 
 namespace Exam.Repository.Sqlsugar.Validators.ExamManages
 {
-    public class ExtractRuleValidator:BaseValidator<ExtractRule>
+    public class ExtractRuleValidator : BaseValidator<ExtractRule>
     {
-        public ExtractRuleValidator()
+        private readonly IExtractRuleRepository _extractRuleRepository;
+
+        public ExtractRuleValidator(IExtractRuleRepository extractRuleRepository)
         {
             RuleSet(ValidatorTypeConstants.Create, () =>
             {
@@ -23,23 +26,37 @@ namespace Exam.Repository.Sqlsugar.Validators.ExamManages
 
                 ValidateRuleWithModify();
             });
+
+            _extractRuleRepository = extractRuleRepository;
         }
 
         protected override void BaseValidateRule()
         {
             base.BaseValidateRule();
+
+            RuleFor(m => m.RuleType).NotEmpty().WithMessage(x => string.Format(ErrorMessage.IsRequired, x.GetType().GetDescription(nameof(ExtractRule.RuleType))));
+            RuleFor(m => m.Name).NotEmpty().WithMessage(x => string.Format(ErrorMessage.IsRequired, x.GetType().GetDescription(nameof(ExtractRule.Name))));
+            RuleFor(m => m.Code).NotEmpty().WithMessage(x => string.Format(ErrorMessage.IsRequired, x.GetType().GetDescription(nameof(ExtractRule.Code))));
+
         }
 
         protected override void ValidateRuleWithAdd()
         {
             base.ValidateRuleWithAdd();
             RuleFor(m => m.CreationTime).NotEmpty().WithMessage(x => string.Format(ErrorMessage.IsRequired, x.GetType().GetDescription(nameof(ExtractRule.CreationTime))));
+
+            RuleFor(m => m.Name).Must(v => !_extractRuleRepository.Queryable().Any(x => x.Name == v)).WithMessage(x => string.Format(ErrorMessage.IsRepeat, x.GetType().GetDescription(nameof(ExtractRule.Name))));
+
+            RuleFor(m => m.Code).Must(v => !_extractRuleRepository.Queryable().Any(x => x.Code == v)).WithMessage(x => string.Format(ErrorMessage.IsRepeat, x.GetType().GetDescription(nameof(ExtractRule.Code))));
         }
 
         protected override void ValidateRuleWithModify()
         {
             base.ValidateRuleWithModify();
             RuleFor(m => m.LastModificationTime).NotEmpty().WithMessage(x => string.Format(ErrorMessage.IsRequired, x.GetType().GetDescription(nameof(ExtractRule.LastModificationTime))));
+            RuleFor(m => m.Name).Must((e,v) => !_extractRuleRepository.Queryable().Any(x => x.Name == v && x.Id!= e.Id)).WithMessage(x => string.Format(ErrorMessage.IsRepeat, x.GetType().GetDescription(nameof(ExtractRule.Name))));
+
+            RuleFor(m => m.Code).Must((e,v) => !_extractRuleRepository.Queryable().Any(x => x.Code == v && x.Id!=e.Id)).WithMessage(x => string.Format(ErrorMessage.IsRepeat, x.GetType().GetDescription(nameof(ExtractRule.Code))));
 
         }
 

+ 3 - 0
src/Hotline.Repository.SqlSugar/Exam/Validators/ExamManages/RuleTagValidator.cs

@@ -28,6 +28,9 @@ namespace Exam.Repository.Sqlsugar.Validators.ExamManages
         protected override void BaseValidateRule()
         {
             base.BaseValidateRule();
+
+            RuleFor(m => m.RuleId).NotEmpty().WithMessage(x => string.Format(ErrorMessage.IsRequired, x.GetType().GetDescription(nameof(RuleTag.RuleId))));
+            RuleFor(m => m.TagId).NotEmpty().WithMessage(x => string.Format(ErrorMessage.IsRequired, x.GetType().GetDescription(nameof(RuleTag.TagId))));
         }
 
         protected override void ValidateRuleWithAdd()

+ 1 - 1
src/Hotline.Repository.SqlSugar/Exam/Validators/Questions/QuestionOptionsValidator.cs

@@ -29,7 +29,7 @@ namespace Exam.Repository.Sqlsugar.Validators.Questions
         protected override void BaseValidateRule()
         {
             base.BaseValidateRule();
-            RuleFor(m => m.Content).NotEmpty().WithMessage(x => string.Format(ErrorMessage.IsRequired,x.GetType().GetDescription(nameof(QuestionOptions))));
+            RuleFor(m => m.Content).NotEmpty().WithMessage(x => string.Format(ErrorMessage.IsRequired,x.GetType().GetDescription(nameof(QuestionOptions.Content))));
             RuleFor(m => m.QuestionId).NotEmpty().WithMessage(x => string.Format(ErrorMessage.IsRequired, typeof(Question).GetDescription()));
         }
 

+ 1 - 4
src/Hotline.Repository.SqlSugar/Exam/Validators/Sourcewares/SourcewareValidator.cs

@@ -33,14 +33,13 @@ namespace Exam.Repository.Sqlsugar.Validators.Sourcewares
         protected override void BaseValidateRule()
         {
             base.BaseValidateRule();
+            RuleFor(m => m.Name).NotEmpty().WithMessage(x => string.Format(ErrorMessage.IsRequired, x.GetType().GetDescription(nameof(Sourceware.Name))));            
         }
 
         protected override void ValidateRuleWithAdd()
         {
             base.ValidateRuleWithAdd();
             RuleFor(m => m.CreationTime).NotEmpty().WithMessage(x => string.Format(ErrorMessage.IsRequired, x.GetType().GetDescription(nameof(Sourceware.CreationTime))));
-            RuleFor(m => m.Name).NotEmpty().WithMessage(x => string.Format(ErrorMessage.IsRequired, x.GetType().GetDescription(nameof(Sourceware.Name))));
-            RuleFor(m => m.CategoryId).NotEmpty().WithMessage(x => string.Format(ErrorMessage.IsRequired, typeof(SourcewareCategory).GetDescription()));
             RuleFor(m => m.Name).Must(v => !_sourcewareRepository.Queryable().Any(x => x.Name == v)).WithMessage(x => string.Format(ErrorMessage.IsRepeat, x.GetType().GetDescription(nameof(Sourceware.Name))));
         }
 
@@ -48,8 +47,6 @@ namespace Exam.Repository.Sqlsugar.Validators.Sourcewares
         {
             base.ValidateRuleWithModify();
             RuleFor(m => m.LastModificationTime).NotEmpty().WithMessage(x => string.Format(ErrorMessage.IsRequired, x.GetType().GetDescription(nameof(Sourceware.LastModificationTime))));
-            RuleFor(m => m.Name).NotEmpty().WithMessage(x => string.Format(ErrorMessage.IsRequired, x.GetType().GetDescription(nameof(Sourceware.Name))));
-            RuleFor(m => m.CategoryId).NotEmpty().WithMessage(x => string.Format(ErrorMessage.IsRequired, typeof(SourcewareCategory).GetDescription()));
             RuleFor(m => m.Name).Must((t,v) => !_sourcewareRepository.Queryable().Any(x => x.Name == v && t.Id != x.Id)).WithMessage(x => string.Format(ErrorMessage.IsRepeat, x.GetType().GetDescription(nameof(Sourceware.Name))));
         }
 

+ 6 - 0
src/Hotline.Repository.SqlSugar/Exam/Validators/TestPapers/TestPaperItemValidator.cs

@@ -1,5 +1,7 @@
+using Exam.ExamManages;
 using Exam.Infrastructure.Extensions;
 using Exam.Infrastructure.Validation.Validation;
+using Exam.Questions;
 using Exam.TestPapers;
 using FluentValidation;
 using Hotline.Repository.SqlSugar.Validate;
@@ -28,6 +30,10 @@ namespace Exam.Repository.Sqlsugar.Validators.TestPapers
         protected override void BaseValidateRule()
         {
             base.BaseValidateRule();
+
+            RuleFor(m => m.TestPaperId).NotEmpty().WithMessage(x => string.Format(ErrorMessage.IsRequired, x.GetType().GetDescription(nameof(TestPaperItem.TestPaperId))));
+            RuleFor(m => m.QuestionId).NotEmpty().WithMessage(x => string.Format(ErrorMessage.IsRequired, typeof(Question).GetDescription()));
+
         }
 
         protected override void ValidateRuleWithAdd()

+ 4 - 0
src/Hotline.Repository.SqlSugar/Exam/Validators/TestPapers/TestPaperRuleTagValidator.cs

@@ -1,3 +1,4 @@
+using Exam.ExamManages;
 using Exam.Infrastructure.Extensions;
 using Exam.Infrastructure.Validation.Validation;
 using Exam.TestPapers;
@@ -28,6 +29,9 @@ namespace Exam.Repository.Sqlsugar.Validators.TestPapers
         protected override void BaseValidateRule()
         {
             base.BaseValidateRule();
+
+            RuleFor(m => m.TestPaperRuleId).NotEmpty().WithMessage(x=>string.Format(ErrorMessage.IsRequired,x.GetType().GetDescription(nameof(TestPaperRuleTag.TestPaperRuleId))));
+            RuleFor(m => m.TagId).NotEmpty().WithMessage(x => string.Format(ErrorMessage.IsRequired, typeof(ExamTag).GetDescription()));
         }
 
         protected override void ValidateRuleWithAdd()

+ 6 - 0
src/Hotline.Repository.SqlSugar/Exam/Validators/TestPapers/TestPaperRuleValidator.cs

@@ -28,6 +28,12 @@ namespace Exam.Repository.Sqlsugar.Validators.TestPapers
         protected override void BaseValidateRule()
         {
             base.BaseValidateRule();
+
+            RuleFor(m => m.TestPaperId).NotEmpty().WithMessage(x=>string.Format(ErrorMessage.IsRequired, x.GetType().GetDescription(nameof(TestPaperRule.TestPaperId))));
+
+            RuleFor(m => m.QuestionType).NotNull().WithMessage(x => string.Format(ErrorMessage.IsRequired, x.GetType().GetDescription(nameof(TestPaperRule.QuestionType))));
+
+            RuleFor(m => m.Count).NotNull().WithMessage(x => string.Format(ErrorMessage.IsRequired, x.GetType().GetDescription(nameof(TestPaperRule.QuestionType))));
         }
 
         protected override void ValidateRuleWithAdd()

+ 21 - 1
src/Hotline.Repository.SqlSugar/Exam/Validators/TestPapers/TestPaperValidator.cs

@@ -1,14 +1,19 @@
+using Exam.ExamManages;
 using Exam.Infrastructure.Extensions;
 using Exam.Infrastructure.Validation.Validation;
 using Exam.TestPapers;
 using FluentValidation;
+using Hotline.Repository.SqlSugar.Exam.Interfaces.ExamManages;
+using Hotline.Repository.SqlSugar.Exam.Interfaces.TestPapers;
 using Hotline.Repository.SqlSugar.Validate;
 
 namespace Exam.Repository.Sqlsugar.Validators.TestPapers
 {
     public class TestPaperValidator:BaseValidator<TestPaper>
     {
-        public TestPaperValidator()
+        private readonly ITestPaperRepository _testPaperRepository;
+
+        public TestPaperValidator(ITestPaperRepository testPaperRepository)
         {
             RuleSet(ValidatorTypeConstants.Create, () =>
             {
@@ -23,17 +28,28 @@ namespace Exam.Repository.Sqlsugar.Validators.TestPapers
 
                 ValidateRuleWithModify();
             });
+            _testPaperRepository = testPaperRepository;
         }
 
         protected override void BaseValidateRule()
         {
             base.BaseValidateRule();
+
+            RuleFor(m => m.Name).NotEmpty().WithMessage(x=>string.Format(ErrorMessage.IsRequired,x.GetType().GetDescription(nameof(TestPaper.Name))));
+            RuleFor(m => m.Code).NotEmpty().WithMessage(x=>string.Format(ErrorMessage.IsRequired,x.GetType().GetDescription(nameof(TestPaper.Code))));
+            RuleFor(m => m.ExamType).NotNull().WithMessage(x => string.Format(ErrorMessage.IsRequired, x.GetType().GetDescription(nameof(TestPaper.ExamType))));
+            RuleFor(m => m.Mode).NotNull().WithMessage(x => string.Format(ErrorMessage.IsRequired, x.GetType().GetDescription(nameof(TestPaper.Mode))));
         }
 
         protected override void ValidateRuleWithAdd()
         {
             base.ValidateRuleWithAdd();
             RuleFor(m => m.CreationTime).NotEmpty().WithMessage(x => string.Format(ErrorMessage.IsRequired, x.GetType().GetDescription(nameof(TestPaper.CreationTime))));
+
+            RuleFor(m => m.Name).Must(v => !_testPaperRepository.Queryable().Any(x => x.Name == v)).WithMessage(x => string.Format(ErrorMessage.IsRepeat, x.GetType().GetDescription(nameof(TestPaper.Name))));
+
+            RuleFor(m => m.Code).Must(v => !_testPaperRepository.Queryable().Any(x => x.Code == v)).WithMessage(x => string.Format(ErrorMessage.IsRepeat, x.GetType().GetDescription(nameof(TestPaper.Code))));
+
         }
 
         protected override void ValidateRuleWithModify()
@@ -41,6 +57,10 @@ namespace Exam.Repository.Sqlsugar.Validators.TestPapers
             base.ValidateRuleWithModify();
             RuleFor(m => m.LastModificationTime).NotEmpty().WithMessage(x => string.Format(ErrorMessage.IsRequired, x.GetType().GetDescription(nameof(TestPaper.LastModificationTime))));
 
+            RuleFor(m => m.Name).Must((e, v) => !_testPaperRepository.Queryable().Any(x => x.Name == v && x.Id != e.Id)).WithMessage(x => string.Format(ErrorMessage.IsRepeat, x.GetType().GetDescription(nameof(TestPaper.Name))));
+
+            RuleFor(m => m.Code).Must((e, v) => !_testPaperRepository.Queryable().Any(x => x.Code == v && x.Id != e.Id)).WithMessage(x => string.Format(ErrorMessage.IsRepeat, x.GetType().GetDescription(nameof(TestPaper.Code))));
+
         }
 
     }

+ 11 - 35
src/Hotline.Repository.SqlSugar/Extensions/ApiServiceExtension.cs

@@ -1,4 +1,5 @@
 using Exam.Infrastructure.Data.Entity;
+using Exam.Infrastructure.Data.Interface;
 using Exam.Infrastructure.Extensions;
 using XF.Domain.Entities;
 using XF.Domain.Repository;
@@ -7,12 +8,14 @@ namespace Hotline.Repository.SqlSugar.Extensions
 {
     public static class ApiServiceExtension
     {
-        public static void ToInsert<T,TActionRequest>(this T entity, TActionRequest actionRequest) where T : class, IEntity<string>, new()
-        where TActionRequest : ActionRequest
+        public static void ToInsert<T>(this T entity) where T : class, IEntity<string>, new()
         {
             if (entity.Id.IsNullOrEmpty())
             {
-                entity.Id = actionRequest.Id ?? Guid.NewGuid().ToString();
+                if (entity is Entity)
+                {
+                    (entity as Entity)?.InitId();
+                }
             }
 
             if (entity is CreationEntity)
@@ -20,65 +23,38 @@ namespace Hotline.Repository.SqlSugar.Extensions
                 var creationEntity = entity as CreationEntity;
                 if (creationEntity != null)
                 {
-                    creationEntity.CreatorId = actionRequest.UserId;
-                    creationEntity.CreatorOrgId = actionRequest.OrgId;
-                    creationEntity.CreatorOrgLevel = actionRequest.OrgLevel;
-                    creationEntity.CreatorOrgName = actionRequest.OrgName;
-                    creationEntity.CreatorName = actionRequest.UserName;
                     creationEntity.CreationTime = DateTime.Now;
-                    creationEntity.AreaId = actionRequest.AreaId;
-
-                    entity = creationEntity as T ?? entity;
                 }
 
             }
         }
 
-        public static void ToInsert<T, TActionRequest>(this List<T> entities,List<TActionRequest> actionRequests) where T : class, IEntity<string>, new()
-        where TActionRequest : ActionRequest
+        public static void ToInsert<T>(this List<T> entities) where T : class, IEntity<string>, new()
         {
             foreach(var entity in entities)
             {
-                var actionRequest = actionRequests.FirstOrDefault(x => x.Id == entity.Id);
-                if (actionRequest != null)
-                {
-                    entity.ToInsert(actionRequest);
-                }
+                entity.ToInsert();
             }
         }
 
-        public static void ToUpdate<T, TActionRequest>(this T entity, TActionRequest actionRequest) where T : class, IEntity<string>, new()
-        where TActionRequest : ActionRequest
+        public static void ToUpdate<T>(this T entity) where T : class, IEntity<string>, new()
         {
             if(entity is FullStateEntity)
             {
                 var fullStateEntity = entity as FullStateEntity;
                 if (fullStateEntity != null)
-                {
-                    fullStateEntity.CreatorId = actionRequest.UserId;
-                    fullStateEntity.CreatorOrgId = actionRequest.OrgId;
-                    fullStateEntity.CreatorOrgLevel = actionRequest.OrgLevel;
-                    fullStateEntity.CreatorOrgName = actionRequest.OrgName;
-                    fullStateEntity.CreatorName = actionRequest.UserName;
                     fullStateEntity.LastModificationTime = DateTime.Now;
-                    fullStateEntity.AreaId = actionRequest.AreaId;
 
                     entity = fullStateEntity as T ?? entity;
-                }
                 
             }          
         }
 
-        public static void ToUpdate<T, TActionRequest>(this List<T> entities, List<TActionRequest> actionRequests) where T : class, IEntity<string>, new()
-       where TActionRequest : ActionRequest
+        public static void ToUpdate<T>(this List<T> entities) where T : class, IEntity<string>, new()       
         {
             foreach (var entity in entities)
             {
-                var actionRequest = actionRequests.FirstOrDefault(x => x.Id == entity.Id);
-                if (actionRequest != null)
-                {
-                    entity.ToUpdate(actionRequest);
-                }
+                entity.ToUpdate();
             }
         }
     }

+ 0 - 2
src/Hotline.Repository.SqlSugar/Hotline.Repository.SqlSugar.csproj

@@ -12,8 +12,6 @@
 
   <ItemGroup>
     <ProjectReference Include="..\01.Infrastructure\Exam.Infrastructure.Validation\Exam.Infrastructure.Validation.csproj" />
-    <ProjectReference Include="..\Exam.Infrastructure.Validation\Exam.Infrastructure.Validation.csproj" />
-    <ProjectReference Include="..\Exam.Infrastructure\Exam.Infrastructure.csproj" />
     <ProjectReference Include="..\Hotline\Hotline.csproj" />
   </ItemGroup>
 

+ 7 - 5
src/Hotline.Repository.SqlSugar/Interface/IApiService.cs

@@ -7,16 +7,18 @@ using XF.Domain.Entities;
 
 namespace Hotline.Repository.SqlSugar.Interface
 {
-    public interface IApiService<T,TEntity>: IDomainService where T : IActionRequest
+    public interface IApiService<TAdd,TUpdate,TEntity>: IDomainService 
+        where TAdd : IAddRequest
+        where TUpdate : IActionRequest
         where TEntity : class, IEntity<string>, new()
     {
-        Task AddAsync(T actionRequest,CancellationToken cancellationToken);
+        Task<string> AddAsync(TAdd actionRequest,CancellationToken cancellationToken);
 
-        Task AddAsync(List<T> actionRequests, CancellationToken cancellationToken);
+        Task AddAsync(List<TAdd> actionRequests, CancellationToken cancellationToken);
 
-        Task UpdateAsync(T actionRequest, CancellationToken cancellationToken);
+        Task UpdateAsync(TUpdate actionRequest, CancellationToken cancellationToken);
 
-        Task UpdateAsync(List<T> actionRequests, CancellationToken cancellationToken);
+        Task UpdateAsync(List<TUpdate> actionRequests, CancellationToken cancellationToken);
 
         Task DeleteAsync(EntityQueryRequest entityQueryRequest, CancellationToken cancellationToken);
 

+ 1 - 1
src/Hotline.Repository.SqlSugar/Interface/IExamRepository.cs

@@ -19,7 +19,7 @@ namespace Hotline.Repository.SqlSugar.Interface
         /// <param name="entity"></param>
         /// <param name="cancellationToken"></param>
         /// <returns></returns>
-        public Task AddWithValidateAsync(TEntity entity, CancellationToken cancellationToken);
+        public Task<string> AddWithValidateAsync(TEntity entity, CancellationToken cancellationToken);
 
         /// <summary>
         /// 单表批量新增

+ 16 - 14
src/Hotline.Repository.SqlSugar/Service/ApiService.cs

@@ -1,4 +1,5 @@
 using Exam.Infrastructure.Data.Entity;
+using Exam.Infrastructure.Data.Interface;
 using FluentValidation;
 using Hotline.Repository.SqlSugar.Entitys;
 using Hotline.Repository.SqlSugar.Extensions;
@@ -10,7 +11,9 @@ using XF.Domain.Entities;
 
 namespace Exam.Insfrastructure.Service.Service
 {
-    public class ApiService<T, TActionRequest, TDBContext> : IApiService<TActionRequest,T> where TActionRequest : ActionRequest
+    public class ApiService<T,TAdd, TUpdate, TDBContext> : IApiService<TAdd,TUpdate, T> 
+        where TAdd : IAddRequest
+        where TUpdate: IActionRequest
         where T : class, IEntity<string>, IHasCreationTime, IDataPermission, new()
         where TDBContext : SugarUnitOfWork, new()
     {
@@ -35,14 +38,13 @@ namespace Exam.Insfrastructure.Service.Service
         /// <param name="actionRequest"></param>
         /// <param name="cancellationToken"></param>
         /// <returns></returns>
-        public virtual async Task AddAsync(TActionRequest actionRequest, CancellationToken cancellationToken)
+        public virtual async Task<string> AddAsync(TAdd actionRequest, CancellationToken cancellationToken)
         {
             var entity = _mapper.Map<T>(actionRequest);
 
-            entity.ToInsert(actionRequest);
+            entity.ToInsert();
 
-
-            await _repository.AddWithValidateAsync(entity, cancellationToken);
+            return await _repository.AddWithValidateAsync(entity, cancellationToken);
         }
 
         /// <summary>
@@ -51,11 +53,11 @@ namespace Exam.Insfrastructure.Service.Service
         /// <param name="actionRequests"></param>
         /// <param name="cancellationToken"></param>
         /// <returns></returns>
-        public virtual async Task AddAsync(List<TActionRequest> actionRequests, CancellationToken cancellationToken)
+        public virtual async Task AddAsync(List<TAdd> actionRequests, CancellationToken cancellationToken)
         {
             var entities = _mapper.Map<List<T>>(actionRequests);
 
-            entities.ToInsert(actionRequests);
+            entities.ToInsert();
 
             await _repository.AddWithValidateAsync(entities, cancellationToken);
         }
@@ -77,13 +79,13 @@ namespace Exam.Insfrastructure.Service.Service
         /// <param name="actionRequest"></param>
         /// <param name="cancellationToken"></param>
         /// <returns></returns>
-        public virtual async Task UpdateAsync(TActionRequest actionRequest, CancellationToken cancellationToken)
+        public virtual async Task UpdateAsync(TUpdate actionRequest, CancellationToken cancellationToken)
         {
             var entity = await _repository.GetAsync(actionRequest.Id);
 
-            entity = _mapper.Map<TActionRequest, T>(actionRequest,entity);
+            entity = _mapper.Map<TUpdate, T>(actionRequest,entity);
 
-            entity.ToUpdate(actionRequest);
+            entity.ToUpdate();
 
             await _repository.UpdateWithValidateAsync(entity, cancellationToken);
         }
@@ -94,14 +96,14 @@ namespace Exam.Insfrastructure.Service.Service
         /// <param name="actionRequests"></param>
         /// <param name="cancellationToken"></param>
         /// <returns></returns>
-        public virtual async Task UpdateAsync(List<TActionRequest> actionRequests, CancellationToken cancellationToken)
+        public virtual async Task UpdateAsync(List<TUpdate> actionRequests, CancellationToken cancellationToken)
         {
             var ids = actionRequests.Select(x => x.Id).ToList();
             var entities = await _repository.QueryAsync(x => ids.Contains(x.Id));
 
-            entities = _mapper.Map<List<TActionRequest>, List<T>>(actionRequests,entities);
+            entities = _mapper.Map<List<TUpdate>, List<T>>(actionRequests,entities);
 
-            entities.ToUpdate(actionRequests);
+            entities.ToUpdate();
 
             await _repository.UpdateWithValidateAsync(entities, cancellationToken);
         }
@@ -119,7 +121,7 @@ namespace Exam.Insfrastructure.Service.Service
 
             entities = _mapper.Map<List<StatusActionRequest>, List<T>>(statusActionRequests,entities);
 
-            entities.ToUpdate(statusActionRequests);
+            entities.ToUpdate();
 
             await _repository.UpdateWithValidateAsync(entities, cancellationToken);
         }

+ 5 - 5
src/Hotline.Repository.SqlSugar/Validate/BaseValidator.cs

@@ -19,11 +19,11 @@ namespace Hotline.Repository.SqlSugar.Validate
         protected virtual void BaseValidateRule()
         {
             RuleFor(m => m.Id).NotEmpty().WithMessage(x => string.Format(ErrorMessage.IsRequired, x.GetType().GetDescription(nameof(CreationEntity.Id))));
-            RuleFor(m => m.CreatorId).NotEmpty().WithMessage(x => string.Format(ErrorMessage.IsRequired, x.GetType().GetDescription(nameof(CreationEntity.CreatorId))));
-            RuleFor(m => m.CreatorName).NotEmpty().WithMessage(x => string.Format(ErrorMessage.IsRequired, x.GetType().GetDescription(nameof(CreationEntity.CreatorName))));
-            RuleFor(m => m.CreatorOrgId).NotEmpty().WithMessage(x => string.Format(ErrorMessage.IsRequired, x.GetType().GetDescription(nameof(CreationEntity.CreatorOrgId))));
-            RuleFor(m => m.CreatorOrgLevel).NotEmpty().WithMessage(x => string.Format(ErrorMessage.IsRequired, x.GetType().GetDescription(nameof(CreationEntity.CreatorOrgLevel))));
-            RuleFor(m => m.CreatorOrgName).NotEmpty().WithMessage(x => string.Format(ErrorMessage.IsRequired, x.GetType().GetDescription(nameof(CreationEntity.CreatorOrgName))));
+            //RuleFor(m => m.CreatorId).NotEmpty().WithMessage(x => string.Format(ErrorMessage.IsRequired, x.GetType().GetDescription(nameof(CreationEntity.CreatorId))));
+            //RuleFor(m => m.CreatorName).NotEmpty().WithMessage(x => string.Format(ErrorMessage.IsRequired, x.GetType().GetDescription(nameof(CreationEntity.CreatorName))));
+            //RuleFor(m => m.CreatorOrgId).NotEmpty().WithMessage(x => string.Format(ErrorMessage.IsRequired, x.GetType().GetDescription(nameof(CreationEntity.CreatorOrgId))));
+            //RuleFor(m => m.CreatorOrgLevel).NotEmpty().WithMessage(x => string.Format(ErrorMessage.IsRequired, x.GetType().GetDescription(nameof(CreationEntity.CreatorOrgLevel))));
+            //RuleFor(m => m.CreatorOrgName).NotEmpty().WithMessage(x => string.Format(ErrorMessage.IsRequired, x.GetType().GetDescription(nameof(CreationEntity.CreatorOrgName))));
         }
     }
 }

+ 52 - 6
src/Hotline.Share/Dtos/ExamManages/ExamManageDto.cs

@@ -1,4 +1,6 @@
 using Exam.Infrastructure.Data.Entity;
+using Exam.Infrastructure.Data.Interface;
+using Hotline.Share.Enums.Exams;
 using System.ComponentModel;
 
 namespace Exam.Share
@@ -7,7 +9,26 @@ namespace Exam.Share
     /// 考试管理
     /// </summary>
     [Description("考试管理")]
-    public class ExamManageDto:ActionRequest
+    public class ExamManageDto:UpdateExamManageDto
+    {
+        /// <summary>
+        /// 题型分数
+        /// </summary>
+        [Description("题型分数")]
+        public new List<ExamQuestionScoreDto> ExamQuestionScoreDtos { get; set; }
+
+        /// <summary>
+        /// 参考人员
+        /// </summary>
+        [Description("参考人员")]
+        public new  List<UserExamDto> UserExamDtos { get; set; }
+    }
+
+    /// <summary>
+    /// 考试管理
+    /// </summary>
+    [Description("考试管理")]
+    public class AddExamManageDto : IAddRequest
     {
         /// <summary>
         /// 考试标题
@@ -25,19 +46,19 @@ namespace Exam.Share
         /// 考试类型
         /// </summary>
         [Description("考试类型")]
-        public int Type { get; set; }
+        public EExamType ExamType { get; set; }
 
         /// <summary>
         /// 组卷方式
         /// </summary>
         [Description("组卷方式")]
-        public int Mode { get; set; }
+        public EExamMode Mode { get; set; }
 
         /// <summary>
         /// 考核方式
         /// </summary>
         [Description("考核方式")]
-        public int Method { get; set; }
+        public EMethod Method { get; set; }
 
         /// <summary>
         /// 试卷Id
@@ -103,12 +124,37 @@ namespace Exam.Share
         /// 题型分数
         /// </summary>
         [Description("题型分数")]
-        public List<ExamQuestionScoreDto> ExamQuestionScoreDtos { get; set; }
+        public List<AddExamQuestionScoreDto> ExamQuestionScoreDtos { get; set; }
+
+        /// <summary>
+        /// 参考人员
+        /// </summary>
+        [Description("参考人员")]
+        public List<AddUserExamDto> UserExamDtos { get; set; }
+    }
+
+    /// <summary>
+    /// 考试管理
+    /// </summary>
+    [Description("考试管理")]
+    public class UpdateExamManageDto : AddExamManageDto, IActionRequest
+    {
+        /// <summary>
+        /// 主键
+        /// </summary>
+        [Description("主键")]
+        public string Id { get; set; }
+
+        /// <summary>
+        /// 题型分数
+        /// </summary>
+        [Description("题型分数")]
+        public new  List<UpdateExamQuestionScoreDto> ExamQuestionScoreDtos { get; set; }
 
         /// <summary>
         /// 参考人员
         /// </summary>
         [Description("参考人员")]
-        public List<UserExamDto> UserExamDtos { get; set; }
+        public new  List<UpdateUserExamDto> UserExamDtos { get; set; }
     }
 }

+ 35 - 3
src/Hotline.Share/Dtos/ExamManages/ExamQuestionScoreDto.cs

@@ -1,4 +1,7 @@
-using Exam.Infrastructure.Data.Entity;
+using Exam.Infrastructure.Data.Interface;
+using Exam.Infrastructure.Enums;
+using Hotline.Share.Enums.Exams;
+using Hotline.Share.Exams.Interface;
 using System.ComponentModel;
 
 namespace Exam.Share
@@ -7,13 +10,22 @@ namespace Exam.Share
     /// 题型分数
     /// </summary>
     [Description("题型分数")]
-    public class ExamQuestionScoreDto:ActionRequest
+    public class ExamQuestionScoreDto: UpdateExamQuestionScoreDto
+    {
+       
+    }
+
+    /// <summary>
+    /// 题型分数
+    /// </summary>
+    [Description("题型分数")]
+    public class AddExamQuestionScoreDto : IAddRequest,IOperationStatus
     {
         /// <summary>
         /// 试题类型
         /// </summary>
         [Description("试题类型")]
-        public int Type { get; set; }
+        public EQuestionType QuestionType { get; set; }
 
         /// <summary>
         /// 试题分数
@@ -26,5 +38,25 @@ namespace Exam.Share
         /// </summary>
         [Description("考试管理Id")]
         public string ExamManageId { get; set; }
+
+        /// <summary>
+        /// 操作状态        
+        /// </summary>
+        [Description("操作状态")]
+        public EEOperationStatus OperationStatus { get; set; }
+    }
+
+    /// <summary>
+    /// 题型分数
+    /// </summary>
+    [Description("题型分数")]
+    public class UpdateExamQuestionScoreDto : AddExamQuestionScoreDto,IActionRequest
+    {
+
+        /// <summary>
+        /// 主键
+        /// </summary>
+        [Description("主键")]
+        public string Id { get; set; }
     }
 }

+ 23 - 1
src/Hotline.Share/Dtos/ExamManages/ExamTagDto.cs

@@ -1,4 +1,5 @@
 using Exam.Infrastructure.Data.Entity;
+using Exam.Infrastructure.Data.Interface;
 using System.ComponentModel;
 
 namespace Hotline.Share.Dtos.ExamManages
@@ -7,7 +8,16 @@ namespace Hotline.Share.Dtos.ExamManages
     /// 考试标签
     /// </summary>
     [Description("考试标签")]
-    public class ExamTagDto:ActionRequest
+    public class ExamTagDto:UpdateExamTagDto
+    {
+        
+    }
+
+    /// <summary>
+    /// 考试标签
+    /// </summary>
+    [Description("考试标签")]
+    public class AddExamTagDto : IAddRequest
     {
         /// <summary>
         /// 名称
@@ -21,4 +31,16 @@ namespace Hotline.Share.Dtos.ExamManages
         [Description("父级ID")]
         public string ParentId { get; set; }
     }
+
+    /// <summary>
+    /// 主键
+    /// </summary>
+    public class UpdateExamTagDto :AddExamTagDto, IActionRequest
+    {
+        /// <summary>
+        /// 主键
+        /// </summary>
+        [Description("主键")]
+        public string Id { get; set; }
+    }
 }

+ 46 - 4
src/Hotline.Share/Dtos/ExamManages/UserExamDto.cs

@@ -1,4 +1,8 @@
 using Exam.Infrastructure.Data.Entity;
+using Exam.Infrastructure.Data.Interface;
+using Exam.Infrastructure.Enums;
+using Hotline.Share.Enums.Exams;
+using Hotline.Share.Exams.Interface;
 using System.ComponentModel;
 
 namespace Exam.Share
@@ -7,7 +11,20 @@ namespace Exam.Share
     /// 用户考试
     /// </summary>
     [Description("用户考试")]
-    public class UserExamDto:ActionRequest
+    public class UserExamDto:UpdateUserExamDto
+    {       
+        /// <summary>
+        /// 用户考试明细
+        /// </summary>
+        [Description("用户考试明细")]
+        public new List<UserExamItemDto> UserExamItems { get; set; }
+    }
+
+    /// <summary>
+    /// 用户考试
+    /// </summary>
+    [Description("用户考试")]
+    public class AddUserExamDto : IAddRequest,IOperationStatus
     {
         /// <summary>
         /// 用户Id
@@ -37,18 +54,43 @@ namespace Exam.Share
         /// 考试状态
         /// </summary>
         [Description("考试状态")]
-        public int ExamStatus { get; set; }
+        public EExamStatus ExamStatus { get; set; }
 
         /// <summary>
         /// 是否已阅卷
         /// </summary>
         [Description("是否已阅卷")]
-        public int IsCheck { get; set; }
+        public ECheck IsCheck { get; set; }
+
+        /// <summary>
+        /// 用户考试明细
+        /// </summary>
+        [Description("用户考试明细")]
+        public List<AddUserExamItemDto> UserExamItems { get; set; }
+
+        /// <summary>
+        /// 操作状态        
+        /// </summary>
+        [Description("操作状态")]
+        public EEOperationStatus OperationStatus { get; set; }
+    }
+
+    /// <summary>
+    /// 用户考试
+    /// </summary>
+    [Description("用户考试")]
+    public class UpdateUserExamDto : AddUserExamDto,IActionRequest
+    {
+        /// <summary>
+        /// 主键
+        /// </summary>
+        [Description("主键")]
+        public string Id { get; set; }
 
         /// <summary>
         /// 用户考试明细
         /// </summary>
         [Description("用户考试明细")]
-        public List<UserExamItemDto> UserExamItems { get; set; }
+        public new List<UpdateUserExamItemDto> UserExamItems { get; set; }
     }
 }

+ 33 - 4
src/Hotline.Share/Dtos/ExamManages/UserExamItemDto.cs

@@ -1,5 +1,8 @@
 using Exam.Infrastructure.Data.Entity;
+using Exam.Infrastructure.Data.Interface;
+using Exam.Infrastructure.Enums;
 using Hotline.Share.Dtos.Questions;
+using Hotline.Share.Exams.Interface;
 using System.ComponentModel;
 
 namespace Exam.Share
@@ -8,7 +11,20 @@ namespace Exam.Share
     /// 用户考试明细
     /// </summary>
     [Description("用户考试明细")]
-    public class UserExamItemDto : ActionRequest
+    public class UserExamItemDto : UpdateUserExamItemDto
+    {
+        /// <summary>
+        /// 试题
+        /// </summary>
+        [Description("试题")]
+        public QuestionDto Question { get; set; }
+    }
+
+    /// <summary>
+    /// 用户考试明细
+    /// </summary>
+    [Description("用户考试明细")]
+    public class AddUserExamItemDto : IAddRequest,IOperationStatus
     {
         /// <summary>
         /// 用户考试Id
@@ -23,9 +39,22 @@ namespace Exam.Share
         public string QuestionId { get; set; }
 
         /// <summary>
-        /// 试题
+        /// 操作状态        
         /// </summary>
-        [Description("试题")]
-        public QuestionDto Question { get; set; }
+        [Description("操作状态")]
+        public EEOperationStatus OperationStatus { get; set; }
+    }
+
+    /// <summary>
+    /// 用户考试明细
+    /// </summary>
+    [Description("用户考试明细")]
+    public class UpdateUserExamItemDto : AddUserExamItemDto, IActionRequest
+    {
+        /// <summary>
+        /// 主键
+        /// </summary>
+        [Description("主键")]
+        public string Id { get; set; }
     }
 }

+ 35 - 2
src/Hotline.Share/Dtos/Practices/PracticeDto.cs

@@ -1,4 +1,5 @@
 using Exam.Infrastructure.Data.Entity;
+using Exam.Infrastructure.Data.Interface;
 using Hotline.Share.Dtos.Practices;
 using System.ComponentModel;
 
@@ -8,7 +9,20 @@ namespace Exam.Share
     /// 练习
     /// </summary>
     [Description("练习")]
-    public class PracticeDto:ActionRequest
+    public class PracticeDto:UpdatePracticeDto
+    {
+        /// <summary>
+        /// 练习标签
+        /// </summary>
+        [Description("练习标签")]
+        public new List<PracticeTagDto> PracticeTagDtos { get; set; }
+    }
+
+    /// <summary>
+    /// 练习
+    /// </summary>
+    [Description("练习")]
+    public class AddPracticeDto : IAddRequest
     {
         /// <summary>
         /// 练习流水号
@@ -33,6 +47,25 @@ namespace Exam.Share
         /// 练习标签
         /// </summary>
         [Description("练习标签")]
-        public List<PracticeTagDto> PracticeTagDtos { get; set; }
+        public List<AddPracticeTagDto> PracticeTagDtos { get; set; }
+    }
+
+    /// <summary>
+    /// 练习
+    /// </summary>
+    [Description("练习")]
+    public class UpdatePracticeDto : AddPracticeDto,IActionRequest
+    {
+        /// <summary>
+        /// 主键
+        /// </summary>
+        [Description("主键")]
+        public string Id { get; set; }
+        
+        /// <summary>
+        /// 练习标签
+        /// </summary>
+        [Description("练习标签")]
+        public new List<UpdatePracticeTagDto> PracticeTagDtos { get; set; }
     }
 }

+ 33 - 1
src/Hotline.Share/Dtos/Practices/PracticeTagDto.cs

@@ -1,4 +1,7 @@
 using Exam.Infrastructure.Data.Entity;
+using Exam.Infrastructure.Data.Interface;
+using Exam.Infrastructure.Enums;
+using Hotline.Share.Exams.Interface;
 using System.ComponentModel;
 
 namespace Hotline.Share.Dtos.Practices
@@ -7,7 +10,16 @@ namespace Hotline.Share.Dtos.Practices
     /// 练习标签
     /// </summary>
     [Description("练习标签")]
-    public class PracticeTagDto:ActionRequest
+    public class PracticeTagDto:UpdatePracticeTagDto
+    {
+        
+    }
+
+    /// <summary>
+    /// 练习标签
+    /// </summary>
+    [Description("练习标签")]
+    public class AddPracticeTagDto : IAddRequest,IOperationStatus
     {
         /// <summary>
         /// 题目标签
@@ -20,5 +32,25 @@ namespace Hotline.Share.Dtos.Practices
         /// </summary>
         [Description("练习Id")]
         public string PracticeId { get; set; }
+
+        /// <summary>
+        /// 操作状态        
+        /// </summary>
+        [Description("操作状态")]
+        public EEOperationStatus OperationStatus { get; set; }
+
+    }
+
+    /// <summary>
+    /// 练习标签
+    /// </summary>
+    [Description("练习标签")]
+    public class UpdatePracticeTagDto : AddPracticeTagDto,IActionRequest
+    {
+        /// <summary>
+        /// 主键
+        /// </summary>
+        [Description("主键")]
+        public string Id { get; set; }
     }
 }

+ 33 - 1
src/Hotline.Share/Dtos/Questions/QuestionAnswerDto.cs

@@ -1,4 +1,7 @@
 using Exam.Infrastructure.Data.Entity;
+using Exam.Infrastructure.Data.Interface;
+using Exam.Infrastructure.Enums;
+using Hotline.Share.Exams.Interface;
 using System.ComponentModel;
 
 namespace Hotline.Share.Dtos.Questions
@@ -7,7 +10,16 @@ namespace Hotline.Share.Dtos.Questions
     /// 试题参考答案
     /// </summary>
     [Description("试题参考答案")]
-    public class QuestionAnswerDto:ActionRequest
+    public class QuestionAnswerDto:UpdateQuestionAnswerDto
+    {
+
+    }
+
+    /// <summary>
+    /// 试题参考答案
+    /// </summary>
+    [Description("试题参考答案")]
+    public class AddQuestionAnswerDto : IAddRequest,IOperationStatus
     {
         /// <summary>
         /// 试题Id
@@ -20,5 +32,25 @@ namespace Hotline.Share.Dtos.Questions
         /// </summary>
         [Description("答案")]
         public string? Answer { get; set; }
+
+        /// <summary>
+        /// 操作状态        
+        /// </summary>
+        [Description("操作状态")]
+        public EEOperationStatus OperationStatus { get; set; }
+
+    }
+
+    /// <summary>
+    /// 试题参考答案
+    /// </summary>
+    [Description("试题参考答案")]
+    public class UpdateQuestionAnswerDto : AddQuestionAnswerDto,IActionRequest
+    {
+        /// <summary>
+        /// 主键
+        /// </summary>
+        [Description("主键")]
+        public string Id { get; set; }
     }
 }

+ 84 - 8
src/Hotline.Share/Dtos/Questions/QuestionDto.cs

@@ -1,4 +1,5 @@
 using Exam.Infrastructure.Data.Entity;
+using Exam.Infrastructure.Data.Interface;
 using Hotline.Share.Enums.Exams;
 using System.ComponentModel;
 
@@ -8,7 +9,42 @@ namespace Hotline.Share.Dtos.Questions
     /// 试题
     /// </summary>
     [Description("试题")]
-    public class QuestionDto : ActionRequest
+    public class QuestionDto : UpdateQuestionDto
+    {
+        /// <summary>
+        /// 试题标签
+        /// </summary>
+        [Description("试题标签")]
+        public new List<QuestionTagDto> QuestionTagDtos { get; set; }
+
+        /// <summary>
+        /// 参考答案
+        /// </summary>
+        [Description("参考答案")]
+        public new QuestionAnswerDto QuestionAnswerDto { get; set; }
+
+        /// <summary>
+        /// 试题选项
+        /// </summary>
+        [Description("试题选项")]
+        public new List<QuestionOptionsDto> QuestionOptionsDtos { get; set; }
+
+
+        /// <summary>
+        /// 关联课件
+        /// </summary>
+        [Description("关联课件")]
+        public new List<QuestionSourcewareDto> QuestionSourcewareDtos { get; set; }
+
+        /// <summary>
+        /// 关联知识
+        /// </summary>
+        [Description("关联知识")]
+        public new List<QuestionKnowladgeDto> QuestionKnowladgeDtos { get; set; }
+    }
+
+
+    public class AddQuestionDto:IAddRequest
     {
         /// <summary>
         /// 题干
@@ -52,35 +88,75 @@ namespace Hotline.Share.Dtos.Questions
         /// </summary>
         [Description("权重")]
         public int Weight { get; set; }
-        
+
+        /// <summary>
+        /// 试题标签
+        /// </summary>
+        [Description("试题标签")]
+        public List<AddQuestionTagDto> QuestionTagDtos { get; set; }
+
+        /// <summary>
+        /// 参考答案
+        /// </summary>
+        [Description("参考答案")]
+        public AddQuestionAnswerDto QuestionAnswerDto { get; set; }
+
+        /// <summary>
+        /// 试题选项
+        /// </summary>
+        [Description("试题选项")]
+        public List<AddQuestionOptionsDto> QuestionOptionsDtos { get; set; }
+
+
+        /// <summary>
+        /// 关联课件
+        /// </summary>
+        [Description("关联课件")]
+        public List<AddQuestionSourcewareDto> QuestionSourcewareDtos { get; set; }
+        /// <summary>
+        /// 关联知识
+        /// </summary>
+        [Description("关联知识")]
+        public List<AddQuestionKnowladgeDto> QuestionKnowladgeDtos { get; set; }
+    }
+
+    public class UpdateQuestionDto:AddQuestionDto, IActionRequest
+    {
+        /// <summary>
+        /// 主键
+        /// </summary>
+        [Description("主键")]
+        public string Id { get; set; }
+
         /// <summary>
         /// 试题标签
         /// </summary>
         [Description("试题标签")]
-        public List<QuestionTagDto> QuestionTagDtos { get; set; }
+        public new List<UpdateQuestionTagDto> QuestionTagDtos { get; set; }
 
         /// <summary>
         /// 参考答案
         /// </summary>
         [Description("参考答案")]
-        public QuestionAnswerDto QuestionAnswerDto { get; set; }
+        public new  UpdateQuestionAnswerDto QuestionAnswerDto { get; set; }
 
         /// <summary>
         /// 试题选项
         /// </summary>
         [Description("试题选项")]
-        public List<QuestionOptionsDto> QuestionOptionsDtos { get; set; }
+        public new List<UpdateQuestionOptionsDto> QuestionOptionsDtos { get; set; }
+
 
-     
         /// <summary>
         /// 关联课件
         /// </summary>
         [Description("关联课件")]
-        public List<QuestionSourcewareDto> QuestionSourcewareDtos { get; set; }
+        public new List<UpdateQuestionSourcewareDto> QuestionSourcewareDtos { get; set; }
+
         /// <summary>
         /// 关联知识
         /// </summary>
         [Description("关联知识")]
-        public List<QuestionKnowladgeDto> QuestionKnowladgeDtos { get; set; }
+        public new List<UpdateQuestionKnowladgeDto> QuestionKnowladgeDtos { get; set; }
     }
 }

+ 33 - 1
src/Hotline.Share/Dtos/Questions/QuestionKnowladgeDto.cs

@@ -1,4 +1,7 @@
 using Exam.Infrastructure.Data.Entity;
+using Exam.Infrastructure.Data.Interface;
+using Exam.Infrastructure.Enums;
+using Hotline.Share.Exams.Interface;
 using System.ComponentModel;
 
 namespace Hotline.Share.Dtos.Questions
@@ -7,7 +10,16 @@ namespace Hotline.Share.Dtos.Questions
     /// 关联知识
     /// </summary>
     [Description("关联知识")]
-    public class QuestionKnowladgeDto:ActionRequest
+    public class QuestionKnowladgeDto:UpdateQuestionKnowladgeDto
+    {
+
+    }
+
+    /// <summary>
+    /// 关联知识
+    /// </summary>
+    [Description("关联知识")]
+    public class AddQuestionKnowladgeDto : IAddRequest,IOperationStatus
     {
         /// <summary>
         /// 试题Id
@@ -20,5 +32,25 @@ namespace Hotline.Share.Dtos.Questions
         /// </summary>
         [Description("知识Id")]
         public string KnowladgeId { get; set; }
+
+        /// <summary>
+        /// 操作状态        
+        /// </summary>
+        [Description("操作状态")]
+        public EEOperationStatus OperationStatus { get; set; }
+
+    }
+
+    /// <summary>
+    /// 关联知识
+    /// </summary>
+    [Description("关联知识")]
+    public class UpdateQuestionKnowladgeDto : AddQuestionKnowladgeDto,IActionRequest
+    {
+        /// <summary>
+        /// 主键
+        /// </summary>
+        [Description("主键")]
+        public string Id { get; set; }
     }
 }

+ 32 - 1
src/Hotline.Share/Dtos/Questions/QuestionOptionsDto.cs

@@ -1,4 +1,7 @@
 using Exam.Infrastructure.Data.Entity;
+using Exam.Infrastructure.Data.Interface;
+using Exam.Infrastructure.Enums;
+using Hotline.Share.Exams.Interface;
 using System.ComponentModel;
 
 namespace Hotline.Share.Dtos.Questions
@@ -7,7 +10,16 @@ namespace Hotline.Share.Dtos.Questions
     /// 试题选项
     /// </summary>
     [Description("试题选项")]
-    public class QuestionOptionsDto:ActionRequest
+    public class QuestionOptionsDto:UpdateQuestionOptionsDto
+    {
+        
+    }
+
+    /// <summary>
+    /// 试题选项
+    /// </summary>
+    [Description("试题选项")]
+    public class AddQuestionOptionsDto : IAddRequest,IOperationStatus
     {
         /// <summary>
         /// 选项内容
@@ -26,5 +38,24 @@ namespace Hotline.Share.Dtos.Questions
         /// </summary>
         [Description("试题")]
         public string QuestionId { get; set; }
+
+        /// <summary>
+        /// 操作状态        
+        /// </summary>
+        [Description("操作状态")]
+        public EEOperationStatus OperationStatus { get; set; }
+    }
+
+    /// <summary>
+    /// 试题选项
+    /// </summary>
+    [Description("试题选项")]
+    public class UpdateQuestionOptionsDto : AddQuestionOptionsDto,IActionRequest
+    {
+        /// <summary>
+        /// 主键
+        /// </summary>
+        [Description("主键")]
+        public string Id { get; set; }
     }
 }

+ 32 - 1
src/Hotline.Share/Dtos/Questions/QuestionSourcewareDto.cs

@@ -1,4 +1,7 @@
 using Exam.Infrastructure.Data.Entity;
+using Exam.Infrastructure.Data.Interface;
+using Exam.Infrastructure.Enums;
+using Hotline.Share.Exams.Interface;
 using System.ComponentModel;
 
 namespace Hotline.Share.Dtos.Questions
@@ -7,7 +10,16 @@ namespace Hotline.Share.Dtos.Questions
     /// 关联课件
     /// </summary>
     [Description("关联课件")]
-    public class QuestionSourcewareDto:ActionRequest
+    public class QuestionSourcewareDto:UpdateQuestionSourcewareDto
+    {
+
+    }
+
+    /// <summary>
+    /// 关联课件
+    /// </summary>
+    [Description("关联课件")]
+    public class AddQuestionSourcewareDto : IAddRequest,IOperationStatus
     {
         /// <summary>
         /// 试题Id
@@ -26,5 +38,24 @@ namespace Hotline.Share.Dtos.Questions
         /// </summary>
         [Description("课件")]
         public string Sourceware { get; set; }
+
+        /// <summary>
+        /// 操作状态        
+        /// </summary>
+        [Description("操作状态")]
+        public EEOperationStatus OperationStatus { get; set; }
+    }
+
+    /// <summary>
+    /// 关联课件
+    /// </summary>
+    [Description("关联课件")]
+    public class UpdateQuestionSourcewareDto : AddQuestionSourcewareDto,IActionRequest
+    {
+        /// <summary>
+        /// 主键
+        /// </summary>
+        [Description("主键")]
+        public string Id { get; set; }
     }
 }

+ 36 - 6
src/Hotline.Share/Dtos/Questions/QuestionTagDto.cs

@@ -1,4 +1,7 @@
 using Exam.Infrastructure.Data.Entity;
+using Exam.Infrastructure.Data.Interface;
+using Exam.Infrastructure.Enums;
+using Hotline.Share.Exams.Interface;
 using System.ComponentModel;
 
 namespace Hotline.Share.Dtos.Questions
@@ -7,7 +10,20 @@ namespace Hotline.Share.Dtos.Questions
     /// 试题标签
     /// </summary>
     [Description("试题标签")]
-    public class QuestionTagDto:ActionRequest
+    public class QuestionTagDto:UpdateQuestionTagDto
+    {
+        /// <summary>
+        /// 标签
+        /// </summary>
+        [Description("标签")]
+        public string Tag { get; set; }
+    }
+
+    /// <summary>
+    /// 试题标签
+    /// </summary>
+    [Description("试题标签")]
+    public class AddQuestionTagDto : IAddRequest, IOperationStatus
     {
         /// <summary>
         /// 标签Id
@@ -15,16 +31,30 @@ namespace Hotline.Share.Dtos.Questions
         [Description("标签Id")]
         public string TagId { get; set; }
 
-        /// <summary>
-        /// 标签
-        /// </summary>
-        [Description("标签")]
-        public string Tag { get; set; }
 
         /// <summary>
         /// 试题Id
         /// </summary>
         [Description("试题Id")]
         public string QuestionId { get; set; }
+
+        /// <summary>
+        /// 操作状态        
+        /// </summary>
+        [Description("操作状态")]
+        public EEOperationStatus OperationStatus { get; set; }
+    }
+
+    /// <summary>
+    /// 试题标签
+    /// </summary>
+    [Description("试题标签")]
+    public class UpdateQuestionTagDto : AddQuestionTagDto,IActionRequest
+    {
+        /// <summary>
+        /// 主键
+        /// </summary>
+        [Description("主键")]
+        public string Id { get; set; }
     }
 }

+ 19 - 1
src/Hotline.Share/Dtos/Sourcewares/SourcewareCategoryDto.cs

@@ -1,4 +1,5 @@
 using Exam.Infrastructure.Data.Entity;
+using Exam.Infrastructure.Data.Interface;
 using System.ComponentModel;
 
 namespace Hotline.Share.Dtos.Sourcewares
@@ -7,7 +8,13 @@ namespace Hotline.Share.Dtos.Sourcewares
     /// 课件类型
     /// </summary>
     [Description("课件类型")]
-    public class SourcewareCategoryDto : ActionRequest
+    public class SourcewareCategoryDto : UpdateSourcewareCategoryDto
+    {
+       
+
+    }
+
+    public class AddSourcewareCategoryDto : IAddRequest
     {
         /// <summary>
         /// 名称
@@ -20,6 +27,17 @@ namespace Hotline.Share.Dtos.Sourcewares
         /// </summary>
         [Description("父级ID")]
         public string ParentId { get; set; }
+    }
 
+    /// <summary>
+    /// 主键
+    /// </summary>
+    public class UpdateSourcewareCategoryDto : AddSourcewareCategoryDto, IActionRequest
+    {
+        /// <summary>
+        /// 主键
+        /// </summary>
+        [Description("主键")]
+        public string Id { get; set; }
     }
 }

+ 28 - 7
src/Hotline.Share/Dtos/Sourcewares/SourcewareDto.cs

@@ -1,4 +1,5 @@
 using Exam.Infrastructure.Data.Entity;
+using Exam.Infrastructure.Data.Interface;
 using System.ComponentModel;
 
 namespace Hotline.Share.Dtos.Sourcewares
@@ -7,7 +8,20 @@ namespace Hotline.Share.Dtos.Sourcewares
     /// 课件
     /// </summary>
     [Description("课件")]
-    public class SourcewareDto:ActionRequest
+    public class SourcewareDto: UpdateSourcewareDto
+    {
+        /// <summary>
+        /// 课件分类
+        /// </summary>
+        [Description("课件分类")]
+        public SourcewareCategoryDto SourcewareCategory { get; set; }
+    }
+
+    /// <summary>
+    /// 课件
+    /// </summary>
+    [Description("课件")]
+    public class AddSourcewareDto:IAddRequest
     {
         /// <summary>
         /// 名称
@@ -21,12 +35,6 @@ namespace Hotline.Share.Dtos.Sourcewares
         [Description("课件分类Id")]
         public string CategoryId { get; set; }
 
-        /// <summary>
-        /// 课件分类
-        /// </summary>
-        [Description("课件分类")]
-        public SourcewareCategoryDto SourcewareCategory { get; set; }
-
         /// <summary>
         /// 附件Id
         /// </summary>
@@ -39,4 +47,17 @@ namespace Hotline.Share.Dtos.Sourcewares
         [Description("课件类型")]
         public string SourcewareType { get; set; }
     }
+
+    /// <summary>
+    /// 课件
+    /// </summary>
+    [Description("课件")]
+    public class UpdateSourcewareDto:AddSourcewareDto,IActionRequest
+    {
+        /// <summary>
+        /// 主键
+        /// </summary>
+        [Description("主键")]
+        public string Id { get; set; }
+    }
 }

+ 48 - 3
src/Hotline.Share/Dtos/TestPapers/ExtractRuleDto.cs

@@ -1,5 +1,8 @@
 using Exam.Infrastructure.Data.Entity;
+using Exam.Infrastructure.Data.Interface;
+using Exam.Infrastructure.Enums;
 using Hotline.Share.Enums.Exams;
+using Hotline.Share.Exams.Interface;
 using System.ComponentModel;
 
 namespace Hotline.Share.Dtos.TestPapers
@@ -8,7 +11,27 @@ namespace Hotline.Share.Dtos.TestPapers
     /// 抽题规则
     /// </summary>
     [Description("抽题规则")]
-    public class ExtractRuleDto : ActionRequest
+    public class ExtractRuleDto : UpdateExtractRuleDto
+    {
+       
+        /// <summary>
+        /// 抽题标签
+        /// </summary>
+        [Description("抽题标签")]
+        public new List<RuleTagDto> RuleTagDtos { get; set; }
+
+        /// <summary>
+        /// 标签试题数
+        /// </summary>
+        [Description("标签试题数")]
+        public new List<TagQuestionDto> TagQuestionDtos { get; set; }
+    }
+
+    /// <summary>
+    /// 抽题规则
+    /// </summary>
+    [Description("抽题规则")]
+    public class AddExtractRuleDto : IAddRequest
     {
         /// <summary>
         /// 规则名称
@@ -38,12 +61,34 @@ namespace Hotline.Share.Dtos.TestPapers
         /// 抽题标签
         /// </summary>
         [Description("抽题标签")]
-        public List<RuleTagDto> RuleTagDtos { get; set; }
+        public List<AddRuleTagDto> RuleTagDtos { get; set; }
+
+        /// <summary>
+        /// 标签试题数
+        /// </summary>
+        [Description("标签试题数")]
+        public List<AddTagQuestionDto> TagQuestionDtos { get; set; }
+
+    }
+
+    /// <summary>
+    /// 主键
+    /// </summary>
+    public class UpdateExtractRuleDto : AddExtractRuleDto,IActionRequest
+    {
+        [Description("主键")]
+        public string Id { get; set; }
+
+        /// <summary>
+        /// 抽题标签
+        /// </summary>
+        [Description("抽题标签")]
+        public new List<UpdateRuleTagDto> RuleTagDtos { get; set; }
 
         /// <summary>
         /// 标签试题数
         /// </summary>
         [Description("标签试题数")]
-        public List<TagQuestionDto> TagQuestionDtos { get; set; }
+        public new List<UpdateTagQuestionDto> TagQuestionDtos { get; set; }
     }
 }

+ 31 - 4
src/Hotline.Share/Dtos/TestPapers/RuleTagDto.cs

@@ -1,4 +1,7 @@
 using Exam.Infrastructure.Data.Entity;
+using Exam.Infrastructure.Data.Interface;
+using Exam.Infrastructure.Enums;
+using Hotline.Share.Exams.Interface;
 using System.ComponentModel;
 
 namespace Hotline.Share.Dtos.TestPapers
@@ -7,7 +10,18 @@ namespace Hotline.Share.Dtos.TestPapers
     /// 规则标签
     /// </summary>
     [Description("规则标签")]
-    public class RuleTagDto:ActionRequest
+    public class RuleTagDto:UpdateRuleTagDto
+    {
+        
+
+        /// <summary>
+        /// 标签
+        /// </summary>
+        [Description("标签")]
+        public string Tag { get; set; }
+    }
+
+    public class AddRuleTagDto:IAddRequest, IOperationStatus
     {
         /// <summary>
         /// 规则Id
@@ -22,9 +36,22 @@ namespace Hotline.Share.Dtos.TestPapers
         public string TagId { get; set; }
 
         /// <summary>
-        /// 标签
+        /// 操作状态        
         /// </summary>
-        [Description("标签")]
-        public string Tag { get; set; }
+        [Description("操作状态")]
+        public EEOperationStatus OperationStatus { get; set; }
+    }
+
+    /// <summary>
+    /// 主键
+    /// </summary>
+    public class UpdateRuleTagDto : AddRuleTagDto, IActionRequest
+    {
+        /// <summary>
+        /// 主键
+        /// </summary>
+        [Description("主键")]
+        public string Id { get; set; }
+
     }
 }

+ 49 - 17
src/Hotline.Share/Dtos/TestPapers/TagQuestionDto.cs

@@ -1,6 +1,9 @@
 using Exam.Infrastructure.Data.Entity;
+using Exam.Infrastructure.Data.Interface;
+using Exam.Infrastructure.Enums;
 using Exam.Infrastructure.Extensions;
 using Hotline.Share.Enums.Exams;
+using Hotline.Share.Exams.Interface;
 using System.ComponentModel;
 
 namespace Hotline.Share.Dtos.TestPapers
@@ -9,7 +12,32 @@ namespace Hotline.Share.Dtos.TestPapers
     /// 标签试题数
     /// </summary>
     [Description("标签试题数")]
-    public class TagQuestionDto:ActionRequest
+    public class TagQuestionDto : UpdateTagQuestionDto
+    {
+        /// <summary>
+        /// 标签
+        /// </summary>
+        [Description("标签")]
+        public string Tag { get; set; }
+        /// <summary>
+        /// 试题类型
+        /// </summary>
+        [Description("试题类型")]
+        public string QuestionTypeDes
+        {
+            get
+            {
+                return QuestionType.GetDescription();
+            }
+        }
+
+    }
+
+    /// <summary>
+    /// 标签试题数
+    /// </summary>
+    [Description("标签试题数")]
+    public class AddTagQuestionDto : IAddRequest, IOperationStatus
     {
         /// <summary>
         /// 标签Id
@@ -17,11 +45,6 @@ namespace Hotline.Share.Dtos.TestPapers
         [Description("标签Id")]
         public string TagId { get; set; }
 
-        /// <summary>
-        /// 标签
-        /// </summary>
-        [Description("标签")]
-        public string Tag { get; set; }
 
         /// <summary>
         /// 规则Id
@@ -35,22 +58,31 @@ namespace Hotline.Share.Dtos.TestPapers
         [Description("试题类型")]
         public EQuestionType QuestionType { get; set; }
 
-        /// <summary>
-        /// 试题类型
-        /// </summary>
-        [Description("试题类型")]
-        public string QuestionTypeDes
-        {
-            get
-            {
-                return QuestionType.GetDescription();
-            }
-        }
 
         /// <summary>
         /// 试题数量
         /// </summary>
         [Description("试题数量")]
         public int Count { get; set; }
+
+        /// <summary>
+        /// 操作状态        
+        /// </summary>
+        [Description("操作状态")]
+        public EEOperationStatus OperationStatus { get; set; }
+    }
+
+
+    /// <summary>
+    /// 标签试题数
+    /// </summary>
+    [Description("标签试题数")]
+    public class UpdateTagQuestionDto : AddTagQuestionDto, IActionRequest
+    {
+        /// <summary>
+        /// 主键
+        /// </summary>
+        [Description("主键")]
+        public string Id { get; set; }
     }
 }

+ 52 - 4
src/Hotline.Share/Dtos/TestPapers/TestPaperDto.cs

@@ -1,4 +1,5 @@
 using Exam.Infrastructure.Data.Entity;
+using Exam.Infrastructure.Data.Interface;
 using Hotline.Share.Enums.Exams;
 using System.ComponentModel;
 
@@ -8,7 +9,28 @@ namespace Hotline.Share.Dtos.TestPapers
     /// 试卷
     /// </summary>
     [Description("试卷")]
-    public class TestPaperDto : ActionRequest
+    public class TestPaperDto : UpdateTestPaperDto
+    {
+     
+        /// <summary>
+        /// 试卷详情
+        /// </summary>
+        [Description("试卷详情")]
+        public new List<TestPaperItemDto> TestPaperItemDtos { get; set; }
+
+        /// <summary>
+        /// 试卷组卷规则
+        /// </summary>
+        [Description("试卷组卷规则")]
+        public new List<TestPaperRuleDto> TestPaperRuleDtos { get; set; }
+    }
+
+
+    /// <summary>
+    /// 试卷
+    /// </summary>
+    [Description("试卷")]
+    public class AddTestPaperDto : IAddRequest
     {
         /// <summary>
         /// 试卷标题
@@ -26,7 +48,7 @@ namespace Hotline.Share.Dtos.TestPapers
         /// 考试类型
         /// </summary>
         [Description("考试类型")]
-        public EExamType Type { get; set; }
+        public EExamType ExamType { get; set; }
 
         /// <summary>
         /// 组卷方式
@@ -50,12 +72,38 @@ namespace Hotline.Share.Dtos.TestPapers
         /// 试卷详情
         /// </summary>
         [Description("试卷详情")]
-        public List<TestPaperItemDto> TestPaperItemDtos { get; set; }
+        public List<AddTestPaperItemDto> TestPaperItemDtos { get; set; }
+
+        /// <summary>
+        /// 试卷组卷规则
+        /// </summary>
+        [Description("试卷组卷规则")]
+        public List<AddTestPaperRuleDto> TestPaperRuleDtos { get; set; }
+    }
+
+
+    /// <summary>
+    /// 试卷
+    /// </summary>
+    [Description("试卷")]
+    public class UpdateTestPaperDto : AddTestPaperDto, IActionRequest
+    {
+        /// <summary>
+        /// 主键
+        /// </summary>
+        [Description("主键")]
+        public string Id { get; set; }
+
+        /// <summary>
+        /// 试卷详情
+        /// </summary>
+        [Description("试卷详情")]
+        public new List<UpdateTestPaperItemDto> TestPaperItemDtos { get; set; }
 
         /// <summary>
         /// 试卷组卷规则
         /// </summary>
         [Description("试卷组卷规则")]
-        public List<TestPaperRuleDto> TestPaperRuleDtos { get; set; }
+        public new List<UpdateTestPaperRuleDto> TestPaperRuleDtos { get; set; }
     }
 }

+ 56 - 23
src/Hotline.Share/Dtos/TestPapers/TestPaperItemDto.cs

@@ -1,7 +1,8 @@
-using Exam.Infrastructure.Data.Entity;
+using Exam.Infrastructure.Data.Interface;
+using Exam.Infrastructure.Enums;
 using Exam.Infrastructure.Extensions;
-using Hotline.Share.Dtos.TrCallCenter;
 using Hotline.Share.Enums.Exams;
+using Hotline.Share.Exams.Interface;
 using System.ComponentModel;
 
 namespace Hotline.Share.Dtos.TestPapers
@@ -10,42 +11,40 @@ namespace Hotline.Share.Dtos.TestPapers
     /// 人工组卷试题
     /// </summary>
     [Description("人工组卷试题")]
-    public class TestPaperItemDto:ActionRequest
+    public class TestPaperItemDto : UpdateTestPaperItemDto
     {
         /// <summary>
-        /// 试题Id
+        /// 难度
         /// </summary>
-        [Description("试题Id")]
-        public string QuestionId { get; set; }
+        [Description("难度")]
+        public EDifficultyLevel DifficultyLevel { get; set; }
+
 
         /// <summary>
-        /// 试卷Id
+        /// 题型
         /// </summary>
-        [Description("试卷Id")]
-        public string TestPaperId { get; set; }
+        [Description("题型")]
+        public EQuestionType QuestionType { get; set; }
+
 
         /// <summary>
-        /// 难度
+        /// 标题
         /// </summary>
-        [Description("难度")]
-        public EDifficultyLevel DifficultyLevel { get; set; }
+        [Description("标题")]
+        public string Title { get; set; }
 
         /// <summary>
         /// 难度
         /// </summary>
         [Description("难度")]
-        public string DifficultyLevelDesc { get
+        public string DifficultyLevelDesc
+        {
+            get
             {
                 return DifficultyLevel.GetDescription();
-            } 
+            }
         }
 
-        /// <summary>
-        /// 题型
-        /// </summary>
-        [Description("题型")]
-        public EQuestionType QuestionType { get; set; }
-
         /// <summary>
         /// 题型
         /// </summary>
@@ -57,11 +56,45 @@ namespace Hotline.Share.Dtos.TestPapers
                 return QuestionType.GetDescription();
             }
         }
+    }
 
+    /// <summary>
+    /// 人工组卷试题
+    /// </summary>
+    [Description("人工组卷试题")]
+    public class AddTestPaperItemDto : IAddRequest, IOperationStatus
+    {
         /// <summary>
-        /// 标题
+        /// 试题Id
         /// </summary>
-        [Description("标题")]
-        public string Title { get; set; }
+        [Description("试题Id")]
+        public string QuestionId { get; set; }
+
+        /// <summary>
+        /// 试卷Id
+        /// </summary>
+        [Description("试卷Id")]
+        public string TestPaperId { get; set; }
+
+        
+
+        /// <summary>
+        /// 操作状态        
+        /// </summary>
+        [Description("操作状态")]
+        public EEOperationStatus OperationStatus { get; set; }
+    }
+
+    /// <summary>
+    /// 人工组卷试题
+    /// </summary>
+    [Description("人工组卷试题")]
+    public class UpdateTestPaperItemDto : AddTestPaperItemDto, IActionRequest
+    {
+        /// <summary>
+        /// 主键
+        /// </summary>
+        [Description("主键")]
+        public string Id { get; set; }
     }
 }

+ 35 - 4
src/Hotline.Share/Dtos/TestPapers/TestPaperRuleDto.cs

@@ -1,5 +1,9 @@
 using Exam.Infrastructure.Data.Entity;
+using Exam.Infrastructure.Data.Interface;
+using Exam.Infrastructure.Enums;
+using Hotline.Share.Enums.CallCenter;
 using Hotline.Share.Enums.Exams;
+using Hotline.Share.Exams.Interface;
 using System.ComponentModel;
 using System.Text.Json.Serialization;
 
@@ -9,7 +13,13 @@ namespace Hotline.Share.Dtos.TestPapers
     /// 试卷规则
     /// </summary>
     [Description("试卷规则")]
-    public class TestPaperRuleDto : ActionRequest
+    public class TestPaperRuleDto : UpdateTestPaperRuleDto
+    {
+       
+
+    }
+
+    public class AddTestPaperRuleDto : IAddRequest,IOperationStatus
     {
         /// <summary>
         /// 试卷Id
@@ -35,6 +45,18 @@ namespace Hotline.Share.Dtos.TestPapers
         [Description("试题数量")]
         public int Count { get; set; }
 
+        /// <summary>
+        /// 标签Id
+        /// </summary>
+        [Description("标签Id")]
+        public string TagId { get; set; }
+
+        /// <summary>
+        /// 排序
+        /// </summary>
+        [Description("排序")]
+        public int SortIndex { get; set; }
+
         /// <summary>
         /// 组卷规则标签
         /// </summary>
@@ -43,9 +65,18 @@ namespace Hotline.Share.Dtos.TestPapers
         public TestPaperRuleTagDto TestPaperRuleTagDto { get; set; }
 
         /// <summary>
-        /// 标签Id
+        /// 操作状态        
         /// </summary>
-        [Description("标签Id")]
-        public string TagId { get; set; }
+        [Description("操作状态")]
+        public EEOperationStatus OperationStatus { get; set; }
+    }
+
+    public class UpdateTestPaperRuleDto : AddTestPaperRuleDto, IActionRequest
+    {
+        /// <summary>
+        /// 主键
+        /// </summary>
+        [Description("主键")]
+        public string Id { get; set; }
     }
 }

+ 32 - 1
src/Hotline.Share/Dtos/TestPapers/TestPaperRuleTagDto.cs

@@ -1,4 +1,7 @@
 using Exam.Infrastructure.Data.Entity;
+using Exam.Infrastructure.Data.Interface;
+using Exam.Infrastructure.Enums;
+using Hotline.Share.Exams.Interface;
 using System.ComponentModel;
 
 namespace Hotline.Share.Dtos.TestPapers
@@ -7,7 +10,16 @@ namespace Hotline.Share.Dtos.TestPapers
     /// 试卷组卷规则标签
     /// </summary>
     [Description("试卷组卷规则标签")]
-    public class TestPaperRuleTagDto:ActionRequest
+    public class TestPaperRuleTagDto:UpdateTestPaperRuleTagDto
+    {
+
+    }
+
+    /// <summary>
+    /// 试卷组卷规则标签
+    /// </summary>
+    [Description("试卷组卷规则标签")]
+    public class AddTestPaperRuleTagDto : IAddRequest,IOperationStatus
     {
         /// <summary>
         /// 试卷组卷规则Id
@@ -20,5 +32,24 @@ namespace Hotline.Share.Dtos.TestPapers
         /// </summary>
         [Description("标签Id")]
         public string TagId { get; set; }
+
+        /// <summary>
+        /// 操作状态        
+        /// </summary>
+        [Description("操作状态")]
+        public EEOperationStatus OperationStatus { get; set; }
+    }
+
+    /// <summary>
+    /// 试卷组卷规则标签
+    /// </summary>
+    [Description("试卷组卷规则标签")]
+    public class UpdateTestPaperRuleTagDto : AddTestPaperRuleTagDto,IActionRequest
+    {
+        /// <summary>
+        /// 主键
+        /// </summary>
+        [Description("主键")]
+        public string Id { get; set; }
     }
 }

+ 41 - 6
src/Hotline.Share/Dtos/Trains/TrainPlanDto.cs

@@ -1,4 +1,5 @@
 using Exam.Infrastructure.Data.Entity;
+using Exam.Infrastructure.Data.Interface;
 using Hotline.Share.Dtos.Trains;
 using System.ComponentModel;
 
@@ -8,7 +9,27 @@ namespace Exam.Share
     /// 培训计划
     /// </summary>
     [Description("培训计划")]
-    public class TrainPlanDto:ActionRequest
+    public class TrainPlanDto:UpdateTrainPlanDto
+    {
+
+        /// <summary>
+        /// 培训模版
+        /// </summary>
+        [Description("培训模版")]
+        public TrainTemplateDto TrainTemplateDto { get; set; }
+
+        /// <summary>
+        /// 培训人员
+        /// </summary>
+        [Description("培训人员")]
+        public List<TrainUserDto> TrainUserDtos { get; set; }
+    }
+
+    /// <summary>
+    /// 培训计划
+    /// </summary>
+    [Description("培训计划")]
+    public class AddTrainPlanDto : IAddRequest
     {
         /// <summary>
         /// 培训编码
@@ -28,11 +49,6 @@ namespace Exam.Share
         [Description("培训模版")]
         public string TrainTemplateId { get; set; }
 
-        /// <summary>
-        /// 培训模版
-        /// </summary>
-        [Description("培训模版")]
-        public TrainTemplateDto TrainTemplateDto { get; set; }
 
         /// <summary>
         /// 培训开始时间
@@ -52,4 +68,23 @@ namespace Exam.Share
         [Description("培训人员")]
         public List<TrainUserDto> TrainUserDtos { get; set; }
     }
+
+    /// <summary>
+    /// 培训计划
+    /// </summary>
+    [Description("培训计划")]
+    public class UpdateTrainPlanDto : AddTrainPlanDto,IActionRequest
+    {
+        /// <summary>
+        /// 主键
+        /// </summary>
+        [Description("主键")]
+        public string Id { get; set; }
+
+        /// <summary>
+        /// 培训人员
+        /// </summary>
+        [Description("培训人员")]
+        public List<TrainUserDto> TrainUserDtos { get; set; }
+    }
 }

Some files were not shown because too many files changed in this diff