Merge branch 'Test_IRC_Net8' of https://gitea.frp.extimaging.com/XCKJ/irc-netcore-api into Test_IRC_Net8
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
commit
7ace6c3593
|
@ -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"
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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": "AeX5r4xHQH7tNJlTTFVv5/zBXie1Kj+mAayKrukp",
|
||||
"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
|
||||
}
|
||||
|
||||
}
|
|
@ -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": "l+yjtvV7Z4jiwm/7xCYv30UeUj/SvuqqYzAwjJHf",
|
||||
"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
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<OSSFileDTO> UploadedFileList { get; set; } = new List<OSSFileDTO>();
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
|
|
@ -83,6 +83,11 @@
|
|||
"CompanyShortName": "Elevate Imaging",
|
||||
"CompanyShortNameCN": "展影医疗",
|
||||
"SiteUrl": "https://lili.elevateimaging.ai/login"
|
||||
},
|
||||
|
||||
"SystemPacsConfig": {
|
||||
"Port": "11113",
|
||||
"IP": "44.210.231.169"
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -89,6 +89,11 @@
|
|||
"CompanyShortName": "Elevate Imaging",
|
||||
"CompanyShortNameCN": "展影医疗",
|
||||
"SiteUrl": "https://lili.test.elevateimaging.ai/login"
|
||||
},
|
||||
|
||||
"SystemPacsConfig": {
|
||||
"Port": "11113",
|
||||
"IP": "3.226.182.187,1435"
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -83,6 +83,11 @@
|
|||
"CompanyShortName": "Elevate Imaging",
|
||||
"CompanyShortNameCN": "展影医疗",
|
||||
"SiteUrl": "https://lili.test.elevateimaging.ai/login"
|
||||
},
|
||||
|
||||
"SystemPacsConfig": {
|
||||
"Port": "11113",
|
||||
"IP": "3.226.182.187,1435"
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc.DTO
|
|||
|
||||
|
||||
|
||||
public List<DicomStudyBasicInfo> DicomStudyList { get; set; }
|
||||
public List<DicomStudyBasicInfo> DicomStudyList { get; set; }=new List<DicomStudyBasicInfo>();
|
||||
|
||||
public List<NoneDicomStudyBasicInfo> NoneDicomStudyList { get; set; }
|
||||
}
|
||||
|
|
|
@ -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<NoneDicomFileInfo> UploadedFileList { get; set; }
|
||||
|
||||
public List<NoneDicomFileInfo> FileList { get; set; }
|
||||
|
||||
public Guid SubjectId { get; set; }
|
||||
|
||||
|
@ -468,7 +484,7 @@ namespace IRaCIS.Core.Application.Contracts
|
|||
public List<Guid> NoneDicomStudyIdList { get; set; }
|
||||
}
|
||||
|
||||
public class IRReadingDownloadQuery:SortInput
|
||||
public class IRReadingDownloadQuery : SortInput
|
||||
{
|
||||
[NotDefault]
|
||||
public Guid SubjectId { get; set; }
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -6,15 +6,23 @@
|
|||
<IsPackable>false</IsPackable>
|
||||
|
||||
<LangVersion>default</LangVersion>
|
||||
|
||||
<OutputType>Exe</OutputType>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<OutputPath>..\bin</OutputPath>
|
||||
<OutputPath>bin</OutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Template\EntityService.liquid">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Template\IEntityService.liquid">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="TT_Template\IRaCIS .Core.ServiceAsync.tt">
|
||||
<LastGenOutput>IRaCIS .Core.ServiceAsync.cs</LastGenOutput>
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
|
@ -65,6 +73,18 @@
|
|||
<Folder Include="TT_Template\IServices_New\" />
|
||||
<Folder Include="TT_Template\Models_New\" />
|
||||
<Folder Include="TT_Template\Services_New\" />
|
||||
<Folder Include="TemplateOutPut\" />
|
||||
<Folder Include="TemplateOutPut\Entity\" />
|
||||
<Folder Include="TemplateOutPut\IService\" />
|
||||
<Folder Include="TemplateOutPut\Service\" />
|
||||
<Folder Include="TemplateOutPut\DTO\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Fluid.Core" Version="2.11.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.8" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="8.0.8" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.8" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -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<string> { "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;
|
||||
}
|
||||
}
|
|
@ -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; }
|
||||
<#}#>
|
||||
<#}#>
|
||||
|
|
|
@ -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<PageOutput<{{TableNameView}}>> 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<List<{{TableNameView}}>> Get{{TableName}}List({{TableNameQuery}} inQuery)
|
||||
{
|
||||
|
||||
|
||||
var {{LowercaseQueryableName}} ={{LowercaseRepositoryName}}
|
||||
.ProjectTo<{{TableNameView}}>(_mapper.ConfigurationProvider);
|
||||
|
||||
return await {{LowercaseQueryableName}}.ToListAsync();
|
||||
}
|
||||
{% endif %}
|
||||
|
||||
|
||||
public async Task<IResponseOutput> 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<IResponseOutput> Delete{{TableName}}(Guid {{LowercaseTableNameId}})
|
||||
{
|
||||
var success = await _<#=char.ToLower(tableName[0]) + tableName.Substring(1)#>Repository.DeleteFromQueryAsync(t => t.Id == {{LowercaseTableNameId}},true);
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -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<PageOutput<<{{TableNameView}}>> Get{{TableName}}List({{TableNameQuery}} inQuery);
|
||||
{% else %}
|
||||
Task<List<{{TableNameView}}>> Get{{TableName}}List({{TableNameQuery}} inQuery);
|
||||
{% endif %}
|
||||
|
||||
Task<IResponseOutput> AddOrUpdate{{TableName}}({{TableNameAddOrEdit}} addOrEdit{{TableName}});
|
||||
|
||||
Task<IResponseOutput> Delete{{TableNameView}}(Guid {{LowercaseTableNameId}});
|
||||
}
|
||||
}
|
||||
|
|
@ -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");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue