@Test public void listIncome() { Long millis = System.currentTimeMillis(); Date start = new Date(millis - 30 * 24 * 60 * 60 * 1000); Date end = new Date(millis); List<Income> incomes = incomeService.listIncome(getUser().getId(), "", start, end); Assert.assertNotNull(incomes); System.out.println(incomes); }
@Override @LogMethod("查询收益记录") public List<Income> listIncome(String userId, String category, Date start, Date end) { Query query = new Query(); Criteria criteria = Criteria.where("assetId").is(getAssetByUserId(userId).getId()); BeeUtils.betweenStartAndEnd(criteria, start, end); if (StrUtil.isNotEmpty(category)) { criteria.andOperator(Criteria.where("category").is(category)); } query.addCriteria(criteria); query.with(new Sort(Sort.Direction.DESC, "date", "createTime")); return mongoTemplate.find(query, Income.class); }
IncomeServiceImpl implements IncomeService { @Override @LogMethod("查询收益记录") public List<Income> listIncome(String userId, String category, Date start, Date end) { Query query = new Query(); Criteria criteria = Criteria.where("assetId").is(getAssetByUserId(userId).getId()); BeeUtils.betweenStartAndEnd(criteria, start, end); if (StrUtil.isNotEmpty(category)) { criteria.andOperator(Criteria.where("category").is(category)); } query.addCriteria(criteria); query.with(new Sort(Sort.Direction.DESC, "date", "createTime")); return mongoTemplate.find(query, Income.class); } }
IncomeServiceImpl implements IncomeService { @Override @LogMethod("查询收益记录") public List<Income> listIncome(String userId, String category, Date start, Date end) { Query query = new Query(); Criteria criteria = Criteria.where("assetId").is(getAssetByUserId(userId).getId()); BeeUtils.betweenStartAndEnd(criteria, start, end); if (StrUtil.isNotEmpty(category)) { criteria.andOperator(Criteria.where("category").is(category)); } query.addCriteria(criteria); query.with(new Sort(Sort.Direction.DESC, "date", "createTime")); return mongoTemplate.find(query, Income.class); } @Autowired  IncomeServiceImpl(AssetDAO assetDAO, IncomeDAO incomeDAO, MongoTemplate mongoTemplate,
                             RedisTemplate<String, Asset> assetRedisTemplate); }
IncomeServiceImpl implements IncomeService { @Override @LogMethod("查询收益记录") public List<Income> listIncome(String userId, String category, Date start, Date end) { Query query = new Query(); Criteria criteria = Criteria.where("assetId").is(getAssetByUserId(userId).getId()); BeeUtils.betweenStartAndEnd(criteria, start, end); if (StrUtil.isNotEmpty(category)) { criteria.andOperator(Criteria.where("category").is(category)); } query.addCriteria(criteria); query.with(new Sort(Sort.Direction.DESC, "date", "createTime")); return mongoTemplate.find(query, Income.class); } @Autowired  IncomeServiceImpl(AssetDAO assetDAO, IncomeDAO incomeDAO, MongoTemplate mongoTemplate,
                             RedisTemplate<String, Asset> assetRedisTemplate); @Override @LogMethod("查询资产可用余额") Long getAssetBalance(String userId); @Override @LogMethod("查询收益记录") List<Income> listIncome(String userId, String category, Date start, Date end); @Override @LogMethod("查询年度账单") List<IncomeBillVO> listYear(String userId, Integer startYear, Integer endYear); @Override @LogMethod("查询月度账单") List<IncomeBillVO> listMonth(String userId, String startMonth, String endMonth); @Override @LogMethod("更新收益记录") Income updateIncome(String userId, String incomeId, IncomeVO incomeVO); @Override @LogMethod("删除收益记录") void remove(String userId, String incomeId); @Override @LogMethod("添加收益记录") Income saveIncome(String userId, IncomeVO incomeVO); }
IncomeServiceImpl implements IncomeService { @Override @LogMethod("查询收益记录") public List<Income> listIncome(String userId, String category, Date start, Date end) { Query query = new Query(); Criteria criteria = Criteria.where("assetId").is(getAssetByUserId(userId).getId()); BeeUtils.betweenStartAndEnd(criteria, start, end); if (StrUtil.isNotEmpty(category)) { criteria.andOperator(Criteria.where("category").is(category)); } query.addCriteria(criteria); query.with(new Sort(Sort.Direction.DESC, "date", "createTime")); return mongoTemplate.find(query, Income.class); } @Autowired  IncomeServiceImpl(AssetDAO assetDAO, IncomeDAO incomeDAO, MongoTemplate mongoTemplate,
                             RedisTemplate<String, Asset> assetRedisTemplate); @Override @LogMethod("查询资产可用余额") Long getAssetBalance(String userId); @Override @LogMethod("查询收益记录") List<Income> listIncome(String userId, String category, Date start, Date end); @Override @LogMethod("查询年度账单") List<IncomeBillVO> listYear(String userId, Integer startYear, Integer endYear); @Override @LogMethod("查询月度账单") List<IncomeBillVO> listMonth(String userId, String startMonth, String endMonth); @Override @LogMethod("更新收益记录") Income updateIncome(String userId, String incomeId, IncomeVO incomeVO); @Override @LogMethod("删除收益记录") void remove(String userId, String incomeId); @Override @LogMethod("添加收益记录") Income saveIncome(String userId, IncomeVO incomeVO);  }