mybatisplus 流式查詢
阿新 • • 發佈:2020-12-25
技術標籤:mybatismybatisplusmybatis
Dao.class 方法
@Select("select ${ew.sqlSelect} from t_app_usermlq t ${ew.customSqlSegment}")
@Options(resultSetType = ResultSetType.FORWARD_ONLY, fetchSize = 1000)
@ResultType(AppUserEntity.class)
void getUserListBigData(@Param(Constants.WRAPPER) QueryWrapper<AppUserEntity> wrapper, ResultHandler<AppUserEntity> handler);
service.class方法呼叫
/**
* @author yangjunxiong
* @date 2020/12/23 10:51
* @param sqlSelect 需要返回的欄位 逗號分隔 欄位越少查詢越快
* @param subDeptIdList
* @return java.util.List<com.allianity.common.learning.entity.AppUserEntity>
**/
@Override
public List<AppUserEntity> getUserListBigData(String sqlSelect,List<Long> subDeptIdList) {
List<AppUserEntity> appUserEntities = new ArrayList<>();
QueryWrapper<AppUserEntity> queryWrapper = new QueryWrapper<>();
queryWrapper. select(sqlSelect);
queryWrapper.eq("status", 0);
queryWrapper.eq("del_flag", 0);
queryWrapper.in("dept_id", subDeptIdList);
//流式條件查詢
this.baseMapper.getUserListBigData(queryWrapper, resultContext -> Optional.ofNullable(resultContext.getResultObject())
.ifPresent(appUserEntities::add));
return appUserEntities;
}