优化代码生成功能

This commit is contained in:
izory
2021-09-21 20:31:35 +08:00
parent 06ec7b0ddc
commit 37174398c3
19 changed files with 350 additions and 218 deletions

View File

@@ -1,9 +1,4 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Linq;
using ZR.CodeGenerator.CodeGenerator;
using ZR.Model.System.Generate;
@@ -14,8 +9,6 @@ namespace ZR.CodeGenerator
/// </summary>
public class CodeGenerateTemplate
{
#region Template
/// <summary>
/// 生成vuejs模板目前只有上传文件方法
/// </summary>
@@ -27,10 +20,10 @@ namespace ZR.CodeGenerator
string js = "";
if (dbColumnInfo.HtmlType.Equals(GenConstants.HTML_IMAGE_UPLOAD))
{
js += $"handleUpload{columnName}Success(res, file) {{\n";
js += $" this.form.{columnName} = URL.createObjectURL(file.raw);\n";
js += " // this.$refs.upload.clearFiles();\n";
js += "},\n";
js += $"handleUpload{columnName}Success(res, file) {{\r\n";
js += $" this.form.{columnName} = URL.createObjectURL(file.raw);\r\n";
js += " // this.$refs.upload.clearFiles();\r\n";
js += " },\r";
}
return js;
}
@@ -40,17 +33,17 @@ namespace ZR.CodeGenerator
{
string vueViewEditFromRuleContent = "";
//Rule 规则验证
if (!dbFieldInfo.IsPk && !dbFieldInfo.IsIncrement)
if ((!dbFieldInfo.IsPk && !dbFieldInfo.IsIncrement) && dbFieldInfo.IsRequired)
{
vueViewEditFromRuleContent += $" {dbFieldInfo.ColumnName}: [\n";
vueViewEditFromRuleContent += $" {{ required: true, message: '请输入{dbFieldInfo.ColumnComment}', trigger: \"blur\"}},\n";
vueViewEditFromRuleContent += " ],\n";
vueViewEditFromRuleContent += $" {dbFieldInfo.ColumnName}: [\r\n";
vueViewEditFromRuleContent += $" {{ required: true, message: '请输入{dbFieldInfo.ColumnComment}', trigger: \"blur\"}},\r\n";
vueViewEditFromRuleContent += " ],\r\n";
}
else if (TableMappingHelper.IsNumber(dbFieldInfo.ColumnType) && dbFieldInfo.IsRequired)
{
vueViewEditFromRuleContent += $" {dbFieldInfo.ColumnName}: [\n";
vueViewEditFromRuleContent += $" {{ type: 'number', message: '{dbFieldInfo.ColumnName}必须为数字值', trigger: \"blur\"}},\n";
vueViewEditFromRuleContent += " ],\n";
vueViewEditFromRuleContent += $" {dbFieldInfo.ColumnName}: [\r\n";
vueViewEditFromRuleContent += $" {{ type: 'number', message: '{dbFieldInfo.ColumnName}必须为数字值', trigger: \"blur\"}},\r\n";
vueViewEditFromRuleContent += " ],\r\n";
}
return vueViewEditFromRuleContent;
@@ -60,28 +53,57 @@ namespace ZR.CodeGenerator
public static string GetModelTemplate(GenTableColumn dbFieldInfo)
{
var modelcontent = "";
modelcontent += " /// <summary>\n";
modelcontent += $" /// 描述 :{dbFieldInfo.ColumnComment}\n";
modelcontent += $" /// 空值 :{dbFieldInfo.IsRequired}\n";
modelcontent += " /// </summary>\n";
modelcontent += " /// <summary>\r\n";
modelcontent += $" /// 描述 :{dbFieldInfo.ColumnComment}\r\n";
modelcontent += $" /// 空值 :{!dbFieldInfo.IsRequired}\r\n";
modelcontent += " /// </summary>\r\n";
if (dbFieldInfo.IsPk || dbFieldInfo.IsIncrement)
{
modelcontent += $"[SqlSugar.SugarColumn(IsPrimaryKey = {dbFieldInfo.IsPk.ToString().ToLower()}, IsIdentity = {dbFieldInfo.IsIncrement.ToString().ToLower()})]\n";
modelcontent += $" [SqlSugar.SugarColumn(IsPrimaryKey = {dbFieldInfo.IsPk.ToString().ToLower()}, IsIdentity = {dbFieldInfo.IsIncrement.ToString().ToLower()})]\r\n";
}
modelcontent += $"public {dbFieldInfo.CsharpType} {dbFieldInfo.CsharpField} {{ get; set; }}\n\r";
modelcontent += $" public {dbFieldInfo.CsharpType}{(GetModelRequired(dbFieldInfo))} {dbFieldInfo.CsharpField} {{ get; set; }}\r\n";
return modelcontent;
}
public static string GetModelRequired(GenTableColumn dbFieldInfo)
{
string str = "";
if (!dbFieldInfo.IsRequired && (dbFieldInfo.CsharpType == "int" || dbFieldInfo.CsharpType == "long" || dbFieldInfo.CsharpType == "DateTime"))
{
str = "?";
}
return str;
}
//DTO model
public static string GetDtoContent(GenTableColumn dbFieldInfo)
public static string GetDtoProperty(GenTableColumn dbFieldInfo)
{
string InputDtoContent = "";
if (dbFieldInfo.IsInsert || dbFieldInfo.IsEdit)
if (CodeGeneratorTool.inputDtoNoField.Any(f => f.Replace("_", "").ToLower().Contains(dbFieldInfo.CsharpField.ToLower().Replace("_", ""))))
{
InputDtoContent += $" public {dbFieldInfo.CsharpType} {dbFieldInfo.CsharpField} {{ get; set; }}\n\r";
return InputDtoContent;
}
else if (dbFieldInfo.IsInsert || dbFieldInfo.IsEdit || dbFieldInfo.IsPk || dbFieldInfo.IsIncrement)
{
InputDtoContent += $" public {dbFieldInfo.CsharpType}{GetModelRequired(dbFieldInfo)} {dbFieldInfo.CsharpField} {{ get; set; }}\r\n";
}
return InputDtoContent;
}
/// <summary>
/// 查询Dto属性
/// </summary>
/// <param name="dbFieldInfo"></param>
/// <returns></returns>
public static string GetQueryDtoProperty(GenTableColumn dbFieldInfo)
{
string QueryDtoContent = "";
if (dbFieldInfo.IsQuery && !CodeGeneratorTool.inputDtoNoField.Any(f => f.Replace("_", "").ToLower().Contains(dbFieldInfo.CsharpField.ToLower().Replace("_", ""))))
{
QueryDtoContent += $" public {dbFieldInfo.CsharpType} {dbFieldInfo.CsharpField} {{ get; set; }}\r\n";
}
return QueryDtoContent;
}
//form-item
public static string GetVueViewFormContent(GenTableColumn dbFieldInfo)
@@ -91,6 +113,10 @@ namespace ZR.CodeGenerator
string vueViewFromContent = "";
string labelDisabled = dbFieldInfo.IsPk ? ":disabled=\"true\"" : "";
string placeHolder = dbFieldInfo.IsIncrement ? "" : $"请输入{labelName}";
if (CodeGeneratorTool.inputDtoNoField.Any(f => f.Replace("_", "").ToLower().Contains(dbFieldInfo.CsharpField.ToLower().Replace("_", ""))))
{
return vueViewFromContent;
}
if (!dbFieldInfo.IsInsert || !dbFieldInfo.IsEdit)
{
return vueViewFromContent;
@@ -98,47 +124,83 @@ namespace ZR.CodeGenerator
if (dbFieldInfo.HtmlType == GenConstants.HTML_DATETIME)
{
//时间
vueViewFromContent += $" <el-form-item label=\"{labelName}\" :label-width=\"labelWidth\" prop=\"{columnName}\">\n";
vueViewFromContent += $" <el-date-picker v-model=\"form.{columnName}\" type=\"datetime\" placeholder=\"选择日期时间\" default-time=\"12:00:00\"> </el-date-picker>\n";
vueViewFromContent += " </el-form-item>\n";
vueViewFromContent += $" <el-form-item label=\"{labelName}\" :label-width=\"labelWidth\" prop=\"{columnName}\">\r\n";
vueViewFromContent += $" <el-date-picker v-model=\"form.{columnName}\" type=\"datetime\" placeholder=\"选择日期时间\" default-time=\"12:00:00\"> </el-date-picker>\r\n";
vueViewFromContent += " </el-form-item>\r\n";
}
else if (dbFieldInfo.HtmlType == GenConstants.HTML_IMAGE_UPLOAD)
{
//图片
vueViewFromContent += $" <el-form-item label=\"{labelName}\" :label-width=\"labelWidth\" prop=\"{columnName}\">\n";
vueViewFromContent += $" <el-upload class=\"avatar-uploader\" name=\"file\" action=\"/api/upload/saveFile/\" :show-file-list=\"false\" :on-success=\"handleUpload{columnName}Success\" :before-upload=\"beforeFileUpload\">\n";
vueViewFromContent += $" <img v-if=\"form.{columnName}\" :src=\"form.{columnName}\" class=\"icon\">\n";
vueViewFromContent += " <i v-else class=\"el-icon-plus uploader-icon\"></i>\n";
vueViewFromContent += " </el-upload>\n";
vueViewFromContent += $" <el-input v-model=\"form.{columnName}\" placeholder=\"请上传文件或手动输入文件地址\"></el-input>\n";
vueViewFromContent += " </el-form-item>\n";
vueViewFromContent += $" <el-form-item label=\"{labelName}\" :label-width=\"labelWidth\" prop=\"{columnName}\">\r\n";
vueViewFromContent += $" <el-upload class=\"avatar-uploader\" name=\"file\" action=\"/api/upload/saveFile/\" :show-file-list=\"false\" :on-success=\"handleUpload{columnName}Success\" :before-upload=\"beforeFileUpload\">\r\n";
vueViewFromContent += $" <img v-if=\"form.{columnName}\" :src=\"form.{columnName}\" class=\"icon\">\r\n";
vueViewFromContent += " <i v-else class=\"el-icon-plus uploader-icon\"></i>\r\n";
vueViewFromContent += " </el-upload>\r\n";
vueViewFromContent += $" <el-input v-model=\"form.{columnName}\" placeholder=\"请上传文件或手动输入文件地址\"></el-input>\r\n";
vueViewFromContent += " </el-form-item>\r\n";
}
else if (dbFieldInfo.HtmlType == GenConstants.HTML_RADIO)
{
vueViewFromContent += $" <el-form-item label=\"{labelName}\" :label-width=\"labelWidth\" prop=\"{columnName}\">\n";
vueViewFromContent += $" <el-radio-group v-model=\"form.{columnName}\">\n";
vueViewFromContent += " <el-radio :key=\"1\" :label=\"1\">是</el-radio>\n";
vueViewFromContent += " <el-radio :key=\"0\" :label=\"0\">否</el-radio>\n";
vueViewFromContent += " </el-radio-group>\n";
vueViewFromContent += " </el-form-item>\n";
vueViewFromContent += $" <el-form-item label=\"{labelName}\" :label-width=\"labelWidth\" prop=\"{columnName}\">\r\n";
vueViewFromContent += $" <el-radio-group v-model=\"form.{columnName}\">\r\n";
vueViewFromContent += " <el-radio :key=\"1\" :label=\"1\">是</el-radio>\r\n";
vueViewFromContent += " <el-radio :key=\"0\" :label=\"0\">否</el-radio>\r\n";
vueViewFromContent += " </el-radio-group>\r\n";
vueViewFromContent += " </el-form-item>\r\n";
}
else if (dbFieldInfo.HtmlType == GenConstants.HTML_TEXTAREA)
{
vueViewFromContent += $" <el-form-item label=\"{ labelName}\" :label-width=\"labelWidth\" prop=\"{columnName}\">\n";
vueViewFromContent += $" <el-input type=\"textarea\" v-model=\"form.{columnName}\" placeholder=\"请输入内容\"/>\n";
vueViewFromContent += " </el-form-item>\n";
vueViewFromContent += $" <el-form-item label=\"{ labelName}\" :label-width=\"labelWidth\" prop=\"{columnName}\">\r\n";
vueViewFromContent += $" <el-input type=\"textarea\" v-model=\"form.{columnName}\" placeholder=\"请输入内容\"/>\r\n";
vueViewFromContent += " </el-form-item>\r\n";
}
else if (dbFieldInfo.HtmlType == GenConstants.HTML_SELECT && !string.IsNullOrEmpty(dbFieldInfo.DictType))
{
vueViewFromContent += $" <el-form-item label=\"{ labelName}\" :label-width=\"labelWidth\" prop=\"{columnName}\">\r\n";
vueViewFromContent += $" <el-select v-model=\"form.{columnName}\" > ";
vueViewFromContent += $" <el-option v-for=\"item in {columnName}Options\" :key=\"item.dictValue\" :label=\"item.dictLabel\" :value=\"item.dictValue\"></el-option>\r\n";
vueViewFromContent += " </el-select>\r\n";
vueViewFromContent += " </el-form-item>\r\n";
}
else
{
string inputNumTxt = TableMappingHelper.IsNumber(dbFieldInfo.CsharpType) ? ".number" : "";
vueViewFromContent += $" <el-form-item label=\"{ labelName}\" :label-width=\"labelWidth\" prop=\"{CodeGeneratorTool.FirstLowerCase(columnName)}\">\n";
vueViewFromContent += $" <el-input v-model{inputNumTxt}=\"form.{CodeGeneratorTool.FirstLowerCase(columnName)}\" placeholder=\"{placeHolder}\" {labelDisabled}/>\n";
vueViewFromContent += " </el-form-item>\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-form-item>\r\n";
}
return vueViewFromContent;
}
/// <summary>
/// 查询表单
/// </summary>
/// <param name="dbFieldInfo"></param>
/// <returns></returns>
public static string GetQueryFormHtml(GenTableColumn dbFieldInfo)
{
string queryFormHtml = "";
string labelName = CodeGeneratorTool.GetLabelName(dbFieldInfo.ColumnComment, dbFieldInfo.ColumnName);
if (!dbFieldInfo.IsQuery || dbFieldInfo.HtmlType == GenConstants.HTML_FILE_UPLOAD) return queryFormHtml;
if (dbFieldInfo.HtmlType == GenConstants.HTML_DATETIME)
{
queryFormHtml += "<el-form-item label=\"时间\">\r\n";
queryFormHtml += " <el-date-picker v-model=\"dateRange\" size=\"small\" value-format=\"yyyy-MM-dd\" type=\"daterange\" range-separator=\"-\" start-placeholder=\"开始日期\" end-placeholder=\"结束日期\"></el-date-picker>\r\n";
queryFormHtml += "</el-form-item>\r\n";
}
else
{
string inputNumTxt = TableMappingHelper.IsNumber(dbFieldInfo.CsharpType) ? ".number" : "";
queryFormHtml += $" <el-form-item label=\"{ labelName}\" :label-width=\"labelWidth\">\r\n";
queryFormHtml += $" <el-input v-model{inputNumTxt}=\"queryParams.{CodeGeneratorTool.FirstLowerCase(dbFieldInfo.CsharpField)}\"/>\r\n";
queryFormHtml += " </el-form-item>\r\n";
}
return queryFormHtml;
}
//table-column
public static string GetTableColumn(GenTableColumn dbFieldInfo)
{
@@ -152,28 +214,26 @@ namespace ZR.CodeGenerator
}
else if (dbFieldInfo.HtmlType.Equals(GenConstants.HTML_IMAGE_UPLOAD))
{
vueViewListContent += $" <el-table-column prop=\"{ columnName}\" label=\"图片\">\n";
vueViewListContent += " <template slot-scope=\"scope\">\n";
vueViewListContent += $" <el-image class=\"table-td-thumb\" :src=\"scope.row.{columnName}\" :preview-src-list=\"[scope.row.{columnName}]\"></el-image>\n";
vueViewListContent += " </template>\n";
vueViewListContent += " </el-table-column>\n";
vueViewListContent += $" <el-table-column prop=\"{ columnName}\" label=\"图片\">\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 += " </template>\r\n";
vueViewListContent += " </el-table-column>\r\n";
}
//else if (dbFieldInfo.HtmlType.Equals(GenConstants.HTML_RADIO))
//{
// vueViewListContent += $" <el-table-column prop=\"{columnName}\" label=\"{label}\" width=\"120\" >\n";
// vueViewListContent += " <template slot-scope=\"scope\">\n";
// vueViewListContent += $" <el-table-column prop=\"{columnName}\" label=\"{label}\" width=\"120\" >\r\n";
// vueViewListContent += " <template slot-scope=\"scope\">\r\n";
// vueViewListContent += $" <el-tag :type=\"scope.row.{columnName} === true ? 'success' : 'info'\" disable-transitions >";
// vueViewListContent += $" {{scope.row.{columnName}===true?'启用':'禁用'}} </el-tag>\n";
// vueViewListContent += " </template>\n";
// vueViewListContent += " </el-table-column>\n";
// vueViewListContent += $" {{scope.row.{columnName}===true?'启用':'禁用'}} </el-tag>\r\n";
// vueViewListContent += " </template>\r\n";
// vueViewListContent += " </el-table-column>\r\n";
//}
else
{
vueViewListContent += $" <el-table-column prop=\"{columnName}\" label=\"{label}\" align=\"center\" width=\"100\" {showToolTip} />\n";
vueViewListContent += $" <el-table-column prop=\"{columnName}\" label=\"{label}\" align=\"center\" width=\"100\" {showToolTip} />\r\n";
}
return vueViewListContent;
}
#endregion
}
}

View File

@@ -23,7 +23,7 @@ namespace ZR.CodeGenerator
/// <summary>
/// InputDto输入实体是不包含字段
/// </summary>
public static readonly string[] inputDtoNoField = new string[] { "DeleteMark", "CreateTime", "updateTime", "addtime" };
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" };
@@ -46,11 +46,7 @@ namespace ZR.CodeGenerator
_option.ServicesNamespace = _option.BaseNamespace + "Service";
_option.ApiControllerNamespace = _option.BaseNamespace + "Admin.WebApi";
//CodeGeneraterService codeGeneraterService = new();
//List<DbColumnInfo> listField = codeGeneraterService.GetColumnInfo(dto.dbName, dbTableInfo.TableName);
GenerateSingle(dbTableInfo?.Columns, dbTableInfo, dto);
//GenerateDtoProfile(_option.ModelsNamespace, profileContent, ifExsitedCovered);
}
/// <summary>
@@ -61,19 +57,12 @@ namespace ZR.CodeGenerator
/// <param name="dto"></param>
public static void GenerateSingle(List<GenTableColumn> listField, GenTable tableInfo, GenerateDto dto)
{
var modelTypeName = tableInfo.ClassName;//表名对应C# 实体类名
string PKName = "id";
string PKType = "int";
string modelContent = "";//数据库模型字段
string InputDtoContent = "";//输入模型
//string outputDtoContent = "";//输出模型
string updateColumn = "";//修改数据映射字段
string vueViewListContent = string.Empty;//Vue列表输出内容
string vueViewFormContent = string.Empty;//Vue表单输出内容
string vueViewEditFromContent = string.Empty;//Vue变量输出内容
string vueViewEditFromRuleContent = string.Empty;//Vue数据校验
string vueJsMethod = string.Empty;//Vue js自定义方法
ReplaceDto replaceDto = new();
replaceDto.ModelTypeName = tableInfo.ClassName;//表名对应C# 实体类名
replaceDto.TableName = tableInfo.TableName;
replaceDto.TableDesc = tableInfo.TableComment;
//循环表字段信息
foreach (GenTableColumn dbFieldInfo in listField)
@@ -82,7 +71,7 @@ namespace ZR.CodeGenerator
if (dbFieldInfo.IsInsert || dbFieldInfo.IsEdit)
{
vueViewEditFromContent += $" {columnName}: undefined,\n";
replaceDto.VueViewEditFormHtml += $"{columnName}: undefined,\r\n";
}
if (dbFieldInfo.IsPk || dbFieldInfo.IsIncrement)
{
@@ -92,30 +81,35 @@ namespace ZR.CodeGenerator
//编辑字段
if (dbFieldInfo.IsEdit)
{
updateColumn += $" {dbFieldInfo.CsharpField} = parm.{dbFieldInfo.CsharpField},\n";
replaceDto.UpdateColumn += $"{dbFieldInfo.CsharpField} = model.{dbFieldInfo.CsharpField}, ";
}
//新增字段
if (dbFieldInfo.IsInsert)
{
replaceDto.InsertColumn += $"it.{dbFieldInfo.CsharpField}, ";
}
//查询
//if (dbFieldInfo.IsQuery)
//{
// replaceDto.Querycondition += $"predicate = predicate.And(m => m.{dbFieldInfo.CsharpField}.Contains(parm.Name));";
//}
if (dbFieldInfo.HtmlType == GenConstants.HTML_SELECT && !string.IsNullOrEmpty(dbFieldInfo.DictType))
{
replaceDto.VueDataContent += $"// {dbFieldInfo.ColumnComment}选项列表\n";
replaceDto.VueDataContent += $"{FirstLowerCase(dbFieldInfo.CsharpField)}Options: [],";
}
modelContent += CodeGenerateTemplate.GetModelTemplate(dbFieldInfo);
vueViewFormContent += CodeGenerateTemplate.GetVueViewFormContent(dbFieldInfo);
vueJsMethod += CodeGenerateTemplate.GetVueJsMethod(dbFieldInfo);
vueViewListContent += CodeGenerateTemplate.GetTableColumn(dbFieldInfo);
vueViewEditFromRuleContent += CodeGenerateTemplate.GetFormRules(dbFieldInfo);
InputDtoContent += CodeGenerateTemplate.GetDtoContent(dbFieldInfo);
replaceDto.QueryProperty += CodeGenerateTemplate.GetQueryDtoProperty(dbFieldInfo);
replaceDto.ModelProperty += CodeGenerateTemplate.GetModelTemplate(dbFieldInfo);
replaceDto.VueViewFormHtml += CodeGenerateTemplate.GetVueViewFormContent(dbFieldInfo);
replaceDto.VueJsMethod += CodeGenerateTemplate.GetVueJsMethod(dbFieldInfo);
replaceDto.VueViewListHtml += CodeGenerateTemplate.GetTableColumn(dbFieldInfo);
replaceDto.VueViewEditFormRuleContent += CodeGenerateTemplate.GetFormRules(dbFieldInfo);
replaceDto.InputDtoProperty += CodeGenerateTemplate.GetDtoProperty(dbFieldInfo);
replaceDto.VueQueryFormHtml += CodeGenerateTemplate.GetQueryFormHtml(dbFieldInfo);
}
ReplaceDto replaceDto = new();
replaceDto.PKName = PKName;
replaceDto.PKType = PKType;
replaceDto.ModelTypeName = modelTypeName;
replaceDto.ModelProperty = modelContent;
replaceDto.TableName = tableInfo.TableName;
replaceDto.TableDesc = tableInfo.TableComment;
replaceDto.InputDtoProperty = InputDtoContent;
replaceDto.updateColumn = updateColumn;
replaceDto.VueJsMethod = vueJsMethod;
replaceDto.VueViewEditFormHtml = vueViewEditFromContent;
replaceDto.VueViewFormHtml = vueViewFormContent;
replaceDto.VueViewEditFormRuleContent = vueViewEditFromRuleContent;
replaceDto.VueViewListHtml = vueViewListContent;
if (dto.genFiles.Contains(1))
{
@@ -205,6 +199,7 @@ namespace ZR.CodeGenerator
.Replace("{ModelsNamespace}", _option.ModelsNamespace)
.Replace("{TableNameDesc}", replaceDto.TableDesc)
.Replace("{PropertyName}", replaceDto.InputDtoProperty)
.Replace("{QueryProperty}", replaceDto.QueryProperty)
.Replace("{ModelTypeName}", replaceDto.ModelTypeName);
WriteAndSave(fullPath, content);
return Tuple.Create(fullPath, content);
@@ -330,7 +325,8 @@ namespace ZR.CodeGenerator
.Replace("{ModelName}", replaceDto.ModelTypeName)
.Replace("{Permission}", replaceDto.ModelTypeName.ToLower())
.Replace("{PrimaryKey}", replaceDto.PKName)
.Replace("{UpdateColumn}", replaceDto.updateColumn)
.Replace("{UpdateColumn}", replaceDto.UpdateColumn)
.Replace("{InsertColumn}", replaceDto.InsertColumn)
.Replace("{KeyTypeName}", replaceDto.PKType);
WriteAndSave(fullPath, content);
return Tuple.Create(fullPath, content);
@@ -362,7 +358,8 @@ namespace ZR.CodeGenerator
.Replace("{Permission}", replaceDto.ModelTypeName.ToLower())
.Replace("{VueViewEditFormContent}", replaceDto.VueViewEditFormHtml)
.Replace("{vueJsMethod}", replaceDto.VueJsMethod)
//.Replace("{VueViewEditFromBindContent}", vueViewEditFromBindContent)
.Replace("{vueQueryFormHtml}", replaceDto.VueQueryFormHtml)
.Replace("{VueDataContent}", replaceDto.VueDataContent)
//.Replace("{VueViewSaveBindContent}", vueViewSaveBindContent)
.Replace("{primaryKey}", FirstLowerCase(replaceDto.PKName))
.Replace("{VueViewEditFormRuleContent}", replaceDto.VueViewEditFormRuleContent);//添加、修改表单验证规则
@@ -458,7 +455,6 @@ namespace ZR.CodeGenerator
sr?.Close();
sr?.Dispose();
return str;
}
/// <summary>

View File

@@ -39,7 +39,14 @@ namespace ZR.CodeGenerator.Model
/// 表描述、说明
/// </summary>
public string TableDesc { get; set; }
public string updateColumn { get; set; }
/// <summary>
/// 修改列
/// </summary>
public string UpdateColumn { get; set; }
/// <summary>
/// 插入列
/// </summary>
public string InsertColumn { get; set; }
/// <summary>
@@ -65,7 +72,25 @@ namespace ZR.CodeGenerator.Model
/// 前端搜索表单html
/// </summary>
public string VueQueryFormHtml { get; set; }
/// <summary>
/// vue js方法
/// </summary>
public string VueJsMethod { get; set; }
/// <summary>
/// vue 添加、编辑表单规则
/// </summary>
public string VueViewEditFormRuleContent { get; set; }
/// <summary>
/// 查询条件
/// </summary>
public string QueryCondition { get; set; }
/// <summary>
/// 查询属性
/// </summary>
public string QueryProperty { get; set; }
/// <summary>
/// vue data内容
/// </summary>
public string VueDataContent { get; set; }
}
}