Beispiel #1
0
  //	@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false, rollbackFor =
  // Exception.class)
  public static void addHits(boolean isLogin) {
    if (lastHits == null) lastHits = getLastHits();
    Calendar now = Calendar.getInstance();
    Calendar last = Calendar.getInstance();
    last.setTime(lastHits.getDate());

    l.info("last time: {}", last.getTime());
    l.info("this time: {}", now.getTime());

    if (now.get(Calendar.DATE) != last.get(Calendar.DATE)) {
      lastHits = new Hits();
      lastHits.setDate(now.getTime());
      lastHits.setHits(1);
      setUniqueHits(lastHits, isLogin);
      lastHits.setUniqueHits(1);
      getEntityManager().persist(lastHits);
    } else {
      lastHits.setHits(lastHits.getHits() + 1);
      setUniqueHits(lastHits, isLogin);
      getEntityManager().merge(lastHits);
    }
  }
Beispiel #2
0
 public static void setUniqueHits(Hits hits, boolean isLogin) {
   if (!isLogin) hits.setUniqueHits(hits.getUniqueHits() + 1);
 }