zoukankan      html  css  js  c++  java
  • queryWrapper in like

    //构建条件
            QueryWrapper<ErpGroup> wrapper = new QueryWrapper<>();
    //        wrapper.eq("deleted","0");
    
            String username = userAuthUtil.getUserName().get();
            if(!username.equals("admin")){
                Long user_id = userAuthUtil.getUserId().get();
                List<ErpGroupMember> erpGroupMemberList = erpGroupMemberService.getErpGroupMemberByUserId(user_id);
    
    //            Long[] id_arr = new Long[erpGroupMemberList.size()];
    //            for(int i=0;i<erpGroupMemberList.size();i++){
    //                id_arr[i]=erpGroupMemberList.get(i).getGroupId();
    //            }
    //            List<Long>  idList=Arrays.asList(id_arr);
    
    //            List<Long> idList = new ArrayList<>();
    //            erpGroupMemberList .forEach(n -> idList.add(n.getGroupId()));
    //            wrapper.in("id", idList);
    
    //            queryWrapper.and(Wrapper -> Wrapper.eq(PcmArticle::getAuState, "1").or().eq(PcmArticle::getAuState, "2"));
    //            QueryWrapper<ErpGroup> like_wrapper = new QueryWrapper<>();
    //            for(int i=0;i<erpGroupMemberList.size();i++){
    //                Long group_id = erpGroupMemberList.get(i).getGroupId();
    //                ErpGroup erpGroup = baseMapper.selectById(group_id);
    //                String group_path = erpGroup.getPath();
    //                if(like_wrapper.isEmptyOfWhere()){
    //                    like_wrapper.likeRight("path",erpGroup.getPath());
    //                }else{
    //                    like_wrapper.or().likeRight("path",erpGroup.getPath());
    //                }
    //            }
    //            wrapper.and((Consumer<QueryWrapper<ErpGroup>>) like_wrapper);
    
                wrapper.and(wr->{
    //                String[] deviceIds = StringUtils.split(deviceIdArr, ",");
    //                Arrays.stream(deviceIds).forEach(e->{
    //                    wr.eq("id", e).or();
    //                });
    
    //                for(int i=0;i<erpGroupMemberList.size();i++){
    ////                    ErpGroup erpGroup = baseMapper.selectById( erpGroupMemberList.get(i).getGroupId());
    ////                    if(wr.isEmptyOfWhere()){
    ////                        wr.likeRight("path",erpGroup.getPath());
    ////                    }else{
    ////                        wr.or().likeRight("path",erpGroup.getPath());
    ////                    }
    ////                }
                    erpGroupMemberList.forEach(e->{
                        wr.likeRight("path",baseMapper.selectById(e.getGroupId()).getPath()).or();
                    });
                });
    
            }
    
            Long id = erpGroupQuery.getId();
            if(id != null) wrapper.eq("id", id);
            if (!StringUtils.isEmpty(erpGroupQuery.getCode())){
                wrapper.eq("code", erpGroupQuery.getCode());
            }
            if (!StringUtils.isEmpty(erpGroupQuery.getName())){
                wrapper.eq("name", erpGroupQuery.getName());
            }
            Long parentId = erpGroupQuery.getParentId();
            if(parentId != null) wrapper.eq("parent_id", parentId);
            if (!StringUtils.isEmpty(erpGroupQuery.getPath())){
                wrapper.like("name", erpGroupQuery.getPath());
            }
            if (!StringUtils.isEmpty(erpGroupQuery.getType())){
                wrapper.eq("type", erpGroupQuery.getType());
            }
            Integer groupType = erpGroupQuery.getGroupType();
            if(groupType != null) wrapper.eq("group_type", groupType);
            if (!StringUtils.isEmpty(erpGroupQuery.getDescription())){
                wrapper.eq("description", erpGroupQuery.getDescription());
            }
            Long ownership = erpGroupQuery.getOwnership();
            if(ownership != null) wrapper.eq("ownership", ownership);
            Boolean status = erpGroupQuery.getStatus();
            if(status != null) wrapper.eq("status", status);
            return baseMapper.selectList(wrapper);
  • 相关阅读:
    破解密码那些事儿(Hacking Secret Ciphers with Python)
    Hacking Secret Ciphers with Python翻译序言
    闲话高并发的那些神话,看京东架构师如何把它拉下神坛
    实现rabbitmq 延迟队列功能
    日志文件的编写
    依赖倒置、控制反转和依赖注入的区分
    Oracle ORA-01722: 无效数字 处理方法
    Time.timeScale 对 协程WaitForSeconds的影响
    [转]Coroutine,你究竟干了什么?
    转:Automatic Layout Groups
  • 原文地址:https://www.cnblogs.com/mingforyou/p/14678617.html
Copyright © 2011-2022 走看看