web123456

mybatis-plus small class: multi-table query [case article]

LambdaQueryWrapper<RiskEquipmentPosition> lambda = new LambdaQueryWrapper<>(); lambda.orderByDesc(TRiskEquipmentPosition::getCreateTime); if (input.getStartTime() != null) { lambda.ge(RiskEquipmentPosition::getCreateTime, input.getStartTime()); } if (input.getEndTime() != null) { lambda.lt(RiskEquipmentPosition::getCreateTime, input.getEndTime()); } if (input.getState() != null) { lambda.eq(RiskEquipmentPosition::getState, input.getState()); } // Terminal SN and merchant number are inquired in this table, and other keywords need to be associated with the merchant table for query. if (null != input.getKeywordType() && StringUtils.isNotBlank(input.getKeyword())) { var keyWordTypes = new ArrayList<String>(); keyWordTypes.add(ERiskEquipmentPositionKeyWord.MER_ID.getCode()); keyWordTypes.add(ERiskEquipmentPositionKeyWord.FAC_ID.getCode()); keyWordTypes.add(ERiskEquipmentPositionKeyWord.TOP_ID.getCode()); Long longKeyWord = 0L; if (keyWordTypes.contains(input.getKeywordType())) { try { longKeyWord = Long.parseLong(input.getKeyword()); } catch (Exception ex) { throw CommonException.create(ServerResponse.createByError("Invalid number")); } } switch (BaseEnum.getEnum(ERiskEquipmentPositionKeyWord.class, input.getKeywordType())) { case SN: lambda.eq(RiskEquipmentPosition::getEquipmentSn, input.getKeyword()); break; case MER_ID: lambda.apply("r.merchant_id = {0}",input.getKeyword()); break; case MER_NAME: lambda.apply("m.merchant_name = {0}",input.getKeyword()); break; case FAC_ID: //The apply method is used to splice custom conditional judgment. If the custom conditional judgment requires independent results, you must remember to add brackets. lambda.apply("m.facilitator_id = {0}",input.getKeyword()); break; case FAC_NAME: lambda.apply("m.facilitator_name = {0}",input.getKeyword()); break; case TOP_ID: lambda.apply("m.faclitator_top_id= {0}",input.getKeyword()); break; case TOP_NAME: lambda.apply("m.facilitator_top_name= {0}",input.getKeyword()); break; } } // Pagination query PageHelper.startPage(input.getPageNum(), input.getPageSize()); List<RiskEquipmentPositionDto> positionList = tRiskEquipmentPositionService.getlist(lambda); PageInfo pageInfo = new PageInfo(positionList); PageHelper.clearPage(); return pageInfo;