模板准备完毕,剩下如何适配生成以后自动生成视图模型和service
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
fff6ef5fe2
commit
55e0624dc6
|
@ -33,13 +33,13 @@
|
|||
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Template\EntityService.liquid">
|
||||
<None Update="LiquidTemplate\EntityService.liquid">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Template\EntityViewModel.liquid">
|
||||
<None Update="LiquidTemplate\EntityViewModel.liquid">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Template\IEntityService.liquid">
|
||||
<None Update="LiquidTemplate\IEntityService.liquid">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="TT_Template\IRaCIS .Core.ServiceAsync.tt">
|
||||
|
@ -92,11 +92,6 @@
|
|||
<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\ViewModel\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -8,6 +8,9 @@ using IRaCIS.Core.Domain.Models;
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using IRaCIS.Core.Application.Interfaces;
|
||||
using IRaCIS.Core.Application.ViewModel;
|
||||
using IRaCIS.Core.Infrastructure.Extention;
|
||||
using System.Threading.Tasks;
|
||||
using IRaCIS.Core.Infra.EFCore;
|
||||
namespace IRaCIS.Core.Application.Service
|
||||
{
|
||||
|
|
@ -12,7 +12,7 @@ namespace IRaCIS.Core.Application.ViewModel
|
|||
public class {{ TableNameView }} : {{ TableNameAddOrEdit }}
|
||||
{
|
||||
{% for field in ViewListFieldList %}
|
||||
public {{ field.CSharpType }} {{ field.FieldName }} { get; set; }
|
||||
public {{ field.CSharpType }} {{ field.FieldName }} { get; set; }
|
||||
{% endfor %}
|
||||
}
|
||||
|
||||
|
@ -21,9 +21,9 @@ namespace IRaCIS.Core.Application.ViewModel
|
|||
{
|
||||
{%- for field in AddOrUpdateFieldList -%}
|
||||
{% if field.IsPrimarykey %}
|
||||
public {{ field.CSharpType }}? {{ field.FieldName }} { get; set; }
|
||||
public {{ field.CSharpType }}? {{ field.FieldName }} { get; set; }
|
||||
{% else %}
|
||||
public {{ field.CSharpType }} {{ field.FieldName }} { get; set; }
|
||||
public {{ field.CSharpType }} {{ field.FieldName }} { get; set; }
|
||||
{% endif %}
|
||||
{%- endfor -%}
|
||||
}
|
||||
|
@ -32,9 +32,9 @@ namespace IRaCIS.Core.Application.ViewModel
|
|||
{
|
||||
{%- for field in QueryListFieldList -%}
|
||||
{% if field.IsNullable and field.IsCSharpString == false %}
|
||||
public {{ field.CSharpType }} {{ field.FieldName }} { get; set; }
|
||||
public {{ field.CSharpType }} {{ field.FieldName }} { get; set; }
|
||||
{% else %}
|
||||
public {{ field.CSharpType }}? {{ field.FieldName }} { get; set; }
|
||||
public {{ field.CSharpType }}? {{ field.FieldName }} { get; set; }
|
||||
{% endif %}
|
||||
{%- endfor -%}
|
||||
}
|
|
@ -4,6 +4,9 @@
|
|||
// 生成时间 {{DateTimeNow}}
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
|
||||
//--------------------------------------------------------------------
|
||||
using System;
|
||||
using IRaCIS.Core.Infrastructure.Extention;
|
||||
using System.Threading.Tasks;
|
||||
using IRaCIS.Core.Application.ViewModel;
|
||||
namespace IRaCIS.Core.Application.Interfaces
|
||||
{
|
|
@ -17,42 +17,46 @@ partial class Program
|
|||
//发布的目录和项目的目录有区别的
|
||||
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");
|
||||
var templateFolderPath = Path.Combine(rootPath, "LiquidTemplate");
|
||||
var outPutTemplateFolderPath = Path.Combine(rootPath, "LiquidTemplateOutPut");
|
||||
|
||||
#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);
|
||||
}
|
||||
#region 废弃 没必要分目录,还是手动设置文件夹
|
||||
//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
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
// 要生成的表名数组
|
||||
var tableNames = new List<string> { /*"Subject", "Order"*/ };
|
||||
var tableNames = new List<string> { "Subject", "Order" };
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -234,7 +238,8 @@ partial class Program
|
|||
|
||||
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;
|
||||
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);
|
||||
|
||||
|
|
|
@ -32,3 +32,6 @@ Scaffold-DbContext "Server=106.14.89.110,1435;Database=Test_IRC;User ID=sa;Passw
|
|||
dotnet ef dbcontext scaffold "Server=106.14.89.110,1435;Database=Test_IRC;User ID=sa;Password=xc@123456;TrustServerCertificate=true" Microsoft.EntityFrameworkCore.SqlServer -p IRaCIS.Core.Test -d -o ModelFolder -c "IRaCISDBContext" -t Subject
|
||||
|
||||
|
||||
开发者PowerShell || 程序包管理控制台命令行 使用:
|
||||
通过Liquid模板生成基础视图模型、服务接口、服务实现基本方法(必须先有数据库实体模型,否则视图模型无法生成)
|
||||
dotnet run --project IRaCIS.Core.Test
|
Loading…
Reference in New Issue