优化代码生成功能

This commit is contained in:
不做码农
2021-12-14 21:50:30 +08:00
parent bb2f64088d
commit 50c48077d7
6 changed files with 126 additions and 124 deletions

View File

@@ -101,14 +101,15 @@ $end
//从 Dto 映射到 实体
var model = parm.Adapt<${replaceDto.ModelTypeName}>().ToCreate(HttpContext);
return SUCCESS(_${replaceDto.ModelTypeName}Service.Insert(model, it => new
var response = _${replaceDto.ModelTypeName}Service.Insert(model, it => new
{
$foreach(item in genTable.Columns)
$if((item.IsInsert))
it.$item.CsharpField,
$end
${end}
}));
});
return ToResponse(response);
}
/// <summary>
@@ -137,7 +138,7 @@ $end
${end}
});
return SUCCESS(response);
return ToResponse(response);
}
/// <summary>
@@ -154,7 +155,7 @@ ${end}
var response = _${replaceDto.ModelTypeName}Service.Delete(idsArr);
return SUCCESS(response);
return ToResponse(response);
}
/// <summary>

View File

@@ -302,31 +302,31 @@ $end
if (valid) {
$foreach(item in genTable.Columns)
$if(item.HtmlType == "checkbox")
this.form.${item.ColumnName} = this.form.${item.columnName}Checked.toString();
this.form.${item.ColumnName} = this.form.${item.columnName}Checked.toString();
$end
$end
console.log(JSON.stringify(this.form));
if (this.form.${replaceDto.FistLowerPk} != undefined || this.title === "修改数据") {
update${genTable.BusinessName}(this.form).then((res) => {
if (!res.data) {
this.msgError("修改失败");
return;
}
if (this.form.${replaceDto.FistLowerPk} != undefined && this.title === "修改数据") {
update${genTable.BusinessName}(this.form)
.then((res) => {
this.msgSuccess("修改成功");
this.open = false;
this.getList();
});
})
.catch((err) => {
//TODO 错误逻辑
});
} else {
add${genTable.BusinessName}(this.form).then((res) => {
if (!res.data) {
this.msgError("新增失败");
return;
}
add${genTable.BusinessName}(this.form)
.then((res) => {
this.msgSuccess("新增成功");
this.open = false;
this.getList();
});
})
.catch((err) => {
//TODO 错误逻辑
});
}
}
});