diff --git a/IRC.Core.SCP/appsettings.Prod_IRC_SCP.json b/IRC.Core.SCP/appsettings.Prod_IRC_SCP.json index 44af0926a..218d5a2c8 100644 --- a/IRC.Core.SCP/appsettings.Prod_IRC_SCP.json +++ b/IRC.Core.SCP/appsettings.Prod_IRC_SCP.json @@ -18,14 +18,6 @@ "roleArn": "acs:ram::1899121822495495:role/oss-upload", "viewEndpoint": "https://zy-irc-cache.oss-cn-shanghai.aliyuncs.com", "region": "oss-cn-shanghai" - }, - "MinIO": { - "endpoint": "http://192.168.3.68", - "port": "8001", - "useSSL": false, - "accessKey": "IDFkwEpWej0b4DtiuThL", - "secretKey": "Lhuu83yMhVwu7c1SnjvGY6lq74jzpYqifK6Qtj4h", - "bucketName": "test" } }, diff --git a/IRC.Core.SCP/appsettings.Test_IRC_SCP.json b/IRC.Core.SCP/appsettings.Test_IRC_SCP.json index 4122b7ecf..077a9194a 100644 --- a/IRC.Core.SCP/appsettings.Test_IRC_SCP.json +++ b/IRC.Core.SCP/appsettings.Test_IRC_SCP.json @@ -44,37 +44,12 @@ "RemoteNew": "Server=106.14.89.110,1435;Database=Test_IRC;User ID=sa;Password=xc@123456;TrustServerCertificate=true", "Hangfire": "Server=106.14.89.110,1435;Database=Test_IRC_Hangfire;User ID=sa;Password=xc@123456;TrustServerCertificate=true" }, - "BasicSystemConfig": { - "OpenUserComplexPassword": false, - - "OpenSignDocumentBeforeWork": false, - - "OpenTrialRelationDelete": true, - - "OpenLoginLimit": false, - "LoginMaxFailCount": 5, - - "LoginFailLockMinutes": 30 - - }, - - "SystemEmailSendConfig": { - "Port": 465, - "Host": "smtp.qiye.aliyun.com", - "FromEmail": "test-study@extimaging.com", - "FromName": "Test_Study", - "AuthorizationCode": "zhanying123", - - "SiteUrl": "http://study.test.extimaging.com/login" - }, "DicomSCPServiceConfig": { "CalledAEList": [ - "STORESCP", - "Value1", - "Value2", - "Value3" + "STORESCP" ], "ServerPort": 11112 } + } diff --git a/IRC.Core.SCP/appsettings.US_Uat_SCP.json b/IRC.Core.SCP/appsettings.US_Uat_SCP.json new file mode 100644 index 000000000..1d15fadf7 --- /dev/null +++ b/IRC.Core.SCP/appsettings.US_Uat_SCP.json @@ -0,0 +1,31 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + }, + "ObjectStoreService": { + "ObjectStoreUse": "AWS", + "AWS": { + "endPoint": "s3.us-east-1.amazonaws.com", + "useSSL": true, + "accessKey": "AKIAW3MEAFJXUO6XYFYN", + "secretKey": "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", + "bucketName": "ei-med-s3-lili-uat-store", + "viewEndpoint": "https://ei-med-s3-lili-uat-store.s3.amazonaws.com/" + } + }, + "ConnectionStrings": { + "RemoteNew": "Server=47.117.164.182,1434;Database=Uat_IRC;User ID=sa;Password=xc@123456;TrustServerCertificate=true", + "Hangfire": "Server=47.117.164.182,1434;Database=Uat_IRC.Hangfire;User ID=sa;Password=xc@123456;TrustServerCertificate=true" + }, + "DicomSCPServiceConfig": { + "CalledAEList": [ + "STORESCP" + ], + "ServerPort": 11112 + } + +} diff --git a/IRC.Core.SCP/appsettings.Uat_IRC_SCP.json b/IRC.Core.SCP/appsettings.Uat_IRC_SCP.json index b2a640967..18a92a53b 100644 --- a/IRC.Core.SCP/appsettings.Uat_IRC_SCP.json +++ b/IRC.Core.SCP/appsettings.Uat_IRC_SCP.json @@ -18,50 +18,17 @@ "roleArn": "acs:ram::1899121822495495:role/oss-upload", "viewEndpoint": "https://zy-irc-uat-store.oss-cn-shanghai.aliyuncs.com", "region": "oss-cn-shanghai" - }, - - "AWS": { - "endPoint": "s3.us-east-1.amazonaws.com", - "useSSL": false, - "accessKey": "AKIAZQ3DRSOHFPJJ6FEU", - "secretKey": "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", - "bucketName": "ei-irc-test-store", - "viewEndpoint": "https://ei-irc-test-store.s3.amazonaws.com/" } }, "ConnectionStrings": { "RemoteNew": "Server=47.117.164.182,1434;Database=Uat_IRC;User ID=sa;Password=xc@123456;TrustServerCertificate=true", "Hangfire": "Server=47.117.164.182,1434;Database=Uat_IRC.Hangfire;User ID=sa;Password=xc@123456;TrustServerCertificate=true" }, - "BasicSystemConfig": { - - "OpenUserComplexPassword": false, - - "OpenSignDocumentBeforeWork": false, - - "OpenTrialRelationDelete": true, - - "OpenLoginLimit": false, - "LoginMaxFailCount": 5, - - "LoginFailLockMinutes": 30 - }, - - "SystemEmailSendConfig": { - "Port": 465, - "Host": "smtp.qiye.aliyun.com", - "FromEmail": "uat-study@extimaging.com", - "FromName": "Uat_Study", - "AuthorizationCode": "zhanying123", - "SiteUrl": "http://study.uat.extimaging.com/login" - }, "DicomSCPServiceConfig": { "CalledAEList": [ - "STORESCP", - "Value1", - "Value2", - "Value3" + "STORESCP" ], "ServerPort": 11112 } + } diff --git a/IRaCIS.Core.API/Controllers/ExtraController.cs b/IRaCIS.Core.API/Controllers/ExtraController.cs index bb8be2517..f9b40bb88 100644 --- a/IRaCIS.Core.API/Controllers/ExtraController.cs +++ b/IRaCIS.Core.API/Controllers/ExtraController.cs @@ -221,9 +221,9 @@ namespace IRaCIS.Api.Controllers if (_verifyConfig.CurrentValue.OpenLoginMFA) { - //发版屏蔽 + - //returnModel.Data.JWTStr = _tokenService.GetToken(IRaCISClaims.Create(returnModel.Data.BasicInfo)); + //MFA 发送邮件 @@ -235,7 +235,17 @@ namespace IRaCIS.Api.Controllers returnModel.Data.BasicInfo.EMail = hiddenEmail; - await _userService.SendMFAEmail(userId); + //修改密码 + if (returnModel.Data.BasicInfo.IsFirstAdd || returnModel.Data.BasicInfo.LoginState == 1) + { + returnModel.Data.JWTStr = _tokenService.GetToken(IRaCISClaims.Create(returnModel.Data.BasicInfo)); + } + else + { + //正常登录才发送邮件 + await _userService.SendMFAEmail(userId); + + } } else diff --git a/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs b/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs index df6500ede..4da2b86f6 100644 --- a/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs +++ b/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs @@ -38,6 +38,7 @@ using Newtonsoft.Json; using SharpCompress.Archives; using System; using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; using System.Data; using System.Globalization; using System.IO; @@ -419,12 +420,20 @@ namespace IRaCIS.Core.API.Controllers public class UploadNoneDicomFileCommand { - public Guid TrialId { get; set; } + [NotDefault] public Guid SubjectVisitId { get; set; } - public Guid NoneDicomStudyId { get; set; } + + + [NotDefault] public Guid StudyMonitorId { get; set; } + public Guid? NoneDicomStudyId { get; set; } + + //IR 上传的时候跟任务绑定 + public Guid? VisitTaskId { get; set; } + + public List UploadedFileList { get; set; } = new List(); @@ -470,7 +479,19 @@ namespace IRaCIS.Core.API.Controllers foreach (var item in incommand.UploadedFileList) { - await _noneDicomStudyFileRepository.AddAsync(new NoneDicomStudyFile() { FileName = item.FileName, Path = item.FilePath, NoneDicomStudyId = noneDicomStudyId,FileType=item.FileType,FileSize=item.FileFize }); + //如果是跟任务绑,那么NoneDicomStudyId 设置为空,不影响之前的检查,同时设置 OriginNoneDicomStudyId 保证关系 + + if(incommand.VisitTaskId!=null && incommand.VisitTaskId !=Guid.Empty) + { + await _noneDicomStudyFileRepository.AddAsync(new NoneDicomStudyFile() { FileName = item.FileName, Path = item.FilePath, OriginNoneDicomStudyId=noneDicomStudyId.Value, FileType = item.FileType, FileSize = item.FileFize }); + + } + else + { + await _noneDicomStudyFileRepository.AddAsync(new NoneDicomStudyFile() { FileName = item.FileName, Path = item.FilePath, NoneDicomStudyId = noneDicomStudyId.Value, FileType = item.FileType, FileSize = item.FileFize }); + + } + } var uploadFinishedTime = DateTime.Now; @@ -483,7 +504,7 @@ namespace IRaCIS.Core.API.Controllers studyMonitor.FileSize = incommand.UploadedFileList.Sum(t => t.FileFize); studyMonitor.IsDicom = false; studyMonitor.IsDicomReUpload = false; - studyMonitor.StudyId = noneDicomStudyId; + studyMonitor.StudyId = noneDicomStudyId.Value; studyMonitor.StudyCode = noneDicomStudy.StudyCode; studyMonitor.ArchiveFinishedTime = DateTime.Now; studyMonitor.IP = _userInfo.IP; diff --git a/IRaCIS.Core.API/appsettings.US_Prod_IRC.json b/IRaCIS.Core.API/appsettings.US_Prod_IRC.json index b2d650a67..a27844759 100644 --- a/IRaCIS.Core.API/appsettings.US_Prod_IRC.json +++ b/IRaCIS.Core.API/appsettings.US_Prod_IRC.json @@ -83,6 +83,11 @@ "CompanyShortName": "Elevate Imaging", "CompanyShortNameCN": "展影医疗", "SiteUrl": "https://lili.elevateimaging.ai/login" + }, + + "SystemPacsConfig": { + "Port": "11113", + "IP": "44.210.231.169" } } diff --git a/IRaCIS.Core.API/appsettings.US_Test_IRC.json b/IRaCIS.Core.API/appsettings.US_Test_IRC.json index a0eed7266..b45479ed8 100644 --- a/IRaCIS.Core.API/appsettings.US_Test_IRC.json +++ b/IRaCIS.Core.API/appsettings.US_Test_IRC.json @@ -89,6 +89,11 @@ "CompanyShortName": "Elevate Imaging", "CompanyShortNameCN": "展影医疗", "SiteUrl": "https://lili.test.elevateimaging.ai/login" + }, + + "SystemPacsConfig": { + "Port": "11113", + "IP": "3.226.182.187,1435" } } diff --git a/IRaCIS.Core.API/appsettings.US_Uat_IRC.json b/IRaCIS.Core.API/appsettings.US_Uat_IRC.json index f16b2410d..faf47a861 100644 --- a/IRaCIS.Core.API/appsettings.US_Uat_IRC.json +++ b/IRaCIS.Core.API/appsettings.US_Uat_IRC.json @@ -83,6 +83,11 @@ "CompanyShortName": "Elevate Imaging", "CompanyShortNameCN": "展影医疗", "SiteUrl": "https://lili.test.elevateimaging.ai/login" + }, + + "SystemPacsConfig": { + "Port": "11113", + "IP": "3.226.182.187,1435" } } diff --git a/IRaCIS.Core.Application/Service/ImageAndDoc/DTO/DownloadAndUploadDTO.cs b/IRaCIS.Core.Application/Service/ImageAndDoc/DTO/DownloadAndUploadDTO.cs index 1ff61ed04..40e97d11b 100644 --- a/IRaCIS.Core.Application/Service/ImageAndDoc/DTO/DownloadAndUploadDTO.cs +++ b/IRaCIS.Core.Application/Service/ImageAndDoc/DTO/DownloadAndUploadDTO.cs @@ -86,7 +86,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc.DTO - public List DicomStudyList { get; set; } + public List DicomStudyList { get; set; }=new List(); public List NoneDicomStudyList { get; set; } } diff --git a/IRaCIS.Core.Application/Service/ImageAndDoc/DTO/UnionStudyViewDodel.cs b/IRaCIS.Core.Application/Service/ImageAndDoc/DTO/UnionStudyViewDodel.cs index 1f24c9735..150d90103 100644 --- a/IRaCIS.Core.Application/Service/ImageAndDoc/DTO/UnionStudyViewDodel.cs +++ b/IRaCIS.Core.Application/Service/ImageAndDoc/DTO/UnionStudyViewDodel.cs @@ -377,7 +377,7 @@ namespace IRaCIS.Core.Application.Contracts public string SubjectCode { get; set; } } - public class CRCUploadTaskStudyQuery: SortInput + public class CRCUploadTaskStudyQuery : SortInput { [NotDefault] @@ -415,7 +415,7 @@ namespace IRaCIS.Core.Application.Contracts public int UploadedFileCount { get; set; } } - public class TaskDicomStudyDTO: DicomStudyBasicInfo + public class TaskDicomStudyDTO : DicomStudyBasicInfo { public Guid SubjectId { get; set; } @@ -438,12 +438,28 @@ namespace IRaCIS.Core.Application.Contracts } + public class NoneDicomFileInfo + { + [JsonIgnore] + public Guid? OriginNoneDicomStudyId { get; set; } + + public string FileType { get; set; } + + public long? FileSize { get; set; } + public string FileName { get; set; } + + public string Path { get; set; } + } + public class TaskNoneDicomStudyDTO : NoneDicomStudyBasicInfo { - + public Guid VisitTaskId { get; set; } public int UploadedFileCount { get; set; } + public List UploadedFileList { get; set; } + + public List FileList { get; set; } public Guid SubjectId { get; set; } @@ -468,7 +484,7 @@ namespace IRaCIS.Core.Application.Contracts public List NoneDicomStudyIdList { get; set; } } - public class IRReadingDownloadQuery:SortInput + public class IRReadingDownloadQuery : SortInput { [NotDefault] public Guid SubjectId { get; set; } diff --git a/IRaCIS.Core.Application/Service/ImageAndDoc/DownloadAndUploadService.cs b/IRaCIS.Core.Application/Service/ImageAndDoc/DownloadAndUploadService.cs index 23f219779..2838c683a 100644 --- a/IRaCIS.Core.Application/Service/ImageAndDoc/DownloadAndUploadService.cs +++ b/IRaCIS.Core.Application/Service/ImageAndDoc/DownloadAndUploadService.cs @@ -1016,6 +1016,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc TaskBlindName = u.TaskBlindName, TaskName = u.TaskName, SourceSubjectVisitId = u.SourceSubjectVisitId, + VisitTaskId=u.Id, Id = ns.Id, Description = ns.Description, @@ -1025,24 +1026,38 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc Modality = ns.Modality, StudyCode = ns.StudyCode, + FileList = ns.NoneDicomFileList.Select(t => new NoneDicomFileInfo() + { + FileType=t.FileType, + FileName = t.FileName, + FileSize = t.FileSize, + Path = t.Path + }).ToList() + }; var list = await query.Where(t => t.SubjectCode == inQuery.SubjectCode).SortToListAsync(inQuery); - var noneDicomStudyIdList = list.Select(t => t.Id).ToList(); + var noneDicomStudyTaskIdList = list.Select(t => t.VisitTaskId).ToList(); - var taskNoneDicomStudyList = _visitTaskRepository.Where(t => noneDicomStudyIdList.Contains(t.Id)) - .SelectMany(t => t.TaskNoneDicomStudyFileList).Where(t => noneDicomStudyIdList.Contains((Guid)t.VisitTaskId)) - .Select(u => new + var taskNoneDicomStudyList = _visitTaskRepository.Where(t => noneDicomStudyTaskIdList.Contains(t.Id)) + .SelectMany(t => t.TaskNoneDicomStudyFileList).Where(t => noneDicomStudyTaskIdList.Contains((Guid)t.VisitTaskId)) + .Select(u => new NoneDicomFileInfo { - u.OriginNoneDicomStudyId, + OriginNoneDicomStudyId = u.OriginNoneDicomStudyId, + + FileType=u.FileType, + FileName = u.FileName, + FileSize = u.FileSize, + Path = u.Path }) .ToList(); foreach (var item in list) { item.UploadedFileCount = taskNoneDicomStudyList.Where(t => t.OriginNoneDicomStudyId == item.Id).Count(); + item.UploadedFileList = taskNoneDicomStudyList.Where(t => t.OriginNoneDicomStudyId == item.Id).ToList(); } return list; diff --git a/IRaCIS.Core.Test/IRaCIS.Core.Test.csproj b/IRaCIS.Core.Test/IRaCIS.Core.Test.csproj index a43f6707d..b00d3c836 100644 --- a/IRaCIS.Core.Test/IRaCIS.Core.Test.csproj +++ b/IRaCIS.Core.Test/IRaCIS.Core.Test.csproj @@ -6,15 +6,23 @@ false default + + Exe - ..\bin + bin + + Always + + + Always + IRaCIS .Core.ServiceAsync.cs TextTemplatingFileGenerator @@ -65,6 +73,18 @@ + + + + + + + + + + + + diff --git a/IRaCIS.Core.Test/Program.cs b/IRaCIS.Core.Test/Program.cs new file mode 100644 index 000000000..533ca55fa --- /dev/null +++ b/IRaCIS.Core.Test/Program.cs @@ -0,0 +1,150 @@ + +using Fluid; +using IRaCIS.Core.Test.Template; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Options; +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; + +partial class Program +{ + static void Main() + { + //发布的目录和项目的目录有区别的 + var rootPath = AppContext.BaseDirectory.Replace(@"\bin\net8.0\", "").Replace(@"\bin\Release\net8.0\", ""); + + var templateFolderPath = Path.Combine(rootPath, "Template"); + var outPutTemplateFolderPath = Path.Combine(rootPath, "TemplateOutPut"); + + #region 生成文件目录准备 + if (!Directory.Exists(outPutTemplateFolderPath)) + { + Directory.CreateDirectory(outPutTemplateFolderPath); + } + var servicePath = Path.Combine(outPutTemplateFolderPath, "Service"); + var iServicePath = Path.Combine(outPutTemplateFolderPath, "IService"); + var entityPath = Path.Combine(outPutTemplateFolderPath, "Entity"); + var dtoPath = Path.Combine(outPutTemplateFolderPath, "DTO"); + + if (!Directory.Exists(servicePath)) + { + Directory.CreateDirectory(servicePath); + } + if (!Directory.Exists(iServicePath)) + { + Directory.CreateDirectory(iServicePath); + } + if (!Directory.Exists(entityPath)) + { + Directory.CreateDirectory(entityPath); + } + if (!Directory.Exists(dtoPath)) + { + Directory.CreateDirectory(dtoPath); + } + #endregion + + using (var context = new YourDbContext()) + { + var model = context.Model; + + foreach (var entityType in model.GetEntityTypes()) + { + string tableName = entityType.GetTableName(); + Console.WriteLine($"Table: {tableName}"); + + foreach (var property in entityType.GetProperties()) + { + string columnName = property.GetColumnName(); + string dataType = property.ClrType.Name; + bool isNullable = property.IsNullable; + + Console.WriteLine($" Column: {columnName}, Data Type: {dataType}, Is Nullable: {isNullable}"); + } + } + } + + + // 要生成的表名数组 + var tableNames = new List { "User", "Product", "Order" }; + + try + { + //便利所有模板文件进行生成操作 + foreach (var templateFilePath in Directory.GetFiles(templateFolderPath)) + { + + var fileName=Path.GetFileNameWithoutExtension(templateFilePath); + + //模板放入具体的文件夹 + var folder = fileName == "Entity" ? "Entity" : fileName.Replace("Entity", ""); + + foreach (var tableName in tableNames) + { + var model = new TemplateModel + { + TableName = tableName, + + IsPaged = true + }; + + + var parser = new FluidParser(); + + var source = File.ReadAllText(templateFilePath); + + if (parser.TryParse(source, out var template, out var error)) + { + var context = new TemplateContext(model); + + //Console.WriteLine(template.Render(context)); + + string outputFilePath = Path.Combine(outPutTemplateFolderPath, folder, $"{fileName.Replace("Entity", tableName)}.cs"); + + File.WriteAllText(outputFilePath, template.Render(context)); + } + else + { + Console.WriteLine($"Error: {error}"); + } + + + + } + } + } + catch (Exception ex) + { + + Console.WriteLine($"Error: {ex.Message}"); + } + + + } + + // Model class to pass data to the template + public class TemplateModel + { + public string TableName { get; set; } + + //生成的列表是是分页 还是不分页 + public bool IsPaged { get; set; } + + // 列表视图模型名称 + public string TableNameView => TableName + "View"; + //列表查询模型名称 + public string TableNameQuery => TableName + "Query"; + //添加和编辑模型名称 + public string TableNameAddOrEdit => TableName + "AddOrEdit"; + //删除主键属性名 + public string LowercaseTableNameId => char.ToLower(TableName[0]) + TableName.Substring(1) + "Id"; + + public string LowercaseRepositoryName => $"_{char.ToLower(TableName[0]) + TableName.Substring(1)}Repository" ; + + public string LowercaseQueryableName => $"{char.ToLower(TableName[0]) + TableName.Substring(1)}Queryable"; + + public DateTime DateTimeNow = DateTime.Now; + } +} diff --git a/IRaCIS.Core.Test/TT_Template/IRaCIS.Core.Entity.tt b/IRaCIS.Core.Test/TT_Template/IRaCIS.Core.Entity.tt index 99090292f..aa45fe94b 100644 --- a/IRaCIS.Core.Test/TT_Template/IRaCIS.Core.Entity.tt +++ b/IRaCIS.Core.Test/TT_Template/IRaCIS.Core.Entity.tt @@ -39,17 +39,18 @@ using IRaCIS.Core.Domain.Share; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel; +using Microsoft.EntityFrameworkCore; namespace IRaCIS.Core.Domain.Models { - [Description("ע: <#=tableName#>")] + [Comment("<#=tableName#>")] [Table("<#=tableName#>")] public class <#=tableName#> : BaseFullAuditEntity { <# var excludedColumns = new[] { "CreateUserId", "Id", "UpdateUserId", "CreateTime", "UpdateTime", "DeleteUserId", "IsDeleted", "DeletedTime" };#> <# foreach(DbColumn column in DbHelper.GetDbColumns(config.ConnectionString, config.DbDatabase, tableName)){ #> <# if (!excludedColumns.Contains(column.ColumnName)){ #> - [Description("<#= column.Remark == "" ? "" : column.Remark.Replace("\r\n"," ") #>")] + [Comment("<#= column.Remark == "" ? "" : column.Remark.Replace("\r\n"," ") #>")] public <#= column.CSharpType#><# if(column.CommonType.IsValueType && column.IsNullable){#>?<#}#> <#=column.ColumnName#> { get; set; } <#}#> <#}#> diff --git a/IRaCIS.Core.Test/Template/EntityService.liquid b/IRaCIS.Core.Test/Template/EntityService.liquid new file mode 100644 index 000000000..f0bce2e1f --- /dev/null +++ b/IRaCIS.Core.Test/Template/EntityService.liquid @@ -0,0 +1,69 @@ + +//-------------------------------------------------------------------- +// 此代码由模板自动生成 byzhouhang 20210918 +// 生成时间 {{DateTimeNow}} +// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。 +//-------------------------------------------------------------------- +using IRaCIS.Core.Domain.Models; +using Microsoft.AspNetCore.Mvc; +using IRaCIS.Core.Application.Interfaces; +using IRaCIS.Core.Application.ViewModel; +namespace IRaCIS.Core.Application.Service +{ + + [ ApiExplorerSettings(GroupName = "Test")] + public class {{TableName}}Service(IRepository<{{TableName}}> {{LowercaseRepositoryName}}): BaseService, I{{TableName}}Service + { + + {% if IsPaged %} + [HttpPost] + public async Task> Get{{TableName}}List({{TableNameQuery}} inQuery) + { + + var {{LowercaseQueryableName}} ={{LowercaseRepositoryName}} + .ProjectTo<{{TableNameView}}>(_mapper.ConfigurationProvider); + + var pageList= await {{LowercaseQueryableName}}.ToPagedListAsync(inQuery); + + return pageList; + } + {% else %} + [HttpPost] + public async Task> Get{{TableName}}List({{TableNameQuery}} inQuery) + { + + + var {{LowercaseQueryableName}} ={{LowercaseRepositoryName}} + .ProjectTo<{{TableNameView}}>(_mapper.ConfigurationProvider); + + return await {{LowercaseQueryableName}}.ToListAsync(); + } + {% endif %} + + + public async Task AddOrUpdate{{TableName}}({{TableName}}AddOrEdit addOrEdit{{TableName}}) + { + // 在此处拷贝automapper 映射 + + CreateMap<{{TableName}}, {{TableNameView}}>(); + CreateMap<{{TableName}},{{TableNameAddOrEdit}}>().ReverseMap(); + + + var entity = await {{LowercaseRepositoryName}}.InsertOrUpdateAsync(addOrEdit{{TableName}}, true); + + return ResponseOutput.Ok(entity.Id.ToString()); + + } + + + [HttpDelete("{{ '{' }}{{LowercaseTableNameId}}:guid{{ '}' }}")] + public async Task Delete{{TableName}}(Guid {{LowercaseTableNameId}}) + { + var success = await _<#=char.ToLower(tableName[0]) + tableName.Substring(1)#>Repository.DeleteFromQueryAsync(t => t.Id == {{LowercaseTableNameId}},true); + return ResponseOutput.Ok(); + } + + + } +} + diff --git a/IRaCIS.Core.Test/Template/IEntityService.liquid b/IRaCIS.Core.Test/Template/IEntityService.liquid new file mode 100644 index 000000000..37c1016f9 --- /dev/null +++ b/IRaCIS.Core.Test/Template/IEntityService.liquid @@ -0,0 +1,25 @@ + +//-------------------------------------------------------------------- +// 此代码由模板自动生成 byzhouhang 20210918 +// 生成时间 {{DateTimeNow}} +// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。 +//-------------------------------------------------------------------- +using IRaCIS.Core.Application.ViewModel; +namespace IRaCIS.Core.Application.Interfaces + { + + public interface I{{TableName}}Service + { + + {% if IsPaged %} + Task> Get{{TableName}}List({{TableNameQuery}} inQuery); + {% else %} + Task> Get{{TableName}}List({{TableNameQuery}} inQuery); + {% endif %} + + Task AddOrUpdate{{TableName}}({{TableNameAddOrEdit}} addOrEdit{{TableName}}); + + Task Delete{{TableNameView}}(Guid {{LowercaseTableNameId}}); + } +} + diff --git a/IRaCIS.Core.Test/Template/YourDbContext.cs b/IRaCIS.Core.Test/Template/YourDbContext.cs new file mode 100644 index 000000000..09593fc25 --- /dev/null +++ b/IRaCIS.Core.Test/Template/YourDbContext.cs @@ -0,0 +1,20 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace IRaCIS.Core.Test.Template +{ + class YourDbContext : DbContext + { + + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + optionsBuilder.UseSqlServer("Server=106.14.89.110,1435;Database=Test_IRC;User ID=sa;Password=xc@123456;TrustServerCertificate=true"); + } + + } +}