Java Code Examples for com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper#and()

The following examples show how to use com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper#and() . 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-cloud with Apache License 2.0 6 votes vote down vote up
/**
 * 【APP端接口】获取用户列表  根据用户名和真实名 模糊匹配
 * @param keyword
 * @param pageNo
 * @param pageSize
 * @return
 */
@GetMapping("/appUserList")
public Result<?> appUserList(@RequestParam(name = "keyword", required = false) String keyword,
           @RequestParam(name = "username", required = false) String username,
		@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
		@RequestParam(name="pageSize", defaultValue="10") Integer pageSize) {
	try {
		//TODO 从查询效率上将不要用mp的封装的page分页查询 建议自己写分页语句
		LambdaQueryWrapper<SysUser> query = new LambdaQueryWrapper<SysUser>();
		query.eq(SysUser::getActivitiSync, "1");
		query.eq(SysUser::getDelFlag,"0");
		if(oConvertUtils.isNotEmpty(username)){
		    query.eq(SysUser::getUsername,username);
           }else{
               query.and(i -> i.like(SysUser::getUsername, keyword).or().like(SysUser::getRealname, keyword));
           }
		Page<SysUser> page = new Page<>(pageNo, pageSize);
		IPage<SysUser> res = this.sysUserService.page(page, query);
		return Result.ok(res);
	} catch (Exception e) {
		log.error(e.getMessage(), e);
		return Result.error(500, "查询失败:" + e.getMessage());
	}
	
}
 
Example 2
Source File: SysUserController.java    From jeecg-boot-with-activiti with MIT License 6 votes vote down vote up
/**
 * 获取用户列表  根据用户名和真实名 模糊匹配
 * @param keyword
 * @param pageNo
 * @param pageSize
 * @return
 */
@GetMapping("/appUserList")
public Result<?> appUserList(@RequestParam(name = "keyword", required = false) String keyword,
		@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
		@RequestParam(name="pageSize", defaultValue="10") Integer pageSize) {
	try {
		//TODO 从查询效率上将不要用mp的封装的page分页查询 建议自己写分页语句
		LambdaQueryWrapper<SysUser> query = new LambdaQueryWrapper<SysUser>();
		query.eq(SysUser::getActivitiSync, "1");
		query.eq(SysUser::getDelFlag,"0");
		query.and(i -> i.like(SysUser::getUsername, keyword).or().like(SysUser::getRealname, keyword));
		
		Page<SysUser> page = new Page<>(pageNo, pageSize);
		IPage<SysUser> res = this.sysUserService.page(page, query);
		return Result.ok(res);
	} catch (Exception e) {
		log.error(e.getMessage(), e);
		return Result.error(500, "查询失败:" + e.getMessage());
	}
	
}
 
Example 3
Source File: SysUserController.java    From teaching with Apache License 2.0 6 votes vote down vote up
/**
 * 获取用户列表  根据用户名和真实名 模糊匹配
 * @param keyword
 * @param pageNo
 * @param pageSize
 * @return
 */
@GetMapping("/appUserList")
public Result<?> appUserList(@RequestParam(name = "keyword", required = false) String keyword,
		@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
		@RequestParam(name="pageSize", defaultValue="10") Integer pageSize) {
	try {
		//TODO 从查询效率上将不要用mp的封装的page分页查询 建议自己写分页语句
		LambdaQueryWrapper<SysUser> query = new LambdaQueryWrapper<SysUser>();
		query.eq(SysUser::getActivitiSync, "1");
		query.eq(SysUser::getDelFlag,"0");
		query.and(i -> i.like(SysUser::getUsername, keyword).or().like(SysUser::getRealname, keyword));
		
		Page<SysUser> page = new Page<>(pageNo, pageSize);
		IPage<SysUser> res = this.sysUserService.page(page, query);
		return Result.ok(res);
	} catch (Exception e) {
		log.error(e.getMessage(), e);
		return Result.error(500, "查询失败:" + e.getMessage());
	}
	
}
 
Example 4
Source File: SysUserController.java    From jeecg-boot with Apache License 2.0 6 votes vote down vote up
/**
 * 【APP端接口】获取用户列表  根据用户名和真实名 模糊匹配
 * @param keyword
 * @param pageNo
 * @param pageSize
 * @return
 */
@GetMapping("/appUserList")
public Result<?> appUserList(@RequestParam(name = "keyword", required = false) String keyword,
           @RequestParam(name = "username", required = false) String username,
		@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
		@RequestParam(name="pageSize", defaultValue="10") Integer pageSize) {
	try {
		//TODO 从查询效率上将不要用mp的封装的page分页查询 建议自己写分页语句
		LambdaQueryWrapper<SysUser> query = new LambdaQueryWrapper<SysUser>();
		query.eq(SysUser::getActivitiSync, "1");
		query.eq(SysUser::getDelFlag,"0");
		if(oConvertUtils.isNotEmpty(username)){
		    query.eq(SysUser::getUsername,username);
           }else{
               query.and(i -> i.like(SysUser::getUsername, keyword).or().like(SysUser::getRealname, keyword));
           }
		Page<SysUser> page = new Page<>(pageNo, pageSize);
		IPage<SysUser> res = this.sysUserService.page(page, query);
		return Result.ok(res);
	} catch (Exception e) {
		log.error(e.getMessage(), e);
		return Result.error(500, "查询失败:" + e.getMessage());
	}
	
}
 
Example 5
Source File: FriendshipLinkServiceImpl.java    From plumemo with Apache License 2.0 5 votes vote down vote up
public List<FriendshipLinkVO> getFriendshipLinkVOList(FriendshipLinkVO friendshipLinkVO,Page<FriendshipLink> page) {
    LambdaQueryWrapper<FriendshipLink> objectLambdaQueryWrapper = new LambdaQueryWrapper<>();
    if (StringUtils.isNotBlank(friendshipLinkVO.getKeywords())) {
        objectLambdaQueryWrapper.and(i -> i.like(FriendshipLink::getName, friendshipLinkVO.getKeywords()));
    }
    if (StringUtils.isNotBlank(friendshipLinkVO.getHref())) {
        objectLambdaQueryWrapper.like(FriendshipLink::getHref,friendshipLinkVO.getHref());
    }
    if (StringUtils.isNotBlank(friendshipLinkVO.getName())) {
        objectLambdaQueryWrapper.eq(FriendshipLink::getName,friendshipLinkVO.getName());
    }
    List<FriendshipLink> friendshipLinks;
    if (null==page){
        friendshipLinks=friendshipLinkDao.selectList(objectLambdaQueryWrapper.orderByDesc(FriendshipLink::getSort));
    }else{
        friendshipLinks=friendshipLinkDao.selectPage(page, objectLambdaQueryWrapper.orderByDesc(FriendshipLink::getSort)).getRecords();
    }
    List<FriendshipLinkVO> friendshipLinkVOList = new ArrayList<>();
    if (!CollectionUtils.isEmpty(friendshipLinks)) {
        friendshipLinks.forEach(friendshipLink -> {
            friendshipLinkVOList.add(new FriendshipLinkVO()
                    .setName(friendshipLink.getName())
                    .setTitle(friendshipLink.getTitle())
                    .setDescription(friendshipLink.getDescription())
                    .setHref(friendshipLink.getHref())
                    .setLogo(friendshipLink.getLogo())
                    .setId(friendshipLink.getId())
                    .setSort(friendshipLink.getSort())
            );
        });
    }
    return friendshipLinkVOList;
}