增加视图模板
continuous-integration/drone/push Build is passing Details

IRC_NewDev
hang 2024-09-05 18:05:26 +08:00
parent 6fd239cf70
commit 753941204f
5 changed files with 81 additions and 35 deletions

View File

@ -345,7 +345,7 @@ namespace IRaCIS.Core.Application.Helper
public async Task DownLoadFromOSSAsync(string ossRelativePath, string localFilePath)
{
ossRelativePath = ossRelativePath.TrimStart('/');
try
{
@ -406,7 +406,7 @@ namespace IRaCIS.Core.Application.Helper
};
await (await amazonS3Client.GetObjectAsync(getObjectArgs)).WriteResponseStreamToFileAsync(localFilePath, true, CancellationToken.None);
await (await amazonS3Client.GetObjectAsync(getObjectArgs)).WriteResponseStreamToFileAsync(localFilePath, true, CancellationToken.None);
}
@ -478,18 +478,26 @@ namespace IRaCIS.Core.Application.Helper
}
else if (ObjectStoreServiceOptions.ObjectStoreUse == "AWS")
{
var minIOConfig = ObjectStoreServiceOptions.AWS;
var awsConfig = ObjectStoreServiceOptions.AWS;
var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.EndPoint}")
.WithCredentials(minIOConfig.AccessKeyId, minIOConfig.SecretAccessKey).WithSSL(minIOConfig.UseSSL)
.Build();
var args = new PresignedGetObjectArgs()
.WithBucket(minIOConfig.BucketName)
.WithObject(ossRelativePath)
.WithExpiry(3600);
// 提供awsAccessKeyId和awsSecretAccessKey构造凭证
var credentials = new BasicAWSCredentials(awsConfig.AccessKeyId, awsConfig.SecretAccessKey);
var presignedUrl = await minioClient.PresignedGetObjectAsync(args);
//提供awsEndPoint域名进行访问配置
var clientConfig = new AmazonS3Config
{
ServiceURL = awsConfig.EndPoint
};
var amazonS3Client = new AmazonS3Client(credentials, clientConfig);
var presignedUrl = await amazonS3Client.GetPreSignedURLAsync(new GetPreSignedUrlRequest()
{
BucketName = awsConfig.BucketName,
Key = ossRelativePath,
Expires = DateTime.UtcNow.AddMinutes(120)
});
Uri uri = new Uri(presignedUrl);
@ -643,7 +651,7 @@ namespace IRaCIS.Core.Application.Helper
var deleteObjectsResponse = await amazonS3Client.DeleteObjectsAsync(deleteObjectsRequest);
}
}
else

View File

@ -20,6 +20,9 @@
<None Update="Template\EntityService.liquid">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Template\EntityViewModel.liquid">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Template\IEntityService.liquid">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>

View File

@ -1,7 +1,6 @@

using Fluid;
using IRaCIS.Core.Infra.EFCore;
using IRaCIS.Core.Test.Template;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
using System;
@ -48,6 +47,7 @@ partial class Program
#endregion
#region 直接通过上下文拿到实体信息
@ -68,11 +68,11 @@ partial class Program
string dataType = property.ClrType.Name;
bool isNullable = property.IsNullable;
Console.WriteLine($" Column: {columnName}, Data Type: {dataType}, Is Nullable: {isNullable}");
}
}
#endregion
#endregion
// 要生成的表名数组
var tableNames = new List<string> { "Product"/*, "Order"*/ };
@ -154,4 +154,39 @@ partial class Program
public DateTime DateTimeNow = DateTime.Now;
}
#region 核对code first 暂时屏蔽
public void CheckCodeFirst()
{
var contextOptions = new DbContextOptionsBuilder<IRaCISDBContext>().UseSqlServer(@"Server=106.14.89.110,1435;Database=Test_IRC;User ID=sa;Password=xc@123456;TrustServerCertificate=true").Options;
using var dbContext = new IRaCISDBContext(contextOptions);
var dbModel = dbContext.Model;
foreach (var entityType in dbModel.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;
int? maxLength = property.GetMaxLength(); // 获取最大长度
string columnType = property.GetColumnType(); // 获取数据库中的列类型
bool isKey = property.IsKey(); // 判断是否为主键
bool isIndex = property.IsIndex(); // 判断是否是索引
object defaultValue = property.GetDefaultValue(); // 获取默认值
bool isGenerated = property.ValueGenerated != Microsoft.EntityFrameworkCore.Metadata.ValueGenerated.Never; // 判断是否是自动生成的值
Console.WriteLine($" Column: {columnName}, Data Type: {dataType}, Is Nullable: {isNullable}, Max Length: {maxLength}, Column Type: {columnType}, Is Key: {isKey}, Is Index: {isIndex}, Default Value: {defaultValue}, Is Generated: {isGenerated}");
}
}
}
#endregion
}

View File

@ -0,0 +1,20 @@
//--------------------------------------------------------------------
// 此代码由T4模板自动生成 byzhouhang 20210918
// 生成时间 {{DateTimeNow}}
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
//--------------------------------------------------------------------
using System;
using IRaCIS.Core.Domain.Share;
using System.Collections.Generic;
namespace IRaCIS.Core.Application.ViewModel
{
public class {{ entityName }}ViewModel
{
{% for property in properties %}
public {{ property.type }} {{ property.name }} { get; set; }
{% endfor %}
}
}

View File

@ -1,20 +0,0 @@
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");
}
}
}