怎样免费做网站视频讲解,skype在网站上怎么做链接,北京商城网站建设费用,如何做网站推广精在垃圾项目中一般都是使用mybatis plus自动返回Page,但是涉及到多表联合或者等等情况最终还是要使用mybatis进行手写sql查询,所以有此文章以便后续使用查询. 首先mysql需要支持多条查询语句,在mysql配置url后加上:
allowMultiQueriestrueuseAffectedRowstrue Mapper…在垃圾项目中一般都是使用mybatis plus自动返回Page,但是涉及到多表联合或者等等情况最终还是要使用mybatis进行手写sql查询,所以有此文章以便后续使用查询. 首先mysql需要支持多条查询语句,在mysql配置url后加上:
allowMultiQueriestrueuseAffectedRowstrue Mapper查询数据的返回值用Object接收 ListObject getWarningDataFromPage(Nullable Param(userId) Long userId,Nullable Param(orderNum) String orderNum,Nullable Param(deviceId) String deviceId,Param(pageSize) long pageSize,Param(pageNo) long pageNo); mapper xml语句
!--需查询数据map--
resultMap idBaseResultMap typecom.jingli.modules.sys.warning.domain.Warningid propertyid columnid jdbcTypeINTEGER/result propertywarningId columnwarning_id jdbcTypeVARCHAR/result propertywarningType columnwarning_type jdbcTypeINTEGER/result propertywarningDesc columnwarning_desc jdbcTypeVARCHAR/result propertywarningContent columnwarning_content jdbcTypeVARCHAR/result propertywarningTime columnwarning_time jdbcTypeTIMESTAMP/result propertyoperatorId columnoperator_id jdbcTypeINTEGER/result propertydeviceId columndevice_id jdbcTypeVARCHAR/result propertyport columnport jdbcTypeVARCHAR/result propertyorderNumber columnorder_number jdbcTypeVARCHAR/result propertystatus columnstatus jdbcTypeINTEGER/result propertyremark columnremark jdbcTypeVARCHAR//resultMap!--total数据--resultMap typejava.lang.Integer idcountresult columntotal//resultMap!--进行多次查询获取到对应数据--
select idgetWarningDataFromPage resultMapBaseResultMap,countSELECT SQL_CALC_FOUND_ROWScw.id, cw.warning_id, cw.warning_type, cw.warning_desc, cw.warning_content, cw.warning_time, cw.operator_id,cw.device_id, cw.port, cw.order_number, cw.status, cw.remarkFROMc_warning AS cwLEFT JOIN c_charging_pile AS ccp ON cw.device_id ccp.IDWHERE 1 1if testnull ! userIdAND ccp.userId #{userId}/ifif testnull ! orderNum and orderNum !AND cw.order_number #{orderNum}/ifif testnull ! deviceId and deviceId !AND cw.device_id #{deviceId}/iflimit #{pageNo},#{pageSize};###用于获取totalSELECT FOUND_ROWS() as total;/select从ListObject中取出数据 Overridepublic PageWarning getWarningPage(Nullable Long userId, Nonnull Long pageSize, Nonnull Long pageNo, Nullable String deviceId, Nullable String orderNum) {Long selectNum (pageNo - 1) * pageSize;ListObject dtoData warningMapper.getWarningDataFromPage(userId, orderNum, deviceId, pageSize, selectNum);ListWarning warningList (ListWarning) dtoData.get(0);Integer total ((ListInteger) dtoData.get(1)).get(0);PageWarning warningPage new Page(pageNo, pageSize);warningPage.setRecords(warningList);warningPage.setTotal(total);warningPage.setSearchCount(true);warningPage.setCurrent(pageNo);warningPage.setSize(pageSize);return warningPage;}
至此可实现mybatis plus的Page查询mysql中执行查询total并不会再次查询而是获取到对应的分页查询到数据的结果.