优化代码生成功能、新增加打包zip文件
This commit is contained in:
parent
44ab0f2141
commit
62407707a5
@ -59,7 +59,7 @@ namespace Infrastructure.Extensions
|
|||||||
services.AddTransient(serviceType, type);
|
services.AddTransient(serviceType, type);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Console.WriteLine($"注册:{serviceType}");
|
//Console.WriteLine($"注册:{serviceType}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -7,18 +7,10 @@ namespace Infrastructure
|
|||||||
public class OptionsSetting
|
public class OptionsSetting
|
||||||
{
|
{
|
||||||
public static string ConnAdmin = "conn_zrAdmin";
|
public static string ConnAdmin = "conn_zrAdmin";
|
||||||
public static string DbType = "conn_admin_Type";
|
public static string ConnDbType = "dbType";
|
||||||
public static string DbKey = "DbKey";
|
public static string DbKey = "DbKey";
|
||||||
public string Conn_Admin { get; set; }
|
|
||||||
|
|
||||||
public string AppName { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 主库
|
|
||||||
/// </summary>
|
|
||||||
public string Master { get; set; }
|
|
||||||
|
|
||||||
public string Redis { get; set; }
|
public string Redis { get; set; }
|
||||||
|
|
||||||
public string Database { get; set; }
|
public string Database { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否演示模式
|
/// 是否演示模式
|
||||||
|
|||||||
@ -2,7 +2,9 @@
|
|||||||
using Infrastructure.Attribute;
|
using Infrastructure.Attribute;
|
||||||
using Infrastructure.Enums;
|
using Infrastructure.Enums;
|
||||||
using Mapster;
|
using Mapster;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -31,10 +33,12 @@ namespace ZR.Admin.WebApi.Controllers
|
|||||||
private CodeGeneraterService _CodeGeneraterService = new CodeGeneraterService();
|
private CodeGeneraterService _CodeGeneraterService = new CodeGeneraterService();
|
||||||
private IGenTableService GenTableService;
|
private IGenTableService GenTableService;
|
||||||
private IGenTableColumnService GenTableColumnService;
|
private IGenTableColumnService GenTableColumnService;
|
||||||
public CodeGeneratorController(IGenTableService genTableService, IGenTableColumnService genTableColumnService)
|
private IWebHostEnvironment WebHostEnvironment;
|
||||||
|
public CodeGeneratorController(IGenTableService genTableService, IGenTableColumnService genTableColumnService, IWebHostEnvironment webHostEnvironment)
|
||||||
{
|
{
|
||||||
GenTableService = genTableService;
|
GenTableService = genTableService;
|
||||||
GenTableColumnService = genTableColumnService;
|
GenTableColumnService = genTableColumnService;
|
||||||
|
WebHostEnvironment = webHostEnvironment;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -84,10 +88,13 @@ namespace ZR.Admin.WebApi.Controllers
|
|||||||
var genTableInfo = GenTableService.GetGenTableInfo(dto.TableId);
|
var genTableInfo = GenTableService.GetGenTableInfo(dto.TableId);
|
||||||
var getTableColumn = GenTableColumnService.GenTableColumns(dto.TableId);
|
var getTableColumn = GenTableColumnService.GenTableColumns(dto.TableId);
|
||||||
genTableInfo.Columns = getTableColumn;
|
genTableInfo.Columns = getTableColumn;
|
||||||
//DbTableInfo dbTableInfo = new() { Name = dto.tableName };
|
|
||||||
CodeGeneratorTool.Generate(genTableInfo, dto);
|
|
||||||
|
|
||||||
return SUCCESS(genTableInfo);
|
dto.ParentPath = WebHostEnvironment.WebRootPath + "\\Generatecode\\" + DateTime.Now.ToString("yyyyMMdd") + "\\";
|
||||||
|
|
||||||
|
CodeGeneratorTool.Generate(genTableInfo, dto);
|
||||||
|
string zipPath = CodeGeneratorTool.ZipGenCode(dto);
|
||||||
|
|
||||||
|
return SUCCESS(new { zipPath });
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -134,8 +141,8 @@ namespace ZR.Admin.WebApi.Controllers
|
|||||||
{
|
{
|
||||||
long[] tableId = Tools.SpitLongArrary(tableIds);
|
long[] tableId = Tools.SpitLongArrary(tableIds);
|
||||||
|
|
||||||
GenTableService.DeleteGenTableByIds(tableId);
|
int result = GenTableService.DeleteGenTableByIds(tableId);
|
||||||
return SUCCESS(1);
|
return SUCCESS(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -173,70 +180,28 @@ namespace ZR.Admin.WebApi.Controllers
|
|||||||
TableComment = tabInfo.Description,
|
TableComment = tabInfo.Description,
|
||||||
Create_by = userName,
|
Create_by = userName,
|
||||||
};
|
};
|
||||||
int rows = GenTableService.ImportGenTable(genTable);
|
genTable.TableId = GenTableService.ImportGenTable(genTable);
|
||||||
if (rows > 0)
|
|
||||||
|
if (genTable.TableId > 0)
|
||||||
{
|
{
|
||||||
//保存列信息
|
//保存列信息
|
||||||
List<DbColumnInfo> dbColumnInfos = _CodeGeneraterService.GetColumnInfo(dbName, tableName);
|
List<DbColumnInfo> dbColumnInfos = _CodeGeneraterService.GetColumnInfo(dbName, tableName);
|
||||||
List<GenTableColumn> genTableColumns = new();
|
List<GenTableColumn> genTableColumns = CodeGeneratorTool.InitGenTableColumn(genTable, dbColumnInfos);
|
||||||
foreach (var column in dbColumnInfos)
|
|
||||||
{
|
|
||||||
GenTableColumn genTableColumn = new()
|
|
||||||
{
|
|
||||||
ColumnName = CodeGeneratorTool.FirstLowerCase(column.DbColumnName),
|
|
||||||
ColumnComment = column.ColumnDescription,
|
|
||||||
IsPk = column.IsPrimarykey,
|
|
||||||
ColumnType = column.DataType,
|
|
||||||
TableId = rows,
|
|
||||||
TableName = tableName,
|
|
||||||
CsharpType = TableMappingHelper.GetPropertyDatatype(column.DataType),
|
|
||||||
CsharpField = column.DbColumnName.Substring(0, 1).ToUpper() + column.DbColumnName[1..],
|
|
||||||
IsRequired = !column.IsNullable,
|
|
||||||
IsIncrement = column.IsIdentity,
|
|
||||||
Create_by = userName,
|
|
||||||
Create_time = DateTime.Now,
|
|
||||||
IsInsert = !column.IsIdentity && !column.IsPrimarykey,
|
|
||||||
IsEdit = !column.IsIdentity && !column.IsPrimarykey,
|
|
||||||
IsList = true,
|
|
||||||
IsQuery = false,
|
|
||||||
HtmlType = GenConstants.HTML_INPUT
|
|
||||||
};
|
|
||||||
|
|
||||||
if (CodeGeneratorTool.imageFiled.Any(f => column.DbColumnName.ToLower().Contains(f.ToLower())))
|
|
||||||
{
|
|
||||||
genTableColumn.HtmlType = GenConstants.HTML_IMAGE_UPLOAD;
|
|
||||||
}
|
|
||||||
else if (genTableColumn.CsharpType.ToLower().Contains("datetime"))
|
|
||||||
{
|
|
||||||
genTableColumn.HtmlType = GenConstants.HTML_DATETIME;
|
|
||||||
}
|
|
||||||
else if (CodeGeneratorTool.radioFiled.Any(f => column.DbColumnName.Contains(f)))
|
|
||||||
{
|
|
||||||
genTableColumn.HtmlType = GenConstants.HTML_RADIO;
|
|
||||||
}
|
|
||||||
else if (CodeGeneratorTool.selectFiled.Any(f => column.DbColumnName.Contains(f)))
|
|
||||||
{
|
|
||||||
genTableColumn.HtmlType = GenConstants.HTML_SELECT;
|
|
||||||
}
|
|
||||||
else if (column.Length > 300)
|
|
||||||
{
|
|
||||||
genTableColumn.HtmlType = GenConstants.HTML_TEXTAREA;
|
|
||||||
}
|
|
||||||
|
|
||||||
genTableColumns.Add(genTableColumn);
|
|
||||||
}
|
|
||||||
|
|
||||||
GenTableColumnService.DeleteGenTableColumnByTableName(tableName);
|
GenTableColumnService.DeleteGenTableColumnByTableName(tableName);
|
||||||
GenTableColumnService.InsertGenTableColumn(genTableColumns);
|
GenTableColumnService.InsertGenTableColumn(genTableColumns);
|
||||||
|
genTable.Columns = genTableColumns;
|
||||||
|
|
||||||
|
return SUCCESS(genTable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return SUCCESS(1);
|
return ToRespose(ResultCode.FAIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 代码生成保存
|
/// 修改保存代码生成业务
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPut]
|
[HttpPut]
|
||||||
|
|||||||
@ -1,130 +0,0 @@
|
|||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// <auto-generated>
|
|
||||||
// 此代码已从模板生成。
|
|
||||||
//
|
|
||||||
// 手动更改此文件可能导致应用程序出现意外的行为。
|
|
||||||
// 如果重新生成代码,将覆盖对此文件的手动更改。
|
|
||||||
// </auto-generated>
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
using Infrastructure.Attribute;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using ZR.Admin.WebApi.Filters;
|
|
||||||
using ZR.Model.System;
|
|
||||||
using ZR.Service.System.IService;
|
|
||||||
using Infrastructure.Model;
|
|
||||||
using SqlSugar;
|
|
||||||
using Mapster;
|
|
||||||
using ZR.Model.System.Dto;
|
|
||||||
using Infrastructure.Enums;
|
|
||||||
using Infrastructure;
|
|
||||||
using ZR.Admin.WebApi.Extensions;
|
|
||||||
|
|
||||||
namespace ZR.Admin.WebApi.Controllers
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// T4代码自动生成
|
|
||||||
/// </summary>
|
|
||||||
|
|
||||||
[Verify]
|
|
||||||
[Route("system/SysFile")]
|
|
||||||
public class SysFile1Controller: BaseController
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 文件管理接口
|
|
||||||
/// </summary>
|
|
||||||
private readonly ISysFileService _SysFileService;
|
|
||||||
|
|
||||||
public SysFile1Controller(ISysFileService SysFileService)
|
|
||||||
{
|
|
||||||
_SysFileService = SysFileService;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 查询文件管理列表
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet("list")]
|
|
||||||
//[ActionPermissionFilter(Permission = "system:SysFile:list")]
|
|
||||||
public IActionResult Query([FromQuery] SysFileQueryDto parm)
|
|
||||||
{
|
|
||||||
//开始拼装查询条件
|
|
||||||
var predicate = Expressionable.Create<SysFile>();
|
|
||||||
|
|
||||||
//TODO 搜索条件
|
|
||||||
//predicate = predicate.And(m => m.Name.Contains(parm.Name));
|
|
||||||
|
|
||||||
var response = _SysFileService.GetPages(predicate.ToExpression(), parm);
|
|
||||||
|
|
||||||
return SUCCESS(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 查询文件管理详情
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet("{id}")]
|
|
||||||
public IActionResult Get(string id)
|
|
||||||
{
|
|
||||||
var response = _SysFileService.GetId(id);
|
|
||||||
|
|
||||||
return SUCCESS(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 添加文件管理
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPost]
|
|
||||||
//[ActionPermissionFilter(Permission = "system:SysFile:add")]
|
|
||||||
[Log(Title = "文件管理添加", BusinessType = BusinessType.INSERT)]
|
|
||||||
public IActionResult Create([FromBody] SysFile parm)
|
|
||||||
{
|
|
||||||
if (parm == null)
|
|
||||||
{
|
|
||||||
throw new CustomException("请求参数错误");
|
|
||||||
}
|
|
||||||
//从 Dto 映射到 实体
|
|
||||||
var addModel = parm.Adapt<SysFile>().ToCreate();
|
|
||||||
//addModel.CreateID = User.Identity.Name;
|
|
||||||
|
|
||||||
return SUCCESS(_SysFileService.Add(addModel));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 更新文件管理
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPut("edit")]
|
|
||||||
//[ActionPermissionFilter(Permission = "system:SysFile:update")]
|
|
||||||
[Log(Title = "文件管理修改", BusinessType = BusinessType.UPDATE)]
|
|
||||||
public IActionResult Update([FromBody] SysFile parm)
|
|
||||||
{
|
|
||||||
//从 Dto 映射到 实体
|
|
||||||
var addModel = parm.Adapt<SysFile>().ToCreate();
|
|
||||||
//addModel.CreateID = User.Identity.Name;
|
|
||||||
//TODO 字段映射
|
|
||||||
var response = _SysFileService.Update(addModel);
|
|
||||||
|
|
||||||
return SUCCESS(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 删除文件管理
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpDelete("{id}")]
|
|
||||||
//[ActionPermissionFilter(Permission = "system:SysFile:delete")]
|
|
||||||
[Log(Title = "文件管理删除", BusinessType = BusinessType.DELETE)]
|
|
||||||
public IActionResult Delete(int id = 0)
|
|
||||||
{
|
|
||||||
if (id <= 0) { return OutputJson(ApiResult.Error($"删除失败Id 不能为空")); }
|
|
||||||
|
|
||||||
// 删除文件管理
|
|
||||||
var response = _SysFileService.Delete(id);
|
|
||||||
|
|
||||||
return SUCCESS(response);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,145 +0,0 @@
|
|||||||
<#@ template debug="false" hostspecific="false" language="C#" #>
|
|
||||||
<#@ assembly name="System.Core" #>
|
|
||||||
<#@ import namespace="System.Linq" #>
|
|
||||||
<#@ import namespace="System.Text" #>
|
|
||||||
<#@ import namespace="System.Collections.Generic" #>
|
|
||||||
<#@ output extension=".cs" #>
|
|
||||||
|
|
||||||
<#
|
|
||||||
string ModelName="SysFile";
|
|
||||||
string ControllerName="SysFile";
|
|
||||||
string ServiceName="SysFileService";
|
|
||||||
string FileName="文件管理";
|
|
||||||
string ModelNameSpace="ZRAdmin.Controllers";
|
|
||||||
#>
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// <auto-generated>
|
|
||||||
// 此代码已从模板生成。
|
|
||||||
//
|
|
||||||
// 手动更改此文件可能导致应用程序出现意外的行为。
|
|
||||||
// 如果重新生成代码,将覆盖对此文件的手动更改。
|
|
||||||
// </auto-generated>
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
using Infrastructure.Attribute;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using ZRAdmin.Filters;
|
|
||||||
using ZR.Model;
|
|
||||||
using ZR.Model.System;
|
|
||||||
using ZR.Model.Vo;
|
|
||||||
using ZR.Service.IService;
|
|
||||||
using Infrastructure.Model;
|
|
||||||
using SqlSugar;
|
|
||||||
using Mapster;
|
|
||||||
using ZR.Model.Dto.System;
|
|
||||||
using Infrastructure.Enums;
|
|
||||||
using Infrastructure;
|
|
||||||
using ZRAdmin.Extensions;
|
|
||||||
|
|
||||||
namespace <#=ModelNameSpace#>
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// T4代码自动生成
|
|
||||||
/// </summary>
|
|
||||||
|
|
||||||
[Verify]
|
|
||||||
[Route("system/<#=ModelName#>")]
|
|
||||||
public class <#=ControllerName#>1Controller: BaseController
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// <#=FileName#>接口
|
|
||||||
/// </summary>
|
|
||||||
private readonly I<#=ServiceName#> _<#=ServiceName#>;
|
|
||||||
|
|
||||||
public <#=ControllerName#>1Controller(I<#=ServiceName#> <#=ServiceName#>)
|
|
||||||
{
|
|
||||||
_<#=ServiceName#> = <#=ServiceName#>;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 查询<#=FileName#>列表
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet("list")]
|
|
||||||
//[ActionPermissionFilter(Permission = "system:<#=ModelName#>:list")]
|
|
||||||
public IActionResult Query([FromQuery] <#=ModelName#>QueryDto parm)
|
|
||||||
{
|
|
||||||
//开始拼装查询条件
|
|
||||||
var predicate = Expressionable.Create<<#=ModelName#>>();
|
|
||||||
|
|
||||||
//TODO 搜索条件
|
|
||||||
//predicate = predicate.And(m => m.Name.Contains(parm.Name));
|
|
||||||
|
|
||||||
var response = _<#=ServiceName#>.GetPages(predicate.ToExpression(), parm);
|
|
||||||
|
|
||||||
return SUCCESS(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 查询<#=FileName#>详情
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet("{id}")]
|
|
||||||
public IActionResult Get(string id)
|
|
||||||
{
|
|
||||||
var response = _<#=ServiceName#>.GetId(id);
|
|
||||||
|
|
||||||
return SUCCESS(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 添加<#=FileName#>
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPost]
|
|
||||||
//[ActionPermissionFilter(Permission = "system:<#=ModelName#>:add")]
|
|
||||||
[Log(Title = "<#=FileName#>添加", BusinessType = BusinessType.INSERT)]
|
|
||||||
public IActionResult Create([FromBody] <#=ModelName#> parm)
|
|
||||||
{
|
|
||||||
if (parm == null)
|
|
||||||
{
|
|
||||||
throw new CustomException("请求参数错误");
|
|
||||||
}
|
|
||||||
//从 Dto 映射到 实体
|
|
||||||
var addModel = parm.Adapt<<#=ModelName#>>().ToCreate();
|
|
||||||
//addModel.CreateID = User.Identity.Name;
|
|
||||||
|
|
||||||
return SUCCESS(_<#=ServiceName#>.Add(addModel));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 更新<#=FileName#>
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPut("edit")]
|
|
||||||
//[ActionPermissionFilter(Permission = "system:<#=ModelName#>:update")]
|
|
||||||
[Log(Title = "<#=FileName#>修改", BusinessType = BusinessType.UPDATE)]
|
|
||||||
public IActionResult Update([FromBody] <#=ModelName#> parm)
|
|
||||||
{
|
|
||||||
//从 Dto 映射到 实体
|
|
||||||
var addModel = parm.Adapt<<#=ModelName#>>().ToCreate();
|
|
||||||
//addModel.CreateID = User.Identity.Name;
|
|
||||||
//TODO 字段映射
|
|
||||||
var response = _<#=ServiceName#>.Update(addModel);
|
|
||||||
|
|
||||||
return SUCCESS(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 删除<#=FileName#>
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpDelete("{id}")]
|
|
||||||
//[ActionPermissionFilter(Permission = "system:<#=ModelName#>:delete")]
|
|
||||||
[Log(Title = "<#=FileName#>删除", BusinessType = BusinessType.DELETE)]
|
|
||||||
public IActionResult Delete(int id = 0)
|
|
||||||
{
|
|
||||||
if (id <= 0) { return OutputJson(ApiResult.Error($"删除失败Id 不能为空")); }
|
|
||||||
|
|
||||||
// 删除<#=FileName#>
|
|
||||||
var response = _<#=ServiceName#>.Delete(id);
|
|
||||||
|
|
||||||
return SUCCESS(response);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -15,6 +15,11 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Remove="Filters\GlobalExceptionFilter.cs" />
|
<Compile Remove="Filters\GlobalExceptionFilter.cs" />
|
||||||
<Compile Remove="Middleware\RequestIPMiddleware.cs" />
|
<Compile Remove="Middleware\RequestIPMiddleware.cs" />
|
||||||
|
<Compile Remove="Template\Controller.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Remove="Template\Controller.tt" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@ -53,10 +58,6 @@
|
|||||||
<None Update="ip2region.db">
|
<None Update="ip2region.db">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Update="Template\Controller.tt">
|
|
||||||
<Generator>TextTemplatingFileGenerator</Generator>
|
|
||||||
<LastGenOutput>Controller.cs</LastGenOutput>
|
|
||||||
</None>
|
|
||||||
<None Update="Template\ControllersTemplate.txt">
|
<None Update="Template\ControllersTemplate.txt">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
@ -86,6 +87,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Controllers\business\" />
|
<Folder Include="Controllers\business\" />
|
||||||
<Folder Include="wwwroot\" />
|
<Folder Include="wwwroot\" />
|
||||||
|
<Folder Include="wwwroot\Generatecode\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@ -102,12 +104,4 @@
|
|||||||
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
|
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Update="Template\Controller.cs">
|
|
||||||
<DesignTime>True</DesignTime>
|
|
||||||
<AutoGen>True</AutoGen>
|
|
||||||
<DependentUpon>Controller.tt</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@ -28,9 +28,9 @@
|
|||||||
},
|
},
|
||||||
"gen": {
|
"gen": {
|
||||||
"conn": "server=127.0.0.1;user=zr;pwd=abc;database={database}",
|
"conn": "server=127.0.0.1;user=zr;pwd=abc;database={database}",
|
||||||
"dbType": 1,
|
"dbType": 0, //MySql = 0, SqlServer = 1
|
||||||
"autoPre": true, //自动去除表前缀
|
"autoPre": true, //自动去除表前缀
|
||||||
"author": "zhaorui",
|
"author": "zr",
|
||||||
"tablePrefix": "live_,sys_" //"表前缀(生成类名不会包含表前缀,多个用逗号分隔)",
|
"tablePrefix": "live_,sys_" //"表前缀(生成类名不会包含表前缀,多个用逗号分隔)",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,6 +13,7 @@ using {ModelsNamespace}.Models;
|
|||||||
using {ServicesNamespace}.Business;
|
using {ServicesNamespace}.Business;
|
||||||
using {ApiControllerNamespace}.Extensions;
|
using {ApiControllerNamespace}.Extensions;
|
||||||
using {ApiControllerNamespace}.Filters;
|
using {ApiControllerNamespace}.Filters;
|
||||||
|
using ZR.Common;
|
||||||
|
|
||||||
namespace {ApiControllerNamespace}.Controllers
|
namespace {ApiControllerNamespace}.Controllers
|
||||||
{
|
{
|
||||||
@ -59,7 +60,7 @@ namespace {ApiControllerNamespace}.Controllers
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet("{{PrimaryKey}}")]
|
[HttpGet("{{PrimaryKey}}")]
|
||||||
[ActionPermissionFilter(Permission = "{Permission}:query")]
|
[ActionPermissionFilter(Permission = "{Permission}:query")]
|
||||||
public IActionResult Get{ModelName}({KeyTypeName} {PrimaryKey})
|
public IActionResult Get{ModelName}({PKCsharpType} {PrimaryKey})
|
||||||
{
|
{
|
||||||
var response = _{ModelName}Service.GetId({PrimaryKey});
|
var response = _{ModelName}Service.GetId({PrimaryKey});
|
||||||
|
|
||||||
@ -117,14 +118,15 @@ namespace {ApiControllerNamespace}.Controllers
|
|||||||
/// 删除{TableDesc}
|
/// 删除{TableDesc}
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpDelete("{{PrimaryKey}}")]
|
[HttpDelete("{ids}")]
|
||||||
[ActionPermissionFilter(Permission = "{Permission}:delete")]
|
[ActionPermissionFilter(Permission = "{Permission}:delete")]
|
||||||
[Log(Title = "{TableDesc}删除", BusinessType = BusinessType.DELETE)]
|
[Log(Title = "{TableDesc}删除", BusinessType = BusinessType.DELETE)]
|
||||||
public IActionResult Delete{ModelName}({KeyTypeName} {PrimaryKey} = 0)
|
public IActionResult Delete{ModelName}(string ids)
|
||||||
{
|
{
|
||||||
if ({PrimaryKey} <= 0) { return OutputJson(ApiResult.Error($"删除失败Id 不能为空")); }
|
int[] idsArr = Tools.SpitIntArrary(ids);
|
||||||
|
if (idsArr.Length <= 0) { return OutputJson(ApiResult.Error($"删除失败Id 不能为空")); }
|
||||||
|
|
||||||
var response = _{ModelName}Service.Delete({PrimaryKey});
|
var response = _{ModelName}Service.Delete(idsArr);
|
||||||
|
|
||||||
return SUCCESS(response);
|
return SUCCESS(response);
|
||||||
}
|
}
|
||||||
@ -143,7 +143,7 @@ export default {
|
|||||||
//TODO 重置字段
|
//TODO 重置字段
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
// 多选框选中数据
|
// 多选框选中数据
|
||||||
handleSelectionChange(selection) {
|
handleSelectionChange(selection) {
|
||||||
this.ids = selection.map((item) => item.{primaryKey});
|
this.ids = selection.map((item) => item.{primaryKey});
|
||||||
this.single = selection.length!=1
|
this.single = selection.length!=1
|
||||||
@ -167,8 +167,8 @@ export default {
|
|||||||
},
|
},
|
||||||
/** 删除按钮操作 */
|
/** 删除按钮操作 */
|
||||||
handleDelete(row) {
|
handleDelete(row) {
|
||||||
const ${primaryKey}s = row.${primaryKey} || this.ids;
|
const {primaryKey}s = row.{primaryKey} || this.ids;
|
||||||
del{ModelTypeName}(${primaryKey}s).then((res) => {
|
del{ModelTypeName}({primaryKey}s.toString()).then((res) => {
|
||||||
this.msgSuccess("删除成功");
|
this.msgSuccess("删除成功");
|
||||||
this.handleQuery();
|
this.handleQuery();
|
||||||
});
|
});
|
||||||
@ -1,4 +1,5 @@
|
|||||||
using System.Linq;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using ZR.CodeGenerator.CodeGenerator;
|
using ZR.CodeGenerator.CodeGenerator;
|
||||||
using ZR.Model.System.Generate;
|
using ZR.Model.System.Generate;
|
||||||
|
|
||||||
@ -14,17 +15,28 @@ namespace ZR.CodeGenerator
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dbColumnInfo"></param>
|
/// <param name="dbColumnInfo"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static string GetVueJsMethod(GenTableColumn dbColumnInfo)
|
public static string GetVueJsMethod(GenTableColumn dbFieldInfo)
|
||||||
{
|
{
|
||||||
string columnName = dbColumnInfo.ColumnName;
|
string columnName = dbFieldInfo.ColumnName;
|
||||||
string js = "";
|
string js = "";
|
||||||
if (dbColumnInfo.HtmlType.Equals(GenConstants.HTML_IMAGE_UPLOAD))
|
if (dbFieldInfo.HtmlType.Equals(GenConstants.HTML_IMAGE_UPLOAD))
|
||||||
{
|
{
|
||||||
js += $"handleUpload{columnName}Success(res, file) {{\r\n";
|
js += " //文件上传成功方法\r\n";
|
||||||
|
js += $" handleUpload{columnName}Success(res, file) {{\r\n";
|
||||||
js += $" this.form.{columnName} = URL.createObjectURL(file.raw);\r\n";
|
js += $" this.form.{columnName} = URL.createObjectURL(file.raw);\r\n";
|
||||||
js += " // this.$refs.upload.clearFiles();\r\n";
|
js += " // this.$refs.upload.clearFiles();\r\n";
|
||||||
js += " },\r";
|
js += " },\r";
|
||||||
}
|
}
|
||||||
|
//有下拉框选项初列表查询数据
|
||||||
|
if (dbFieldInfo.HtmlType == GenConstants.HTML_SELECT && !string.IsNullOrEmpty(dbFieldInfo.DictType))
|
||||||
|
{
|
||||||
|
var sb = new System.Text.StringBuilder(500);
|
||||||
|
sb.AppendLine(@$" // {dbFieldInfo.ColumnComment}字典翻译");
|
||||||
|
sb.AppendLine($" {columnName}Format(row, column) {{");
|
||||||
|
sb.AppendLine(@$" return this.selectDictLabel(this.{columnName}Options, row.{columnName});");
|
||||||
|
sb.AppendLine(@" },");
|
||||||
|
js += sb.ToString();
|
||||||
|
}
|
||||||
return js;
|
return js;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,7 +90,7 @@ namespace ZR.CodeGenerator
|
|||||||
public static string GetDtoProperty(GenTableColumn dbFieldInfo)
|
public static string GetDtoProperty(GenTableColumn dbFieldInfo)
|
||||||
{
|
{
|
||||||
string InputDtoContent = "";
|
string InputDtoContent = "";
|
||||||
if (CodeGeneratorTool.inputDtoNoField.Any(f => f.Replace("_", "").ToLower().Contains(dbFieldInfo.CsharpField.ToLower().Replace("_", ""))))
|
if (GenConstants.inputDtoNoField.Any(f => f.Replace("_", "").ToLower().Contains(dbFieldInfo.CsharpField.ToLower().Replace("_", ""))))
|
||||||
{
|
{
|
||||||
return InputDtoContent;
|
return InputDtoContent;
|
||||||
}
|
}
|
||||||
@ -97,7 +109,7 @@ namespace ZR.CodeGenerator
|
|||||||
public static string GetQueryDtoProperty(GenTableColumn dbFieldInfo)
|
public static string GetQueryDtoProperty(GenTableColumn dbFieldInfo)
|
||||||
{
|
{
|
||||||
string QueryDtoContent = "";
|
string QueryDtoContent = "";
|
||||||
if (dbFieldInfo.IsQuery && !CodeGeneratorTool.inputDtoNoField.Any(f => f.Replace("_", "").ToLower().Contains(dbFieldInfo.CsharpField.ToLower().Replace("_", ""))))
|
if (dbFieldInfo.IsQuery && !GenConstants.inputDtoNoField.Any(f => f.Replace("_", "").ToLower().Contains(dbFieldInfo.CsharpField.ToLower().Replace("_", ""))))
|
||||||
{
|
{
|
||||||
QueryDtoContent += $" public {dbFieldInfo.CsharpType} {dbFieldInfo.CsharpField} {{ get; set; }}\r\n";
|
QueryDtoContent += $" public {dbFieldInfo.CsharpType} {dbFieldInfo.CsharpField} {{ get; set; }}\r\n";
|
||||||
}
|
}
|
||||||
@ -113,7 +125,7 @@ namespace ZR.CodeGenerator
|
|||||||
string vueViewFromContent = "";
|
string vueViewFromContent = "";
|
||||||
string labelDisabled = dbFieldInfo.IsPk ? ":disabled=\"true\"" : "";
|
string labelDisabled = dbFieldInfo.IsPk ? ":disabled=\"true\"" : "";
|
||||||
string placeHolder = dbFieldInfo.IsIncrement ? "" : $"请输入{labelName}";
|
string placeHolder = dbFieldInfo.IsIncrement ? "" : $"请输入{labelName}";
|
||||||
if (CodeGeneratorTool.inputDtoNoField.Any(f => f.Replace("_", "").ToLower().Contains(dbFieldInfo.CsharpField.ToLower().Replace("_", ""))))
|
if (GenConstants.inputDtoNoField.Any(f => f.Replace("_", "").ToLower().Contains(dbFieldInfo.CsharpField.ToLower().Replace("_", ""))))
|
||||||
{
|
{
|
||||||
return vueViewFromContent;
|
return vueViewFromContent;
|
||||||
}
|
}
|
||||||
@ -156,16 +168,17 @@ namespace ZR.CodeGenerator
|
|||||||
}
|
}
|
||||||
else if (dbFieldInfo.HtmlType == GenConstants.HTML_SELECT && !string.IsNullOrEmpty(dbFieldInfo.DictType))
|
else if (dbFieldInfo.HtmlType == GenConstants.HTML_SELECT && !string.IsNullOrEmpty(dbFieldInfo.DictType))
|
||||||
{
|
{
|
||||||
|
string value = TableMappingHelper.IsNumber(dbFieldInfo.CsharpType) ? "parseInt(item.dictValue)" : "item.dictValue";
|
||||||
vueViewFromContent += $" <el-form-item label=\"{ labelName}\" :label-width=\"labelWidth\" prop=\"{columnName}\">\r\n";
|
vueViewFromContent += $" <el-form-item label=\"{ labelName}\" :label-width=\"labelWidth\" prop=\"{columnName}\">\r\n";
|
||||||
vueViewFromContent += $" <el-select v-model=\"form.{columnName}\" > ";
|
vueViewFromContent += $" <el-select v-model=\"form.{columnName}\">\r\n";
|
||||||
vueViewFromContent += $" <el-option v-for=\"item in {columnName}Options\" :key=\"item.dictValue\" :label=\"item.dictLabel\" :value=\"item.dictValue\"></el-option>\r\n";
|
vueViewFromContent += $" <el-option v-for=\"item in {columnName}Options\" :key=\"item.dictValue\" :label=\"item.dictLabel\" :value=\"{value}\"></el-option>\r\n";
|
||||||
vueViewFromContent += " </el-select>\r\n";
|
vueViewFromContent += " </el-select>\r\n";
|
||||||
vueViewFromContent += " </el-form-item>\r\n";
|
vueViewFromContent += " </el-form-item>\r\n";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string inputNumTxt = TableMappingHelper.IsNumber(dbFieldInfo.CsharpType) ? ".number" : "";
|
string inputNumTxt = TableMappingHelper.IsNumber(dbFieldInfo.CsharpType) ? ".number" : "";
|
||||||
vueViewFromContent += $" <el-form-item label=\"{ labelName}\" :label-width=\"labelWidth\" prop=\"{CodeGeneratorTool.FirstLowerCase(columnName)}\">\r\n";
|
vueViewFromContent += $" <el-form-item label=\"{labelName}\" :label-width=\"labelWidth\" prop=\"{CodeGeneratorTool.FirstLowerCase(columnName)}\">\r\n";
|
||||||
vueViewFromContent += $" <el-input v-model{inputNumTxt}=\"form.{CodeGeneratorTool.FirstLowerCase(columnName)}\" placeholder=\"{placeHolder}\" {labelDisabled}/>\r\n";
|
vueViewFromContent += $" <el-input v-model{inputNumTxt}=\"form.{CodeGeneratorTool.FirstLowerCase(columnName)}\" placeholder=\"{placeHolder}\" {labelDisabled}/>\r\n";
|
||||||
vueViewFromContent += " </el-form-item>\r\n";
|
vueViewFromContent += " </el-form-item>\r\n";
|
||||||
}
|
}
|
||||||
@ -208,13 +221,11 @@ namespace ZR.CodeGenerator
|
|||||||
string label = CodeGeneratorTool.GetLabelName(dbFieldInfo.ColumnComment, columnName);
|
string label = CodeGeneratorTool.GetLabelName(dbFieldInfo.ColumnComment, columnName);
|
||||||
string vueViewListContent = "";
|
string vueViewListContent = "";
|
||||||
string showToolTip = dbFieldInfo.ColumnType.Contains("varchar") ? ":show-overflow-tooltip=\"true\"" : "";
|
string showToolTip = dbFieldInfo.ColumnType.Contains("varchar") ? ":show-overflow-tooltip=\"true\"" : "";
|
||||||
if (!dbFieldInfo.IsList)
|
string formatter = !string.IsNullOrEmpty(dbFieldInfo.DictType) ? $" :formatter=\"{columnName}Format\"" : "";
|
||||||
|
|
||||||
|
if (dbFieldInfo.IsList && dbFieldInfo.HtmlType.Equals(GenConstants.HTML_IMAGE_UPLOAD))
|
||||||
{
|
{
|
||||||
|
vueViewListContent += $" <el-table-column prop=\"{columnName}\" label=\"图片\">\r\n";
|
||||||
}
|
|
||||||
else if (dbFieldInfo.HtmlType.Equals(GenConstants.HTML_IMAGE_UPLOAD))
|
|
||||||
{
|
|
||||||
vueViewListContent += $" <el-table-column prop=\"{ columnName}\" label=\"图片\">\r\n";
|
|
||||||
vueViewListContent += " <template slot-scope=\"scope\">\r\n";
|
vueViewListContent += " <template slot-scope=\"scope\">\r\n";
|
||||||
vueViewListContent += $" <el-image class=\"table-td-thumb\" :src=\"scope.row.{columnName}\" :preview-src-list=\"[scope.row.{columnName}]\"></el-image>\r\n";
|
vueViewListContent += $" <el-image class=\"table-td-thumb\" :src=\"scope.row.{columnName}\" :preview-src-list=\"[scope.row.{columnName}]\"></el-image>\r\n";
|
||||||
vueViewListContent += " </template>\r\n";
|
vueViewListContent += " </template>\r\n";
|
||||||
@ -229,9 +240,9 @@ namespace ZR.CodeGenerator
|
|||||||
// vueViewListContent += " </template>\r\n";
|
// vueViewListContent += " </template>\r\n";
|
||||||
// vueViewListContent += " </el-table-column>\r\n";
|
// vueViewListContent += " </el-table-column>\r\n";
|
||||||
//}
|
//}
|
||||||
else
|
else if(dbFieldInfo.IsList)
|
||||||
{
|
{
|
||||||
vueViewListContent += $" <el-table-column prop=\"{columnName}\" label=\"{label}\" align=\"center\" width=\"100\" {showToolTip} />\r\n";
|
vueViewListContent += $" <el-table-column prop=\"{columnName}\" label=\"{label}\" align=\"center\" {showToolTip}{formatter}/>\r\n";
|
||||||
}
|
}
|
||||||
return vueViewListContent;
|
return vueViewListContent;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,10 @@
|
|||||||
using Infrastructure;
|
using Infrastructure;
|
||||||
|
using SqlSugar;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using ZR.CodeGenerator.CodeGenerator;
|
||||||
using ZR.CodeGenerator.Model;
|
using ZR.CodeGenerator.Model;
|
||||||
using ZR.Model.System.Generate;
|
using ZR.Model.System.Generate;
|
||||||
|
|
||||||
@ -20,24 +22,15 @@ namespace ZR.CodeGenerator
|
|||||||
/// 代码生成器配置
|
/// 代码生成器配置
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static CodeGenerateOption _option = new CodeGenerateOption();
|
private static CodeGenerateOption _option = new CodeGenerateOption();
|
||||||
/// <summary>
|
|
||||||
/// InputDto输入实体是不包含字段
|
|
||||||
/// </summary>
|
|
||||||
public static readonly string[] inputDtoNoField = new string[] { "createTime", "updateTime", "addtime" };
|
|
||||||
public static readonly string[] imageFiled = new string[] { "icon", "img", "image", "url", "pic", "photo" };
|
|
||||||
public static readonly string[] selectFiled = new string[] { "status", "type", "state", "sex", "gender" };
|
|
||||||
public static readonly string[] radioFiled = new string[] { "status", "state", "isShow", "isHidden", "ishide" };
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 代码生成器入口方法
|
/// 代码生成器入口方法
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dbTableInfo"></param>
|
/// <param name="dbTableInfo"></param>
|
||||||
/// <param name="dto"></param>
|
/// <param name="dto"></param>
|
||||||
public static void Generate(GenTable dbTableInfo, GenerateDto dto)
|
public static List<string> Generate(GenTable dbTableInfo, GenerateDto dto)
|
||||||
{
|
{
|
||||||
_option.BaseNamespace = "ZR.";
|
_option.BaseNamespace = dbTableInfo.BaseNameSpace;
|
||||||
//_option.TableList = listTable;
|
|
||||||
_option.ReplaceTableNameStr = dto.replaceTableNameStr;
|
|
||||||
_option.DtosNamespace = _option.BaseNamespace + "Model";
|
_option.DtosNamespace = _option.BaseNamespace + "Model";
|
||||||
_option.ModelsNamespace = _option.BaseNamespace + "Model";
|
_option.ModelsNamespace = _option.BaseNamespace + "Model";
|
||||||
_option.RepositoriesNamespace = _option.BaseNamespace + "Repository";
|
_option.RepositoriesNamespace = _option.BaseNamespace + "Repository";
|
||||||
@ -46,7 +39,43 @@ namespace ZR.CodeGenerator
|
|||||||
_option.ServicesNamespace = _option.BaseNamespace + "Service";
|
_option.ServicesNamespace = _option.BaseNamespace + "Service";
|
||||||
_option.ApiControllerNamespace = _option.BaseNamespace + "Admin.WebApi";
|
_option.ApiControllerNamespace = _option.BaseNamespace + "Admin.WebApi";
|
||||||
|
|
||||||
GenerateSingle(dbTableInfo?.Columns, dbTableInfo, dto);
|
List<string> list = GenerateSingle(dbTableInfo?.Columns, dbTableInfo, dto);
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 打包压缩代码
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dto"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string ZipGenCode(GenerateDto dto)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string zipPath = Environment.CurrentDirectory + "\\wwwroot\\Generatecode\\";
|
||||||
|
//生成压缩包
|
||||||
|
string zipReturnFileName = dto.baseSpace + DateTime.Now.ToString("yyyyMMddHHmmss") + ".zip";
|
||||||
|
|
||||||
|
if (!Directory.Exists(zipPath))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(zipPath);
|
||||||
|
}
|
||||||
|
string zipFileName = zipPath + "\\" + zipReturnFileName;
|
||||||
|
if (File.Exists(zipFileName))
|
||||||
|
{
|
||||||
|
File.Delete(zipFileName);
|
||||||
|
}
|
||||||
|
Console.WriteLine(zipFileName);
|
||||||
|
FileHelper.ZipFileDirectory(dto.ParentPath, zipFileName, 7, "", "", "*.*");
|
||||||
|
FileHelper.DeleteDirectory(dto.ParentPath);
|
||||||
|
return zipFileName;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine(ex.Message);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -55,10 +84,11 @@ namespace ZR.CodeGenerator
|
|||||||
/// <param name="listField">表字段集合</param>
|
/// <param name="listField">表字段集合</param>
|
||||||
/// <param name="tableInfo">表信息</param>
|
/// <param name="tableInfo">表信息</param>
|
||||||
/// <param name="dto"></param>
|
/// <param name="dto"></param>
|
||||||
public static void GenerateSingle(List<GenTableColumn> listField, GenTable tableInfo, GenerateDto dto)
|
public static List<string> GenerateSingle(List<GenTableColumn> listField, GenTable tableInfo, GenerateDto dto)
|
||||||
{
|
{
|
||||||
string PKName = "id";
|
string PKName = "id";
|
||||||
string PKType = "int";
|
string PKType = "int";
|
||||||
|
List<string> genPathList = new();
|
||||||
ReplaceDto replaceDto = new();
|
ReplaceDto replaceDto = new();
|
||||||
replaceDto.ModelTypeName = tableInfo.ClassName;//表名对应C# 实体类名
|
replaceDto.ModelTypeName = tableInfo.ClassName;//表名对应C# 实体类名
|
||||||
replaceDto.TableName = tableInfo.TableName;
|
replaceDto.TableName = tableInfo.TableName;
|
||||||
@ -88,15 +118,19 @@ namespace ZR.CodeGenerator
|
|||||||
{
|
{
|
||||||
replaceDto.InsertColumn += $"it.{dbFieldInfo.CsharpField}, ";
|
replaceDto.InsertColumn += $"it.{dbFieldInfo.CsharpField}, ";
|
||||||
}
|
}
|
||||||
//查询
|
//TODO 查询
|
||||||
//if (dbFieldInfo.IsQuery)
|
//if (dbFieldInfo.IsQuery)
|
||||||
//{
|
//{
|
||||||
// replaceDto.Querycondition += $"predicate = predicate.And(m => m.{dbFieldInfo.CsharpField}.Contains(parm.Name));";
|
// replaceDto.Querycondition += $"predicate = predicate.And(m => m.{dbFieldInfo.CsharpField}.Contains(parm.Name));";
|
||||||
//}
|
//}
|
||||||
if (dbFieldInfo.HtmlType == GenConstants.HTML_SELECT && !string.IsNullOrEmpty(dbFieldInfo.DictType))
|
if ((dbFieldInfo.HtmlType == GenConstants.HTML_SELECT || dbFieldInfo.HtmlType == GenConstants.HTML_RADIO) && !string.IsNullOrEmpty(dbFieldInfo.DictType))
|
||||||
{
|
{
|
||||||
replaceDto.VueDataContent += $"// {dbFieldInfo.ColumnComment}选项列表\n";
|
replaceDto.VueDataContent += $"// {dbFieldInfo.ColumnComment}选项列表\n";
|
||||||
replaceDto.VueDataContent += $"{FirstLowerCase(dbFieldInfo.CsharpField)}Options: [],";
|
replaceDto.VueDataContent += $"{FirstLowerCase(dbFieldInfo.CsharpField)}Options: [],";
|
||||||
|
|
||||||
|
replaceDto.MountedMethod += $" this.getDicts(\"{dbFieldInfo.DictType}\").then((response) => {{\n";
|
||||||
|
replaceDto.MountedMethod += $" this.{FirstLowerCase(dbFieldInfo.CsharpField)}Options = response.data;\n";
|
||||||
|
replaceDto.MountedMethod += " })\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
replaceDto.QueryProperty += CodeGenerateTemplate.GetQueryDtoProperty(dbFieldInfo);
|
replaceDto.QueryProperty += CodeGenerateTemplate.GetQueryDtoProperty(dbFieldInfo);
|
||||||
@ -113,29 +147,44 @@ namespace ZR.CodeGenerator
|
|||||||
|
|
||||||
if (dto.genFiles.Contains(1))
|
if (dto.genFiles.Contains(1))
|
||||||
{
|
{
|
||||||
GenerateModels(replaceDto, dto);
|
Tuple<string, string> tuple = GenerateModels(replaceDto, dto);
|
||||||
|
genPathList.Add(tuple.Item1);
|
||||||
|
//WriteAndSave(tuple.Item1, tuple.Item2);
|
||||||
}
|
}
|
||||||
if (dto.genFiles.Contains(2))
|
if (dto.genFiles.Contains(2))
|
||||||
{
|
{
|
||||||
GenerateInputDto(replaceDto, dto);
|
Tuple<string, string> tuple = GenerateInputDto(replaceDto, dto);
|
||||||
|
genPathList.Add(tuple.Item1);
|
||||||
|
//WriteAndSave(tuple.Item1, tuple.Item2);
|
||||||
}
|
}
|
||||||
if (dto.genFiles.Contains(3))
|
if (dto.genFiles.Contains(3))
|
||||||
{
|
{
|
||||||
GenerateRepository(replaceDto, dto);
|
Tuple<string, string> tuple = GenerateRepository(replaceDto, dto);
|
||||||
|
genPathList.Add(tuple.Item1);
|
||||||
|
//WriteAndSave(tuple.Item1, tuple.Item2);
|
||||||
}
|
}
|
||||||
if (dto.genFiles.Contains(4))
|
if (dto.genFiles.Contains(4))
|
||||||
{
|
{
|
||||||
GenerateIService(replaceDto, dto);
|
Tuple<string, string> tuple = GenerateIService(replaceDto, dto);
|
||||||
GenerateService(replaceDto, dto);
|
Tuple<string, string> tuple_1 = GenerateService(replaceDto, dto);
|
||||||
|
genPathList.Add(tuple.Item1);
|
||||||
|
genPathList.Add(tuple_1.Item1);
|
||||||
|
//WriteAndSave(tuple.Item1, tuple.Item2);
|
||||||
|
//WriteAndSave(tuple_1.Item1, tuple_1.Item2);
|
||||||
}
|
}
|
||||||
if (dto.genFiles.Contains(5))
|
if (dto.genFiles.Contains(5))
|
||||||
{
|
{
|
||||||
GenerateControllers(replaceDto, dto);
|
Tuple<string, string> tuple = GenerateControllers(replaceDto, dto);
|
||||||
|
genPathList.Add(tuple.Item1);
|
||||||
|
//WriteAndSave(tuple.Item1, tuple.Item2);
|
||||||
}
|
}
|
||||||
if (dto.genFiles.Contains(6))
|
if (dto.genFiles.Contains(6))
|
||||||
{
|
{
|
||||||
GenerateVueViews(replaceDto, dto);
|
Tuple<string, string> tuple = GenerateVueViews(replaceDto, dto);
|
||||||
|
genPathList.Add(tuple.Item1);
|
||||||
|
//WriteAndSave(tuple.Item1, tuple.Item2);
|
||||||
}
|
}
|
||||||
|
return genPathList;
|
||||||
//GenerateIRepository(modelTypeName, modelTypeDesc, keyTypeName, ifExsitedCovered);
|
//GenerateIRepository(modelTypeName, modelTypeDesc, keyTypeName, ifExsitedCovered);
|
||||||
//GenerateOutputDto(modelTypeName, modelTypeDesc, outputDtocontent, ifExsitedCovered);
|
//GenerateOutputDto(modelTypeName, modelTypeDesc, outputDtocontent, ifExsitedCovered);
|
||||||
}
|
}
|
||||||
@ -150,7 +199,7 @@ namespace ZR.CodeGenerator
|
|||||||
/// <param name="replaceDto">替换实体</param>
|
/// <param name="replaceDto">替换实体</param>
|
||||||
private static Tuple<string, string> GenerateModels(ReplaceDto replaceDto, GenerateDto generateDto)
|
private static Tuple<string, string> GenerateModels(ReplaceDto replaceDto, GenerateDto generateDto)
|
||||||
{
|
{
|
||||||
var parentPath = "..";
|
var parentPath = generateDto.ParentPath;
|
||||||
//../ZR.Model
|
//../ZR.Model
|
||||||
var servicesPath = parentPath + "\\" + _option.ModelsNamespace + "\\Models\\";
|
var servicesPath = parentPath + "\\" + _option.ModelsNamespace + "\\Models\\";
|
||||||
if (!Directory.Exists(servicesPath))
|
if (!Directory.Exists(servicesPath))
|
||||||
@ -159,7 +208,7 @@ namespace ZR.CodeGenerator
|
|||||||
}
|
}
|
||||||
// ../ZR.Model/Models/User.cs
|
// ../ZR.Model/Models/User.cs
|
||||||
var fullPath = servicesPath + replaceDto.ModelTypeName + ".cs";
|
var fullPath = servicesPath + replaceDto.ModelTypeName + ".cs";
|
||||||
Console.WriteLine(fullPath);
|
|
||||||
if (File.Exists(fullPath) && !generateDto.coverd)
|
if (File.Exists(fullPath) && !generateDto.coverd)
|
||||||
return Tuple.Create(fullPath, "");
|
return Tuple.Create(fullPath, "");
|
||||||
var content = ReadTemplate("ModelTemplate.txt");
|
var content = ReadTemplate("ModelTemplate.txt");
|
||||||
@ -174,7 +223,6 @@ namespace ZR.CodeGenerator
|
|||||||
return Tuple.Create(fullPath, content);
|
return Tuple.Create(fullPath, content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 生成InputDto文件
|
/// 生成InputDto文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -182,7 +230,7 @@ namespace ZR.CodeGenerator
|
|||||||
/// <param name="replaceDto">替换实体</param>
|
/// <param name="replaceDto">替换实体</param>
|
||||||
private static Tuple<string, string> GenerateInputDto(ReplaceDto replaceDto, GenerateDto generateDto)
|
private static Tuple<string, string> GenerateInputDto(ReplaceDto replaceDto, GenerateDto generateDto)
|
||||||
{
|
{
|
||||||
var parentPath = "..";
|
var parentPath = generateDto.ParentPath;
|
||||||
var servicesPath = parentPath + "\\" + _option.ModelsNamespace + "\\Dto\\";
|
var servicesPath = parentPath + "\\" + _option.ModelsNamespace + "\\Dto\\";
|
||||||
if (!Directory.Exists(servicesPath))
|
if (!Directory.Exists(servicesPath))
|
||||||
{
|
{
|
||||||
@ -190,7 +238,7 @@ namespace ZR.CodeGenerator
|
|||||||
}
|
}
|
||||||
// ../ZR.Model/Dto/User.cs
|
// ../ZR.Model/Dto/User.cs
|
||||||
var fullPath = servicesPath + replaceDto.ModelTypeName + "Dto.cs";
|
var fullPath = servicesPath + replaceDto.ModelTypeName + "Dto.cs";
|
||||||
Console.WriteLine(fullPath);
|
|
||||||
if (File.Exists(fullPath) && !generateDto.coverd)
|
if (File.Exists(fullPath) && !generateDto.coverd)
|
||||||
return Tuple.Create(fullPath, ""); ;
|
return Tuple.Create(fullPath, ""); ;
|
||||||
var content = ReadTemplate("InputDtoTemplate.txt");
|
var content = ReadTemplate("InputDtoTemplate.txt");
|
||||||
@ -215,14 +263,14 @@ namespace ZR.CodeGenerator
|
|||||||
/// <param name="replaceDto">替换实体</param>
|
/// <param name="replaceDto">替换实体</param>
|
||||||
private static Tuple<string, string> GenerateRepository(ReplaceDto replaceDto, GenerateDto generateDto)
|
private static Tuple<string, string> GenerateRepository(ReplaceDto replaceDto, GenerateDto generateDto)
|
||||||
{
|
{
|
||||||
var parentPath = "..";
|
var parentPath = generateDto.ParentPath;
|
||||||
var repositoryPath = parentPath + "\\" + _option.RepositoriesNamespace + "\\Repositories\\";
|
var repositoryPath = parentPath + "\\" + _option.RepositoriesNamespace + "\\Repositories\\";
|
||||||
if (!Directory.Exists(repositoryPath))
|
if (!Directory.Exists(repositoryPath))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(repositoryPath);
|
Directory.CreateDirectory(repositoryPath);
|
||||||
}
|
}
|
||||||
var fullPath = repositoryPath + "\\" + replaceDto.ModelTypeName + "Repository.cs";
|
var fullPath = repositoryPath + "\\" + replaceDto.ModelTypeName + "Repository.cs";
|
||||||
Console.WriteLine(fullPath);
|
|
||||||
if (File.Exists(fullPath) && !generateDto.coverd)
|
if (File.Exists(fullPath) && !generateDto.coverd)
|
||||||
return Tuple.Create(fullPath, "");
|
return Tuple.Create(fullPath, "");
|
||||||
var content = ReadTemplate("RepositoryTemplate.txt");
|
var content = ReadTemplate("RepositoryTemplate.txt");
|
||||||
@ -247,7 +295,7 @@ namespace ZR.CodeGenerator
|
|||||||
/// <param name="replaceDto">替换实体</param>
|
/// <param name="replaceDto">替换实体</param>
|
||||||
private static Tuple<string, string> GenerateIService(ReplaceDto replaceDto, GenerateDto generateDto)
|
private static Tuple<string, string> GenerateIService(ReplaceDto replaceDto, GenerateDto generateDto)
|
||||||
{
|
{
|
||||||
var parentPath = "..";
|
var parentPath = generateDto.ParentPath;
|
||||||
var iServicesPath = parentPath + "\\" + _option.IServicsNamespace + "\\Business\\IBusService\\";
|
var iServicesPath = parentPath + "\\" + _option.IServicsNamespace + "\\Business\\IBusService\\";
|
||||||
if (!Directory.Exists(iServicesPath))
|
if (!Directory.Exists(iServicesPath))
|
||||||
{
|
{
|
||||||
@ -274,7 +322,7 @@ namespace ZR.CodeGenerator
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private static Tuple<string, string> GenerateService(ReplaceDto replaceDto, GenerateDto generateDto)
|
private static Tuple<string, string> GenerateService(ReplaceDto replaceDto, GenerateDto generateDto)
|
||||||
{
|
{
|
||||||
var parentPath = "..";
|
var parentPath = generateDto.ParentPath;
|
||||||
var servicesPath = parentPath + "\\" + _option.ServicesNamespace + "\\Business\\";
|
var servicesPath = parentPath + "\\" + _option.ServicesNamespace + "\\Business\\";
|
||||||
if (!Directory.Exists(servicesPath))
|
if (!Directory.Exists(servicesPath))
|
||||||
{
|
{
|
||||||
@ -306,14 +354,13 @@ namespace ZR.CodeGenerator
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private static Tuple<string, string> GenerateControllers(ReplaceDto replaceDto, GenerateDto generateDto)
|
private static Tuple<string, string> GenerateControllers(ReplaceDto replaceDto, GenerateDto generateDto)
|
||||||
{
|
{
|
||||||
var parentPath = "..";
|
var parentPath = generateDto.ParentPath;
|
||||||
var servicesPath = parentPath + "\\" + _option.ApiControllerNamespace + "\\Controllers\\business\\";
|
var servicesPath = parentPath + "\\" + _option.ApiControllerNamespace + "\\Controllers\\business\\";
|
||||||
if (!Directory.Exists(servicesPath))
|
if (!Directory.Exists(servicesPath))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(servicesPath);
|
Directory.CreateDirectory(servicesPath);
|
||||||
}
|
}
|
||||||
var fullPath = servicesPath + replaceDto.ModelTypeName + "Controller.cs";
|
var fullPath = servicesPath + replaceDto.ModelTypeName + "Controller.cs";
|
||||||
Console.WriteLine(fullPath);
|
|
||||||
if (File.Exists(fullPath) && !generateDto.coverd)
|
if (File.Exists(fullPath) && !generateDto.coverd)
|
||||||
return Tuple.Create(fullPath, "");
|
return Tuple.Create(fullPath, "");
|
||||||
var content = ReadTemplate("ControllersTemplate.txt");
|
var content = ReadTemplate("ControllersTemplate.txt");
|
||||||
@ -327,7 +374,7 @@ namespace ZR.CodeGenerator
|
|||||||
.Replace("{PrimaryKey}", replaceDto.PKName)
|
.Replace("{PrimaryKey}", replaceDto.PKName)
|
||||||
.Replace("{UpdateColumn}", replaceDto.UpdateColumn)
|
.Replace("{UpdateColumn}", replaceDto.UpdateColumn)
|
||||||
.Replace("{InsertColumn}", replaceDto.InsertColumn)
|
.Replace("{InsertColumn}", replaceDto.InsertColumn)
|
||||||
.Replace("{KeyTypeName}", replaceDto.PKType);
|
.Replace("{PKCsharpType}", replaceDto.PKType);
|
||||||
WriteAndSave(fullPath, content);
|
WriteAndSave(fullPath, content);
|
||||||
return Tuple.Create(fullPath, content);
|
return Tuple.Create(fullPath, content);
|
||||||
}
|
}
|
||||||
@ -339,14 +386,14 @@ namespace ZR.CodeGenerator
|
|||||||
private static Tuple<string, string> GenerateVueViews(ReplaceDto replaceDto, GenerateDto generateDto)
|
private static Tuple<string, string> GenerateVueViews(ReplaceDto replaceDto, GenerateDto generateDto)
|
||||||
{
|
{
|
||||||
//var parentPath = "..\\CodeGenerate";//若要生成到项目中将路径改成 “..\\ZR.Vue\\src”
|
//var parentPath = "..\\CodeGenerate";//若要生成到项目中将路径改成 “..\\ZR.Vue\\src”
|
||||||
var parentPath = "..\\ZR.Vue\\src";
|
var parentPath = $"{generateDto.ParentPath}\\ZR.Vue\\src";
|
||||||
var servicesPath = parentPath + "\\views\\" + FirstLowerCase(replaceDto.ModelTypeName);
|
var servicesPath = parentPath + "\\views\\" + FirstLowerCase(replaceDto.ModelTypeName);
|
||||||
if (!Directory.Exists(servicesPath))
|
if (!Directory.Exists(servicesPath))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(servicesPath);
|
Directory.CreateDirectory(servicesPath);
|
||||||
}
|
}
|
||||||
var fullPath = servicesPath + "\\" + "index.vue";
|
var fullPath = servicesPath + "\\" + "index.vue";
|
||||||
Console.WriteLine(fullPath);
|
|
||||||
if (File.Exists(fullPath) && !generateDto.coverd)
|
if (File.Exists(fullPath) && !generateDto.coverd)
|
||||||
return Tuple.Create(fullPath, ""); ;
|
return Tuple.Create(fullPath, ""); ;
|
||||||
var content = ReadTemplate("VueTemplate.txt");
|
var content = ReadTemplate("VueTemplate.txt");
|
||||||
@ -360,8 +407,8 @@ namespace ZR.CodeGenerator
|
|||||||
.Replace("{vueJsMethod}", replaceDto.VueJsMethod)
|
.Replace("{vueJsMethod}", replaceDto.VueJsMethod)
|
||||||
.Replace("{vueQueryFormHtml}", replaceDto.VueQueryFormHtml)
|
.Replace("{vueQueryFormHtml}", replaceDto.VueQueryFormHtml)
|
||||||
.Replace("{VueDataContent}", replaceDto.VueDataContent)
|
.Replace("{VueDataContent}", replaceDto.VueDataContent)
|
||||||
//.Replace("{VueViewSaveBindContent}", vueViewSaveBindContent)
|
|
||||||
.Replace("{primaryKey}", FirstLowerCase(replaceDto.PKName))
|
.Replace("{primaryKey}", FirstLowerCase(replaceDto.PKName))
|
||||||
|
.Replace("{MountedMethod}", replaceDto.MountedMethod)
|
||||||
.Replace("{VueViewEditFormRuleContent}", replaceDto.VueViewEditFormRuleContent);//添加、修改表单验证规则
|
.Replace("{VueViewEditFormRuleContent}", replaceDto.VueViewEditFormRuleContent);//添加、修改表单验证规则
|
||||||
WriteAndSave(fullPath, content);
|
WriteAndSave(fullPath, content);
|
||||||
|
|
||||||
@ -369,14 +416,14 @@ namespace ZR.CodeGenerator
|
|||||||
servicesPath = parentPath + "\\api\\";
|
servicesPath = parentPath + "\\api\\";
|
||||||
Directory.CreateDirectory(servicesPath);
|
Directory.CreateDirectory(servicesPath);
|
||||||
fullPath = servicesPath + "\\" + FirstLowerCase(replaceDto.ModelTypeName) + ".js";
|
fullPath = servicesPath + "\\" + FirstLowerCase(replaceDto.ModelTypeName) + ".js";
|
||||||
Console.WriteLine(fullPath);
|
|
||||||
if (File.Exists(fullPath) && !generateDto.coverd)
|
if (File.Exists(fullPath) && !generateDto.coverd)
|
||||||
return Tuple.Create(fullPath, "");
|
return Tuple.Create(fullPath, "");
|
||||||
content = ReadTemplate("VueJsTemplate.txt");
|
content = ReadTemplate("VueJsTemplate.txt");
|
||||||
content = content
|
content = content
|
||||||
.Replace("{ModelTypeName}", replaceDto.ModelTypeName)
|
.Replace("{ModelTypeName}", replaceDto.ModelTypeName)
|
||||||
.Replace("{ModelTypeDesc}", replaceDto.TableDesc);
|
.Replace("{ModelTypeDesc}", replaceDto.TableDesc);
|
||||||
//.Replace("{fileClassName}", fileClassName)
|
|
||||||
WriteAndSave(fullPath, content);
|
WriteAndSave(fullPath, content);
|
||||||
return Tuple.Create(fullPath, content);
|
return Tuple.Create(fullPath, content);
|
||||||
}
|
}
|
||||||
@ -437,8 +484,9 @@ namespace ZR.CodeGenerator
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private static string ReadTemplate(string templateName)
|
private static string ReadTemplate(string templateName)
|
||||||
{
|
{
|
||||||
var path = AppDomain.CurrentDomain.BaseDirectory;
|
string path = Environment.CurrentDirectory;
|
||||||
string fullName = $"{path}\\Template\\{templateName}";
|
//var path = AppDomain.CurrentDomain.BaseDirectory;
|
||||||
|
string fullName = $"{path}\\wwwroot\\CodeGenTemplate\\{templateName}";
|
||||||
string temp = fullName;
|
string temp = fullName;
|
||||||
string str = "";
|
string str = "";
|
||||||
if (!File.Exists(temp))
|
if (!File.Exists(temp))
|
||||||
@ -485,5 +533,74 @@ namespace ZR.CodeGenerator
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 初始化列属性字段数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="genTable"></param>
|
||||||
|
/// <param name="dbColumnInfos"></param>
|
||||||
|
public static List<GenTableColumn> InitGenTableColumn(GenTable genTable, List<DbColumnInfo> dbColumnInfos)
|
||||||
|
{
|
||||||
|
List<GenTableColumn> genTableColumns = new();
|
||||||
|
foreach (var column in dbColumnInfos)
|
||||||
|
{
|
||||||
|
GenTableColumn genTableColumn = new()
|
||||||
|
{
|
||||||
|
ColumnName = FirstLowerCase(column.DbColumnName),
|
||||||
|
ColumnComment = column.ColumnDescription,
|
||||||
|
IsPk = column.IsPrimarykey,
|
||||||
|
ColumnType = column.DataType,
|
||||||
|
TableId = genTable.TableId,
|
||||||
|
TableName = genTable.TableName,
|
||||||
|
CsharpType = TableMappingHelper.GetCSharpDatatype(column.DataType),
|
||||||
|
CsharpField = column.DbColumnName.Substring(0, 1).ToUpper() + column.DbColumnName[1..],
|
||||||
|
IsRequired = !column.IsNullable,
|
||||||
|
IsIncrement = column.IsIdentity,
|
||||||
|
Create_by = genTable.Create_by,
|
||||||
|
Create_time = DateTime.Now,
|
||||||
|
IsInsert = !column.IsIdentity,//非自增字段都需要插入
|
||||||
|
IsQuery = false,
|
||||||
|
HtmlType = GenConstants.HTML_INPUT
|
||||||
|
};
|
||||||
|
|
||||||
|
if (GenConstants.imageFiled.Any(f => column.DbColumnName.ToLower().Contains(f.ToLower())))
|
||||||
|
{
|
||||||
|
genTableColumn.HtmlType = GenConstants.HTML_IMAGE_UPLOAD;
|
||||||
|
}
|
||||||
|
else if (GenConstants.COLUMNTYPE_TIME.Any(f => genTableColumn.CsharpType.ToLower().Contains(f.ToLower())))
|
||||||
|
{
|
||||||
|
genTableColumn.HtmlType = GenConstants.HTML_DATETIME;
|
||||||
|
}
|
||||||
|
else if (GenConstants.radioFiled.Any(f => column.DbColumnName.EndsWith(f, StringComparison.OrdinalIgnoreCase)) ||
|
||||||
|
GenConstants.radioFiled.Any(f => column.DbColumnName.StartsWith(f, StringComparison.OrdinalIgnoreCase)))
|
||||||
|
{
|
||||||
|
genTableColumn.HtmlType = GenConstants.HTML_RADIO;
|
||||||
|
}
|
||||||
|
else if (GenConstants.selectFiled.Any(f => column.DbColumnName == f) ||
|
||||||
|
GenConstants.selectFiled.Any(f => column.DbColumnName.EndsWith(f, StringComparison.OrdinalIgnoreCase)))
|
||||||
|
{
|
||||||
|
genTableColumn.HtmlType = GenConstants.HTML_SELECT;
|
||||||
|
}
|
||||||
|
else if (column.Length > 500)
|
||||||
|
{
|
||||||
|
genTableColumn.HtmlType = GenConstants.HTML_TEXTAREA;
|
||||||
|
}
|
||||||
|
//编辑字段
|
||||||
|
if (GenConstants.COLUMNNAME_NOT_EDIT.Any(f => column.DbColumnName.Contains(f)) && !column.IsIdentity && !column.IsPrimarykey)
|
||||||
|
{
|
||||||
|
genTableColumn.IsEdit = true;
|
||||||
|
}
|
||||||
|
//列表字段
|
||||||
|
if (GenConstants.COLUMNNAME_NOT_LIST.Any(f => column.DbColumnName.Contains(f) && !column.IsPrimarykey))
|
||||||
|
{
|
||||||
|
genTableColumn.IsList = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
genTableColumns.Add(genTableColumn);
|
||||||
|
}
|
||||||
|
return genTableColumns;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,7 +28,7 @@ namespace ZR.CodeGenerator
|
|||||||
if (string.IsNullOrEmpty(dbName))
|
if (string.IsNullOrEmpty(dbName))
|
||||||
{
|
{
|
||||||
connStr = ConfigUtils.Instance.GetConnectionStrings(OptionsSetting.ConnAdmin);
|
connStr = ConfigUtils.Instance.GetConnectionStrings(OptionsSetting.ConnAdmin);
|
||||||
dbType = ConfigUtils.Instance.GetAppConfig<int>(OptionsSetting.DbType);
|
dbType = ConfigUtils.Instance.GetAppConfig<int>(OptionsSetting.ConnDbType);
|
||||||
}
|
}
|
||||||
var db = new SqlSugarScope(new List<ConnectionConfig>()
|
var db = new SqlSugarScope(new List<ConnectionConfig>()
|
||||||
{
|
{
|
||||||
|
|||||||
182
ZR.CodeGenerator/FileHelper.cs
Normal file
182
ZR.CodeGenerator/FileHelper.cs
Normal file
@ -0,0 +1,182 @@
|
|||||||
|
using ICSharpCode.SharpZipLib.Checksum;
|
||||||
|
using ICSharpCode.SharpZipLib.Zip;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ZR.CodeGenerator
|
||||||
|
{
|
||||||
|
public class FileHelper
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 制作压缩包(多个文件压缩到一个压缩包,支持加密、注释)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="fileNames">要压缩的文件</param>
|
||||||
|
/// <param name="topDirectoryName">压缩文件目录</param>
|
||||||
|
/// <param name="zipedFileName">压缩包文件名</param>
|
||||||
|
/// <param name="compresssionLevel">压缩级别 1-9</param>
|
||||||
|
/// <param name="password">密码</param>
|
||||||
|
/// <param name="comment">注释</param>
|
||||||
|
public static void ZipFiles(string[] fileNames, string topDirectoryName, string zipedFileName, int? compresssionLevel, string password = "", string comment = "")
|
||||||
|
{
|
||||||
|
using (ZipOutputStream zos = new ZipOutputStream(File.Open(zipedFileName, FileMode.OpenOrCreate)))
|
||||||
|
{
|
||||||
|
if (compresssionLevel.HasValue)
|
||||||
|
{
|
||||||
|
zos.SetLevel(compresssionLevel.Value);//设置压缩级别
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(password))
|
||||||
|
{
|
||||||
|
zos.Password = password;//设置zip包加密密码
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(comment))
|
||||||
|
{
|
||||||
|
zos.SetComment(comment);//设置zip包的注释
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (string file in fileNames)
|
||||||
|
{
|
||||||
|
//string fileName = string.Format("{0}/{1}", topDirectoryName, file);
|
||||||
|
string fileName = file;
|
||||||
|
|
||||||
|
if (File.Exists(fileName))
|
||||||
|
{
|
||||||
|
FileInfo item = new FileInfo(fileName);
|
||||||
|
FileStream fs = File.OpenRead(item.FullName);
|
||||||
|
byte[] buffer = new byte[fs.Length];
|
||||||
|
fs.Read(buffer, 0, buffer.Length);
|
||||||
|
|
||||||
|
ZipEntry entry = new ZipEntry(item.Name);
|
||||||
|
zos.PutNextEntry(entry);
|
||||||
|
zos.Write(buffer, 0, buffer.Length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 压缩多层目录
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="topDirectoryName">压缩文件目录</param>
|
||||||
|
/// <param name="zipedFileName">压缩包文件名</param>
|
||||||
|
/// <param name="compresssionLevel">压缩级别 1-9 </param>
|
||||||
|
/// <param name="password">密码</param>
|
||||||
|
/// <param name="comment">注释</param>
|
||||||
|
/// <param name="filetype">文件类型</param>
|
||||||
|
public static void ZipFileDirectory(string topDirectoryName, string zipedFileName, int compresssionLevel, string password, string comment, string filetype)
|
||||||
|
{
|
||||||
|
using (System.IO.FileStream ZipFile = File.Open(zipedFileName, FileMode.OpenOrCreate))
|
||||||
|
{
|
||||||
|
using (ZipOutputStream zos = new ZipOutputStream(ZipFile))
|
||||||
|
{
|
||||||
|
if (compresssionLevel != 0)
|
||||||
|
{
|
||||||
|
zos.SetLevel(compresssionLevel);//设置压缩级别
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrEmpty(password))
|
||||||
|
{
|
||||||
|
zos.Password = password;//设置zip包加密密码
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrEmpty(comment))
|
||||||
|
{
|
||||||
|
zos.SetComment(comment);//设置zip包的注释
|
||||||
|
}
|
||||||
|
ZipSetp(topDirectoryName, zos, "", filetype);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 递归遍历目录
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strDirectory">The directory.</param>
|
||||||
|
/// <param name="s">The ZipOutputStream Object.</param>
|
||||||
|
/// <param name="parentPath">The parent path.</param>
|
||||||
|
private static void ZipSetp(string strDirectory, ZipOutputStream s, string parentPath, string filetype)
|
||||||
|
{
|
||||||
|
if (strDirectory[^1] != Path.DirectorySeparatorChar)
|
||||||
|
{
|
||||||
|
strDirectory += Path.DirectorySeparatorChar;
|
||||||
|
}
|
||||||
|
|
||||||
|
Crc32 crc = new Crc32();
|
||||||
|
|
||||||
|
string[] filenames = Directory.GetFileSystemEntries(strDirectory, filetype);
|
||||||
|
foreach (string file in filenames)// 遍历所有的文件和目录
|
||||||
|
{
|
||||||
|
if (Directory.Exists(file))// 先当作目录处理如果存在这个目录就递归Copy该目录下面的文件
|
||||||
|
{
|
||||||
|
string pPath = parentPath;
|
||||||
|
pPath += file.Substring(file.LastIndexOf("\\") + 1);
|
||||||
|
pPath += "\\";
|
||||||
|
ZipSetp(file, s, pPath, filetype);
|
||||||
|
}
|
||||||
|
else // 否则直接压缩文件
|
||||||
|
{
|
||||||
|
//打开压缩文件
|
||||||
|
using (FileStream fs = File.OpenRead(file))
|
||||||
|
{
|
||||||
|
byte[] buffer = new byte[fs.Length];
|
||||||
|
fs.Read(buffer, 0, buffer.Length);
|
||||||
|
string fileName = parentPath + file[(file.LastIndexOf("\\") + 1)..];
|
||||||
|
ZipEntry entry = new ZipEntry(fileName);
|
||||||
|
entry.DateTime = DateTime.Now;
|
||||||
|
entry.Size = fs.Length;
|
||||||
|
fs.Close();
|
||||||
|
crc.Reset();
|
||||||
|
crc.Update(buffer);
|
||||||
|
entry.Crc = crc.Value;
|
||||||
|
s.PutNextEntry(entry);
|
||||||
|
s.Write(buffer, 0, buffer.Length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除指定目录下的所有文件及文件夹(保留目录)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="file">文件目录</param>
|
||||||
|
public static void DeleteDirectory(string file)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//判断文件夹是否还存在
|
||||||
|
if (Directory.Exists(file))
|
||||||
|
{
|
||||||
|
DirectoryInfo fileInfo = new DirectoryInfo(file);
|
||||||
|
//去除文件夹的只读属性
|
||||||
|
fileInfo.Attributes = FileAttributes.Normal & FileAttributes.Directory;
|
||||||
|
foreach (string f in Directory.GetFileSystemEntries(file))
|
||||||
|
{
|
||||||
|
if (File.Exists(f))
|
||||||
|
{
|
||||||
|
//去除文件的只读属性
|
||||||
|
File.SetAttributes(file, FileAttributes.Normal);
|
||||||
|
//如果有子文件删除文件
|
||||||
|
File.Delete(f);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//循环递归删除子文件夹
|
||||||
|
DeleteDirectory(f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//删除空文件夹
|
||||||
|
Directory.Delete(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex) // 异常处理
|
||||||
|
{
|
||||||
|
//Log4NetHelper.Error("代码生成异常", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,8 +1,4 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ZR.CodeGenerator
|
namespace ZR.CodeGenerator
|
||||||
{
|
{
|
||||||
@ -17,6 +13,24 @@ namespace ZR.CodeGenerator
|
|||||||
public static string Gen_autoPre = "gen:autoPre";
|
public static string Gen_autoPre = "gen:autoPre";
|
||||||
public static string Gen_tablePrefix = "gen:tablePrefix";
|
public static string Gen_tablePrefix = "gen:tablePrefix";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// InputDto输入实体是不包含字段
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string[] inputDtoNoField = new string[] { "createTime", "updateTime", "addtime" };
|
||||||
|
/// <summary>
|
||||||
|
/// 图片字段
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string[] imageFiled = new string[] { "icon", "img", "image", "url", "pic", "photo", "avatar" };
|
||||||
|
/// <summary>
|
||||||
|
/// 下拉框字段
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string[] selectFiled = new string[] { "status", "type", "state", "sex", "gender" };
|
||||||
|
/// <summary>
|
||||||
|
/// 单选按钮字段
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string[] radioFiled = new string[] { "status", "state", "is"};
|
||||||
|
|
||||||
|
|
||||||
/** 单表(增删改查) */
|
/** 单表(增删改查) */
|
||||||
public static string TPL_CRUD = "crud";
|
public static string TPL_CRUD = "crud";
|
||||||
|
|
||||||
@ -55,14 +69,14 @@ namespace ZR.CodeGenerator
|
|||||||
"bit", "bigint", "float", "double", "decimal" };
|
"bit", "bigint", "float", "double", "decimal" };
|
||||||
|
|
||||||
/** 页面不需要编辑字段 */
|
/** 页面不需要编辑字段 */
|
||||||
public static string[] COLUMNNAME_NOT_EDIT = { "id", "create_by", "create_time", "del_flag" };
|
public static string[] COLUMNNAME_NOT_EDIT = { "id", "create_by", "create_time", "delFlag" };
|
||||||
|
|
||||||
/** 页面不需要显示的列表字段 */
|
/** 页面不需要显示的列表字段 */
|
||||||
public static string[] COLUMNNAME_NOT_LIST = { "id", "create_by", "create_time", "del_flag", "update_by",
|
public static string[] COLUMNNAME_NOT_LIST = { "id", "create_by", "create_time", "delFlag", "update_by",
|
||||||
"update_time" };
|
"update_time" , "password"};
|
||||||
|
|
||||||
/** 页面不需要查询字段 */
|
/** 页面不需要查询字段 */
|
||||||
public static string[] COLUMNNAME_NOT_QUERY = { "id", "create_by", "create_time", "del_flag", "update_by",
|
public static string[] COLUMNNAME_NOT_QUERY = { "id", "create_by", "create_time", "delFlag", "update_by",
|
||||||
"update_time", "remark" };
|
"update_time", "remark" };
|
||||||
|
|
||||||
/** Entity基类字段 */
|
/** Entity基类字段 */
|
||||||
@ -102,17 +116,14 @@ namespace ZR.CodeGenerator
|
|||||||
public static string TYPE_STRING = "string";
|
public static string TYPE_STRING = "string";
|
||||||
|
|
||||||
/** 整型 */
|
/** 整型 */
|
||||||
public static string TYPE_INTEGER = "Integer";
|
public static string TYPE_INT = "int";
|
||||||
|
|
||||||
/** 长整型 */
|
/** 长整型 */
|
||||||
public static string TYPE_LONG = "Long";
|
public static string TYPE_LONG = "long";
|
||||||
|
|
||||||
/** 浮点型 */
|
/** 浮点型 */
|
||||||
public static string TYPE_DOUBLE = "Double";
|
public static string TYPE_DOUBLE = "Double";
|
||||||
|
|
||||||
/** 高精度计算类型 */
|
|
||||||
public static string TYPE_BIGDECIMAL = "BigDecimal";
|
|
||||||
|
|
||||||
/** 时间类型 */
|
/** 时间类型 */
|
||||||
public static string TYPE_DATE = "Date";
|
public static string TYPE_DATE = "Date";
|
||||||
|
|
||||||
|
|||||||
@ -25,7 +25,7 @@ namespace ZR.CodeGenerator.Model
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 要删除表名的字符串用
|
/// 要删除表名的字符串用
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string replaceTableNameStr { get; set; }
|
//public string replaceTableNameStr { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 要生成的文件
|
/// 要生成的文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -34,5 +34,16 @@ namespace ZR.CodeGenerator.Model
|
|||||||
/// 如果目标文件存在,是否覆盖。默认为false
|
/// 如果目标文件存在,是否覆盖。默认为false
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool coverd { get; set; } = true;
|
public bool coverd { get; set; } = true;
|
||||||
|
|
||||||
|
#region 存储路径
|
||||||
|
//public string ModelPath { get; set; }
|
||||||
|
//public string ServicePath { get; set; }
|
||||||
|
//public string RepositoryPath { get; set; }
|
||||||
|
//public string ApiPath { get; set; }
|
||||||
|
//public string VuePath { get; set; }
|
||||||
|
//public string VueApiPath { get; set; }
|
||||||
|
|
||||||
|
public string ParentPath { get; set; } = "..";
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -92,5 +92,9 @@ namespace ZR.CodeGenerator.Model
|
|||||||
/// vue data内容
|
/// vue data内容
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string VueDataContent { get; set; }
|
public string VueDataContent { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// vue mounted 方法
|
||||||
|
/// </summary>
|
||||||
|
public string MountedMethod { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -45,75 +45,33 @@ namespace ZR.CodeGenerator.CodeGenerator
|
|||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetPropertyDatatype(string sDatatype)
|
/// <summary>
|
||||||
|
/// 获取C# 类型
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sDatatype"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string GetCSharpDatatype(string sDatatype)
|
||||||
{
|
{
|
||||||
string sTempDatatype = string.Empty;
|
|
||||||
sDatatype = sDatatype.ToLower();
|
sDatatype = sDatatype.ToLower();
|
||||||
switch (sDatatype)
|
string sTempDatatype = sDatatype switch
|
||||||
{
|
{
|
||||||
case "int":
|
"int" or "number" or "integer" or "smallint" => "int",
|
||||||
case "number":
|
"bigint" => "long",
|
||||||
case "integer":
|
"tinyint" => "byte",
|
||||||
case "smallint":
|
"numeric" or "real" or "float" => "float",
|
||||||
sTempDatatype = "int";
|
"decimal" or "numer(8,2)" => "decimal",
|
||||||
break;
|
"bit" => "bool",
|
||||||
|
"date" or "datetime" or "datetime2" or "smalldatetime" => "DateTime",
|
||||||
case "bigint":
|
"money" or "smallmoney" => "double",
|
||||||
sTempDatatype = "long";
|
_ => "string",
|
||||||
break;
|
};
|
||||||
|
|
||||||
case "tinyint":
|
|
||||||
sTempDatatype = "byte";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "numeric":
|
|
||||||
case "real":
|
|
||||||
sTempDatatype = "Single";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "float":
|
|
||||||
sTempDatatype = "float";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "decimal":
|
|
||||||
case "numer(8,2)":
|
|
||||||
sTempDatatype = "decimal";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "bit":
|
|
||||||
sTempDatatype = "bool";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "date":
|
|
||||||
case "datetime":
|
|
||||||
case "datetime2":
|
|
||||||
case "smalldatetime":
|
|
||||||
sTempDatatype = "DateTime";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "money":
|
|
||||||
case "smallmoney":
|
|
||||||
sTempDatatype = "double";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "char":
|
|
||||||
case "varchar":
|
|
||||||
case "nvarchar2":
|
|
||||||
case "text":
|
|
||||||
case "nchar":
|
|
||||||
case "nvarchar":
|
|
||||||
case "ntext":
|
|
||||||
default:
|
|
||||||
sTempDatatype = "string";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return sTempDatatype;
|
return sTempDatatype;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsNumber(string tableDataType)
|
public static bool IsNumber(string tableDataType)
|
||||||
{
|
{
|
||||||
string[] arr = new string[] { "int", "long" };
|
string[] arr = new string[] { "int", "long" };
|
||||||
return arr.Any(f => f.Contains(GetPropertyDatatype(tableDataType)));
|
return arr.Any(f => f.Contains(GetCSharpDatatype(tableDataType)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,7 +22,7 @@ namespace ZR.Repository.DbProvider
|
|||||||
{
|
{
|
||||||
string connStr = ConfigUtils.Instance.GetConnectionStrings(OptionsSetting.ConnAdmin);
|
string connStr = ConfigUtils.Instance.GetConnectionStrings(OptionsSetting.ConnAdmin);
|
||||||
string dbKey = ConfigUtils.Instance.GetAppConfig<string>(OptionsSetting.DbKey);
|
string dbKey = ConfigUtils.Instance.GetAppConfig<string>(OptionsSetting.DbKey);
|
||||||
string dbType = ConfigUtils.Instance.GetConnectionStrings(OptionsSetting.DbType);
|
int dbType = ConfigUtils.Instance.GetAppConfig<int>(OptionsSetting.ConnDbType);
|
||||||
if (!string.IsNullOrEmpty(dbKey))
|
if (!string.IsNullOrEmpty(dbKey))
|
||||||
{
|
{
|
||||||
connStr = NETCore.Encrypt.EncryptProvider.DESDecrypt(connStr, dbKey);
|
connStr = NETCore.Encrypt.EncryptProvider.DESDecrypt(connStr, dbKey);
|
||||||
@ -32,7 +32,7 @@ namespace ZR.Repository.DbProvider
|
|||||||
{
|
{
|
||||||
new ConnectionConfig(){
|
new ConnectionConfig(){
|
||||||
ConnectionString = connStr,
|
ConnectionString = connStr,
|
||||||
DbType = (DbType)Convert.ToInt32(dbType),
|
DbType = (DbType)dbType,
|
||||||
IsAutoCloseConnection = true,//开启自动释放模式和EF原理一样
|
IsAutoCloseConnection = true,//开启自动释放模式和EF原理一样
|
||||||
InitKeyType = InitKeyType.Attribute,//从特性读取主键和自增列信息
|
InitKeyType = InitKeyType.Attribute,//从特性读取主键和自增列信息
|
||||||
ConfigId = 0
|
ConfigId = 0
|
||||||
|
|||||||
@ -42,11 +42,11 @@ export const constantRoutes = [
|
|||||||
component: (resolve) => require(['@/views/login'], resolve),
|
component: (resolve) => require(['@/views/login'], resolve),
|
||||||
hidden: true
|
hidden: true
|
||||||
},
|
},
|
||||||
// {
|
{
|
||||||
// path: '/demo',
|
path: '/demo',
|
||||||
// component: (resolve) => require(['@/views/gift/index'], resolve),
|
component: (resolve) => require(['@/views/userInfo/index'], resolve),
|
||||||
// hidden: true
|
hidden: true
|
||||||
// },
|
},
|
||||||
{
|
{
|
||||||
path: '/404',
|
path: '/404',
|
||||||
component: (resolve) => require(['@/views/error/404'], resolve),
|
component: (resolve) => require(['@/views/error/404'], resolve),
|
||||||
|
|||||||
71
ZRAdmin.xml
71
ZRAdmin.xml
@ -27,44 +27,44 @@
|
|||||||
<param name="data"></param>
|
<param name="data"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
<member name="T:ZR.Admin.WebApi.Controllers.GendemoController">
|
<member name="T:ZR.Admin.WebApi.Controllers.UserInfoController">
|
||||||
<summary>
|
<summary>
|
||||||
代码自动生成
|
代码自动生成
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="F:ZR.Admin.WebApi.Controllers.GendemoController._GendemoService">
|
<member name="F:ZR.Admin.WebApi.Controllers.UserInfoController._UserInfoService">
|
||||||
<summary>
|
<summary>
|
||||||
测试接口
|
用户信息接口
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:ZR.Admin.WebApi.Controllers.GendemoController.QueryGendemo(ZR.Model.Dto.GendemoQueryDto)">
|
<member name="M:ZR.Admin.WebApi.Controllers.UserInfoController.QueryUserInfo(ZR.Model.Dto.UserInfoQueryDto)">
|
||||||
<summary>
|
<summary>
|
||||||
查询测试列表
|
查询用户信息列表
|
||||||
</summary>
|
</summary>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:ZR.Admin.WebApi.Controllers.GendemoController.GetGendemo(System.Int32)">
|
<member name="M:ZR.Admin.WebApi.Controllers.UserInfoController.GetUserInfo(System.Int32)">
|
||||||
<summary>
|
<summary>
|
||||||
查询测试详情
|
查询用户信息详情
|
||||||
</summary>
|
</summary>
|
||||||
<param name="Id"></param>
|
<param name="Luid"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:ZR.Admin.WebApi.Controllers.GendemoController.AddGendemo(ZR.Model.Dto.GendemoDto)">
|
<member name="M:ZR.Admin.WebApi.Controllers.UserInfoController.AddUserInfo(ZR.Model.Dto.UserInfoDto)">
|
||||||
<summary>
|
<summary>
|
||||||
添加测试
|
添加用户信息
|
||||||
</summary>
|
</summary>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:ZR.Admin.WebApi.Controllers.GendemoController.UpdateGendemo(ZR.Model.Dto.GendemoDto)">
|
<member name="M:ZR.Admin.WebApi.Controllers.UserInfoController.UpdateUserInfo(ZR.Model.Dto.UserInfoDto)">
|
||||||
<summary>
|
<summary>
|
||||||
更新测试
|
更新用户信息
|
||||||
</summary>
|
</summary>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:ZR.Admin.WebApi.Controllers.GendemoController.DeleteGendemo(System.Int32)">
|
<member name="M:ZR.Admin.WebApi.Controllers.UserInfoController.DeleteUserInfo(System.String)">
|
||||||
<summary>
|
<summary>
|
||||||
删除测试
|
删除用户信息
|
||||||
</summary>
|
</summary>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
@ -127,7 +127,7 @@
|
|||||||
</member>
|
</member>
|
||||||
<member name="M:ZR.Admin.WebApi.Controllers.CodeGeneratorController.EditSave(ZR.Model.System.Dto.GenTableDto)">
|
<member name="M:ZR.Admin.WebApi.Controllers.CodeGeneratorController.EditSave(ZR.Model.System.Dto.GenTableDto)">
|
||||||
<summary>
|
<summary>
|
||||||
代码生成保存
|
修改保存代码生成业务
|
||||||
</summary>
|
</summary>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
@ -792,47 +792,6 @@
|
|||||||
<param name="formFile"></param>
|
<param name="formFile"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
<member name="T:ZR.Admin.WebApi.Controllers.SysFile1Controller">
|
|
||||||
<summary>
|
|
||||||
T4代码自动生成
|
|
||||||
</summary>
|
|
||||||
</member>
|
|
||||||
<member name="F:ZR.Admin.WebApi.Controllers.SysFile1Controller._SysFileService">
|
|
||||||
<summary>
|
|
||||||
文件管理接口
|
|
||||||
</summary>
|
|
||||||
</member>
|
|
||||||
<member name="M:ZR.Admin.WebApi.Controllers.SysFile1Controller.Query(ZR.Model.System.Dto.SysFileQueryDto)">
|
|
||||||
<summary>
|
|
||||||
查询文件管理列表
|
|
||||||
</summary>
|
|
||||||
<returns></returns>
|
|
||||||
</member>
|
|
||||||
<member name="M:ZR.Admin.WebApi.Controllers.SysFile1Controller.Get(System.String)">
|
|
||||||
<summary>
|
|
||||||
查询文件管理详情
|
|
||||||
</summary>
|
|
||||||
<param name="id"></param>
|
|
||||||
<returns></returns>
|
|
||||||
</member>
|
|
||||||
<member name="M:ZR.Admin.WebApi.Controllers.SysFile1Controller.Create(ZR.Model.System.SysFile)">
|
|
||||||
<summary>
|
|
||||||
添加文件管理
|
|
||||||
</summary>
|
|
||||||
<returns></returns>
|
|
||||||
</member>
|
|
||||||
<member name="M:ZR.Admin.WebApi.Controllers.SysFile1Controller.Update(ZR.Model.System.SysFile)">
|
|
||||||
<summary>
|
|
||||||
更新文件管理
|
|
||||||
</summary>
|
|
||||||
<returns></returns>
|
|
||||||
</member>
|
|
||||||
<member name="M:ZR.Admin.WebApi.Controllers.SysFile1Controller.Delete(System.Int32)">
|
|
||||||
<summary>
|
|
||||||
删除文件管理
|
|
||||||
</summary>
|
|
||||||
<returns></returns>
|
|
||||||
</member>
|
|
||||||
<member name="T:ZR.Admin.WebApi.Extensions.HttpContextExtension">
|
<member name="T:ZR.Admin.WebApi.Extensions.HttpContextExtension">
|
||||||
<summary>
|
<summary>
|
||||||
HttpContext扩展类
|
HttpContext扩展类
|
||||||
|
|||||||
@ -253,13 +253,15 @@ INSERT INTO sys_menu VALUES (108, '日志管理', 1, 9, 'log', '', 0, 0, 'M', '0
|
|||||||
INSERT INTO sys_menu VALUES (105, '字典管理', 1, 5, 'dict', 'system/dict/index', 0, 0, 'C', '0', '0', 'system:dict:list', 'dict', '', SYSDATE(), '', NULL, '');
|
INSERT INTO sys_menu VALUES (105, '字典管理', 1, 5, 'dict', 'system/dict/index', 0, 0, 'C', '0', '0', 'system:dict:list', 'dict', '', SYSDATE(), '', NULL, '');
|
||||||
INSERT INTO sys_menu VALUES (106, '分配用户', 1, 3, 'roleusers', 'system/roleusers/index', 0, 0, 'C', '0', '0', 'system:role:list', 'people', '', SYSDATE(), '', NULL, NULL);
|
INSERT INTO sys_menu VALUES (106, '分配用户', 1, 3, 'roleusers', 'system/roleusers/index', 0, 0, 'C', '0', '0', 'system:role:list', 'people', '', SYSDATE(), '', NULL, NULL);
|
||||||
|
|
||||||
|
-- 一级菜单 缓存监控
|
||||||
|
INSERT INTO sys_menu VALUES (113, '缓存监控', 2, 5, 'cache', 'monitor/cache/index', 0, 0, 'C', '1', '1', 'monitor:cache:list', 'redis', '', SYSDATE(), '', NULL, '缓存监控菜单');
|
||||||
|
|
||||||
-- 一级菜单 系统工具
|
-- 一级菜单 系统工具
|
||||||
INSERT INTO sys_menu VALUES (114, '表单构建', 3, 1, 'build', 'tool/build/index', 0, 0, 'C', '0', '0', 'tool:build:list', 'build', '', SYSDATE(), '', NULL, '表单构建菜单');
|
INSERT INTO sys_menu VALUES (114, '表单构建', 3, 1, 'build', 'tool/build/index', 0, 0, 'C', '0', '0', 'tool:build:list', 'build', '', SYSDATE(), '', NULL, '表单构建菜单');
|
||||||
INSERT INTO sys_menu VALUES (115, '代码生成', 3, 1, 'gen', 'tool/gen/index', 0, 0, 'C', '0', '0', 'tool:gen:list', 'code', '', SYSDATE(), '', NULL, '代码生成菜单');
|
INSERT INTO sys_menu VALUES (115, '代码生成', 3, 1, 'gen', 'tool/gen/index', 0, 0, 'C', '0', '0', 'tool:gen:list', 'code', '', SYSDATE(), '', NULL, '代码生成菜单');
|
||||||
INSERT INTO sys_menu VALUES (116, '系统接口', 3, 3, 'swagger', 'tool/swagger/index', 0, 0, 'C', '0', '0', 'tool:swagger:list', 'swagger', '', SYSDATE(), '', NULL, '系统接口菜单');
|
INSERT INTO sys_menu VALUES (116, '系统接口', 3, 3, 'swagger', 'tool/swagger/index', 0, 0, 'C', '0', '0', 'tool:swagger:list', 'swagger', '', SYSDATE(), '', NULL, '系统接口菜单');
|
||||||
|
INSERT INTO sys_menu VALUES (117, '编辑表格', 3, 3, 'editTable', 'tool/gen/editTable', 0, 0, 'C', '1', '0', 'tool:gen:edittable', '', '', SYSDATE(), '', NULL, '代码生成编辑表格菜单');
|
||||||
|
|
||||||
-- 一级菜单 缓存监控
|
|
||||||
INSERT INTO sys_menu VALUES (113, '缓存监控', 2, 5, 'cache', 'monitor/cache/index', 0, 0, 'C', '1', '1', 'monitor:cache:list', 'redis', '', SYSDATE(), '', NULL, '缓存监控菜单');
|
|
||||||
|
|
||||||
-- 日志管理
|
-- 日志管理
|
||||||
INSERT INTO sys_menu VALUES (500, '操作日志', 108, 1, 'operlog', 'monitor/operlog/index', 0, 0, 'C', '0', '0', 'monitor:operlog:list', 'form', '', SYSDATE(), '', NULL, '操作日志菜单');
|
INSERT INTO sys_menu VALUES (500, '操作日志', 108, 1, 'operlog', 'monitor/operlog/index', 0, 0, 'C', '0', '0', 'monitor:operlog:list', 'form', '', SYSDATE(), '', NULL, '操作日志菜单');
|
||||||
@ -633,30 +635,32 @@ create table gen_table (
|
|||||||
-- 19、代码生成业务表字段
|
-- 19、代码生成业务表字段
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
drop table if exists gen_table_column;
|
drop table if exists gen_table_column;
|
||||||
create table gen_table_column (
|
CREATE TABLE `gen_table_column` (
|
||||||
columnId bigint(20) not null auto_increment comment '编号',
|
`columnId` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '编号',
|
||||||
tableId varchar(64) comment '归属表编号',
|
`tableName` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '表名',
|
||||||
tableName varchar(20) comment '表名',
|
`tableId` bigint(20) NULL DEFAULT NULL COMMENT '归属表编号',
|
||||||
columnName varchar(200) comment '列名称',
|
`columnName` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '列名称',
|
||||||
columnComment varchar(500) comment '列描述',
|
`columnComment` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '列描述',
|
||||||
columnType varchar(100) comment '列类型',
|
`columnType` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '列类型',
|
||||||
csharpType varchar(500) comment 'JAVA类型',
|
`csharpType` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'C#类型',
|
||||||
csharpField varchar(200) comment 'JAVA字段名',
|
`csharpField` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'C#字段名',
|
||||||
isPk char(1) comment '是否主键(1是)',
|
`isPk` tinyint(1) NULL DEFAULT NULL COMMENT '是否主键(1是)',
|
||||||
isIncrement char(1) comment '是否自增(1是)',
|
`isIncrement` tinyint(1) NULL DEFAULT NULL COMMENT '是否自增(1是)',
|
||||||
isRequired char(1) comment '是否必填(1是)',
|
`isRequired` tinyint(1) NULL DEFAULT NULL COMMENT '是否必填(1是)',
|
||||||
isInsert char(1) comment '是否为插入字段(1是)',
|
`isInsert` tinyint(1) NULL DEFAULT NULL COMMENT '是否为插入字段(1是)',
|
||||||
isEdit char(1) comment '是否编辑字段(1是)',
|
`isEdit` tinyint(1) NULL DEFAULT NULL COMMENT '是否编辑字段(1是)',
|
||||||
isList char(1) comment '是否列表字段(1是)',
|
`isList` tinyint(1) NULL DEFAULT NULL COMMENT '是否列表字段(1是)',
|
||||||
isQuery char(1) comment '是否查询字段(1是)',
|
`isQuery` tinyint(4) NULL DEFAULT NULL COMMENT '是否查询字段(1是)',
|
||||||
queryType varchar(200) default 'EQ' comment '查询方式(等于、不等于、大于、小于、范围)',
|
`queryType` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT 'EQ' COMMENT '查询方式(等于、不等于、大于、小于、范围)',
|
||||||
htmlType varchar(200) comment '显示类型(文本框、文本域、下拉框、复选框、单选框、日期控件)',
|
`htmlType` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '显示类型(文本框、文本域、下拉框、复选框、单选框、日期控件)',
|
||||||
dictType varchar(200) default '' comment '字典类型',
|
`dictType` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '字典类型',
|
||||||
sort int comment '排序',
|
`sort` int(11) NULL DEFAULT NULL COMMENT '排序',
|
||||||
create_by varchar(64) default '' comment '创建者',
|
`create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '创建者',
|
||||||
create_time datetime comment '创建时间',
|
`create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
|
||||||
update_by varchar(64) default '' comment '更新者',
|
`update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '更新者',
|
||||||
update_time datetime comment '更新时间',
|
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
|
||||||
remark varchar(200),
|
`remark` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
|
||||||
primary key (column_id)
|
PRIMARY KEY (`columnId`) USING BTREE
|
||||||
) engine=innodb auto_increment=1 comment = '代码生成业务表字段';
|
) ENGINE = InnoDB AUTO_INCREMENT = 63 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '代码生成业务表字段' ROW_FORMAT = Dynamic;
|
||||||
|
|
||||||
|
SET FOREIGN_KEY_CHECKS = 1;
|
||||||
|
|||||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user