@Override public void process(VisitLog visitLog) { visitLog.setArea(IPSeeker.getInstance().getArea(visitLog.getIp())); visitLog.setCountry(IPSeeker.getInstance().getCountry(visitLog.getIp())); VisitLog origin = null; if (VisitTypeEnum.INDEX.value().equals(visitLog.getPage())) { origin = visitLogDao.getVisitedIndexLog(visitLog); } else { origin = visitLogDao.getVisitedProdLog(visitLog); } if (origin != null) { Integer num = origin.getVisitNum(); if (num == null) { num = 1; } else { num++; } origin.setVisitNum(num); origin.setDate(new Date()); visitLogDao.updateVisitLog(origin); } else { visitLog.setVisitNum(1); visitLogDao.save(visitLog); } }
/* * (non-Javadoc) * * @see * com.legendshop.business.service.VisitLogService#save(com.legendshop.model * .entity.VisitLog) */ @Override public Long save(VisitLog visitLog) { if (!AppUtils.isBlank(visitLog.getVisitId())) { update(visitLog); return visitLog.getVisitId(); } return (Long) visitLogDao.save(visitLog); }
/* * (non-Javadoc) * * @see * com.legendshop.business.service.VisitLogService#update(com.legendshop * .model.entity.VisitLog) */ @Override public void update(VisitLog visitLog) { visitLogDao.updateVisitLog(visitLog); }
/* * (non-Javadoc) * * @see * com.legendshop.business.service.VisitLogService#delete(java.lang.Long) */ @Override public void delete(Long id) { visitLogDao.deleteVisitLogById(id); }
/* * (non-Javadoc) * * @see com.legendshop.business.service.VisitLogService#load(java.lang.Long) */ @Override public VisitLog getVisitLogById(Long id) { return visitLogDao.get(VisitLog.class, id); }
/* * (non-Javadoc) * * @see * com.legendshop.business.service.VisitLogService#list(java.lang.String) */ @Override public List<VisitLog> getVisitLogList(String userName) { return visitLogDao.findByHQL("from VisitLog where userName = ?", new Object[] {userName}); }
/* * (non-Javadoc) * * @see * com.legendshop.business.service.VisitLogService#getDataByCriteriaQuery * (com.legendshop.core.dao.support.CriteriaQuery) */ @Override public PageSupport getVisitLogList(CriteriaQuery cq) { return visitLogDao.find(cq); }