具体代码如下所示 :
WalletDetailSresp WalletDetailSresp = new WalletDetailSresp (); List <WalletDetailSresp.WalletDetail> LIST = New ArrayList <> (); WalletDetailsResp.PageInfobean PageInfobean = New WalletDetailsResp.PageInfobean (); Lista <Toinger> Tipos = Tipos = NEWGEAND ArrayList <> (); tipos.add (innerCashType.finisher_add_cutmoney.getCode ()); tipos.add (innerCashType.finisher_add_reward.getCode () ); tipos.add (innerCashType.Finisher_Sub_WithDraw.getCode ()); tipos.add (innerCashType.finisher_add_withdraw.getCode ()); eatCriteria = Criteria.where("_change_type").in(types).and("_downstream_user_id").is(userId);Sort.Order orders = new Sort.Order(Sort.Direction.DESC, "changeDate");Aggregation eatAggregation = Aggregation.newAggregation( Aggregation.match(eatCriteria), Agregation.project ("_ change_money", "_ cambie_type"). AndExpression ("substr (_change_time, 0,10)"). As ("cambiado"), agregation.group ("cambiado", "_ cambie_type"). Sum ("_ cambio_money"). As ("changeoney"), agregation.sort.sort (orders) (orders) (orders) (ordeners). Aggregation.skip(pageIndex > 1 ? (pageIndex - 1) * pageSize : 0L), Aggregation.limit(pageSize));AggregationResults<BasicDBObject> eatOutputType = mongoTemplate.aggregate(eatAggregation, "inner_cash_change", BasicDBObject.class);for (DBObject obj : eatOutputType) {WalletDetailSresp.WalletDetail WalletDetail = new WalletDetailSresp.WalletDetail (); WalletDetail.SetchangeType (Integer.ParseInt (obj.get ("_ Change_type"). ToString ())); WalletDetail.SetchangeMoney (nuevo BigDecimal (obj.get ("Changemoney"). ToString ()). Divide (Qrtype.yuan_to_fen)); WalletDetail.Setchangedate (obj.get ("cambiado"). toString ()); list.add (WalletDetail);} WalletDetailSresp.SetWalletDetails (List); PageInfobean.SetPageIndex (PageIndex); PageInfobean.SetPagesiz e (pageSize); pageInfobean.setRecordTotal (EloutputType.getMappedResults (). Size ()); WalletDetailsResp.SetPageInfo (PageInfobean);总结
以上所述是小编给大家介绍的 springboot+mongoDB 实现按日期分组分页查询功能 , 希望对大家有所帮助 如果大家有任何疑问请给我留言 , 小编会及时回复大家的。在此也非常感谢大家对武林网网站的支持!