Java Code Examples for com.baomidou.mybatisplus.core.conditions.query.QueryWrapper#or()

The following examples show how to use com.baomidou.mybatisplus.core.conditions.query.QueryWrapper#or() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MyBatisAccessor.java    From jstarcraft-core with Apache License 2.0 6 votes vote down vote up
@Override
public <K extends Comparable, T extends IdentityObject<K>> List<T> queryUnion(Class<T> clazz, Map<String, Object> condition, StoragePagination pagination) {
	MyBatisMetadata metadata = metadatas.get(clazz);
	BaseMapper mapper = template.getMapper(metadata.getMapperClass());
	QueryWrapper<?> query = new QueryWrapper<>();
	for (Entry<String, Object> term : condition.entrySet()) {
		query.or((wrapper) -> {
			return wrapper.eq(metadata.getColumnName(term.getKey()), term.getValue());
		});
	}
	if (pagination == null) {
		return mapper.selectList(query);
	} else {
		IPage<T> page = mapper.selectPage(new Page(pagination.getPage(), pagination.getSize()), query);
		return page.getRecords();
	}
}
 
Example 2
Source File: MyBatisAccessor.java    From jstarcraft-core with Apache License 2.0 5 votes vote down vote up
@Override
public <K extends Comparable, T extends IdentityObject<K>> long countUnion(Class<T> clazz, Map<String, Object> condition) {
	MyBatisMetadata metadata = metadatas.get(clazz);
	BaseMapper mapper = template.getMapper(metadata.getMapperClass());
	QueryWrapper<?> query = new QueryWrapper<>();
	for (Entry<String, Object> term : condition.entrySet()) {
		query.or((wrapper) -> {
			return wrapper.eq(metadata.getColumnName(term.getKey()), term.getValue());
		});
	}
	return mapper.selectCount(query);
}
 
Example 3
Source File: MyBatisAccessor.java    From jstarcraft-core with Apache License 2.0 5 votes vote down vote up
@Override
public <K extends Comparable, T extends IdentityObject<K>> void iterateUnion(StorageIterator<T> iterator, Class<T> clazz, Map<String, Object> condition, StoragePagination pagination) {
	MyBatisMetadata metadata = metadatas.get(clazz);
	BaseMapper mapper = template.getMapper(metadata.getMapperClass());
	QueryWrapper<?> query = new QueryWrapper<>();
	for (Entry<String, Object> term : condition.entrySet()) {
		query.or((wrapper) -> {
			return wrapper.eq(metadata.getColumnName(term.getKey()), term.getValue());
		});
	}
	IPage<T> page = mapper.selectPage(new Page(pagination.getPage(), pagination.getSize()), query);
	for (T object : page.getRecords()) {
		iterator.iterate(object);
	}
}