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

The following examples show how to use com.baomidou.mybatisplus.core.conditions.query.QueryWrapper#gt() . 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: OrderServiceImpl.java    From supplierShop with MIT License 6 votes vote down vote up
/**
 *
 * @param type 1-积分 2-余额
 * @param userId
 * @param page
 * @param limit
 * @return
 */
@Override
public List<StorePointsMoneyLog> pointsMoneyLogs(int type, int userId, int page, int limit) {
    QueryWrapper<StorePointsMoneyLog> wrapper = new QueryWrapper<>();
    wrapper.eq("user_id",userId).orderByDesc("create_time");
    if(type == 1){
        wrapper.gt("points_number",0);
    }else{
        wrapper.gt("money_number",0);
    }
    Page<StorePointsMoneyLog> pageModel = new Page<>(page, limit);
    IPage<StorePointsMoneyLog> pageList = storePointsMoneyLogMapper.selectPage(pageModel,wrapper);
    List<StorePointsMoneyLog> list = pageList.getRecords();

    return list;
}
 
Example 2
Source File: ObjectParseUtil.java    From jeecg-cloud with Apache License 2.0 5 votes vote down vote up
/**
 * 
 * @param queryWrapper QueryWrapper
 * @param name         字段名字
 * @param rule         查询规则
 * @param value        查询条件值
 */
public static void addCriteria(QueryWrapper<?> queryWrapper, String name, QueryRuleEnum rule, Object value) {
	if (value == null || rule == null) {
		return;
	}
	switch (rule) {
	case GT:
		queryWrapper.gt(name, value);
		break;
	case GE:
		queryWrapper.ge(name, value);
		break;
	case LT:
		queryWrapper.lt(name, value);
		break;
	case LE:
		queryWrapper.le(name, value);
		break;
	case EQ:
		queryWrapper.eq(name, value);
		break;
	case NE:
		queryWrapper.ne(name, value);
		break;
	case IN:
		queryWrapper.in(name, (Object[]) value);
		break;
	case LIKE:
		queryWrapper.like(name, value);
		break;
	case LEFT_LIKE:
		queryWrapper.likeLeft(name, value);
		break;
	case RIGHT_LIKE:
		queryWrapper.likeRight(name, value);
		break;
	default:
		break;
	}
}
 
Example 3
Source File: ObjectParseUtil.java    From jeecg-boot-with-activiti with MIT License 5 votes vote down vote up
/**
 * 
 * @param queryWrapper QueryWrapper
 * @param name         字段名字
 * @param rule         查询规则
 * @param value        查询条件值
 */
public static void addCriteria(QueryWrapper<?> queryWrapper, String name, QueryRuleEnum rule, Object value) {
	if (value == null || rule == null) {
		return;
	}
	switch (rule) {
	case GT:
		queryWrapper.gt(name, value);
		break;
	case GE:
		queryWrapper.ge(name, value);
		break;
	case LT:
		queryWrapper.lt(name, value);
		break;
	case LE:
		queryWrapper.le(name, value);
		break;
	case EQ:
		queryWrapper.eq(name, value);
		break;
	case NE:
		queryWrapper.ne(name, value);
		break;
	case IN:
		queryWrapper.in(name, (Object[]) value);
		break;
	case LIKE:
		queryWrapper.like(name, value);
		break;
	case LEFT_LIKE:
		queryWrapper.likeLeft(name, value);
		break;
	case RIGHT_LIKE:
		queryWrapper.likeRight(name, value);
		break;
	default:
		break;
	}
}
 
Example 4
Source File: ObjectParseUtil.java    From teaching with Apache License 2.0 5 votes vote down vote up
/**
 * 
 * @param queryWrapper QueryWrapper
 * @param name         字段名字
 * @param rule         查询规则
 * @param value        查询条件值
 */
public static void addCriteria(QueryWrapper<?> queryWrapper, String name, QueryRuleEnum rule, Object value) {
	if (value == null || rule == null) {
		return;
	}
	switch (rule) {
	case GT:
		queryWrapper.gt(name, value);
		break;
	case GE:
		queryWrapper.ge(name, value);
		break;
	case LT:
		queryWrapper.lt(name, value);
		break;
	case LE:
		queryWrapper.le(name, value);
		break;
	case EQ:
		queryWrapper.eq(name, value);
		break;
	case NE:
		queryWrapper.ne(name, value);
		break;
	case IN:
		queryWrapper.in(name, (Object[]) value);
		break;
	case LIKE:
		queryWrapper.like(name, value);
		break;
	case LEFT_LIKE:
		queryWrapper.likeLeft(name, value);
		break;
	case RIGHT_LIKE:
		queryWrapper.likeRight(name, value);
		break;
	default:
		break;
	}
}
 
Example 5
Source File: ObjectParseUtil.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
/**
 * 
 * @param queryWrapper QueryWrapper
 * @param name         字段名字
 * @param rule         查询规则
 * @param value        查询条件值
 */
public static void addCriteria(QueryWrapper<?> queryWrapper, String name, QueryRuleEnum rule, Object value) {
	if (value == null || rule == null) {
		return;
	}
	switch (rule) {
	case GT:
		queryWrapper.gt(name, value);
		break;
	case GE:
		queryWrapper.ge(name, value);
		break;
	case LT:
		queryWrapper.lt(name, value);
		break;
	case LE:
		queryWrapper.le(name, value);
		break;
	case EQ:
		queryWrapper.eq(name, value);
		break;
	case NE:
		queryWrapper.ne(name, value);
		break;
	case IN:
		queryWrapper.in(name, (Object[]) value);
		break;
	case LIKE:
		queryWrapper.like(name, value);
		break;
	case LEFT_LIKE:
		queryWrapper.likeLeft(name, value);
		break;
	case RIGHT_LIKE:
		queryWrapper.likeRight(name, value);
		break;
	default:
		break;
	}
}
 
Example 6
Source File: MyBatisAccessor.java    From jstarcraft-core with Apache License 2.0 5 votes vote down vote up
@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 7
Source File: QueryGenerator.java    From jeecg-cloud with Apache License 2.0 4 votes vote down vote up
/**
  * 根据规则走不同的查询
 * @param queryWrapper QueryWrapper
 * @param name         字段名字
 * @param rule         查询规则
 * @param value        查询条件值
 */
private static void addEasyQuery(QueryWrapper<?> queryWrapper, String name, QueryRuleEnum rule, Object value) {
	if (value == null || rule == null || oConvertUtils.isEmpty(value)) {
		return;
	}
	name = oConvertUtils.camelToUnderline(name);
	log.info("--查询规则-->"+name+" "+rule.getValue()+" "+value);
	switch (rule) {
	case GT:
		queryWrapper.gt(name, value);
		break;
	case GE:
		queryWrapper.ge(name, value);
		break;
	case LT:
		queryWrapper.lt(name, value);
		break;
	case LE:
		queryWrapper.le(name, value);
		break;
	case EQ:
		queryWrapper.eq(name, value);
		break;
	case NE:
		queryWrapper.ne(name, value);
		break;
	case IN:
		if(value instanceof String) {
			queryWrapper.in(name, (Object[])value.toString().split(","));
		}else if(value instanceof String[]) {
			queryWrapper.in(name, (Object[]) value);
		}else {
			queryWrapper.in(name, value);
		}
		break;
	case LIKE:
		queryWrapper.like(name, value);
		break;
	case LEFT_LIKE:
		queryWrapper.likeLeft(name, value);
		break;
	case RIGHT_LIKE:
		queryWrapper.likeRight(name, value);
		break;
	default:
		log.info("--查询规则未匹配到---");
		break;
	}
}
 
Example 8
Source File: QueryGenerator.java    From jeecg-boot-with-activiti with MIT License 4 votes vote down vote up
/**
  * 根据规则走不同的查询
 * @param queryWrapper QueryWrapper
 * @param name         字段名字
 * @param rule         查询规则
 * @param value        查询条件值
 */
private static void addEasyQuery(QueryWrapper<?> queryWrapper, String name, QueryRuleEnum rule, Object value) {
	if (value == null || rule == null) {
		return;
	}
	name = oConvertUtils.camelToUnderline(name);
	log.info("--查询规则-->"+name+" "+rule.getValue()+" "+value);
	switch (rule) {
	case GT:
		queryWrapper.gt(name, value);
		break;
	case GE:
		queryWrapper.ge(name, value);
		break;
	case LT:
		queryWrapper.lt(name, value);
		break;
	case LE:
		queryWrapper.le(name, value);
		break;
	case EQ:
		queryWrapper.eq(name, value);
		break;
	case NE:
		queryWrapper.ne(name, value);
		break;
	case IN:
		if(value instanceof String) {
			queryWrapper.in(name, (Object[])value.toString().split(","));
		}else if(value instanceof String[]) {
			queryWrapper.in(name, (Object[]) value);
		}else {
			queryWrapper.in(name, value);
		}
		break;
	case LIKE:
		queryWrapper.like(name, value);
		break;
	case LEFT_LIKE:
		queryWrapper.likeLeft(name, value);
		break;
	case RIGHT_LIKE:
		queryWrapper.likeRight(name, value);
		break;
	default:
		log.info("--查询规则未匹配到---");
		break;
	}
}
 
Example 9
Source File: QueryGenerator.java    From teaching with Apache License 2.0 4 votes vote down vote up
/**
  * 根据规则走不同的查询
 * @param queryWrapper QueryWrapper
 * @param name         字段名字
 * @param rule         查询规则
 * @param value        查询条件值
 */
private static void addEasyQuery(QueryWrapper<?> queryWrapper, String name, QueryRuleEnum rule, Object value) {
	if (value == null || rule == null || oConvertUtils.isEmpty(value)) {
		return;
	}
	name = oConvertUtils.camelToUnderline(name);
	log.info("--查询规则-->"+name+" "+rule.getValue()+" "+value);
	switch (rule) {
	case GT:
		queryWrapper.gt(name, value);
		break;
	case GE:
		queryWrapper.ge(name, value);
		break;
	case LT:
		queryWrapper.lt(name, value);
		break;
	case LE:
		queryWrapper.le(name, value);
		break;
	case EQ:
		queryWrapper.eq(name, value);
		break;
	case NE:
		queryWrapper.ne(name, value);
		break;
	case IN:
		if(value instanceof String) {
			queryWrapper.in(name, (Object[])value.toString().split(","));
		}else if(value instanceof String[]) {
			queryWrapper.in(name, (Object[]) value);
		}else {
			queryWrapper.in(name, value);
		}
		break;
	case LIKE:
		queryWrapper.like(name, value);
		break;
	case LEFT_LIKE:
		queryWrapper.likeLeft(name, value);
		break;
	case RIGHT_LIKE:
		queryWrapper.likeRight(name, value);
		break;
	default:
		log.info("--查询规则未匹配到---");
		break;
	}
}
 
Example 10
Source File: QueryGenerator.java    From jeecg-boot with Apache License 2.0 4 votes vote down vote up
/**
  * 根据规则走不同的查询
 * @param queryWrapper QueryWrapper
 * @param name         字段名字
 * @param rule         查询规则
 * @param value        查询条件值
 */
private static void addEasyQuery(QueryWrapper<?> queryWrapper, String name, QueryRuleEnum rule, Object value) {
	if (value == null || rule == null || oConvertUtils.isEmpty(value)) {
		return;
	}
	name = oConvertUtils.camelToUnderline(name);
	log.info("--查询规则-->"+name+" "+rule.getValue()+" "+value);
	switch (rule) {
	case GT:
		queryWrapper.gt(name, value);
		break;
	case GE:
		queryWrapper.ge(name, value);
		break;
	case LT:
		queryWrapper.lt(name, value);
		break;
	case LE:
		queryWrapper.le(name, value);
		break;
	case EQ:
		queryWrapper.eq(name, value);
		break;
	case NE:
		queryWrapper.ne(name, value);
		break;
	case IN:
		if(value instanceof String) {
			queryWrapper.in(name, (Object[])value.toString().split(","));
		}else if(value instanceof String[]) {
			queryWrapper.in(name, (Object[]) value);
		}else {
			queryWrapper.in(name, value);
		}
		break;
	case LIKE:
		queryWrapper.like(name, value);
		break;
	case LEFT_LIKE:
		queryWrapper.likeLeft(name, value);
		break;
	case RIGHT_LIKE:
		queryWrapper.likeRight(name, value);
		break;
	default:
		log.info("--查询规则未匹配到---");
		break;
	}
}
 
Example 11
Source File: MyBatisAccessor.java    From jstarcraft-core with Apache License 2.0 4 votes vote down vote up
@Override
public <K extends Comparable, I, T extends IdentityObject<K>> Map<K, I> queryIdentities(Class<T> clazz, String name, StorageCondition<I> condition) {
	MyBatisMetadata metadata = metadatas.get(clazz);
	BaseMapper mapper = template.getMapper(metadata.getMapperClass());
	QueryWrapper<?> query = new QueryWrapper<>();
	String id = metadata.getColumnName(metadata.getPrimaryName());
	String column = metadata.getColumnName(name);
	query.select(id, column);
	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<Map<String, Object>> list = mapper.selectMaps(query);
	switch (getCaseStrategy()) {
	case LOWER:
		id = id.toLowerCase();
		column = column.toLowerCase();
		break;
	case UPPER:
		id = id.toUpperCase();
		column = column.toUpperCase();
		break;
	}
	Map<K, I> map = new HashMap<>();
	for (Map<String, Object> element : list) {
		map.put((K) element.get(id), (I) element.get(column));
	}
	return map;
}