Java Code Examples for com.baomidou.mybatisplus.core.mapper.BaseMapper#selectList()
The following examples show how to use
com.baomidou.mybatisplus.core.mapper.BaseMapper#selectList() .
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 |
@Override public <K extends Comparable, T extends IdentityObject<K>> List<T> queryIntersection(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.and((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 | 6 votes |
@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 3
Source File: MyBatisAccessor.java From jstarcraft-core with Apache License 2.0 | 5 votes |
@Override public <K extends Comparable, I, T extends IdentityObject<K>> List<T> queryInstances(Class<T> clazz, String name, StorageCondition<I> condition) { MyBatisMetadata metadata = metadatas.get(clazz); BaseMapper mapper = template.getMapper(metadata.getMapperClass()); QueryWrapper<?> query = new QueryWrapper<>(); String column = metadata.getColumnName(name); ConditionType type = condition.getType(); I[] values = condition.getValues(); switch (type) { case All: break; case Between: query.between(column, values[0], values[1]); break; case Equal: query.eq(column, values[0]); break; case Higher: query.gt(column, values[0]); break; case In: query.in(column, values); break; case Lower: query.lt(column, values[0]); break; case Unequal: query.ne(column, values[0]); break; } List<T> list = mapper.selectList(query); return list; }
Example 4
Source File: MyBatisAccessor.java From jstarcraft-core with Apache License 2.0 | 5 votes |
@Override public <K extends Comparable, T extends IdentityObject<K>> List<T> queryInstances(Class<T> clazz, StoragePagination pagination) { MyBatisMetadata metadata = metadatas.get(clazz); BaseMapper mapper = template.getMapper(metadata.getMapperClass()); QueryWrapper<?> query = new QueryWrapper<>(); if (pagination == null) { return mapper.selectList(query); } else { IPage<T> page = mapper.selectPage(new Page(pagination.getPage(), pagination.getSize()), query); return page.getRecords(); } }