From f8b5b4bf615ab24c9a76dc561bbfb40fed18f6f6 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Sun, 3 Jul 2022 20:40:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=80=E8=87=B4=E6=80=A7=E5=88=86=E6=9E=90?= =?UTF-8?q?=E9=A2=84=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IRaCIS.Core.Application.xml | 24 +++++ .../DTO/TaskConsistentRuleViewModel.cs | 53 +++++++++++ .../Allocation/DTO/VisitTaskViewModel.cs | 2 +- .../Interface/ITaskConsistentRuleService.cs | 25 ++++++ .../Allocation/TaskConsistentRuleService.cs | 89 +++++++++++++++++++ .../Allocation/TaskMedicalReviewService.cs | 16 +++- .../Service/Allocation/VisitTaskService.cs | 88 ++++++++++-------- .../Service/Allocation/_MapConfig.cs | 7 +- .../Allocation/TaskConsistentRule.cs | 62 +++++++++++++ IRaCIS.Core.Domain/Allocation/VisitTask.cs | 2 + .../Context/IRaCISDBContext.cs | 2 + IRaCIS.Core.Test/DbHelper.ttinclude | 2 +- .../TT_Template/IRaCIS .Core.ServiceAsync.tt | 2 +- .../Services_New/TaskConsistentRuleService.cs | 64 +++++++++++++ 14 files changed, 396 insertions(+), 42 deletions(-) create mode 100644 IRaCIS.Core.Application/Service/Allocation/DTO/TaskConsistentRuleViewModel.cs create mode 100644 IRaCIS.Core.Application/Service/Allocation/Interface/ITaskConsistentRuleService.cs create mode 100644 IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs create mode 100644 IRaCIS.Core.Domain/Allocation/TaskConsistentRule.cs create mode 100644 IRaCIS.Core.Test/TT_Template/Services_New/TaskConsistentRuleService.cs diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index 8e3ed0c73..fb4e96eb4 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -53,6 +53,11 @@ + + + 一致性分析配置表 + + 医学审核生成规则 @@ -2161,6 +2166,11 @@ + + + 阅片医学审核 + + 医学审核问题 @@ -2325,6 +2335,15 @@ 阅片期 + + TaskConsistentRuleView 列表视图模型 + + + TaskConsistentRuleQuery 列表查询参数模型 + + + TaskConsistentRuleAddOrEdit 列表查询参数模型 + TaskTaskMedicalReviewRuleView 列表视图模型 @@ -2717,6 +2736,11 @@ ITaskAllocationRuleService + + + ITaskConsistentRuleService + + ITaskTaskMedicalReviewRuleService diff --git a/IRaCIS.Core.Application/Service/Allocation/DTO/TaskConsistentRuleViewModel.cs b/IRaCIS.Core.Application/Service/Allocation/DTO/TaskConsistentRuleViewModel.cs new file mode 100644 index 000000000..f0f0f8631 --- /dev/null +++ b/IRaCIS.Core.Application/Service/Allocation/DTO/TaskConsistentRuleViewModel.cs @@ -0,0 +1,53 @@ +//-------------------------------------------------------------------- +// 此代码由T4模板自动生成 byzhouhang 20210918 +// 生成时间 2022-07-01 15:33:01 +// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。 +//-------------------------------------------------------------------- +using System; +using IRaCIS.Core.Domain.Share; +using System.Collections.Generic; +namespace IRaCIS.Core.Application.ViewModel +{ + /// TaskConsistentRuleView 列表视图模型 + public class TaskConsistentRuleView: TaskConsistentRuleAddOrEdit + { + public Guid CreateUserId { get; set; } + public DateTime CreateTime { get; set; } + public DateTime UpdateTime { get; set; } + public Guid UpdateUserId { get; set; } + + public UserSimpleInfo AnalysisDoctorUser { get; set; } + + public UserSimpleInfo CompareDoctorUser { get; set; } + + } + + ///TaskConsistentRuleQuery 列表查询参数模型 + public class TaskConsistentRuleQuery + { + public Guid TrialId { get; set; } + + public bool IsSelfAnalysis { get; set; } + + } + + /// TaskConsistentRuleAddOrEdit 列表查询参数模型 + public class TaskConsistentRuleAddOrEdit + { + public Guid? Id { get; set; } + public Guid AnalysisDoctorUserId { get; set; } + public bool IsEnable { get; set; } + public string Note { get; set; } + public Guid TrialId { get; set; } + public int PlanSubjectCount { get; set; } + public int PlanVisitCount { get; set; } + public int IntervalWeeks { get; set; } + public Guid? CompareDoctorUserId { get; set; } + public bool IsHaveReadingPeriod { get; set; } + public bool IsGenerateGlobalTask { get; set; } + } + + +} + + diff --git a/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs b/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs index 4e2bad049..fba033359 100644 --- a/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs +++ b/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs @@ -67,7 +67,7 @@ namespace IRaCIS.Core.Application.ViewModel public string UserName { get; set; } public string FullName { get; set; } - public string UserTypeShortName { get; set; } + //public string UserTypeShortName { get; set; } } diff --git a/IRaCIS.Core.Application/Service/Allocation/Interface/ITaskConsistentRuleService.cs b/IRaCIS.Core.Application/Service/Allocation/Interface/ITaskConsistentRuleService.cs new file mode 100644 index 000000000..61cb8b39b --- /dev/null +++ b/IRaCIS.Core.Application/Service/Allocation/Interface/ITaskConsistentRuleService.cs @@ -0,0 +1,25 @@ +//-------------------------------------------------------------------- +// 此代码由T4模板自动生成 byzhouhang 20210918 +// 生成时间 2022-07-01 15:35:00 +// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。 +//-------------------------------------------------------------------- + +using IRaCIS.Core.Application.ViewModel; +namespace IRaCIS.Core.Application.Interfaces +{ + /// + /// ITaskConsistentRuleService + /// + public interface ITaskConsistentRuleService + { + + + Task> GetTaskConsistentRuleList(TaskConsistentRuleQuery inQuery); + + Task AddOrUpdateTaskConsistentRule(TaskConsistentRuleAddOrEdit addOrEditTaskConsistentRule); + + Task DeleteTaskConsistentRule(Guid taskConsistentRuleId); + + + } +} diff --git a/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs b/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs new file mode 100644 index 000000000..dac728c83 --- /dev/null +++ b/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs @@ -0,0 +1,89 @@ +//-------------------------------------------------------------------- +// 此代码由T4模板自动生成 byzhouhang 20210918 +// 生成时间 2022-07-01 15:33:04 +// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。 +//-------------------------------------------------------------------- + +using IRaCIS.Core.Domain.Models; +using Microsoft.AspNetCore.Mvc; +using IRaCIS.Core.Application.Interfaces; +using IRaCIS.Core.Application.ViewModel; +using IRaCIS.Core.Infrastructure; + +namespace IRaCIS.Core.Application.Service +{ + /// + /// 一致性分析配置表 + /// + [ApiExplorerSettings(GroupName = "Trial")] + public class TaskConsistentRuleService : BaseService, ITaskConsistentRuleService + { + + private readonly IRepository _taskConsistentRuleRepository; + private readonly IRepository _visitTaskRepository; + + public TaskConsistentRuleService(IRepository visitTaskRepository, IRepository taskConsistentRuleRepository) + { + _taskConsistentRuleRepository = taskConsistentRuleRepository; + _visitTaskRepository = visitTaskRepository; + } + + [HttpPost] + public async Task> GetTaskConsistentRuleList(TaskConsistentRuleQuery inQuery) + { + + var taskConsistentRuleQueryable = _taskConsistentRuleRepository.Where(t => t.TrialId == inQuery.TrialId) + .WhereIf(inQuery.IsSelfAnalysis, t => t.CompareDoctorUserId != null) + .WhereIf(inQuery.IsSelfAnalysis == false, t => t.CompareDoctorUserId == null) + .ProjectTo(_mapper.ConfigurationProvider); + + return await taskConsistentRuleQueryable.ToListAsync(); + } + + + public async Task AddOrUpdateTaskConsistentRule(TaskConsistentRuleAddOrEdit addOrEditTaskConsistentRule) + { + + var verifyExp1 = new EntityVerifyExp() + { + VerifyExp = t => t.AnalysisDoctorUserId == addOrEditTaskConsistentRule.AnalysisDoctorUserId && t.CompareDoctorUserId == addOrEditTaskConsistentRule.CompareDoctorUserId && t.TrialId == addOrEditTaskConsistentRule.TrialId, + VerifyMsg = "已有该医生配置,不允许继续增加" + }; + + var entity = await _taskConsistentRuleRepository.InsertOrUpdateAsync(addOrEditTaskConsistentRule, true, verifyExp1); + + return ResponseOutput.Ok(entity.Id.ToString()); + + } + + + [HttpDelete("{taskConsistentRuleId:guid}")] + public async Task DeleteTaskConsistentRule(Guid taskConsistentRuleId) + { + var config = await _taskConsistentRuleRepository.FirstOrDefaultAsync(t => t.Id == taskConsistentRuleId); + + //自身一致性分析 + if (config.CompareDoctorUserId == null) + { + if (await _visitTaskRepository.AnyAsync(t => t.IsAnalysisCreate && t.DoctorUserId == config.AnalysisDoctorUserId && t.TrialId == config.TrialId)) + { + throw new BusinessValidationFailedException("已产生一致性分析任务,不允许删除"); + } + } + //组内一致性分析 + else + { + if (await _visitTaskRepository.AnyAsync(t => t.IsAnalysisCreate && t.DoctorUserId == config.CompareDoctorUserId && t.TrialId == config.TrialId)) + { + throw new BusinessValidationFailedException("已产生一致性分析任务,不允许删除"); + } + } + + + var success = await _taskConsistentRuleRepository.DeleteFromQueryAsync(t => t.Id == taskConsistentRuleId, true); + return ResponseOutput.Ok(); + } + + + } +} diff --git a/IRaCIS.Core.Application/Service/Allocation/TaskMedicalReviewService.cs b/IRaCIS.Core.Application/Service/Allocation/TaskMedicalReviewService.cs index 225db36d2..19cd24d04 100644 --- a/IRaCIS.Core.Application/Service/Allocation/TaskMedicalReviewService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/TaskMedicalReviewService.cs @@ -8,6 +8,7 @@ using IRaCIS.Core.Domain.Models; using Microsoft.AspNetCore.Mvc; using IRaCIS.Core.Application.Interfaces; using IRaCIS.Core.Application.ViewModel; +using IRaCIS.Core.Infrastructure; namespace IRaCIS.Core.Application.Service { @@ -32,7 +33,6 @@ namespace IRaCIS.Core.Application.Service _taskMedicalReviewRuleRepository = taskMedicalReviewRuleRepository; - } /// @@ -208,6 +208,8 @@ namespace IRaCIS.Core.Application.Service /// /// /// + [UnitOfWork] + [HttpPost] public async Task AssignMedicalReviewTask(AssignMedicalReviewTaskCommand command) { @@ -215,12 +217,22 @@ namespace IRaCIS.Core.Application.Service { var task = await _taskMedicalReviewRepository.FirstOrDefaultAsync(t => t.Id == id); - if (command.TaskOptType == MedicalReviewTaskOptType.Assign || command.TaskOptType == MedicalReviewTaskOptType.ReAssign) + if (command.TaskOptType == MedicalReviewTaskOptType.Assign ) { + if (task.MedicalManagerUserId != null && task.MedicalManagerUserId !=command.MedicalManagerUserId) + { + throw new BusinessValidationFailedException("当前有任务已分配给其他人,不允许分配,请刷新列表"); + } + task.MedicalManagerUserId = command.MedicalManagerUserId; task.AllocateTime = DateTime.Now; } + else if (command.TaskOptType == MedicalReviewTaskOptType.ReAssign) + { + task.MedicalManagerUserId = command.MedicalManagerUserId; + task.AllocateTime = DateTime.Now; + } else if (command.TaskOptType == MedicalReviewTaskOptType.CancelAssign) { diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs index 65724e16d..fdad5bcc6 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs @@ -231,49 +231,67 @@ namespace IRaCIS.Core.Application.Service } - [HttpPost] - public async Task> GetSelfConsistentList(SelfConsistentQuery inQuery) - { - var query = _visitTaskRepository.Where(t => t.TrialId == inQuery.TrialId && t.DoctorUserId == inQuery.AnalysisDoctorUserId) - .Where(t => t.ReadingTaskState == ReadingTaskState.HaveSigned && t.TaskState == TaskState.Effect) - .Where(t => t.SignTime!.Value.AddDays(inQuery.IntervalWeeks * 7 + 1) > DateTime.Now) - //重阅产生的访视任务 要把之前的访视任务去除 - .Where(t => t.ReReadingApplyState != ReReadingApplyState.Agree) - .WhereIf(inQuery.IsHaveReadingPeriod == false, t => t.ReadingCategory == ReadingCategory.Visit) - .WhereIf(inQuery.IsHaveReadingPeriod == true, t => t.ReadingCategory == ReadingCategory.Visit || t.ReadingCategory == ReadingCategory.Global) - .GroupBy(t => t.SubjectId) - .Select(g => new SelfConsistentView() - { - SubjectId = g.Key, - - VisitTaskList = g.OrderBy(t => t.SubjectVisit.VisitNum).Select(c => new VisitTaskSimpleView() - { - Id = c.Id, - ReadingCategory = c.ReadingCategory, - TaskBlindName = c.TaskBlindName, - TaskCode = c.TaskCode, - TaskName = c.TaskName, - TaskState = c.TaskState, - ArmEnum = c.ArmEnum, - SubjectId = c.SubjectId, - TrialId = c.TrialId, - SubjectCode = c.Subject.Code, - TrialSiteCode = c.Subject.TrialSite.TrialSiteCode, - }).Take(2).ToList(), + //[HttpPost] + //public async Task> GetSelfConsistentList(SelfConsistentQuery inQuery) + //{ + // var group = _visitTaskRepository.Where(t => t.TrialId == inQuery.TrialId && t.DoctorUserId == inQuery.AnalysisDoctorUserId) + // .Where(t => t.ReadingTaskState == ReadingTaskState.HaveSigned && t.TaskState == TaskState.Effect) + // .Where(t => t.SignTime!.Value.AddDays(inQuery.IntervalWeeks * 7 + 1) > DateTime.Now) + // //重阅产生的访视任务 要把之前的访视任务去除 + // .Where(t => t.ReReadingApplyState != ReReadingApplyState.Agree) + // .WhereIf(inQuery.IsHaveReadingPeriod == false, t => t.ReadingCategory == ReadingCategory.Visit) + // .WhereIf(inQuery.IsHaveReadingPeriod == true, t => t.ReadingCategory == ReadingCategory.Visit || t.ReadingCategory == ReadingCategory.Global) + // .GroupBy(t => t.SubjectId) + // ; - VisitValidTaskCount = g.Count() + // var query= group.Select(g => new SelfConsistentView() + // { + // SubjectId = g.Key, - }); + // VisitTaskList = g.OrderBy(t => t.SubjectVisit.VisitNum).Select(c => new VisitTaskSimpleView() + // { + // Id = c.Id, + // ReadingCategory = c.ReadingCategory, + // TaskBlindName = c.TaskBlindName, + // TaskCode = c.TaskCode, + // TaskName = c.TaskName, + // TaskState = c.TaskState, + // ArmEnum = c.ArmEnum, + // SubjectId = c.SubjectId, + // TrialId = c.TrialId, + // SubjectCode = c.Subject.Code, + // TrialSiteCode = c.Subject.TrialSite.TrialSiteCode, + // }).Take(2).ToList(), + + // VisitValidTaskCount = g.Count() + + // }) - var count = query.Count(); - var list= query.Skip(0).Take(10).ToList(); + // //source = source.Skip((pageNumber - 1) * pageSize); + // //var items = await source + // // .Take(pageSize) + // // .ToArrayAsync(cancellationToken) + // // .ConfigureAwait(false); + + // //var pagedList = new PageOutput() + // //{ + // // PageIndex = pageNumber, + // // PageSize = pageSize, + // // TotalCount = count, + // // CurrentPageData = items + // //}; + + + // //var count = group.Count(); + + // //var list= query.Skip((pageNumber - 1) * pageSize).Take(pageSize).ToList(); - return query.ToList(); - } + // return query.ToList(); + //} diff --git a/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs b/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs index ec74df080..4a93ef6e4 100644 --- a/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs @@ -190,8 +190,8 @@ namespace IRaCIS.Core.Application.Service .ForMember(o => o.UserId, t => t.MapFrom(u => u.Id)) .ForMember(o => o.UserCode, t => t.MapFrom(u => u.UserCode)) .ForMember(o => o.UserName, t => t.MapFrom(u => u.UserName)) - .ForMember(o => o.FullName, t => t.MapFrom(u => u.FullName)) - .ForMember(o => o.UserTypeShortName, t => t.MapFrom(u => u.UserTypeRole.UserTypeShortName)); + .ForMember(o => o.FullName, t => t.MapFrom(u => u.FullName)); + //.ForMember(o => o.UserTypeShortName, t => t.MapFrom(u => u.UserTypeRole.UserTypeShortName)); @@ -214,6 +214,9 @@ namespace IRaCIS.Core.Application.Service + CreateMap(); + + CreateMap(); } } diff --git a/IRaCIS.Core.Domain/Allocation/TaskConsistentRule.cs b/IRaCIS.Core.Domain/Allocation/TaskConsistentRule.cs new file mode 100644 index 000000000..63cd6f40b --- /dev/null +++ b/IRaCIS.Core.Domain/Allocation/TaskConsistentRule.cs @@ -0,0 +1,62 @@ + +//-------------------------------------------------------------------- +// 此代码由T4模板自动生成 byzhouhang 20210918 +// 生成时间 2022-07-01 15:32:56 +// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。 +using System; +using IRaCIS.Core.Domain.Share; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +namespace IRaCIS.Core.Domain.Models +{ + /// + ///TaskConsistentRule + /// + [Table("TaskConsistentRule")] + public class TaskConsistentRule : Entity, IAuditUpdate, IAuditAdd + { + + + public Guid CreateUserId { get; set; } + + + public DateTime CreateTime { get; set; } + + public DateTime UpdateTime { get; set; } + + public Guid UpdateUserId { get; set; } + + + public Guid AnalysisDoctorUserId { get; set; } + + + public bool IsEnable { get; set; } + + public string Note { get; set; } + + public Guid TrialId { get; set; } + + + public int PlanSubjectCount { get; set; } + + public int PlanVisitCount { get; set; } + + + public int IntervalWeeks { get; set; } + + + public Guid? CompareDoctorUserId { get; set; } + + + public bool IsHaveReadingPeriod { get; set; } + + + public bool IsGenerateGlobalTask { get; set; } + + + public User CompareDoctorUser { get; set; } + + public User AnalysisDoctorUser { get; set; } + } + +} diff --git a/IRaCIS.Core.Domain/Allocation/VisitTask.cs b/IRaCIS.Core.Domain/Allocation/VisitTask.cs index a1e6711f7..6e8fef1f0 100644 --- a/IRaCIS.Core.Domain/Allocation/VisitTask.cs +++ b/IRaCIS.Core.Domain/Allocation/VisitTask.cs @@ -196,6 +196,8 @@ namespace IRaCIS.Core.Domain.Models public decimal VisitTaskNum { get; set; } + + public Guid? TaskConsistentRuleId { get; set; } } } diff --git a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs index db02b2e8b..cbbb55969 100644 --- a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs +++ b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs @@ -593,6 +593,8 @@ namespace IRaCIS.Core.Infra.EFCore public virtual DbSet TaskMedicalReviewRule { get; set; } + public virtual DbSet TaskConsistentRule { get; set; } + diff --git a/IRaCIS.Core.Test/DbHelper.ttinclude b/IRaCIS.Core.Test/DbHelper.ttinclude index 0fa70c738..78f15acbc 100644 --- a/IRaCIS.Core.Test/DbHelper.ttinclude +++ b/IRaCIS.Core.Test/DbHelper.ttinclude @@ -4,7 +4,7 @@ public static readonly string ConnectionString = "Server=123.56.94.154,1433\\MSSQLSERVER;Database=IRaCIS_New_Tet;User ID=sa;Password=dev123456DEV;TrustServerCertificate=true"; public static readonly string DbDatabase = "IRaCIS_New_Tet"; //ַ,ƴ - public static readonly string TableName = "ReadingMedicalReviewDialog"; + public static readonly string TableName = "TaskConsistentRule"; //ļ service Ƿҳ } #> diff --git a/IRaCIS.Core.Test/TT_Template/IRaCIS .Core.ServiceAsync.tt b/IRaCIS.Core.Test/TT_Template/IRaCIS .Core.ServiceAsync.tt index 6f4012cde..77388dbd7 100644 --- a/IRaCIS.Core.Test/TT_Template/IRaCIS .Core.ServiceAsync.tt +++ b/IRaCIS.Core.Test/TT_Template/IRaCIS .Core.ServiceAsync.tt @@ -113,7 +113,7 @@ namespace IRaCIS.Core.Application.Service public async Task Delete<#=tableName#>(Guid <#=char.ToLower(tableName[0]) + tableName.Substring(1)#>Id) { var success = await _<#=char.ToLower(tableName[0]) + tableName.Substring(1)#>Repository.DeleteFromQueryAsync(t => t.Id == <#=char.ToLower(tableName[0]) + tableName.Substring(1)#>Id,true); - return ResponseOutput.Result(success); + return ResponseOutput.Ok(); } diff --git a/IRaCIS.Core.Test/TT_Template/Services_New/TaskConsistentRuleService.cs b/IRaCIS.Core.Test/TT_Template/Services_New/TaskConsistentRuleService.cs new file mode 100644 index 000000000..64ff26bb3 --- /dev/null +++ b/IRaCIS.Core.Test/TT_Template/Services_New/TaskConsistentRuleService.cs @@ -0,0 +1,64 @@ +//-------------------------------------------------------------------- +// 此代码由T4模板自动生成 byzhouhang 20210918 +// 生成时间 2022-07-01 15:37:24 +// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。 +//-------------------------------------------------------------------- + +using IRaCIS.Core.Domain.Models; +using Microsoft.AspNetCore.Mvc; +using IRaCIS.Core.Application.Interfaces; +using IRaCIS.Core.Application.ViewModel; +namespace IRaCIS.Core.Application.Service +{ + /// + /// TaskConsistentRuleService + /// + [ ApiExplorerSettings(GroupName = "Test")] + public class TaskConsistentRuleService: BaseService, ITaskConsistentRuleService + { + + private readonly IRepository _taskConsistentRuleRepository; + + public TaskConsistentRuleService(IRepository taskConsistentRuleRepository) + { + _taskConsistentRuleRepository = taskConsistentRuleRepository; + } + + + public async Task> GetTaskConsistentRuleList(TaskConsistentRuleQuery inQuery) + { + + + var taskConsistentRuleQueryable = _taskConsistentRuleRepository + .ProjectTo(_mapper.ConfigurationProvider); + + return await taskConsistentRuleQueryable.ToListAsync(); + } + + + public async Task AddOrUpdateTaskConsistentRule(TaskConsistentRuleAddOrEdit addOrEditTaskConsistentRule) + { + // 在此处拷贝automapper 映射 + + + CreateMap(); + // CreateMap< TaskConsistentRule,TaskConsistentRuleAddOrEdit>().ReverseMap(); + + + var entity = await _taskConsistentRuleRepository.InsertOrUpdateAsync(addOrEditTaskConsistentRule, true); + + return ResponseOutput.Ok(entity.Id.ToString()); + + } + + + [HttpDelete("{taskConsistentRuleId:guid}")] + public async Task DeleteTaskConsistentRule(Guid taskConsistentRuleId) + { + var success = await _taskConsistentRuleRepository.DeleteFromQueryAsync(t => t.Id == taskConsistentRuleId,true); + return ResponseOutput.Ok(); + } + + + } +}