mirror of https://gitee.com/xiaonuobase/snowy
【升级】查询条件增加为全部字段,可根据不同程序删减代码
parent
36a753a604
commit
67cca92a1b
|
@ -32,7 +32,7 @@ public class TableField {
|
|||
public String columnKey;
|
||||
|
||||
/**
|
||||
* 主键(转换后的)
|
||||
* 字段名,用来 get set方法使用的
|
||||
*/
|
||||
public String columnKeyName;
|
||||
|
||||
|
|
|
@ -227,10 +227,12 @@ public class CodeGenerateServiceImpl extends ServiceImpl<CodeGenerateMapper, Cod
|
|||
BeanUtil.copyProperties(item, tableField);
|
||||
if (tableField.getColumnKey().equals(Config.DB_TABLE_COM_KRY)) {
|
||||
tableField.setPrimaryKeyFlag(true);
|
||||
String columnName = NamingConTool.UnderlineToHump(item.getColumnName(),"");
|
||||
tableField.setColumnKeyName(columnName.substring(0,1).toUpperCase() + columnName.substring(1,columnName.length()));
|
||||
}
|
||||
|
||||
// 加入后端查询参数get set参数
|
||||
String columnName = NamingConTool.UnderlineToHump(item.getColumnName(),"");
|
||||
tableField.setColumnKeyName(columnName.substring(0,1).toUpperCase() + columnName.substring(1,columnName.length()));
|
||||
|
||||
// 字段类型转换Java类型
|
||||
tableField.setJavaType(JavaSqlTool.sqlToJava(item.getDataType()));
|
||||
|
||||
|
|
|
@ -58,14 +58,22 @@ public class ${ClassName}ServiceImpl extends ServiceImpl<${ClassName}Mapper, ${C
|
|||
public PageResult<${ClassName}> page(${ClassName}Param ${className}Param) {
|
||||
QueryWrapper<${ClassName}> queryWrapper = new QueryWrapper<>();
|
||||
if (ObjectUtil.isNotNull(${className}Param)) {
|
||||
#foreach ($column in $tableField)
|
||||
#if (${column.primaryKeyFlag})
|
||||
// 根据条件 模糊查询
|
||||
|
||||
#foreach ($column in $tableField)
|
||||
#if (${column.primaryKeyFlag})
|
||||
// 根据${column.columnComment} 查询
|
||||
if (ObjectUtil.isNotEmpty(${className}Param.get${column.columnKeyName}())) {
|
||||
queryWrapper.lambda().eq(${ClassName}::get${column.columnKeyName}, ${className}Param.get${column.columnKeyName}());
|
||||
}
|
||||
|
||||
#else
|
||||
// 根据${column.columnComment} 模糊查询
|
||||
if (ObjectUtil.isNotEmpty(${className}Param.get${column.columnKeyName}())) {
|
||||
queryWrapper.lambda().like(${ClassName}::get${column.columnKeyName}, ${className}Param.get${column.columnKeyName}());
|
||||
}
|
||||
#end
|
||||
#end
|
||||
|
||||
#end
|
||||
#end
|
||||
}
|
||||
return new PageResult<>(this.page(PageFactory.defaultPage(), queryWrapper));
|
||||
}
|
||||
|
@ -74,13 +82,21 @@ public class ${ClassName}ServiceImpl extends ServiceImpl<${ClassName}Mapper, ${C
|
|||
public List<${ClassName}> list(${ClassName}Param ${className}Param) {
|
||||
LambdaQueryWrapper<${ClassName}> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if (ObjectUtil.isNotNull(${className}Param)) {
|
||||
//根据条件模糊查询
|
||||
|
||||
#foreach ($column in $tableField)
|
||||
#if (${column.primaryKeyFlag})
|
||||
if (ObjectUtil.isNotEmpty(${className}Param.get${column.columnKeyName}())) {
|
||||
queryWrapper.eq(${ClassName}::get${column.columnKeyName}, ${className}Param.get${column.columnKeyName}());
|
||||
}
|
||||
#end
|
||||
#if (${column.primaryKeyFlag})
|
||||
// 根据${column.columnComment} 查询
|
||||
if (ObjectUtil.isNotEmpty(${className}Param.get${column.columnKeyName}())) {
|
||||
queryWrapper.eq(${ClassName}::get${column.columnKeyName}, ${className}Param.get${column.columnKeyName}());
|
||||
}
|
||||
|
||||
#else
|
||||
// 根据${column.columnComment} 模糊查询
|
||||
if (ObjectUtil.isNotEmpty(${className}Param.get${column.columnKeyName}())) {
|
||||
queryWrapper.like(${ClassName}::get${column.columnKeyName}, ${className}Param.get${column.columnKeyName}());
|
||||
}
|
||||
|
||||
#end
|
||||
#end
|
||||
}
|
||||
return this.list(queryWrapper);
|
||||
|
|
|
@ -4,15 +4,12 @@
|
|||
<a-form layout="inline">
|
||||
<a-row :gutter="48">
|
||||
#foreach ($column in $tableField)
|
||||
#if (${column.primaryKeyFlag})
|
||||
<a-col :md="8" :sm="24">
|
||||
<a-form-item label="${column.columnComment}" >
|
||||
<a-input v-model="queryParam.${column.columnName}" allow-clear placeholder="请输入${column.columnComment}"/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
#end
|
||||
#end
|
||||
|
||||
<a-col :md="!advanced && 8 || 24" :sm="24">
|
||||
<span class="table-page-search-submitButtons" :style="advanced && { float: 'right', overflow: 'hidden' } || {} ">
|
||||
<a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
|
||||
|
@ -36,7 +33,6 @@
|
|||
:rowKey="(record) => record.${column.columnName}"
|
||||
#end
|
||||
#end
|
||||
|
||||
:rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
|
||||
>
|
||||
<span slot="action" slot-scope="text, record">
|
||||
|
|
Loading…
Reference in New Issue