@Test public void updateDaily() { DailyVO dailyVO = new DailyVO(); dailyVO.setContent(RandomUtil.randomString(9)); dailyVO.setDate(new Date(System.currentTimeMillis())); dailyVO.setScore(RandomUtil.randomInt(10)); dailyVO.setWeather(RandomUtil.randomString(3)); dailyService.updateDaily(getUser().getId(), dailyDAO.findAll().get(0).getId(), dailyVO); }
@Override @LogMethod("更新日程记录") public Daily updateDaily(String userId, String dailyId, DailyVO dailyVO) { Daily daily = dailyDAO.getById(dailyId); AssertUtils.throwIfNull(daily, BeeErrorConsts.DAILY_NOT_FOUND); AssertUtils.throwIf(exists(userId, dailyId, dailyVO.getDate()), BeeErrorConsts.DAILY_EXISTS); return dailyDAO.save(daily.copyFrom(dailyVO)); }
DailyServiceImpl implements DailyService { @Override @LogMethod("更新日程记录") public Daily updateDaily(String userId, String dailyId, DailyVO dailyVO) { Daily daily = dailyDAO.getById(dailyId); AssertUtils.throwIfNull(daily, BeeErrorConsts.DAILY_NOT_FOUND); AssertUtils.throwIf(exists(userId, dailyId, dailyVO.getDate()), BeeErrorConsts.DAILY_EXISTS); return dailyDAO.save(daily.copyFrom(dailyVO)); } }
DailyServiceImpl implements DailyService { @Override @LogMethod("更新日程记录") public Daily updateDaily(String userId, String dailyId, DailyVO dailyVO) { Daily daily = dailyDAO.getById(dailyId); AssertUtils.throwIfNull(daily, BeeErrorConsts.DAILY_NOT_FOUND); AssertUtils.throwIf(exists(userId, dailyId, dailyVO.getDate()), BeeErrorConsts.DAILY_EXISTS); return dailyDAO.save(daily.copyFrom(dailyVO)); } @Autowired  DailyServiceImpl(DailyDAO dailyDAO, MongoTemplate mongoTemplate); }
DailyServiceImpl implements DailyService { @Override @LogMethod("更新日程记录") public Daily updateDaily(String userId, String dailyId, DailyVO dailyVO) { Daily daily = dailyDAO.getById(dailyId); AssertUtils.throwIfNull(daily, BeeErrorConsts.DAILY_NOT_FOUND); AssertUtils.throwIf(exists(userId, dailyId, dailyVO.getDate()), BeeErrorConsts.DAILY_EXISTS); return dailyDAO.save(daily.copyFrom(dailyVO)); } @Autowired  DailyServiceImpl(DailyDAO dailyDAO, MongoTemplate mongoTemplate); @Override @LogMethod("检测日程记录是否存在") boolean exists(String dailyId); @Override @LogMethod("查找日程记录") Daily getDaily(String userId, Date date); @Override @LogMethod("列出日程记录") List<Daily> listDaily(String userId, Date startDate, Date endDate); @Override @LogMethod("删除日程记录") void remove(String dailyId); @Override @LogMethod("添加日程记录") Daily saveDaily(String userId, DailyVO dailyVO); @Override @LogMethod("检测日程记录是否存在") boolean exists(String userId, String dailyId, Date date); @Override @LogMethod("更新日程记录") Daily updateDaily(String userId, String dailyId, DailyVO dailyVO); }
DailyServiceImpl implements DailyService { @Override @LogMethod("更新日程记录") public Daily updateDaily(String userId, String dailyId, DailyVO dailyVO) { Daily daily = dailyDAO.getById(dailyId); AssertUtils.throwIfNull(daily, BeeErrorConsts.DAILY_NOT_FOUND); AssertUtils.throwIf(exists(userId, dailyId, dailyVO.getDate()), BeeErrorConsts.DAILY_EXISTS); return dailyDAO.save(daily.copyFrom(dailyVO)); } @Autowired  DailyServiceImpl(DailyDAO dailyDAO, MongoTemplate mongoTemplate); @Override @LogMethod("检测日程记录是否存在") boolean exists(String dailyId); @Override @LogMethod("查找日程记录") Daily getDaily(String userId, Date date); @Override @LogMethod("列出日程记录") List<Daily> listDaily(String userId, Date startDate, Date endDate); @Override @LogMethod("删除日程记录") void remove(String dailyId); @Override @LogMethod("添加日程记录") Daily saveDaily(String userId, DailyVO dailyVO); @Override @LogMethod("检测日程记录是否存在") boolean exists(String userId, String dailyId, Date date); @Override @LogMethod("更新日程记录") Daily updateDaily(String userId, String dailyId, DailyVO dailyVO);  }