Просмотр исходного кода

😁代码整理-代码生成增加模板打印相关

zuohuaijun 2 лет назад
Родитель
Сommit
f4a0686681

+ 14 - 14
Admin.NET/Admin.NET.Core/Entity/SysCodeGen.cs

@@ -16,20 +16,6 @@ namespace Admin.NET.Core;
 [SysTable]
 public class SysCodeGen : EntityBase
 {
-    /// <summary>
-    /// 支持打印类型
-    /// </summary>
-    [SugarColumn(ColumnDescription = "支持打印类型", Length = 32)]
-    [MaxLength(32)]
-    public string? PrintType { get; set; }
-
-    /// <summary>
-    /// 打印模版名称
-    /// </summary>
-    [SugarColumn(ColumnDescription = "打印模版名称", Length = 32)]
-    [MaxLength(32)]
-    public string? PrintName { get; set; }
-
     /// <summary>
     /// 作者姓名
     /// </summary>
@@ -105,4 +91,18 @@ public class SysCodeGen : EntityBase
     /// </summary>
     [SugarColumn(ColumnDescription = "菜单编码")]
     public long MenuPid { get; set; }
+
+    /// <summary>
+    /// 支持打印类型
+    /// </summary>
+    [SugarColumn(ColumnDescription = "支持打印类型", Length = 32)]
+    [MaxLength(32)]
+    public string? PrintType { get; set; }
+
+    /// <summary>
+    /// 打印模版名称
+    /// </summary>
+    [SugarColumn(ColumnDescription = "打印模版名称", Length = 32)]
+    [MaxLength(32)]
+    public string? PrintName { get; set; }
 }

+ 2 - 2
Admin.NET/Admin.NET.Core/SeedData/SysDictTypeSeedData.cs

@@ -27,8 +27,8 @@ public class SysDictTypeSeedData : ISqlSugarEntitySeedData<SysDictType>
             new SysDictType{ Id=1300000000103, Name="代码生成.NET类型", Code="code_gen_net_type", OrderNo=102, Remark="代码生成.NET类型", Status=StatusEnum.Enable, CreateTime=DateTime.Parse("2022-02-10 00:00:00") },
             new SysDictType{ Id=1300000000104, Name="代码生成方式", Code="code_gen_create_type", OrderNo=103, Remark="代码生成方式", Status=StatusEnum.Enable, CreateTime=DateTime.Parse("2022-02-10 00:00:00") },
             new SysDictType{ Id=1300000000105, Name="代码生成基类", Code="code_gen_base_class", OrderNo=104, Remark="代码生成基类", Status=StatusEnum.Enable, CreateTime=DateTime.Parse("2022-02-10 00:00:00") },
-            new SysDictType{ Id=1300000000106, Name="机构类型", Code="org_type", OrderNo=105, Remark="机构类型", Status=StatusEnum.Enable, CreateTime=DateTime.Parse("2023-02-10 00:00:00") },
-            new SysDictType{ Id=1300000000107, Name="代码生成支持打印类型", Code="code_gen_print_type", OrderNo=106, Remark="代码生成支持打印类型", Status=StatusEnum.Enable, CreateTime=DateTime.Parse("2023-12-04 00:00:00") },
+            new SysDictType{ Id=1300000000106, Name="代码生成打印类型", Code="code_gen_print_type", OrderNo=105, Remark="代码生成打印类型", Status=StatusEnum.Enable, CreateTime=DateTime.Parse("2023-12-04 00:00:00") },
+            new SysDictType{ Id=1300000000107, Name="机构类型", Code="org_type", OrderNo=106, Remark="机构类型", Status=StatusEnum.Enable, CreateTime=DateTime.Parse("2023-02-10 00:00:00") },
         };
     }
 }

+ 8 - 8
Admin.NET/Admin.NET.Core/Service/CodeGen/CustomViewEngine.cs

@@ -27,10 +27,6 @@ public class CustomViewEngine : ViewEngineModel
     /// </summary>
     public string ConfigId { get; set; } = SqlSugarConst.MainConfigId;
 
-    public string PrintType { get; set; }
-
-    public string PrintName { get; set; }
-
     public string AuthorName { get; set; }
 
     public string BusName { get; set; }
@@ -49,14 +45,18 @@ public class CustomViewEngine : ViewEngineModel
         }
     }
 
-    public List<CodeGenConfig> QueryWhetherList { get; set; }
-
-    public List<CodeGenConfig> TableField { get; set; }
-
     public bool IsJoinTable { get; set; }
 
     public bool IsUpload { get; set; }
 
+    public string PrintType { get; set; }
+
+    public string PrintName { get; set; }
+
+    public List<CodeGenConfig> QueryWhetherList { get; set; }
+
+    public List<CodeGenConfig> TableField { get; set; }
+
     private List<ColumnOuput> ColumnList { get; set; }
 
     public string GetColumnNetType(object tbName, object colName)

+ 10 - 10
Admin.NET/Admin.NET.Core/Service/CodeGen/Dto/CodeGenInput.cs

@@ -14,16 +14,6 @@ namespace Admin.NET.Core.Service;
 /// </summary>
 public class CodeGenInput : BasePageInput
 {
-    /// <summary>
-    /// 支持打印类型
-    /// </summary>
-    public virtual string PrintType { get; set; }
-
-    /// <summary>
-    /// 打印模版名称
-    /// </summary>
-    public virtual string PrintName { get; set; }
-
     /// <summary>
     /// 作者姓名
     /// </summary>
@@ -93,6 +83,16 @@ public class CodeGenInput : BasePageInput
     /// 菜单父级
     /// </summary>
     public virtual long MenuPid { get; set; }
+
+    /// <summary>
+    /// 支持打印类型
+    /// </summary>
+    public virtual string PrintType { get; set; }
+
+    /// <summary>
+    /// 打印模版名称
+    /// </summary>
+    public virtual string PrintName { get; set; }
 }
 
 public class AddCodeGenInput : CodeGenInput

+ 10 - 10
Admin.NET/Admin.NET.Core/Service/CodeGen/Dto/CodeGenOutput.cs

@@ -19,16 +19,6 @@ public class CodeGenOutput
     /// </summary>
     public long Id { get; set; }
 
-    /// <summary>
-    /// 支持打印类型
-    /// </summary>
-    public string PrintType { get; set; }
-
-    /// <summary>
-    /// 打印模版名称
-    /// </summary>
-    public string PrintName { get; set; }
-
     /// <summary>
     /// 作者姓名
     /// </summary>
@@ -78,4 +68,14 @@ public class CodeGenOutput
     /// 菜单父级
     /// </summary>
     public long MenuPid { get; set; }
+
+    /// <summary>
+    /// 支持打印类型
+    /// </summary>
+    public string PrintType { get; set; }
+
+    /// <summary>
+    /// 打印模版名称
+    /// </summary>
+    public string PrintName { get; set; }
 }

+ 2 - 2
Admin.NET/Admin.NET.Core/Service/CodeGen/SysCodeGenService.cs

@@ -329,8 +329,6 @@ public class SysCodeGenService : IDynamicApiController, ITransient
         var data = new CustomViewEngine(_db)
         {
             ConfigId = input.ConfigId,
-            PrintType = input.PrintType,
-            PrintName = input.PrintName,
             AuthorName = input.AuthorName,
             BusName = input.BusName,
             NameSpace = input.NameSpace,
@@ -340,6 +338,8 @@ public class SysCodeGenService : IDynamicApiController, ITransient
             TableField = tableFieldList,
             IsJoinTable = joinTableList.Count > 0,
             IsUpload = joinTableList.Where(u => u.EffectType == "Upload").Any(),
+            PrintType = input.PrintType,
+            PrintName = input.PrintName,
         };
 
         for (var i = 0; i < templatePathList.Count; i++)

+ 4 - 0
Admin.NET/Admin.NET.Web.Entry/wwwroot/Template/Service.cs.vm

@@ -78,6 +78,10 @@ if (@column.QueryWhether == "Y"){
                 @:@(@column.PropertyName)@(@column.FkColumnName) = @(@column.PropertyName.ToLower()).@(@column.FkColumnName),
                 } else if(@column.EffectType == "ApiTreeSelect"){   
                 @:@(@column.PropertyName)@(@column.DisplayColumn) = @(@column.PropertyName.ToLower()).@(@column.DisplayColumn),
+                } else if(@column.NetType?.TrimEnd('?').EndsWith("Enum") == true){
+                @:@(@column.PropertyName)@(@column.DisplayColumn) = u.@(@column.PropertyName),
+                } else {
+                @:@(@column.PropertyName) = u.@(@column.PropertyName),
                 }
 }
             @:})