Skip to content

Commit

Permalink
Move page list to mapper
Browse files Browse the repository at this point in the history
  • Loading branch information
tangllty committed May 29, 2024
1 parent 8962874 commit b91f79c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,43 @@ package ${packageName}.mapper;
import org.apache.ibatis.annotations.Mapper;

import com.mybatisflex.core.BaseMapper;
import com.mybatisflex.core.query.QueryWrapper;
import com.tang.commons.utils.If;
import com.tang.commons.utils.page.PageResult;
import com.tang.extension.mybatisflex.utils.PageUtils;
import ${packageName}.entity.$ClassName;

import static ${packageName}.entity.table.${ClassName}TableDef.$CLASS_NAME;

/**
* ${classComment}数据访问层
*
* @author $author
*/
@Mapper
public interface ${ClassName}Mapper extends BaseMapper<$ClassName> {

/**
* 查询${classComment}列表
*
* @param $className ${classComment}对象
* @return ${classComment}列表
*/
default PageResult select${ClassName}List($ClassName $className) {
QueryWrapper queryWrapper = QueryWrapper.create();
queryWrapper.select().from($CLASS_NAME);
#foreach ($column in $columnList)
#if($column.queryType == "equal")
queryWrapper.and(${CLASS_NAME}.${column.columnNameUpperUnderscore}.eq(${className}.get${column.columnNameUpperCamel}(), If::nonEmpty));
#end
#if($column.queryType == "fuzzy")
queryWrapper.and(${CLASS_NAME}.${column.columnNameUpperUnderscore}.like(${className}.get${column.columnNameUpperCamel}(), If::nonEmpty));
#end
#if($column.queryType == "findInSet")
queryWrapper.and(${CLASS_NAME}.${column.columnNameUpperUnderscore}.in(${className}.get${column.columnNameUpperCamel}()));
#end
#end
return PageUtils.page(this, queryWrapper);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,14 @@ import java.util.List;

import org.springframework.stereotype.Service;

import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.tang.commons.utils.If;
import com.tang.commons.utils.page.PageResult;
import com.tang.extension.mybatisflex.utils.PageUtils;
import ${packageName}.entity.$ClassName;
import ${packageName}.mapper.${ClassName}Mapper;
import ${packageName}.service.${ClassName}Service;

import lombok.RequiredArgsConstructor;

import static ${packageName}.entity.table.${ClassName}TableDef.$CLASS_NAME;

/**
* ${classComment}业务逻辑层接口实现
*
Expand All @@ -36,20 +31,7 @@ public class ${ClassName}ServiceImpl extends ServiceImpl<${ClassName}Mapper, $Cl
*/
@Override
public PageResult select${ClassName}List($ClassName $className) {
QueryWrapper queryWrapper = QueryWrapper.create();
queryWrapper.select().from($CLASS_NAME);
#foreach ($column in $columnList)
#if($column.queryType == "equal")
queryWrapper.and(${CLASS_NAME}.${column.columnNameUpperUnderscore}.eq(${className}.get${column.columnNameUpperCamel}(), If::nonEmpty));
#end
#if($column.queryType == "fuzzy")
queryWrapper.and(${CLASS_NAME}.${column.columnNameUpperUnderscore}.like(${className}.get${column.columnNameUpperCamel}(), If::nonEmpty));
#end
#if($column.queryType == "findInSet")
queryWrapper.and(${CLASS_NAME}.${column.columnNameUpperUnderscore}.in(${className}.get${column.columnNameUpperCamel}()));
#end
#end
return PageUtils.page(${className}Mapper, queryWrapper);
return ${className}Mapper.select${ClassName}List($className);
}

/**
Expand Down

0 comments on commit b91f79c

Please sign in to comment.