@Override public int addSharePoints(String userId) { int points = (int) (Math.random() * 59) + 1; User user = userDao.load(userId); user.setPoints(user.getPoints() + points); userDao.update(user); return points; }
@Override public void psychologicalTest(String userId, int points) { User user = userDao.load(userId); if (user.getPoints() < points) { throw new ServiceException("当前积分不足,无法进行评测!"); } user.setPoints(user.getPoints() - points); userDao.update(user); }