Java Code Examples for com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper#eq()
The following examples show how to use
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper#eq() .
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: SysUserServiceImpl.java From jeecg-boot-with-activiti with MIT License | 6 votes |
@Override @CacheEvict(value={CacheConstant.SYS_USERS_CACHE}, allEntries=true) @Transactional(rollbackFor = Exception.class) public boolean deleteBatchUsers(String userIds) { //1.删除用户 this.removeByIds(Arrays.asList(userIds.split(","))); //2.删除用户部门关系 LambdaQueryWrapper<SysUserDepart> query = new LambdaQueryWrapper<SysUserDepart>(); for(String id : userIds.split(",")) { query.eq(SysUserDepart::getUserId, id); this.sysUserDepartMapper.delete(query); } //3.删除用户角色关系 //TODO return false; }
Example 2
Source File: SysPermissionController.java From jeecg-cloud with Apache License 2.0 | 6 votes |
/** * 系统菜单列表(一级菜单) * * @return */ @RequestMapping(value = "/getSystemMenuList", method = RequestMethod.GET) public Result<List<SysPermissionTree>> getSystemMenuList() { long start = System.currentTimeMillis(); Result<List<SysPermissionTree>> result = new Result<>(); try { LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<SysPermission>(); query.eq(SysPermission::getMenuType,CommonConstant.MENU_TYPE_0); query.eq(SysPermission::getDelFlag, CommonConstant.DEL_FLAG_0); query.orderByAsc(SysPermission::getSortNo); List<SysPermission> list = sysPermissionService.list(query); List<SysPermissionTree> sysPermissionTreeList = new ArrayList<SysPermissionTree>(); for(SysPermission sysPermission : list){ SysPermissionTree sysPermissionTree = new SysPermissionTree(sysPermission); sysPermissionTreeList.add(sysPermissionTree); } result.setResult(sysPermissionTreeList); result.setSuccess(true); } catch (Exception e) { log.error(e.getMessage(), e); } log.info("======获取一级菜单数据=====耗时:" + (System.currentTimeMillis() - start) + "毫秒"); return result; }
Example 3
Source File: GoodsBrandServiceImpl.java From spring-cloud-shop with MIT License | 6 votes |
@Override public Response<List<GoodsBrandResponse>> queryPage(GoodsBrandPageRequest request) { LambdaQueryWrapper<GoodsBrand> wrapper = new LambdaQueryWrapper<>(); wrapper.eq(GoodsBrand::getDeleteStatus, Boolean.FALSE); if (StringUtils.isNotBlank(request.getBrandCode())) { wrapper.eq(GoodsBrand::getBrandCode, request.getBrandCode()); } if (StringUtils.isNotBlank(request.getBrandName())) { wrapper.likeRight(GoodsBrand::getBrandName, request.getBrandName()); } if (!CollectionUtils.isEmpty(request.getDateTimes())) { wrapper.ge(GoodsBrand::getCreateTime, request.getDateTimes().get(0)); wrapper.le(GoodsBrand::getCreateTime, request.getDateTimes().get(1)); } Response<List<GoodsBrand>> page = this.toPage(request.getPage(), request.getPageSize(), wrapper); return Response.toResponse(page.getData().stream().map(this::convert).collect(Collectors.toList()), page.getTotal()); }
Example 4
Source File: SysUserDepartServiceImpl.java From jeecg-boot with Apache License 2.0 | 6 votes |
/** * 根据部门id查询用户信息 */ @Override public List<SysUser> queryUserByDepId(String depId) { LambdaQueryWrapper<SysUserDepart> queryUDep = new LambdaQueryWrapper<SysUserDepart>(); queryUDep.eq(SysUserDepart::getDepId, depId); List<String> userIdList = new ArrayList<>(); List<SysUserDepart> uDepList = this.list(queryUDep); if(uDepList != null && uDepList.size() > 0) { for(SysUserDepart uDep : uDepList) { userIdList.add(uDep.getUserId()); } List<SysUser> userList = (List<SysUser>) sysUserService.listByIds(userIdList); //update-begin-author:taoyan date:201905047 for:接口调用查询返回结果不能返回密码相关信息 for (SysUser sysUser : userList) { sysUser.setSalt(""); sysUser.setPassword(""); } //update-end-author:taoyan date:201905047 for:接口调用查询返回结果不能返回密码相关信息 return userList; } return new ArrayList<SysUser>(); }
Example 5
Source File: SysUserController.java From teaching with Apache License 2.0 | 6 votes |
/** * 获取用户列表 根据用户名和真实名 模糊匹配 * @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 6
Source File: SysPermissionController.java From jeecg-boot-with-activiti with MIT License | 6 votes |
/** * 系统菜单列表(一级菜单) * * @return */ @RequestMapping(value = "/getSystemMenuList", method = RequestMethod.GET) public Result<List<SysPermissionTree>> getSystemMenuList() { long start = System.currentTimeMillis(); Result<List<SysPermissionTree>> result = new Result<>(); try { LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<SysPermission>(); query.eq(SysPermission::getMenuType,CommonConstant.MENU_TYPE_0); query.eq(SysPermission::getDelFlag, CommonConstant.DEL_FLAG_0); query.orderByAsc(SysPermission::getSortNo); List<SysPermission> list = sysPermissionService.list(query); List<SysPermissionTree> sysPermissionTreeList = new ArrayList<SysPermissionTree>(); for(SysPermission sysPermission : list){ SysPermissionTree sysPermissionTree = new SysPermissionTree(sysPermission); sysPermissionTreeList.add(sysPermissionTree); } result.setResult(sysPermissionTreeList); result.setSuccess(true); } catch (Exception e) { log.error(e.getMessage(), e); } log.info("======获取一级菜单数据=====耗时:" + (System.currentTimeMillis() - start) + "毫秒"); return result; }
Example 7
Source File: AssembleServiceRuleImpl.java From spring-cloud-shop with MIT License | 5 votes |
@Override public Response<AssembleActivityRuleResponse> info(Long activityId) { AssembleActivity assembleActivity = this.assembleActivityMapper.selectById(activityId); if (Objects.isNull(assembleActivity) || assembleActivity.getServerStatus() || assembleActivity.getDeleteStatus()) { return new Response<>(ResponseStatus.Code.FAIL_CODE, "活动已过期"); } LambdaQueryWrapper<AssembleActivityRule> wrapper = new LambdaQueryWrapper<>(); wrapper.eq(AssembleActivityRule::getDeleteStatus, Boolean.FALSE); wrapper.eq(AssembleActivityRule::getActivityId, activityId); AssembleActivityRule updateRule = this.baseMapper.selectOne(wrapper); AssembleActivityRuleResponse response = new AssembleActivityRuleResponse(); LocalDateTime time = DateUtils.dateTime(); if (Objects.nonNull(updateRule)) { response.setId(updateRule.getId()); response.setActivityId(activityId); response.setPurchaseLimit(updateRule.getPurchaseLimit()); response.setAssembleCount(updateRule.getAssembleCount()); response.setDescription(updateRule.getDescription()); response.setCreateTime(time); } response.setUpdateTime(time); response.setActivityId(activityId); response.setActivityName(assembleActivity.getActivityName()); return new Response<>(response); }
Example 8
Source File: GroupServiceImpl.java From iot-dc3 with Apache License 2.0 | 5 votes |
@Override @Cacheable(value = Common.Cache.GROUP + Common.Cache.NAME, key = "#name", unless = "#result==null") public Group selectByName(String name) { LambdaQueryWrapper<Group> queryWrapper = Wrappers.<Group>query().lambda(); queryWrapper.eq(Group::getName, name); return groupMapper.selectOne(queryWrapper); }
Example 9
Source File: SysPermissionServiceImpl.java From jeecg-boot with Apache License 2.0 | 5 votes |
/** * 根据permissionId删除其关联的SysPermissionDataRule表中的数据 */ @Override public void deletePermRuleByPermId(String id) { LambdaQueryWrapper<SysPermissionDataRule> query = new LambdaQueryWrapper<>(); query.eq(SysPermissionDataRule::getPermissionId, id); int countValue = this.permissionDataRuleService.count(query); if(countValue > 0) { this.permissionDataRuleService.remove(query); } }
Example 10
Source File: RoleServiceImpl.java From spring-cloud-shop with MIT License | 5 votes |
@Override public Response<List<RoleResponse>> queryList(RoleOtherParam param) { LambdaQueryWrapper<Role> wrapper = new LambdaQueryWrapper<>(); wrapper.eq(Role::getDeleteStatus, Boolean.FALSE); if (StringUtils.isNotEmpty(param.getRoleName())) { wrapper.eq(Role::getRoleName, param.getRoleName()); } List<Role> roles = this.list(wrapper); return new Response<>(roles.stream().map(item -> BeanCopier.create(item, new RoleResponse()).copy()).collect(Collectors.toList())); }
Example 11
Source File: SysPermissionController.java From jeecg-boot with Apache License 2.0 | 5 votes |
/** * 查询子菜单 * * @param parentIds 父ID(多个采用半角逗号分割) * @return 返回 key-value 的 Map */ @GetMapping("/getSystemSubmenuBatch") public Result getSystemSubmenuBatch(@RequestParam("parentIds") String parentIds) { try { LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<>(); List<String> parentIdList = Arrays.asList(parentIds.split(",")); query.in(SysPermission::getParentId, parentIdList); query.eq(SysPermission::getDelFlag, CommonConstant.DEL_FLAG_0); query.orderByAsc(SysPermission::getSortNo); List<SysPermission> list = sysPermissionService.list(query); Map<String, List<SysPermissionTree>> listMap = new HashMap<>(); for (SysPermission item : list) { String pid = item.getParentId(); if (parentIdList.contains(pid)) { List<SysPermissionTree> mapList = listMap.get(pid); if (mapList == null) { mapList = new ArrayList<>(); } mapList.add(new SysPermissionTree(item)); listMap.put(pid, mapList); } } return Result.ok(listMap); } catch (Exception e) { log.error(e.getMessage(), e); return Result.error("批量查询子菜单失败:" + e.getMessage()); } }
Example 12
Source File: SysPermissionServiceImpl.java From jeecg-boot-with-activiti with MIT License | 5 votes |
/** * 根据permissionId删除其关联的SysPermissionDataRule表中的数据 */ @Override public void deletePermRuleByPermId(String id) { LambdaQueryWrapper<SysPermissionDataRule> query = new LambdaQueryWrapper<>(); query.eq(SysPermissionDataRule::getPermissionId, id); int countValue = this.permissionDataRuleService.count(query); if(countValue > 0) { this.permissionDataRuleService.remove(query); } }
Example 13
Source File: SysDepartServiceImpl.java From jeecg-boot-with-activiti with MIT License | 5 votes |
/** * queryTreeList 对应 queryTreeList 查询所有的部门数据,以树结构形式响应给前端 */ @Cacheable(value = CacheConstant.SYS_DEPARTS_CACHE) @Override public List<SysDepartTreeModel> queryTreeList() { LambdaQueryWrapper<SysDepart> query = new LambdaQueryWrapper<SysDepart>(); query.eq(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_0.toString()); query.orderByAsc(SysDepart::getDepartOrder); List<SysDepart> list = this.list(query); // 调用wrapTreeDataToTreeList方法生成树状数据 List<SysDepartTreeModel> listResult = FindsDepartsChildrenUtil.wrapTreeDataToTreeList(list); return listResult; }
Example 14
Source File: SysDepartServiceImpl.java From jeecg-boot-with-activiti with MIT License | 5 votes |
/** * delete 方法调用 * @param id * @param idList */ private void checkChildrenExists(String id, List<String> idList) { LambdaQueryWrapper<SysDepart> query = new LambdaQueryWrapper<SysDepart>(); query.eq(SysDepart::getParentId,id); List<SysDepart> departList = this.list(query); if(departList != null && departList.size() > 0) { for(SysDepart depart : departList) { idList.add(depart.getId()); this.checkChildrenExists(depart.getId(), idList); } } }
Example 15
Source File: SysPermissionController.java From jeecg-boot-with-activiti with MIT License | 5 votes |
/** * 获取全部的权限树 * * @return */ @RequestMapping(value = "/queryTreeList", method = RequestMethod.GET) public Result<Map<String, Object>> queryTreeList() { Result<Map<String, Object>> result = new Result<>(); // 全部权限ids List<String> ids = new ArrayList<>(); try { LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<SysPermission>(); query.eq(SysPermission::getDelFlag, CommonConstant.DEL_FLAG_0); query.orderByAsc(SysPermission::getSortNo); List<SysPermission> list = sysPermissionService.list(query); for (SysPermission sysPer : list) { ids.add(sysPer.getId()); } List<TreeModel> treeList = new ArrayList<>(); getTreeModelList(treeList, list, null); Map<String, Object> resMap = new HashMap<String, Object>(); resMap.put("treeList", treeList); // 全部树节点数据 resMap.put("ids", ids);// 全部树ids result.setResult(resMap); result.setSuccess(true); } catch (Exception e) { log.error(e.getMessage(), e); } return result; }
Example 16
Source File: SysPermissionController.java From jeecg-cloud with Apache License 2.0 | 4 votes |
/** * 查询用户拥有的菜单权限和按钮权限(根据TOKEN) * * @return */ @RequestMapping(value = "/getUserPermissionByToken", method = RequestMethod.GET) public Result<?> getUserPermissionByToken(@RequestParam(name = "token", required = true) String token) { Result<JSONObject> result = new Result<JSONObject>(); try { if (oConvertUtils.isEmpty(token)) { return Result.error("TOKEN不允许为空!"); } log.info(" ------ 通过令牌获取用户拥有的访问菜单 ---- TOKEN ------ " + token); String username = JwtUtil.getUsername(token); List<SysPermission> metaList = sysPermissionService.queryByUser(username); //添加首页路由 //update-begin-author:taoyan date:20200211 for: TASK #3368 【路由缓存】首页的缓存设置有问题,需要根据后台的路由配置来实现是否缓存 if(!PermissionDataUtil.hasIndexPage(metaList)){ SysPermission indexMenu = sysPermissionService.list(new LambdaQueryWrapper<SysPermission>().eq(SysPermission::getName,"首页")).get(0); metaList.add(0,indexMenu); } //update-end-author:taoyan date:20200211 for: TASK #3368 【路由缓存】首页的缓存设置有问题,需要根据后台的路由配置来实现是否缓存 JSONObject json = new JSONObject(); JSONArray menujsonArray = new JSONArray(); this.getPermissionJsonArray(menujsonArray, metaList, null); JSONArray authjsonArray = new JSONArray(); this.getAuthJsonArray(authjsonArray, metaList); //查询所有的权限 LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<SysPermission>(); query.eq(SysPermission::getDelFlag, CommonConstant.DEL_FLAG_0); query.eq(SysPermission::getMenuType, CommonConstant.MENU_TYPE_2); //query.eq(SysPermission::getStatus, "1"); List<SysPermission> allAuthList = sysPermissionService.list(query); JSONArray allauthjsonArray = new JSONArray(); this.getAllAuthJsonArray(allauthjsonArray, allAuthList); //路由菜单 json.put("menu", menujsonArray); //按钮权限(用户拥有的权限集合) json.put("auth", authjsonArray); //全部权限配置集合(按钮权限,访问权限) json.put("allAuth", allauthjsonArray); result.setResult(json); result.success("查询成功"); } catch (Exception e) { result.error500("查询失败:" + e.getMessage()); log.error(e.getMessage(), e); } return result; }
Example 17
Source File: SysPermissionController.java From teaching with Apache License 2.0 | 4 votes |
/** * 查询用户拥有的菜单权限和按钮权限(根据TOKEN) * * @return */ @RequestMapping(value = "/getUserPermissionByToken", method = RequestMethod.GET) public Result<?> getUserPermissionByToken(@RequestParam(name = "token", required = true) String token) { Result<JSONObject> result = new Result<JSONObject>(); try { if (oConvertUtils.isEmpty(token)) { return Result.error("TOKEN不允许为空!"); } log.info(" ------ 通过令牌获取用户拥有的访问菜单 ---- TOKEN ------ " + token); String username = JwtUtil.getUsername(token); List<SysPermission> metaList = sysPermissionService.queryByUser(username); //添加首页路由 //update-begin-author:taoyan date:20200211 for: TASK #3368 【路由缓存】首页的缓存设置有问题,需要根据后台的路由配置来实现是否缓存 if(!PermissionDataUtil.hasIndexPage(metaList)){ SysPermission indexMenu = sysPermissionService.list(new LambdaQueryWrapper<SysPermission>().eq(SysPermission::getName,"首页")).get(0); metaList.add(0,indexMenu); } //update-end-author:taoyan date:20200211 for: TASK #3368 【路由缓存】首页的缓存设置有问题,需要根据后台的路由配置来实现是否缓存 JSONObject json = new JSONObject(); JSONArray menujsonArray = new JSONArray(); this.getPermissionJsonArray(menujsonArray, metaList, null); JSONArray authjsonArray = new JSONArray(); this.getAuthJsonArray(authjsonArray, metaList); //查询所有的权限 LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<SysPermission>(); query.eq(SysPermission::getDelFlag, CommonConstant.DEL_FLAG_0); query.eq(SysPermission::getMenuType, CommonConstant.MENU_TYPE_2); //query.eq(SysPermission::getStatus, "1"); List<SysPermission> allAuthList = sysPermissionService.list(query); JSONArray allauthjsonArray = new JSONArray(); this.getAllAuthJsonArray(allauthjsonArray, allAuthList); //路由菜单 json.put("menu", menujsonArray); //按钮权限 json.put("auth", authjsonArray); //全部权限配置(按钮权限,访问权限) json.put("allAuth", allauthjsonArray); result.setResult(json); result.success("查询成功"); } catch (Exception e) { result.error500("查询失败:" + e.getMessage()); log.error(e.getMessage(), e); } return result; }
Example 18
Source File: SysCheckRuleServiceImpl.java From teaching with Apache License 2.0 | 4 votes |
@Override public SysCheckRule getByCode(String ruleCode) { LambdaQueryWrapper<SysCheckRule> queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(SysCheckRule::getRuleCode, ruleCode); return super.getOne(queryWrapper); }
Example 19
Source File: UserDataPermissionServiceImpl.java From FEBS-Cloud with Apache License 2.0 | 4 votes |
@Override public String findByUserId(String userId) { LambdaQueryWrapper<UserDataPermission> wrapper = new LambdaQueryWrapper<>(); wrapper.eq(UserDataPermission::getUserId, userId); return this.baseMapper.selectList(wrapper).stream().map(permission -> String.valueOf(permission.getDeptId())).collect(Collectors.joining(StringConstant.COMMA)); }
Example 20
Source File: OnlineInterceptor.java From jeecg-boot with Apache License 2.0 | 4 votes |
@Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { // 请求的方法是否有注解 boolean anno = handler.getClass().isAssignableFrom(HandlerMethod.class); if (anno) { OnlineAuth onlineAuth = ((HandlerMethod) handler).getMethodAnnotation(OnlineAuth.class); if (onlineAuth != null) { String requestPath = request.getRequestURI().substring(request.getContextPath().length()); requestPath = filterUrl(requestPath); //1.通过前端请求地址得到code String authKey = onlineAuth.value(); String code = requestPath.substring(requestPath.lastIndexOf(authKey) + authKey.length()); log.info("拦截请求(" + request.getMethod() + "):" + requestPath + ","); if ("form".equals(authKey) && "DELETE".equals(request.getMethod())) { code = code.substring(0, code.lastIndexOf("/")); } List<String> possibleUrl = new ArrayList<>(); //获取可能的表单地址 for (String pre : ONLINE_TEST_PRE) { possibleUrl.add(pre + code); } //查询菜单 LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<SysPermission>(); query.eq(SysPermission::getDelFlag, 0); query.in(SysPermission::getUrl, possibleUrl); List<SysPermission> permissionList = sysPermissionService.list(query); String username = JwtUtil.getUserNameByToken(request); if (permissionList == null || permissionList.size() == 0) { //没有配置菜单 找online表单菜单地址 boolean hasPermission = sysPermissionService.hasPermission(username, ONLINE_FORM); if (!hasPermission) { backError(response, authKey); return false; } } else { //找到菜单了 boolean has = false; for (SysPermission p : permissionList) { has = has || sysPermissionService.hasPermission(username, p); } if (!has) { backError(response, authKey); return false; } } } } return true; }