条件查询list,分页条件查询

List<CustomerPoJo> list =
    list(
        query ->
            query
                .getConditions()
                .eq(AbstractEntityPoJo::getCompanyId, companyId)
                .eq(CustomerPoJo::getIsDelete, false)
                .eq(CustomerPoJo::getId, customerId),
        CustomerPoJo.class);
    Page<CustomerResponse> customerResponsePage =
        CollectionUtils.toPage(
            page(
                queryColumn ->
                    queryColumn
                        .getConditions()
                        .eq(AbstractEntityPoJo::getCompanyId, companyId)
                        .eq(CustomerPoJo::getIsCaller, false)
                        .in(finalVipIds.size() > 0, CustomerPoJo::getVipId, finalVipIds)
                        .and(
                            Objects.nonNull(keywords) && StringUtils.isNotEmpty(keywords)
                                ? Conditions.of(queryColumn)
                                    .like(CustomerPoJo::getName, keywords)
                                    .or(
                                        Conditions.of(queryColumn)
                                            .like(CustomerPoJo::getWxNickname, keywords))
                                : null)
                        .and(
                            Objects.nonNull(tel) && StringUtils.isNotEmpty(tel)
                                ? Conditions.of(queryColumn).like(CustomerPoJo::getTel, tel)
                                : null),
                page,
                size,
                SortColumn.builder().add(SortColumn.desc("update_time")).build(),
                CustomerPoJo.class),
            customer -> {
              if (customer.getVipId() != 0) {
                CustomerVipPoJo customerVipPoJo = customerVipService.getById(customer.getVipId());
                if (ObjectUtils.isNotNull(customerVipPoJo)) {
                  customer.setVipName(customerVipPoJo.getName());
                } else {
                  customer.setVipName("");
                }
              } else {
                customer.setVipName("");
              }
              return CustomerResponse.of(customer);
            },
            null);
条件查询list,分页条件查询条件查询list,分页条件查询 正在改BUG 发布了95 篇原创文章 · 获赞 0 · 访问量 8399 私信 关注
上一篇:手机号@符号的处理


下一篇:unittest(20)- 自动更新表格中的数据(3)