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進行建構