Java Code Examples for com.baomidou.mybatisplus.core.conditions.query.QueryWrapper

The following examples show how to use com.baomidou.mybatisplus.core.conditions.query.QueryWrapper. These examples are extracted from open source projects. 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 Project: jeecg-boot   Source File: JeecgDemoController.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 分页列表查询
 *
 * @param jeecgDemo
 * @param pageNo
 * @param pageSize
 * @param req
 * @return
 */
@ApiOperation(value = "获取Demo数据列表", notes = "获取所有Demo数据列表")
@GetMapping(value = "/list")
@PermissionData(pageComponent = "jeecg/JeecgDemoList")
public Result<?> list(JeecgDemo jeecgDemo, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                      HttpServletRequest req) {
    QueryWrapper<JeecgDemo> queryWrapper = QueryGenerator.initQueryWrapper(jeecgDemo, req.getParameterMap());
    Page<JeecgDemo> page = new Page<JeecgDemo>(pageNo, pageSize);

    IPage<JeecgDemo> pageList = jeecgDemoService.page(page, queryWrapper);
    log.info("查询当前页:" + pageList.getCurrent());
    log.info("查询当前页数量:" + pageList.getSize());
    log.info("查询结果数量:" + pageList.getRecords().size());
    log.info("数据总数:" + pageList.getTotal());
    return Result.ok(pageList);
}
 
Example 2
Source Project: jeecg-cloud   Source File: SysDepartController.java    License: Apache License 2.0 6 votes vote down vote up
/**
  * 导出excel
  *
  * @param request
  */
 @RequestMapping(value = "/exportXls")
 public ModelAndView exportXls(SysDepart sysDepart,HttpServletRequest request) {
     // Step.1 组装查询条件
     QueryWrapper<SysDepart> queryWrapper = QueryGenerator.initQueryWrapper(sysDepart, request.getParameterMap());
     //Step.2 AutoPoi 导出Excel
     ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
     List<SysDepart> pageList = sysDepartService.list(queryWrapper);
     //按字典排序
     Collections.sort(pageList, new Comparator<SysDepart>() {
         @Override
public int compare(SysDepart arg0, SysDepart arg1) {
         	return arg0.getOrgCode().compareTo(arg1.getOrgCode());
         }
     });
     //导出文件名称
     mv.addObject(NormalExcelConstants.FILE_NAME, "部门列表");
     mv.addObject(NormalExcelConstants.CLASS, SysDepart.class);
     LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
     mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("部门列表数据", "导出人:"+user.getRealname(), "导出信息"));
     mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
     return mv;
 }
 
Example 3
Source Project: sophia_scaffolding   Source File: PermissionServiceImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Transactional(rollbackFor = CommonException.class)
@Override
public boolean deletePermission(String id) {
    boolean flag = false;
    List<Permission> permissions = baseMapper.selectList(new QueryWrapper<Permission>().eq("STATUS", 1).orderByAsc("SORT").orderByDesc("CREATE_TIME"));
    if (permissions.size() > 0) {
        List<Permission> chilrenPermissionList = new LinkedList<>();
        childPermissionList(permissions, id, chilrenPermissionList);
        chilrenPermissionList = chilrenPermissionList.parallelStream().distinct().collect(Collectors.toList());
        if (chilrenPermissionList.size() > 0) {
            List<String> ids = chilrenPermissionList.parallelStream().map(Permission::getId).collect(Collectors.toList());
            if (ids.size() > 0) {
                List<RolePermission> list = rolePermissionMapper.selectBatchPerIds(ids);
                if (list.size() > 0) {
                    rolePermissionMapper.deleteBatchIds(list.stream().map(RolePermission::getId).collect(Collectors.toList()));
                }
                flag = baseMapper.updateBatchIds(ids) > 0;
            }
        }
    }
    return flag;
}
 
Example 4
/**
 * 导出excel
 *
 * @param request
 */
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(SysAnnouncement sysAnnouncement,HttpServletRequest request) {
    // Step.1 组装查询条件
    QueryWrapper<SysAnnouncement> queryWrapper = QueryGenerator.initQueryWrapper(sysAnnouncement, request.getParameterMap());
    //Step.2 AutoPoi 导出Excel
    ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
    List<SysAnnouncement> pageList = sysAnnouncementService.list(queryWrapper);
    //导出文件名称
    mv.addObject(NormalExcelConstants.FILE_NAME, "系统通告列表");
    mv.addObject(NormalExcelConstants.CLASS, SysAnnouncement.class);
    LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
    mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("系统通告列表数据", "导出人:"+user.getRealname(), "导出信息"));
    mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
    return mv;
}
 
Example 5
@Override
public void saveDeptRolePermission(String roleId, String permissionIds, String lastPermissionIds) {
    List<String> add = getDiff(lastPermissionIds,permissionIds);
    if(add!=null && add.size()>0) {
        List<SysDepartRolePermission> list = new ArrayList<SysDepartRolePermission>();
        for (String p : add) {
            if(oConvertUtils.isNotEmpty(p)) {
                SysDepartRolePermission rolepms = new SysDepartRolePermission(roleId, p);
                list.add(rolepms);
            }
        }
        this.saveBatch(list);
    }

    List<String> delete = getDiff(permissionIds,lastPermissionIds);
    if(delete!=null && delete.size()>0) {
        for (String permissionId : delete) {
            this.remove(new QueryWrapper<SysDepartRolePermission>().lambda().eq(SysDepartRolePermission::getRoleId, roleId).eq(SysDepartRolePermission::getPermissionId, permissionId));
        }
    }
}
 
Example 6
Source Project: Moss   Source File: DictServiceImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public PageResult<DictTypeListVO> findByPageVague(DictTypeListRequest dictTypeListRequest) {
    Page pageRequest = new Page(dictTypeListRequest.getPageNo(),dictTypeListRequest.getPageSize());
    QueryWrapper<DictType> queryWrapper = new QueryWrapper<>();
    if(StringUtils.isNotEmpty(dictTypeListRequest.getDictCode())){
        queryWrapper.like("dict_code",dictTypeListRequest.getDictCode());
    }
    if(StringUtils.isNotEmpty(dictTypeListRequest.getDictName())){
        queryWrapper.like("dict_name",dictTypeListRequest.getDictName());
    }
    queryWrapper.eq("is_deleted",Constants.IS_DELETE_FALSE);
    IPage<DictType> page=dictTypeMapper.selectPage(pageRequest, queryWrapper);
    List<DictTypeListVO> list= BeanMapper.mapList(page.getRecords(),DictType.class,DictTypeListVO.class);
    for (DictTypeListVO dictTypeListVO:list) {
        List<DictData> dictDataList= dictDataMapper.findDictDataByDictCode(dictTypeListVO.getDictCode());
        dictTypeListVO.setDictDataModelList(BeanMapper.mapList(dictDataList,DictData.class,DictDataModel.class));
    }
    PageResult<DictTypeListVO> pageResult=new PageResult<DictTypeListVO>();
    pageResult.setCurrentPage(page.getCurrent());
    pageResult.setTotalCount(page.getTotal());
    pageResult.setList(list);
    pageResult.setTotalPage(page.getSize());
    return pageResult;
}
 
Example 7
Source Project: jeecg-boot-with-activiti   Source File: SysUserController.java    License: MIT License 6 votes vote down vote up
/**
 * 批量删除指定角色的用户关系
 *
 * @param
 * @return
 */
@RequestMapping(value = "/deleteUserRoleBatch", method = RequestMethod.DELETE)
public Result<SysUserRole> deleteUserRoleBatch(
        @RequestParam(name="roleId") String roleId,
        @RequestParam(name="userIds",required=true) String userIds) {
    Result<SysUserRole> result = new Result<SysUserRole>();
    try {
        QueryWrapper<SysUserRole> queryWrapper = new QueryWrapper<SysUserRole>();
        queryWrapper.eq("role_id", roleId).in("user_id",Arrays.asList(userIds.split(",")));
        sysUserRoleService.remove(queryWrapper);
        result.success("删除成功!");
    }catch(Exception e) {
        log.error(e.getMessage(), e);
        result.error500("删除失败!");
    }
    return result;
}
 
Example 8
Source Project: spring-boot-demo   Source File: CrudTest.java    License: MIT License 6 votes vote down vote up
@Test
public void testTableFieldExistFalse() {
    QueryWrapper<User> wrapper = new QueryWrapper<>();
    wrapper.select("age, count(age) as count")
            .groupBy("age");
    List<User> list = mapper.selectList(wrapper);
    list.forEach(System.out::println);
    list.forEach(x -> {
        Assert.assertNull(x.getId());
        Assert.assertNotNull(x.getAge());
        Assert.assertNotNull(x.getCount());
    });
    mapper.insert(
            new User().setId(10088L)
                    .setName("miemie")
                    .setEmail("[email protected]")
                    .setAge(3));
    User miemie = mapper.selectById(10088L);
    Assert.assertNotNull(miemie);

}
 
Example 9
Source Project: supplierShop   Source File: GoodsServiceImpl.java    License: MIT License 6 votes vote down vote up
/**
 * 购物车列表
 * @param pageVO
 * @param userId
 * @return
 */
@Override
public List<CartDTO> cartList(PageVO pageVO,int userId) {
    QueryWrapper<StoreCart> cartQueryWrapper = new QueryWrapper<>();
    cartQueryWrapper.eq("user_id",userId).groupBy("goods_id");
    Page<StoreCart> pageModel = new Page<>(pageVO.getPage(), pageVO.getLimit());
    IPage<StoreCart> storeCarts = storeCartMapper
            .selectPage(pageModel,cartQueryWrapper);
    List<StoreCart> storeCartList = storeCarts.getRecords();
    List<CartDTO> carts = new ArrayList<>();

    for (StoreCart storeCart : storeCartList) {
        CartDTO cartDTO = new CartDTO();
        StoreGoods storeGoods = getById(storeCart.getGoodsId());
        cartDTO.setGoodsId(storeCart.getGoodsId());
        cartDTO.setGoodsName(storeGoods.getGoodsName());
        cartDTO.setGoodsSn(storeGoods.getGoodsSn());
        cartDTO.setGoodsLogo(storeGoods.getGoodsLogo());
        QueryWrapper<StoreCart> wrapper = new QueryWrapper<>();
        wrapper.eq("user_id",userId).eq("goods_id",storeCart.getGoodsId());
        cartDTO.setSpecList(cartMapper.toDto(storeCartMapper.selectList(wrapper)));
        carts.add(cartDTO);
    }
    return carts;
}
 
Example 10
Source Project: jeecg-boot-with-activiti   Source File: SysDepartController.java    License: MIT License 6 votes vote down vote up
/**
  * 导出excel
  *
  * @param request
  * @param response
  */
 @RequestMapping(value = "/exportXls")
 public ModelAndView exportXls(SysDepart sysDepart,HttpServletRequest request) {
     // Step.1 组装查询条件
     QueryWrapper<SysDepart> queryWrapper = QueryGenerator.initQueryWrapper(sysDepart, request.getParameterMap());
     //Step.2 AutoPoi 导出Excel
     ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
     List<SysDepart> pageList = sysDepartService.list(queryWrapper);
     //按字典排序
     Collections.sort(pageList, new Comparator<SysDepart>() {
         @Override
public int compare(SysDepart arg0, SysDepart arg1) {
         	return arg0.getOrgCode().compareTo(arg1.getOrgCode());
         }
     });
     //导出文件名称
     mv.addObject(NormalExcelConstants.FILE_NAME, "部门列表");
     mv.addObject(NormalExcelConstants.CLASS, SysDepart.class);
     LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
     mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("部门列表数据", "导出人:"+user.getRealname(), "导出信息"));
     mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
     return mv;
 }
 
Example 11
Source Project: jeecg-cloud   Source File: SysCategoryController.java    License: Apache License 2.0 6 votes vote down vote up
/**
  * 分页列表查询
 * @param sysCategory
 * @param pageNo
 * @param pageSize
 * @param req
 * @return
 */
@GetMapping(value = "/rootList")
public Result<IPage<SysCategory>> queryPageList(SysCategory sysCategory,
								  @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
								  @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
								  HttpServletRequest req) {
	if(oConvertUtils.isEmpty(sysCategory.getPid())){
		sysCategory.setPid("0");
	}
	Result<IPage<SysCategory>> result = new Result<IPage<SysCategory>>();
	
	//--author:os_chengtgen---date:20190804 -----for: 分类字典页面显示错误,issues:377--------start
	//QueryWrapper<SysCategory> queryWrapper = QueryGenerator.initQueryWrapper(sysCategory, req.getParameterMap());
	QueryWrapper<SysCategory> queryWrapper = new QueryWrapper<SysCategory>();
	queryWrapper.eq("pid", sysCategory.getPid());
	//--author:os_chengtgen---date:20190804 -----for: 分类字典页面显示错误,issues:377--------end
	
	Page<SysCategory> page = new Page<SysCategory>(pageNo, pageSize);
	IPage<SysCategory> pageList = sysCategoryService.page(page, queryWrapper);
	result.setSuccess(true);
	result.setResult(pageList);
	return result;
}
 
Example 12
Source Project: jeecg-boot-with-activiti   Source File: SysRoleController.java    License: MIT License 6 votes vote down vote up
/**
 * 导出excel
 * @param request
 * @param response
 */
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(SysRole sysRole,HttpServletRequest request) {
	// Step.1 组装查询条件
	QueryWrapper<SysRole> queryWrapper = QueryGenerator.initQueryWrapper(sysRole, request.getParameterMap());
	//Step.2 AutoPoi 导出Excel
	ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
	List<SysRole> pageList = sysRoleService.list(queryWrapper);
	//导出文件名称
	mv.addObject(NormalExcelConstants.FILE_NAME,"角色列表");
	mv.addObject(NormalExcelConstants.CLASS,SysRole.class);
	LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
	mv.addObject(NormalExcelConstants.PARAMS,new ExportParams("角色列表数据","导出人:"+user.getRealname(),"导出信息"));
	mv.addObject(NormalExcelConstants.DATA_LIST,pageList);
	return mv;
}
 
Example 13
Source Project: sophia_scaffolding   Source File: UserServiceImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public boolean updateRole(UserDto userDto) {
    UserRole userRole = userRoleMapper.selectOne(new QueryWrapper<UserRole>().eq("USER_ID", userDto.getId()));
    if (null == userRole) {
        UserRole userRole1 = new UserRole();
        userRole1.setId(UuidUtil.getUuid());
        userRole1.setUserId(userDto.getId());
        userRole1.setRoleId(userDto.getRoleId());
        return userRoleMapper.insert(userRole1) > 0;
    } else {
        if (!(userRole.getRoleId().equals(userDto.getRoleId()))) {
            userRole.setRoleId(userDto.getRoleId());
            return userRoleMapper.updateById(userRole) > 0;
        }
        return true;
    }
}
 
Example 14
Source Project: Guns   Source File: UserService.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * 修改用户
 *
 * @author fengshuonan
 * @Date 2018/12/24 22:53
 */
@Transactional(rollbackFor = Exception.class)
public void editUser(UserDto user) {
    User oldUser = this.getById(user.getUserId());

    if (LoginContextHolder.getContext().hasRole(Const.ADMIN_NAME)) {
        this.updateById(UserFactory.editUser(user, oldUser));
    } else {
        this.assertAuth(user.getUserId());
        LoginUser shiroUser = LoginContextHolder.getContext().getUser();
        if (shiroUser.getId().equals(user.getUserId())) {
            this.updateById(UserFactory.editUser(user, oldUser));
        } else {
            throw new ServiceException(BizExceptionEnum.NO_PERMITION);
        }
    }

    //删除职位关联
    userPosService.remove(new QueryWrapper<UserPos>().eq("user_id", user.getUserId()));

    //添加职位关联
    addPosition(user.getPosition(), user.getUserId());
}
 
Example 15
Source Project: mogu_blog_v2   Source File: SysDictTypeServiceImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public String addSysDictType(SysDictTypeVO sysDictTypeVO) {
    HttpServletRequest request = RequestHolder.getRequest();
    // 判断添加的字典类型是否存在
    QueryWrapper<SysDictType> queryWrapper = new QueryWrapper<>();
    queryWrapper.eq(SQLConf.DICT_TYPE, sysDictTypeVO.getDictType());
    queryWrapper.eq(SQLConf.STATUS, EStatus.ENABLE);
    queryWrapper.last("LIMIT 1");
    SysDictType temp = sysDictTypeService.getOne(queryWrapper);
    if (temp != null) {
        return ResultUtil.result(SysConf.ERROR, MessageConf.ENTITY_EXIST);
    }
    SysDictType sysDictType = new SysDictType();
    sysDictType.setDictName(sysDictTypeVO.getDictName());
    sysDictType.setDictType(sysDictTypeVO.getDictType());
    sysDictType.setRemark(sysDictTypeVO.getRemark());
    sysDictType.setIsPublish(sysDictTypeVO.getIsPublish());
    sysDictType.setSort(sysDictTypeVO.getSort());
    sysDictType.setCreateByUid(request.getAttribute(SysConf.ADMIN_UID).toString());
    sysDictType.setUpdateByUid(request.getAttribute(SysConf.ADMIN_UID).toString());
    sysDictType.insert();
    return ResultUtil.result(SysConf.SUCCESS, MessageConf.INSERT_SUCCESS);
}
 
Example 16
Source Project: yshopmall   Source File: DeptController.java    License: Apache License 2.0 6 votes vote down vote up
@Log("删除部门")
@ApiOperation("删除部门")
@DeleteMapping
@PreAuthorize("@el.check('admin','dept:del')")
public ResponseEntity<Object> delete(@RequestBody Set<Long> ids){

    List<Long> deptIds = new ArrayList<>();
    for (Long id : ids) {
        List<Dept> deptList = deptService.findByPid(id);
        Dept dept =  deptService.getOne(new QueryWrapper<Dept>().eq("id",id));
        if(null!=dept){
            deptIds.add(dept.getId());
        }
        if(CollectionUtil.isNotEmpty(deptList)){
            for(Dept d:deptList){
                deptIds.add(d.getId());
            }
        }
    }
    try {
        deptService.removeByIds(deptIds);
    }catch (Throwable e){
        throw new BadRequestException( "所选部门中存在岗位或者角色关联,请取消关联后再试");
    }
    return new ResponseEntity<>(HttpStatus.OK);
}
 
Example 17
Source Project: yshopmall   Source File: PictureServiceImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void synchronize() {
    //链式构建请求
    String result = HttpRequest.get(YshopConstant.Url.SM_MS_URL + "/v2/upload_history")
            //头信息,多个头信息多次调用此方法即可
            .header("Authorization", token)
            .timeout(20000)
            .execute().body();
    JSONObject jsonObject = JSONUtil.parseObj(result);
    List<Picture> pictures = JSON.parseArray(jsonObject.get("data").toString(), Picture.class);
    for (Picture picture : pictures) {
        if(this.getOne(new QueryWrapper<Picture>().eq("url",picture.getUrl()))==null){
            picture.setSize(FileUtil.getSize(Integer.parseInt(picture.getSize())));
            picture.setUsername("System Sync");
            picture.setMd5code(null);
            this.save(picture);
        }
    }
}
 
Example 18
Source Project: teaching   Source File: SysDataLogController.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 查询版本信息
 * @param req
 * @return
 */
@RequestMapping(value = "/queryDataVerList", method = RequestMethod.GET)
public Result<List<SysDataLog>> queryDataVerList(HttpServletRequest req) {
	Result<List<SysDataLog>> result = new Result<>();
	String dataTable = req.getParameter("dataTable");
	String dataId = req.getParameter("dataId");
	QueryWrapper<SysDataLog> queryWrapper = new QueryWrapper<SysDataLog>();
	queryWrapper.eq("data_table", dataTable);
	queryWrapper.eq("data_id", dataId);
	List<SysDataLog> list = service.list(queryWrapper);
	if(list==null||list.size()<=0) {
		result.error500("未找到版本信息");
	}else {
		result.setResult(list);
		result.setSuccess(true);
	}
	return result;
}
 
Example 19
Source Project: teaching   Source File: SysRolePermissionServiceImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void saveRolePermission(String roleId, String permissionIds, String lastPermissionIds) {
	List<String> add = getDiff(lastPermissionIds,permissionIds);
	if(add!=null && add.size()>0) {
		List<SysRolePermission> list = new ArrayList<SysRolePermission>();
		for (String p : add) {
			if(oConvertUtils.isNotEmpty(p)) {
				SysRolePermission rolepms = new SysRolePermission(roleId, p);
				list.add(rolepms);
			}
		}
		this.saveBatch(list);
	}
	
	List<String> delete = getDiff(permissionIds,lastPermissionIds);
	if(delete!=null && delete.size()>0) {
		for (String permissionId : delete) {
			this.remove(new QueryWrapper<SysRolePermission>().lambda().eq(SysRolePermission::getRoleId, roleId).eq(SysRolePermission::getPermissionId, permissionId));
		}
	}
}
 
Example 20
Source Project: jeecg-boot-with-activiti   Source File: SysUserAgentController.java    License: MIT License 6 votes vote down vote up
/**
    * 导出excel
 *
 * @param request
 * @param response
 */
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(SysUserAgent sysUserAgent,HttpServletRequest request) {
    // Step.1 组装查询条件
    QueryWrapper<SysUserAgent> queryWrapper = QueryGenerator.initQueryWrapper(sysUserAgent, request.getParameterMap());
    //Step.2 AutoPoi 导出Excel
    ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
    List<SysUserAgent> pageList = sysUserAgentService.list(queryWrapper);
    //导出文件名称
    mv.addObject(NormalExcelConstants.FILE_NAME, "用户代理人设置列表");
    mv.addObject(NormalExcelConstants.CLASS, SysUserAgent.class);
    LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
    mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("用户代理人设置列表数据", "导出人:"+user.getRealname(), "导出信息"));
    mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
    return mv;
}
 
Example 21
Source Project: jeecg-cloud   Source File: SysLogController.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * @功能:查询日志记录
 * @param syslog
 * @param pageNo
 * @param pageSize
 * @param req
 * @return
 */
@RequestMapping(value = "/list", method = RequestMethod.GET)
public Result<IPage<SysLog>> queryPageList(SysLog syslog,@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
								  @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,HttpServletRequest req) {
	Result<IPage<SysLog>> result = new Result<IPage<SysLog>>();
	QueryWrapper<SysLog> queryWrapper = QueryGenerator.initQueryWrapper(syslog, req.getParameterMap());
	Page<SysLog> page = new Page<SysLog>(pageNo, pageSize);
	//日志关键词
	String keyWord = req.getParameter("keyWord");
	if(oConvertUtils.isNotEmpty(keyWord)) {
		queryWrapper.like("log_content",keyWord);
	}
	//TODO 过滤逻辑处理
	//TODO begin、end逻辑处理
	//TODO 一个强大的功能,前端传一个字段字符串,后台只返回这些字符串对应的字段
	//创建时间/创建人的赋值
	IPage<SysLog> pageList = sysLogService.page(page, queryWrapper);
	log.info("查询当前页:"+pageList.getCurrent());
	log.info("查询当前页数量:"+pageList.getSize());
	log.info("查询结果数量:"+pageList.getRecords().size());
	log.info("数据总数:"+pageList.getTotal());
	result.setSuccess(true);
	result.setResult(pageList);
	return result;
}
 
Example 22
Source Project: charging_pile_cloud   Source File: AppWxPayController.java    License: MIT License 6 votes vote down vote up
/**
 * 微信充值回调
 */
@ResponseBody
@RequestMapping("/wxBack")
public String payNotify(HttpServletRequest request, HttpServletResponse response) {
    try {
        String xmlResult = IOUtils.toString(request.getInputStream(), request.getCharacterEncoding());
        WxPayOrderNotifyResult result = wxPayService.parseOrderNotifyResult(xmlResult);
        // 结果正确
        String orderId = result.getOutTradeNo();
        String tradeNo = result.getTransactionId();
        //自己处理订单的业务逻辑,需要判断订单是否已经支付过,否则可能会重复调用
        StockUserCharge stockUserCharge = stockUserChargeService.getOne(new QueryWrapper<StockUserCharge>()
        .eq("swift_no",orderId));
        if(stockUserCharge.getWithdrawStatus() == WithdrawStatusEnum.STATUS_4.getCode().byteValue()){
           //更新付款状态 用户付款成功
            stockUserCharge.setTranId(tradeNo);
            stockUserChargeService.withdrawStatusSuccess(stockUserCharge);
        }
        return WxPayNotifyResponse.success("处理成功!");
    } catch (Exception e) {
        log.error("微信回调结果异常,异常原因{}", e.getMessage());
        return WxPayNotifyResponse.fail(e.getMessage());
    }
}
 
Example 23
Source Project: mogu_blog_v2   Source File: BlogSortServiceImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public List<BlogSort> getList() {
    QueryWrapper<BlogSort> queryWrapper = new QueryWrapper<>();
    queryWrapper.eq(SysConf.STATUS, EStatus.ENABLE);
    queryWrapper.orderByDesc(SQLConf.SORT);
    List<BlogSort> blogSortList = blogSortService.list(queryWrapper);
    return blogSortList;
}
 
Example 24
Source Project: mogu_blog_v2   Source File: BlogServiceImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Integer getBlogCount(Integer status) {
    QueryWrapper<Blog> queryWrapper = new QueryWrapper<>();
    queryWrapper.eq(BaseSQLConf.STATUS, EStatus.ENABLE);
    queryWrapper.eq(BaseSQLConf.IS_PUBLISH, EPublish.PUBLISH);

    return blogMapper.selectCount(queryWrapper);
}
 
Example 25
Source Project: jeecg-boot   Source File: SysBaseApiImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public List<ComboModel> queryAllRole() {
	List<ComboModel> list = new ArrayList<ComboModel>();
	List<SysRole> roleList = roleMapper.selectList(new QueryWrapper<SysRole>());
	for(SysRole role : roleList){
		ComboModel model = new ComboModel();
		model.setTitle(role.getRoleName());
		model.setId(role.getId());
		list.add(model);
	}
	return list;
}
 
Example 26
Source Project: teaching   Source File: SysDepartRoleController.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 根据用户id获取已设置部门角色
 * @param userId
 * @return
 */
@RequestMapping(value = "/getDeptRoleByUserId", method = RequestMethod.GET)
public Result<List<SysDepartRoleUser>> getDeptRoleByUserId(@RequestParam(value = "userId") String userId){
 Result<List<SysDepartRoleUser>> result = new Result<>();
 List<SysDepartRoleUser> roleUserList = departRoleUserService.list(new QueryWrapper<SysDepartRoleUser>().eq("user_id",userId));
 result.setSuccess(true);
 result.setResult(roleUserList);
 return result;
}
 
Example 27
Source Project: SENS   Source File: ThirdAppBindServiceImpl.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public ThirdAppBind findByAppTypeAndOpenId(String appType, String openId) {
    QueryWrapper queryWrapper = new QueryWrapper();
    queryWrapper.eq("app_type", appType);
    queryWrapper.eq("open_id", openId);
    return thirdAppBindMapper.selectOne(queryWrapper);
}
 
Example 28
Source Project: summerframework   Source File: MyBaseMapper.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 模糊总数查询
 * 
 * @param param: key须是数据库字段,value是比较值
 * @return
 */
default Integer selectCountBlurry(Map<String, Object> param) {
    QueryWrapper<T> query = Wrappers.<T>query();
    if (null != param) {
        param.forEach((k, v) -> {
            query.like(k, v);
        });
    }
    return selectCount(query);
}
 
Example 29
Source Project: jeecg-boot-with-activiti   Source File: SysRoleController.java    License: MIT License 5 votes vote down vote up
/**
  * 分页列表查询
 * @param role
 * @param pageNo
 * @param pageSize
 * @param req
 * @return
 */
@RequestMapping(value = "/list", method = RequestMethod.GET)
public Result<IPage<SysRole>> queryPageList(SysRole role,
								  @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
								  @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
								  HttpServletRequest req) {
	Result<IPage<SysRole>> result = new Result<IPage<SysRole>>();
	QueryWrapper<SysRole> queryWrapper = QueryGenerator.initQueryWrapper(role, req.getParameterMap());
	Page<SysRole> page = new Page<SysRole>(pageNo, pageSize);
	IPage<SysRole> pageList = sysRoleService.page(page, queryWrapper);
	result.setSuccess(true);
	result.setResult(pageList);
	return result;
}
 
Example 30
Source Project: supplierShop   Source File: OrderServiceImpl.java    License: MIT License 5 votes vote down vote up
@Override
public Map<String, Integer> countInfo(int userId) {
    QueryWrapper<StoreOrder> wrapper = new QueryWrapper<>();
    wrapper.eq("deleted",0).eq("user_id",userId).eq("pay_status",0);
    int unpayCount  = count(wrapper);

    QueryWrapper<StoreOrder> wrapper1 = new QueryWrapper<>();
    wrapper1.eq("deleted",0).eq("user_id",userId)
            .eq("pay_status",1).eq("shipping_status",0);
    int undeliverCount  = count(wrapper1);

    QueryWrapper<StoreOrder> wrapper2 = new QueryWrapper<>();
    wrapper2.eq("deleted",0).eq("user_id",userId)
            .eq("shipping_status",1).eq("order_status",0);
    int deliveringCount  = count(wrapper2);

    QueryWrapper<StoreOrder> wrapper3 = new QueryWrapper<>();
    wrapper3.eq("deleted",0).eq("user_id",userId)
            .eq("shipping_status",1).eq("order_status",1);
    int unevalCount  = count(wrapper3);

    QueryWrapper<StoreOrder> wrapper4 = new QueryWrapper<>();
    wrapper4.eq("deleted",0).eq("user_id",userId).gt("shipping_status",1);
    int returnCount  = count(wrapper4);

    Map<String,Integer> map = new HashMap<>();
    map.put("unpayCount",unpayCount);
    map.put("undeliverCount",undeliverCount);
    map.put("deliveringCount",deliveringCount);
    map.put("unevalCount",unevalCount);
    map.put("returnCount",returnCount);
    return map;
}