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

The following examples show how to use com.baomidou.mybatisplus.core.conditions.query.QueryWrapper#ne() . 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: CommentServiceImpl.java    From SENS with GNU General Public License v3.0 5 votes vote down vote up
@Override
public List<Comment> findCommentsByPostAndCommentStatusNot(Long postId, Integer status) {
    QueryWrapper queryWrapper = new QueryWrapper();
    queryWrapper.eq("post_id", postId);
    queryWrapper.ne("comment_status", status);
    return commentMapper.selectList(queryWrapper);
}
 
Example 2
Source File: SysUserController.java    From jeecg-cloud with Apache License 2.0 5 votes vote down vote up
/**
    * 获取用户列表数据
    * @param user
    * @param pageNo
    * @param pageSize
    * @param req
    * @return
    */
   @PermissionData(pageComponent = "system/UserList")
@RequestMapping(value = "/list", method = RequestMethod.GET)
public Result<IPage<SysUser>> queryPageList(SysUser user,@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
								  @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,HttpServletRequest req) {
	Result<IPage<SysUser>> result = new Result<IPage<SysUser>>();
	QueryWrapper<SysUser> queryWrapper = QueryGenerator.initQueryWrapper(user, req.getParameterMap());
   	//TODO 外部模拟登陆临时账号,列表不显示
       queryWrapper.ne("username","_reserve_user_external");
	Page<SysUser> page = new Page<SysUser>(pageNo, pageSize);
	IPage<SysUser> pageList = sysUserService.page(page, queryWrapper);

	//批量查询用户的所属部门
       //step.1 先拿到全部的 useids
       //step.2 通过 useids,一次性查询用户的所属部门名字
       List<String> userIds = pageList.getRecords().stream().map(SysUser::getId).collect(Collectors.toList());
       if(userIds!=null && userIds.size()>0){
           Map<String,String>  useDepNames = sysUserService.getDepNamesByUserIds(userIds);
           pageList.getRecords().forEach(item->{
               //TODO 临时借用这个字段用于页面展示
               item.setOrgCode(useDepNames.get(item.getId()));
           });
       }
	result.setSuccess(true);
	result.setResult(pageList);
	log.info(pageList.toString());
	return result;
}
 
Example 3
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 4
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 5
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 6
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 7
Source File: SysUserController.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
/**
    * 获取用户列表数据
    * @param user
    * @param pageNo
    * @param pageSize
    * @param req
    * @return
    */
   @PermissionData(pageComponent = "system/UserList")
@RequestMapping(value = "/list", method = RequestMethod.GET)
public Result<IPage<SysUser>> queryPageList(SysUser user,@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
								  @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,HttpServletRequest req) {
	Result<IPage<SysUser>> result = new Result<IPage<SysUser>>();
	QueryWrapper<SysUser> queryWrapper = QueryGenerator.initQueryWrapper(user, req.getParameterMap());
   	//TODO 外部模拟登陆临时账号,列表不显示
       queryWrapper.ne("username","_reserve_user_external");
	Page<SysUser> page = new Page<SysUser>(pageNo, pageSize);
	IPage<SysUser> pageList = sysUserService.page(page, queryWrapper);

	//批量查询用户的所属部门
       //step.1 先拿到全部的 useids
       //step.2 通过 useids,一次性查询用户的所属部门名字
       List<String> userIds = pageList.getRecords().stream().map(SysUser::getId).collect(Collectors.toList());
       if(userIds!=null && userIds.size()>0){
           Map<String,String>  useDepNames = sysUserService.getDepNamesByUserIds(userIds);
           pageList.getRecords().forEach(item->{
               //TODO 临时借用这个字段用于页面展示
               item.setOrgCode(useDepNames.get(item.getId()));
           });
       }
	result.setSuccess(true);
	result.setResult(pageList);
	log.info(pageList.toString());
	return result;
}
 
Example 8
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 9
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 10
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 11
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 12
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 13
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;
}