@Test public void updateIncome() { IncomeVO incomeVO = new IncomeVO(); incomeVO.setCategory(RandomUtil.randomString(4)); incomeVO.setDate(new Date(System.currentTimeMillis())); incomeVO.setMoney(RandomUtil.randomLong(Integer.MAX_VALUE)); incomeVO.setRemark(RandomUtil.randomString(6)); incomeVO.setType(TestConsts.TYPE); incomeVO.setWay(TestConsts.WAY); Assert.assertNotNull(incomeService.updateIncome(getUser().getId(), incomeDAO.findAll().get(0).getId(), incomeVO)); }
@Override @LogMethod("更新收益记录") public Income updateIncome(String userId, String incomeId, IncomeVO incomeVO) { Income income = incomeDAO.getById(incomeId); AssertUtils.throwIfNull(income, BeeErrorConsts.INCOME_NOT_FOUND); Long changeValue = incomeVO.getMoney() * incomeVO.getType() - income.getMoney() * income.getType(); updateAssetBalance(userId, changeValue); return incomeDAO.save(income.copyFrom(incomeVO)); }
IncomeServiceImpl implements IncomeService { @Override @LogMethod("更新收益记录") public Income updateIncome(String userId, String incomeId, IncomeVO incomeVO) { Income income = incomeDAO.getById(incomeId); AssertUtils.throwIfNull(income, BeeErrorConsts.INCOME_NOT_FOUND); Long changeValue = incomeVO.getMoney() * incomeVO.getType() - income.getMoney() * income.getType(); updateAssetBalance(userId, changeValue); return incomeDAO.save(income.copyFrom(incomeVO)); } }
IncomeServiceImpl implements IncomeService { @Override @LogMethod("更新收益记录") public Income updateIncome(String userId, String incomeId, IncomeVO incomeVO) { Income income = incomeDAO.getById(incomeId); AssertUtils.throwIfNull(income, BeeErrorConsts.INCOME_NOT_FOUND); Long changeValue = incomeVO.getMoney() * incomeVO.getType() - income.getMoney() * income.getType(); updateAssetBalance(userId, changeValue); return incomeDAO.save(income.copyFrom(incomeVO)); } @Autowired  IncomeServiceImpl(AssetDAO assetDAO, IncomeDAO incomeDAO, MongoTemplate mongoTemplate,
                             RedisTemplate<String, Asset> assetRedisTemplate); }
IncomeServiceImpl implements IncomeService { @Override @LogMethod("更新收益记录") public Income updateIncome(String userId, String incomeId, IncomeVO incomeVO) { Income income = incomeDAO.getById(incomeId); AssertUtils.throwIfNull(income, BeeErrorConsts.INCOME_NOT_FOUND); Long changeValue = incomeVO.getMoney() * incomeVO.getType() - income.getMoney() * income.getType(); updateAssetBalance(userId, changeValue); return incomeDAO.save(income.copyFrom(incomeVO)); } @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 Income updateIncome(String userId, String incomeId, IncomeVO incomeVO) { Income income = incomeDAO.getById(incomeId); AssertUtils.throwIfNull(income, BeeErrorConsts.INCOME_NOT_FOUND); Long changeValue = incomeVO.getMoney() * incomeVO.getType() - income.getMoney() * income.getType(); updateAssetBalance(userId, changeValue); return incomeDAO.save(income.copyFrom(incomeVO)); } @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);  }