1、线上设计表
通过后台对表名称,字段 及 类型进行设计,设计完成后执行命令调用接口生成表。
2、一键生成并部署
通过设计的表,调用后端接口一键生成 实体Model,仓储类,服务类及控制器(CURD)等文件到指定的源代码位置,然后通过执行.bat或者.sh 文件. 进行提交Git命令 ,Gogs中Webhooks对git内容改变触发 Jenkins 自动化部署,从而形成增删改详情等接口。
public class CodeHelperTest : IClassFixture<CodeHelperFixture>
{
private readonly ICodeGeneratorHelper _codeHelper;
private readonly ITestOutputHelper _testOutputHelper;
public CodeHelperTest(CodeHelperFixture helper, ITestOutputHelper testOutputHelper)
{
_codeHelper = helper.codeHelper;
_testOutputHelper = testOutputHelper;
}
[Fact]
public void Test1()
{
_codeHelper.Run();
Task.Delay(1000);
Process proc = new Process();
string MainAppPath = @"D:\个人文档\项目参考\EF\master\Project\Start.bat";//git 执行命令
proc.StartInfo.FileName = MainAppPath;
proc.StartInfo.WorkingDirectory = Path.GetDirectoryName(MainAppPath); ;
proc.Start();
//System.Diagnostics.Process.Start(@"D:\个人文档\项目参考\EF\master\Project\Start.bat");
}
}
public class CodeHelperFixture
{
public ICodeGeneratorHelper codeHelper { get; }
public CodeHelperFixture() =>
codeHelper = new CodeGeneratorHelper(new CodeHelperOptions {
#region 数据连接配置
ConnectConnectionString = "Server=127.0.0.1;Uid=root;Pwd=123456;Database=logistics;Port=3306;SslMode=none;CharSet=utf8;",
ProviderName = "MySql.Data.MySqlClient",
#endregion
#region 项目空间命名配置
NameSpace = new CodeNamespace
{
ModelsNamespace = "XmSoft.Core.Domain.Models",
ApiControllerNamespace = "XmSoft.Core.Api.Controllers",
InterfaceName = "XmSoft.Core.Interface",
ServicesNamespace = "XmSoft.Core.Service",
RepositoriesNamespace = "XmSoft.Core.Repository",
ValidatorNamespace = "XmSoft.Core.Validation",
DomainName = "XmSoft.Core.Domain",
},
#endregion
#region 输出路径配置
CodePath = new OutCodePath
{
ControllerPath = @"D:\个人文档\项目参考\EF\master\Project\XmSoft.Core.WebApi\Controllers\",
RepositoriesPath = @"D:\个人文档\项目参考\EF\master\Project\XmSoft.Core.Repository\",
IRepositoriesPath = @"D:\个人文档\项目参考\EF\master\Project\XmSoft.Core.IRepository\",
IServicesPath = @"D:\个人文档\项目参考\EF\master\Project\XmSoft.Core.IService\",
ServicesPath = @"D:\个人文档\项目参考\EF\master\Project\XmSoft.Core.Service\",
ModelsPath = @"D:\个人文档\项目参考\EF\master\Project\XmSoft.Core.Domain\Models\",
ValidatorPath = @"D:\个人文档\项目参考\EF\master\Project\XmSoft.Core.Validation\"
},
#endregion
//执行的表 名称配置
Tables = new string[] { "h_delivery_domain" },
});
}
3、配置
a. Gogs配置 :创建仓库并提交代码
b. Jenkins配置
c.Gogs 钩子配置
4、测试
提交代码
@echo off
chcp 65001
echo ---拉取---
git pull
echo ---新增---
git add .
echo ---提交更新---
git commit -am '更新说明'
echo ---提交---
git push
pause
自动执行jenkins进行构建