😎 优化代码生成相关代码
This commit is contained in:
parent
de7be3dd64
commit
30082e0084
@ -39,7 +39,7 @@
|
||||
<PackageReference Include="SqlSugarCore" Version="5.1.4.167" />
|
||||
<PackageReference Include="SSH.NET" Version="2024.1.0" />
|
||||
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.4.4" />
|
||||
<PackageReference Include="TencentCloudSDK.Sms" Version="3.0.1071" />
|
||||
<PackageReference Include="TencentCloudSDK.Sms" Version="3.0.1072" />
|
||||
<PackageReference Include="UAParser" Version="3.1.47" />
|
||||
<PackageReference Include="Yitter.IdGenerator" Version="1.0.14" />
|
||||
</ItemGroup>
|
||||
|
||||
@ -7,9 +7,9 @@
|
||||
namespace Admin.NET.Core;
|
||||
|
||||
/// <summary>
|
||||
/// 代码生成模板配置
|
||||
/// 代码生成模板配置表
|
||||
/// </summary>
|
||||
[SugarTable(null, "代码生成模板配置")]
|
||||
[SugarTable(null, "代码生成模板配置表")]
|
||||
[SysTable]
|
||||
public partial class SysCodeGenTemplate : EntityBase
|
||||
{
|
||||
@ -21,27 +21,29 @@ public partial class SysCodeGenTemplate : EntityBase
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否是内置模板(Y-是,N-否)
|
||||
/// 代码生成类型
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "是否是内置模板")]
|
||||
public CodeGenTypeEnum Type { get; set; }
|
||||
[SugarColumn(ColumnDescription = "代码生成类型")]
|
||||
public CodeGenTypeEnum Type { get; set; } = CodeGenTypeEnum.Backend;
|
||||
|
||||
/// <summary>
|
||||
/// 是否是内置模板(Y-是,N-否)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "是否是内置模板")]
|
||||
public YesNoEnum SysFlag { get; set; }
|
||||
public YesNoEnum SysFlag { get; set; } = YesNoEnum.Y;
|
||||
|
||||
/// <summary>
|
||||
/// 输出位置
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "输出位置", Length = 256)]
|
||||
[Required, MaxLength(256)]
|
||||
public string OutputFile { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 描述
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "描述", Length = 200)]
|
||||
[SugarColumn(ColumnDescription = "描述", Length = 256)]
|
||||
[Required, MaxLength(256)]
|
||||
public string Describe { get; set; }
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
namespace Admin.NET.Core;
|
||||
|
||||
/// <summary>
|
||||
/// 系统配置表种子数据
|
||||
/// 代码生成模板配置表种子数据
|
||||
/// </summary>
|
||||
public class SysCodeGenTemplateSeedData : ISqlSugarEntitySeedData<SysCodeGenTemplate>
|
||||
{
|
||||
@ -25,7 +25,7 @@ public class SysCodeGenTemplateSeedData : ISqlSugarEntitySeedData<SysCodeGenTemp
|
||||
|
||||
new SysCodeGenTemplate{ Id=36036980202001, SysFlag=YesNoEnum.Y, Type=CodeGenTypeEnum.Backend, Name="service_Service.cs.vm", OutputFile="Service/{TableName}/{TableName}Service.cs", Describe ="(服务端)业务"},
|
||||
new SysCodeGenTemplate{ Id=36036980202002, SysFlag=YesNoEnum.Y, Type=CodeGenTypeEnum.Backend, Name="service_InputDto.cs.vm", OutputFile="Service/{TableName}/Dto/{TableName}Input.cs", Describe ="(服务端)输入参数"},
|
||||
new SysCodeGenTemplate{ Id=36036980202003, SysFlag=YesNoEnum.Y, Type=CodeGenTypeEnum.Backend, Name="service_OutputDto.cs.vm", OutputFile="Service/{TableName}/Dto/{TableName}Output.cs", Describe ="(服务端)输出参数"},
|
||||
new SysCodeGenTemplate{ Id=36036980202003, SysFlag=YesNoEnum.Y, Type=CodeGenTypeEnum.Backend, Name="service_OutputDto.cs.vm", OutputFile="Service/{TableName}/Dto/{TableName}Output.cs", Describe ="(服务端)输出参数"},
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -4,8 +4,6 @@
|
||||
//
|
||||
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
|
||||
|
||||
using Elastic.Clients.Elasticsearch.MachineLearning;
|
||||
|
||||
namespace Admin.NET.Core.Service;
|
||||
|
||||
/// <summary>
|
||||
@ -137,7 +135,7 @@ public class SysCodeGenConfigService : IDynamicApiController, ITransient
|
||||
orderNo += 10; // 每个配置排序间隔10
|
||||
}
|
||||
// 多库代码生成---这里要切回主库
|
||||
var provider = _db.AsTenant().GetConnectionScope(SqlSugarConst.MainConfigId);
|
||||
var provider = _db.AsTenant().GetConnectionScope(SqlSugarConst.MainConfigId);
|
||||
provider.Insertable(codeGenConfigs).ExecuteCommand();
|
||||
}
|
||||
|
||||
|
||||
@ -84,7 +84,7 @@ public class SysCodeGenService : IDynamicApiController, ITransient
|
||||
var codeGen = input.Adapt<SysCodeGen>();
|
||||
await _db.Updateable(codeGen).ExecuteCommandAsync();
|
||||
|
||||
// 更新配置表
|
||||
// 更新配置表
|
||||
_codeGenConfigService.AddList(GetColumnList(input.Adapt<AddCodeGenInput>()), codeGen);
|
||||
}
|
||||
|
||||
@ -377,13 +377,13 @@ public class SysCodeGenService : IDynamicApiController, ITransient
|
||||
if (templateList[i].Type == CodeGenTypeEnum.Frontend)
|
||||
tmpPath = Path.Combine(new DirectoryInfo(App.WebHostEnvironment.ContentRootPath).Parent!.Parent!.FullName, _codeGenOptions.FrontRootPath, "src");
|
||||
else
|
||||
tmpPath = Path.Combine(new DirectoryInfo(App.WebHostEnvironment.ContentRootPath).Parent!.FullName, input.NameSpace);
|
||||
tmpPath = Path.Combine(new DirectoryInfo(App.WebHostEnvironment.ContentRootPath).Parent!.FullName, input.NameSpace);
|
||||
}
|
||||
else
|
||||
{
|
||||
tmpPath = templateList[i].Type == CodeGenTypeEnum.Frontend ? Path.Combine(outputPath, _codeGenOptions.FrontRootPath, "src") : Path.Combine(outputPath, input!.NameSpace!);
|
||||
}
|
||||
targetFile = Path.Combine( tmpPath, targetFile);
|
||||
targetFile = Path.Combine(tmpPath, targetFile);
|
||||
|
||||
var dirPath = new DirectoryInfo(targetFile).Parent!.FullName;
|
||||
if (!Directory.Exists(dirPath))
|
||||
|
||||
@ -64,7 +64,7 @@ public class PhoneInput
|
||||
/// <summary>
|
||||
/// 手机号码
|
||||
/// </summary>
|
||||
/// <example>13980134216</example>
|
||||
/// <example>13980134216</example>
|
||||
[Required(ErrorMessage = "手机号码不能为空")]
|
||||
[DataValidation(ValidationTypes.PhoneNumber, ErrorMessage = "手机号码不正确")]
|
||||
public string Phone { get; set; }
|
||||
|
||||
@ -13,37 +13,37 @@ public class BaseOutput
|
||||
{
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
/// </summary>
|
||||
public virtual DateTime CreateTime { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 更新时间
|
||||
/// </summary>
|
||||
/// </summary>
|
||||
public virtual DateTime UpdateTime { get; set; }
|
||||
|
||||
|
||||
///// <summary>
|
||||
///// 创建者Id
|
||||
///// </summary>
|
||||
///// </summary>
|
||||
//public virtual long CreateUserId { get; set; }
|
||||
|
||||
|
||||
///// <summary>
|
||||
///// 创建者部门Id
|
||||
///// </summary>
|
||||
///// </summary>
|
||||
//public virtual long CreateOrgId { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 创建者名称
|
||||
/// </summary>
|
||||
/// </summary>
|
||||
public virtual string CreateUserName { get; set; }
|
||||
|
||||
|
||||
///// <summary>
|
||||
///// 修改者Id
|
||||
///// </summary>
|
||||
///// </summary>
|
||||
//public virtual long UpdateUserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改者名称
|
||||
/// </summary>
|
||||
/// </summary>
|
||||
public virtual string UpdateUserName { get; set; }
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user