优化代码生成模板

This commit is contained in:
不做码农 2023-04-27 20:43:00 +08:00
parent a4ef9ac415
commit 4e628e58db
3 changed files with 14 additions and 16 deletions

View File

@ -22,8 +22,6 @@ namespace ${options.ServicesNamespace}.${options.SubNamespace}
[AppService(ServiceType = typeof(I${replaceDto.ModelTypeName}Service), ServiceLifetime = LifeTime.Transient)] [AppService(ServiceType = typeof(I${replaceDto.ModelTypeName}Service), ServiceLifetime = LifeTime.Transient)]
public class ${replaceDto.ModelTypeName}Service : BaseService<${replaceDto.ModelTypeName}>, I${replaceDto.ModelTypeName}Service public class ${replaceDto.ModelTypeName}Service : BaseService<${replaceDto.ModelTypeName}>, I${replaceDto.ModelTypeName}Service
{ {
#region 业务逻辑代码
/// <summary> /// <summary>
/// 查询${genTable.FunctionName}列表 /// 查询${genTable.FunctionName}列表
/// </summary> /// </summary>
@ -31,10 +29,8 @@ namespace ${options.ServicesNamespace}.${options.SubNamespace}
/// <returns></returns> /// <returns></returns>
public PagedInfo<${replaceDto.ModelTypeName}Dto> GetList(${replaceDto.ModelTypeName}QueryDto parm) public PagedInfo<${replaceDto.ModelTypeName}Dto> GetList(${replaceDto.ModelTypeName}QueryDto parm)
{ {
//开始拼装查询条件
var predicate = Expressionable.Create<${replaceDto.ModelTypeName}>(); var predicate = Expressionable.Create<${replaceDto.ModelTypeName}>();
//搜索条件查询语法参考Sqlsugar
$foreach(column in genTable.Columns) $foreach(column in genTable.Columns)
$if(column.IsQuery) $if(column.IsQuery)
$if(column.HtmlType == "selectMulti") $if(column.HtmlType == "selectMulti")
@ -70,10 +66,8 @@ $if(genTable.TplCategory == "tree")
/// <returns></returns> /// <returns></returns>
public List<${replaceDto.ModelTypeName}> GetTreeList(${replaceDto.ModelTypeName}QueryDto parm) public List<${replaceDto.ModelTypeName}> GetTreeList(${replaceDto.ModelTypeName}QueryDto parm)
{ {
//开始拼装查询条件
var predicate = Expressionable.Create<${replaceDto.ModelTypeName}>(); var predicate = Expressionable.Create<${replaceDto.ModelTypeName}>();
//搜索条件查询语法参考Sqlsugar
$foreach(column in genTable.Columns) $foreach(column in genTable.Columns)
$if(column.IsQuery) $if(column.IsQuery)
$if(column.CsharpType == "string") $if(column.CsharpType == "string")
@ -130,6 +124,5 @@ $if(replaceDto.ShowBtnTruncate)
Truncate(); Truncate();
} }
$end $end
#endregion
} }
} }

View File

@ -36,7 +36,7 @@ export function treelist${genTable.BusinessName}(query) {
}) })
} }
$end $end
$if(replaceDto.ShowBtnAdd)
/** /**
* 新增${genTable.functionName} * 新增${genTable.functionName}
* @param data * @param data
@ -48,7 +48,8 @@ export function add${genTable.BusinessName}(data) {
data: data, data: data,
}) })
} }
$end
$if(replaceDto.ShowBtnEdit)
/** /**
* 修改${genTable.functionName} * 修改${genTable.functionName}
* @param data * @param data
@ -60,7 +61,7 @@ export function update${genTable.BusinessName}(data) {
data: data, data: data,
}) })
} }
$end
/** /**
* 获取${genTable.functionName}详情 * 获取${genTable.functionName}详情
* @param {Id} * @param {Id}
@ -72,6 +73,7 @@ export function get${genTable.BusinessName}(id) {
}) })
} }
$if(replaceDto.ShowBtnDelete)
/** /**
* 删除${genTable.functionName} * 删除${genTable.functionName}
* @param {主键} pid * @param {主键} pid
@ -82,7 +84,8 @@ export function del${genTable.BusinessName}(pid) {
method: 'delete' method: 'delete'
}) })
} }
$end
$if(replaceDto.ShowBtnTruncate)
// 清空${genTable.functionName} // 清空${genTable.functionName}
export function clear${genTable.BusinessName}() { export function clear${genTable.BusinessName}() {
return request({ return request({
@ -90,14 +93,14 @@ export function clear${genTable.BusinessName}() {
method: 'delete' method: 'delete'
}) })
} }
$end
$if(replaceDto.ShowBtnExport)
// 导出${genTable.functionName} // 导出${genTable.functionName}
export async function export${genTable.BusinessName}(query) { export async function export${genTable.BusinessName}(query) {
await downFile('${genTable.ModuleName}/${genTable.BusinessName}/export', { ...query }) await downFile('${genTable.ModuleName}/${genTable.BusinessName}/export', { ...query })
} }
$end
$if(showCustomInput) $if(showCustomInput)
//排序
export function changeSort(data) { export function changeSort(data) {
return request({ return request({
url: '${genTable.ModuleName}/${genTable.BusinessName}/ChangeSort', url: '${genTable.ModuleName}/${genTable.BusinessName}/ChangeSort',

View File

@ -212,16 +212,18 @@ $end
$foreach(column in genTable.Columns) $foreach(column in genTable.Columns)
$set(columnName = column.CsharpFieldFl) $set(columnName = column.CsharpFieldFl)
$set(value = "item.dictValue") $set(value = "item.dictValue")
$set(number = "")
$set(labelName = column.ColumnComment) $set(labelName = column.ColumnComment)
$if(column.CsharpType == "int" || column.CsharpType == "long") $if(column.CsharpType == "int" || column.CsharpType == "long")
$set(value = "parseInt(item.dictValue)") $set(value = "parseInt(item.dictValue)")
$set(number = ".number")
$end $end
$if(column.IsPK || column.IsIncrement) $if(column.IsPK || column.IsIncrement)
$if(column.IsPK && column.IsIncrement == false) $if(column.IsPK && column.IsIncrement == false)
<el-col :lg="${options.ColNum}"> <el-col :lg="${options.ColNum}">
<el-form-item label="${labelName}" prop="${columnName}"> <el-form-item label="${labelName}" prop="${columnName}">
<el-input v-model="form.${columnName}" placeholder="请输入${labelName}" :disabled="opertype != 1"/> <el-input v-model${number}="form.${columnName}" placeholder="请输入${labelName}" :disabled="opertype != 1"/>
</el-form-item> </el-form-item>
</el-col> </el-col>
$else $else
@ -304,7 +306,7 @@ $elseif(column.HtmlType == "colorPicker")
$else $else
<el-col :lg="${options.ColNum}"> <el-col :lg="${options.ColNum}">
<el-form-item label="${labelName}" prop="${columnName}"> <el-form-item label="${labelName}" prop="${columnName}">
<el-input v-model="form.${columnName}" placeholder="请输入${labelName}" ${column.DisabledStr}/> <el-input v-model${number}="form.${columnName}" placeholder="请输入${labelName}" ${column.DisabledStr}/>
</el-form-item> </el-form-item>
</el-col> </el-col>
$end $end