优化代码生成模板

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

View File

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

View File

@ -212,16 +212,18 @@ $end
$foreach(column in genTable.Columns)
$set(columnName = column.CsharpFieldFl)
$set(value = "item.dictValue")
$set(number = "")
$set(labelName = column.ColumnComment)
$if(column.CsharpType == "int" || column.CsharpType == "long")
$set(value = "parseInt(item.dictValue)")
$set(number = ".number")
$end
$if(column.IsPK || column.IsIncrement)
$if(column.IsPK && column.IsIncrement == false)
<el-col :lg="${options.ColNum}">
<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-col>
$else
@ -304,7 +306,7 @@ $elseif(column.HtmlType == "colorPicker")
$else
<el-col :lg="${options.ColNum}">
<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-col>
$end