diff --git a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplControllers.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplControllers.txt index fec4063..902db54 100644 --- a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplControllers.txt +++ b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplControllers.txt @@ -66,7 +66,7 @@ $end { var response = _${replaceDto.ModelTypeName}Service.GetInfo(${replaceDto.PKName}); - var info = response.Adapt<${replaceDto.ModelTypeName}>(); + var info = response.Adapt<${replaceDto.ModelTypeName}Dto>(); return SUCCESS(info); } diff --git a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplService.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplService.txt index f8d525e..8cd6983 100644 --- a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplService.txt +++ b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplService.txt @@ -117,7 +117,12 @@ $end $if(null != genTable.SubTableName && "" != genTable.SubTableName) return Context.InsertNav(model).Include(s1 => s1.${genTable.SubTable.ClassName}Nav).ExecuteReturnEntity(); $else - return Context.Insertable(model).ExecuteReturnEntity(); +$if(replaceDto.useSnowflakeId) + model.${replaceDto.PKName} = Insertable(model).ExecuteReturnSnowflakeId(); + return model; +$else + return Insertable(model).ExecuteReturnEntity(); +$end $end } diff --git a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/v3/Vue.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/v3/Vue.txt index 702c64b..38b0979 100644 --- a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/v3/Vue.txt +++ b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/v3/Vue.txt @@ -267,7 +267,7 @@ $if(column.CsharpType == "int" || column.CsharpType == "long") $end $if(column.IsPK || column.IsIncrement) -$if(column.IsPK && column.IsIncrement == false) +$if(column.IsPK && column.IsIncrement == false && replaceDto.useSnowflakeId == false) @@ -635,9 +635,11 @@ const state = reactive({ form: {}, rules: { $foreach(column in genTable.Columns) -$if(column.IsRequired && column.IsIncrement == false) +$if(column.IsRequired && column.IsPk && replaceDto.useSnowflakeId) + ${column.CsharpFieldFl}: [{ required: true, message: "${column.ColumnComment}不能为空", trigger: $if(column.htmlType == "select")"change"$else"blur"$end }], +$elseif(column.IsRequired && column.IsIncrement == false) ${column.CsharpFieldFl}: [{ required: true, message: "${column.ColumnComment}不能为空", trigger: $if(column.htmlType == "select")"change"$else"blur"$end -$if(column.CsharpType == "int" || column.CsharpType == "long"), type: "number"$end }], + $if(column.CsharpType == "int" || column.CsharpType == "long"), type: "number" $end }], $end $end }, diff --git a/ZR.CodeGenerator/CodeGeneratorTool.cs b/ZR.CodeGenerator/CodeGeneratorTool.cs index feb82b7..8a28cfa 100644 --- a/ZR.CodeGenerator/CodeGeneratorTool.cs +++ b/ZR.CodeGenerator/CodeGeneratorTool.cs @@ -53,7 +53,8 @@ namespace ZR.CodeGenerator ShowBtnMultiDel = dto.GenTable.Options.CheckedBtn.Any(f => f == 7), ShowBtnImport = dto.GenTable.Options.CheckedBtn.Any(f => f == 8), ViewFileName = dto.GenTable.BusinessName.FirstUpperCase(), - OperBtnStyle = dto.GenTable.Options.OperBtnStyle + OperBtnStyle = dto.GenTable.Options.OperBtnStyle, + UseSnowflakeId = dto.GenTable.Options.UseSnowflakeId }; var columns = dto.GenTable.Columns; diff --git a/ZR.CodeGenerator/Model/ReplaceDto.cs b/ZR.CodeGenerator/Model/ReplaceDto.cs index 3719e49..030038e 100644 --- a/ZR.CodeGenerator/Model/ReplaceDto.cs +++ b/ZR.CodeGenerator/Model/ReplaceDto.cs @@ -11,7 +11,7 @@ namespace ZR.CodeGenerator.Model /// /// 首字母小写主键 /// - public string FistLowerPk{ get; set; } + public string FistLowerPk { get; set; } /// /// 主键类型 /// @@ -74,5 +74,9 @@ namespace ZR.CodeGenerator.Model /// 操作按钮样式 /// public int OperBtnStyle { get; set; } + /// + /// 是否使用雪花id + /// + public bool UseSnowflakeId { get; set; } } } diff --git a/ZR.ServiceCore/Model/Generate/GenTable.cs b/ZR.ServiceCore/Model/Generate/GenTable.cs index 6e3199e..6e2ceaa 100644 --- a/ZR.ServiceCore/Model/Generate/GenTable.cs +++ b/ZR.ServiceCore/Model/Generate/GenTable.cs @@ -132,5 +132,9 @@ namespace ZR.Model.System.Generate /// 操作按钮样式 /// public int OperBtnStyle { get; set; } = 1; + /// + /// 是否使用雪花id + /// + public bool UseSnowflakeId { get; set; } = false; } }