开发代码生成功能
This commit is contained in:
@@ -3,6 +3,7 @@ using Infrastructure.Attribute;
|
||||
using Infrastructure.Enums;
|
||||
using Infrastructure.Model;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -74,20 +75,18 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
[Log(Title = "代码生成", BusinessType = BusinessType.OTHER)]
|
||||
public IActionResult Generate(string dbName, string baseSpace, string tables, string replaceTableNameStr)
|
||||
{
|
||||
if (string.IsNullOrEmpty(tables))
|
||||
{
|
||||
throw new CustomException(ResultCode.CUSTOM_ERROR, "请求参数为空");
|
||||
}
|
||||
if (string.IsNullOrEmpty(baseSpace))
|
||||
{
|
||||
throw new CustomException(ResultCode.CUSTOM_ERROR, "命名空间不能为空");
|
||||
}
|
||||
string[] tableList = tables.Split(",");
|
||||
List<DbTableInfo> tableInfos = new List<DbTableInfo>();// CodeGeneratorService.GetAllTables(tables);
|
||||
foreach (var item in tableList)
|
||||
{
|
||||
tableInfos.Add(new DbTableInfo() { TableName = item });
|
||||
//baseSpace = "Zr";
|
||||
}
|
||||
DbTableInfo dbTableInfo = new() { Name = tables };
|
||||
CodeGeneratorTool.Generate(dbName, baseSpace, dbTableInfo, replaceTableNameStr, true);
|
||||
|
||||
CodeGeneratorTool.Generate(dbName, baseSpace, tableInfos, replaceTableNameStr, true);
|
||||
|
||||
return SUCCESS(null);
|
||||
return SUCCESS(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
"appName": "ZR Admin System",
|
||||
"ConnectionStrings": {
|
||||
"Conn_Admin": "server=127.0.0.1;database=admin;user=zr;pwd=abc"
|
||||
},
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
"appName": "ZR Admin system",
|
||||
"ConnectionStrings": {
|
||||
"Conn_Admin": "server=127.0.0.1;database=admin;user=zr;pwd=abc"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user