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

The following examples show how to use com.baomidou.mybatisplus.core.conditions.query.QueryWrapper#in() . 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: SysUserController.java    From jeecg-boot with Apache License 2.0 8 votes vote down vote up
/**
   * 导出excel
   *
   * @param request
   * @param response
   */
  @RequestMapping(value = "/exportXls")
  public ModelAndView exportXls(SysUser sysUser,HttpServletRequest request) {
      // Step.1 组装查询条件
      QueryWrapper<SysUser> queryWrapper = QueryGenerator.initQueryWrapper(sysUser, request.getParameterMap());
      //Step.2 AutoPoi 导出Excel
      ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
      //update-begin--Author:kangxiaolin  Date:20180825 for:[03]用户导出,如果选择数据则只导出相关数据--------------------
      String selections = request.getParameter("selections");
     if(!oConvertUtils.isEmpty(selections)){
         queryWrapper.in("id",selections.split(","));
     }
      //update-end--Author:kangxiaolin  Date:20180825 for:[03]用户导出,如果选择数据则只导出相关数据----------------------
      List<SysUser> pageList = sysUserService.list(queryWrapper);

      //导出文件名称
      mv.addObject(NormalExcelConstants.FILE_NAME, "用户列表");
      mv.addObject(NormalExcelConstants.CLASS, SysUser.class);
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
      ExportParams exportParams = new ExportParams("用户列表数据", "导出人:"+user.getRealname(), "导出信息");
      exportParams.setImageBasePath(upLoadPath);
      mv.addObject(NormalExcelConstants.PARAMS, exportParams);
      mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
      return mv;
  }
 
Example 2
Source File: SysUserController.java    From jeecg-cloud with Apache License 2.0 8 votes vote down vote up
/**
   * 导出excel
   *
   * @param request
   */
  @RequestMapping(value = "/exportXls")
  public ModelAndView exportXls(SysUser sysUser,HttpServletRequest request) {
      // Step.1 组装查询条件
      QueryWrapper<SysUser> queryWrapper = QueryGenerator.initQueryWrapper(sysUser, request.getParameterMap());
      //Step.2 AutoPoi 导出Excel
      ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
      //update-begin--Author:kangxiaolin  Date:20180825 for:[03]用户导出,如果选择数据则只导出相关数据--------------------
      String selections = request.getParameter("selections");
     if(!oConvertUtils.isEmpty(selections)){
         queryWrapper.in("id",selections.split(","));
     }
      //update-end--Author:kangxiaolin  Date:20180825 for:[03]用户导出,如果选择数据则只导出相关数据----------------------
      List<SysUser> pageList = sysUserService.list(queryWrapper);

      //导出文件名称
      mv.addObject(NormalExcelConstants.FILE_NAME, "用户列表");
      mv.addObject(NormalExcelConstants.CLASS, SysUser.class);
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
      ExportParams exportParams = new ExportParams("用户列表数据", "导出人:"+user.getRealname(), "导出信息");
      exportParams.setImageBasePath(upLoadPath);
      mv.addObject(NormalExcelConstants.PARAMS, exportParams);
      mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
      return mv;
  }
 
Example 3
Source File: SysDepartRoleController.java    From teaching with Apache License 2.0 6 votes vote down vote up
/**
 * 分页列表查询
 *
 * @param sysDepartRole
 * @param pageNo
 * @param pageSize
 * @param req
 * @return
 */
@AutoLog(value = "部门角色-分页列表查询")
@ApiOperation(value="部门角色-分页列表查询", notes="部门角色-分页列表查询")
@GetMapping(value = "/list")
public Result<?> queryPageList(SysDepartRole sysDepartRole,
							   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
							   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
							   @RequestParam(name="deptId",required=false) String deptId,
							   HttpServletRequest req) {
	QueryWrapper<SysDepartRole> queryWrapper = QueryGenerator.initQueryWrapper(sysDepartRole, req.getParameterMap());
	Page<SysDepartRole> page = new Page<SysDepartRole>(pageNo, pageSize);
	LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
	List<String> deptIds = null;
	if(oConvertUtils.isEmpty(deptId)){
		if(oConvertUtils.isNotEmpty(user.getIdentity()) && user.getIdentity() == CommonConstant.USER_IDENTITY_2 ){
			deptIds = sysDepartService.getMySubDepIdsByDepId(user.getDepartIds());
		}else{
			return Result.ok(null);
		}
	}else{
		deptIds = sysDepartService.getSubDepIdsByDepId(deptId);
	}
	queryWrapper.in("depart_id",deptIds);
	IPage<SysDepartRole> pageList = sysDepartRoleService.page(page, queryWrapper);
	return Result.ok(pageList);
}
 
Example 4
Source File: CategoryMenuServiceImpl.java    From mogu_blog_v2 with Apache License 2.0 6 votes vote down vote up
@Override
public String deleteCategoryMenu(CategoryMenuVO categoryMenuVO) {
    QueryWrapper<CategoryMenu> queryWrapper = new QueryWrapper<>();
    queryWrapper.eq(SQLConf.STATUS, EStatus.ENABLE);
    queryWrapper.in(SQLConf.PARENT_UID, categoryMenuVO.getUid());
    Integer menuCount = categoryMenuService.count(queryWrapper);
    if (menuCount > 0) {
        return ResultUtil.result(SysConf.ERROR, MessageConf.CHILDREN_MENU_UNDER_THIS_MENU);
    }

    CategoryMenu categoryMenu = categoryMenuService.getById(categoryMenuVO.getUid());
    categoryMenu.setStatus(EStatus.DISABLED);
    categoryMenu.setUpdateTime(new Date());
    categoryMenu.updateById();

    // 修改成功后,需要删除redis中所有的admin访问路径
    deleteAdminVisitUrl();

    return ResultUtil.result(SysConf.SUCCESS, MessageConf.DELETE_SUCCESS);
}
 
Example 5
Source File: SysUserController.java    From teaching with Apache License 2.0 6 votes vote down vote up
/**
   * 导出excel
   *
   * @param request
   * @param response
   */
  @RequestMapping(value = "/exportXls")
  public ModelAndView exportXls(SysUser sysUser,HttpServletRequest request) {
      // Step.1 组装查询条件
      QueryWrapper<SysUser> queryWrapper = QueryGenerator.initQueryWrapper(sysUser, request.getParameterMap());
      //Step.2 AutoPoi 导出Excel
      ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
      //update-begin--Author:kangxiaolin  Date:20180825 for:[03]用户导出,如果选择数据则只导出相关数据--------------------
      String selections = request.getParameter("selections");
     if(!oConvertUtils.isEmpty(selections)){
         queryWrapper.in("id",selections.split(","));
     }
      //update-end--Author:kangxiaolin  Date:20180825 for:[03]用户导出,如果选择数据则只导出相关数据----------------------
      List<SysUser> pageList = sysUserService.list(queryWrapper);

      //导出文件名称
      mv.addObject(NormalExcelConstants.FILE_NAME, "用户列表");
      mv.addObject(NormalExcelConstants.CLASS, SysUser.class);
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
      mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("用户列表数据", "导出人:"+user.getRealname(), "导出信息"));
      mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
      return mv;
  }
 
Example 6
Source File: SysUserController.java    From jeecg-boot-with-activiti with MIT License 6 votes vote down vote up
/**
   * 导出excel
   *
   * @param request
   * @param response
   */
  @RequestMapping(value = "/exportXls")
  public ModelAndView exportXls(SysUser sysUser,HttpServletRequest request) {
      // Step.1 组装查询条件
      QueryWrapper<SysUser> queryWrapper = QueryGenerator.initQueryWrapper(sysUser, request.getParameterMap());
      //Step.2 AutoPoi 导出Excel
      ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
      //update-begin--Author:kangxiaolin  Date:20180825 for:[03]用户导出,如果选择数据则只导出相关数据--------------------
      String selections = request.getParameter("selections");
     if(!oConvertUtils.isEmpty(selections)){
         queryWrapper.in("id",selections.split(","));
     }
      //update-end--Author:kangxiaolin  Date:20180825 for:[03]用户导出,如果选择数据则只导出相关数据----------------------
      List<SysUser> pageList = sysUserService.list(queryWrapper);

      //导出文件名称
      mv.addObject(NormalExcelConstants.FILE_NAME, "用户列表");
      mv.addObject(NormalExcelConstants.CLASS, SysUser.class);
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
      mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("用户列表数据", "导出人:"+user.getRealname(), "导出信息"));
      mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
      return mv;
  }
 
Example 7
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 8
Source File: SysBaseApiImpl.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
@Override
public List<LoginUser> queryAllUserByIds(String[] userIds) {
	QueryWrapper<SysUser> queryWrapper = new QueryWrapper<SysUser>().eq("status",1).eq("del_flag",0);
	queryWrapper.in("id",userIds);
	List<LoginUser> loginUsers = new ArrayList<>();
	List<SysUser> sysUsers = userMapper.selectList(queryWrapper);
	for (SysUser user:sysUsers) {
		LoginUser loginUser=new LoginUser();
		BeanUtils.copyProperties(user, loginUser);
		loginUsers.add(loginUser);
	}
	return loginUsers;
}
 
Example 9
Source File: SysBaseApiImpl.java    From jeecg-cloud with Apache License 2.0 5 votes vote down vote up
@Override
public List<LoginUser> queryUserByNames(String[] userNames) {
	QueryWrapper<SysUser> queryWrapper = new QueryWrapper<SysUser>().eq("status",1).eq("del_flag",0);
	queryWrapper.in("username",userNames);
	List<LoginUser> loginUsers = new ArrayList<>();
	List<SysUser> sysUsers = userMapper.selectList(queryWrapper);
	for (SysUser user:sysUsers) {
		LoginUser loginUser=new LoginUser();
		BeanUtils.copyProperties(user, loginUser);
		loginUsers.add(loginUser);
	}
	return loginUsers;
}
 
Example 10
Source File: SysBaseApiImpl.java    From jeecg-cloud with Apache License 2.0 5 votes vote down vote up
@Override
public List<LoginUser> queryAllUserByIds(String[] userIds) {
	QueryWrapper<SysUser> queryWrapper = new QueryWrapper<SysUser>().eq("status",1).eq("del_flag",0);
	queryWrapper.in("id",userIds);
	List<LoginUser> loginUsers = new ArrayList<>();
	List<SysUser> sysUsers = userMapper.selectList(queryWrapper);
	for (SysUser user:sysUsers) {
		LoginUser loginUser=new LoginUser();
		BeanUtils.copyProperties(user, loginUser);
		loginUsers.add(loginUser);
	}
	return loginUsers;
}
 
Example 11
Source File: SysDictTypeServiceImpl.java    From mogu_blog_v2 with Apache License 2.0 5 votes vote down vote up
@Override
public String deleteBatchSysDictType(List<SysDictTypeVO> sysDictTypeVOList) {
    HttpServletRequest request = RequestHolder.getRequest();
    String adminUid = request.getAttribute(SysConf.ADMIN_UID).toString();
    if (sysDictTypeVOList.size() <= 0) {
        return ResultUtil.result(SysConf.ERROR, MessageConf.PARAM_INCORRECT);
    }
    List<String> uids = new ArrayList<>();
    sysDictTypeVOList.forEach(item -> {
        uids.add(item.getUid());
    });

    // 判断要删除的分类,是否有博客
    QueryWrapper<SysDictData> queryWrapper = new QueryWrapper<>();
    queryWrapper.eq(SQLConf.STATUS, EStatus.ENABLE);
    queryWrapper.in(SQLConf.DICT_TYPE_UID, uids);
    Integer count = sysDictDataService.count(queryWrapper);
    if (count > 0) {
        return ResultUtil.result(SysConf.ERROR, MessageConf.DICT_DATA_UNDER_THIS_SORT);
    }
    Collection<SysDictType> sysDictTypeList = sysDictTypeService.listByIds(uids);
    sysDictTypeList.forEach(item -> {
        item.setStatus(EStatus.DISABLED);
        item.setUpdateByUid(adminUid);
    });

    Boolean save = sysDictTypeService.updateBatchById(sysDictTypeList);

    // 获取Redis中特定前缀
    Set<String> keys = redisUtil.keys(SysConf.REDIS_DICT_TYPE + SysConf.REDIS_SEGMENTATION + "*");
    redisUtil.delete(keys);
    if (save) {
        return ResultUtil.result(SysConf.SUCCESS, MessageConf.DELETE_SUCCESS);
    } else {
        return ResultUtil.result(SysConf.ERROR, MessageConf.DELETE_FAIL);
    }
}
 
Example 12
Source File: ResourceSortServiceImpl.java    From mogu_blog_v2 with Apache License 2.0 5 votes vote down vote up
@Override
public String deleteBatchResourceSort(List<ResourceSortVO> resourceSortVOList) {
    if (resourceSortVOList.size() <= 0) {
        return ResultUtil.result(BaseSysConf.ERROR, BaseMessageConf.PARAM_INCORRECT);
    }
    List<String> uids = new ArrayList<>();
    resourceSortVOList.forEach(item -> {
        uids.add(item.getUid());
    });

    // 判断要删除的分类,是否有资源
    QueryWrapper<StudyVideo> studyVideoQueryWrapper = new QueryWrapper<>();
    studyVideoQueryWrapper.eq(BaseSQLConf.STATUS, EStatus.ENABLE);
    studyVideoQueryWrapper.in(BaseSQLConf.RESOURCE_SORT_UID, uids);
    Integer count = studyVideoService.count(studyVideoQueryWrapper);
    if (count > 0) {
        return ResultUtil.result(BaseSysConf.ERROR, BaseMessageConf.RESOURCE_UNDER_THIS_SORT);
    }

    Collection<ResourceSort> resourceSortList = resourceSortService.listByIds(uids);

    resourceSortList.forEach(item -> {
        item.setUpdateTime(new Date());
        item.setStatus(EStatus.DISABLED);
    });

    Boolean save = resourceSortService.updateBatchById(resourceSortList);

    if (save) {
        return ResultUtil.result(BaseSysConf.SUCCESS, BaseMessageConf.DELETE_SUCCESS);
    } else {
        return ResultUtil.result(BaseSysConf.ERROR, BaseMessageConf.DELETE_FAIL);
    }
}
 
Example 13
Source File: TagServiceImpl.java    From mogu_blog_v2 with Apache License 2.0 5 votes vote down vote up
@Override
public String deleteBatchTag(List<TagVO> tagVOList) {
    if (tagVOList.size() <= 0) {
        return ResultUtil.result(SysConf.ERROR, MessageConf.PARAM_INCORRECT);
    }
    List<String> uids = new ArrayList<>();
    tagVOList.forEach(item -> {
        uids.add(item.getUid());
    });

    // 判断要删除的分类,是否有博客
    QueryWrapper<Blog> blogQueryWrapper = new QueryWrapper<>();
    blogQueryWrapper.eq(SQLConf.STATUS, EStatus.ENABLE);
    blogQueryWrapper.in(SQLConf.TAG_UID, uids);
    Integer blogCount = blogService.count(blogQueryWrapper);
    if (blogCount > 0) {
        return ResultUtil.result(SysConf.ERROR, MessageConf.BLOG_UNDER_THIS_TAG);
    }

    Collection<Tag> tagList = tagService.listByIds(uids);

    tagList.forEach(item -> {
        item.setUpdateTime(new Date());
        item.setStatus(EStatus.DISABLED);
    });

    Boolean save = tagService.updateBatchById(tagList);

    if (save) {
        return ResultUtil.result(SysConf.SUCCESS, MessageConf.DELETE_SUCCESS);
    } else {
        return ResultUtil.result(SysConf.ERROR, MessageConf.DELETE_FAIL);
    }
}
 
Example 14
Source File: FileRestApi.java    From mogu_blog_v2 with Apache License 2.0 4 votes vote down vote up
/**
 * 获取文件的信息接口
 * fileIds 获取文件信息的ids
 * code ids用什么分割的,默认“,”
 *
 * @return
 */

@ApiOperation(value = "通过fileIds获取图片信息接口", notes = "获取图片信息接口")
@GetMapping("/getPicture")
public String getPicture(
        @ApiParam(name = "fileIds", value = "文件ids", required = false) @RequestParam(name = "fileIds", required = false) String fileIds,
        @ApiParam(name = "code", value = "切割符", required = false) @RequestParam(name = "code", required = false) String code) {

    if (StringUtils.isEmpty(code)) {
        code = ",";
    }
    if (StringUtils.isEmpty(fileIds)) {
        return ResultUtil.result(SysConf.ERROR, "数据错误");
    } else {
        List<Map<String, Object>> list = new ArrayList<>();
        List<String> changeStringToString = StringUtils.changeStringToString(fileIds, code);
        QueryWrapper<com.moxi.mogublog.picture.entity.File> queryWrapper = new QueryWrapper<>();
        queryWrapper.in(SQLConf.UID, changeStringToString);
        List<com.moxi.mogublog.picture.entity.File> fileList = fileService.list(queryWrapper);
        if (fileList.size() > 0) {
            for (com.moxi.mogublog.picture.entity.File file : fileList) {
                if (file != null) {
                    Map<String, Object> remap = new HashMap<>();

                    // 获取七牛云地址
                    remap.put(SysConf.QI_NIU_URL, file.getQiNiuUrl());

                    // 获取本地地址
                    remap.put(SysConf.URL, file.getPicUrl());

                    // 后缀名,也就是类型
                    remap.put(SysConf.EXPANDED_NAME, file.getPicExpandedName());

                    remap.put(SysConf.FILE_OLD_NAME, file.getFileOldName());

                    //名称
                    remap.put(SysConf.NAME, file.getPicName());
                    remap.put(SysConf.UID, file.getUid());
                    remap.put("file_old_name", file.getFileOldName());
                    list.add(remap);
                }
            }
        }
        return ResultUtil.result(SysConf.SUCCESS, list);
    }
}
 
Example 15
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 16
Source File: RoleResourceService.java    From SpringCloud with Apache License 2.0 4 votes vote down vote up
@Override
public List<RoleResource> queryByRoleIds(Set<String> roleIds) {
    QueryWrapper<RoleResource> queryWrapper = new QueryWrapper<>();
    queryWrapper.in("role_id", roleIds);
    return this.list(queryWrapper);
}
 
Example 17
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 18
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;
}
 
Example 19
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 20
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;
	}
}