99
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
using MyCode.Project.Infrastructure;
|
||||
using MyCode.Project.Infrastructure.Extensions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MyCode.Project.Generate.Template
|
||||
{
|
||||
public class BaseTemplate
|
||||
{
|
||||
/// <summary>
|
||||
/// 表名
|
||||
/// </summary>
|
||||
public string ClassName;
|
||||
|
||||
/// <summary>
|
||||
/// 要保存的路径
|
||||
/// </summary>
|
||||
protected string SavePath { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 模板内容
|
||||
/// </summary>
|
||||
protected string TemplateContent { get; set; }
|
||||
|
||||
|
||||
public BaseTemplate(string tableName)
|
||||
{
|
||||
ClassName = tableName.ToHumpName();
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生成文件
|
||||
/// </summary>
|
||||
public void CreateFile() {
|
||||
|
||||
if (!FileUtils.IsFileExists(SavePath))
|
||||
{
|
||||
FileUtils.CreateFile(SavePath, TemplateContent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace MyCode.Project.Generate.Template
|
||||
{
|
||||
public class TemplateForRepository:BaseTemplate
|
||||
{
|
||||
|
||||
|
||||
public TemplateForRepository(string tablename):base(tablename)
|
||||
{
|
||||
base.SavePath = Path.Combine(FileUtils.GetSolutionPath(), "MyCode.Project.Repositories", "ZHMD",$"{ClassName}Repository.cs");
|
||||
|
||||
base.TemplateContent = $@"using MyCode.Project.Repositories.Common;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using MyCode.Project.Domain.Message;
|
||||
using MyCode.Project.Domain.ZHMDModel;
|
||||
using MyCode.Project.Infrastructure.Common;
|
||||
using MyCode.Project.Infrastructure.Search;
|
||||
using MyCode.Project.Domain.Repositories.ZHMDRepositories;
|
||||
|
||||
namespace MyCode.Project.Repositories.ZHMD
|
||||
{{
|
||||
public class {ClassName}Repository: LxmRepository,I{ClassName}Repository
|
||||
{{
|
||||
public {ClassName}Repository(LxmSqlSugarClient context) : base(context)
|
||||
{{ }}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}}
|
||||
}}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace MyCode.Project.Generate.Template
|
||||
{
|
||||
public class TemplateForRepositoryInterface:BaseTemplate
|
||||
{
|
||||
|
||||
|
||||
public TemplateForRepositoryInterface(string tablename):base(tablename)
|
||||
{
|
||||
|
||||
|
||||
base.SavePath = Path.Combine(FileUtils.GetSolutionPath(), "MyCode.Project.Domain", "ZHMDRepositories",$"I{ClassName}Repository.cs");
|
||||
|
||||
base.TemplateContent = $@"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using MyCode.Project.Infrastructure;
|
||||
using MyCode.Project.Domain;
|
||||
using MyCode.Project.Domain.ZHMDModel;
|
||||
using MyCode.Project.Infrastructure.Common;
|
||||
using MyCode.Project.Domain.Message;
|
||||
|
||||
namespace MyCode.Project.Domain.Repositories.ZHMDRepositories
|
||||
{{
|
||||
public interface I{ClassName}Repository
|
||||
{{
|
||||
|
||||
}}
|
||||
}}
|
||||
";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user