com.cory.service.AccessCountService Maven / Gradle / Ivy
package com.cory.service;
import com.cory.dao.AccessCountDao;
import com.cory.dto.AccessCountStatDTO;
import com.cory.model.AccessCount;
import com.cory.util.DateFormatUtils;
import com.cory.util.DateUtils;
import com.cory.vo.AccessCountStatVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
* generated by CodeGenerator on 2017/5/10.
*/
@Service
@Scope(proxyMode = ScopedProxyMode.TARGET_CLASS)
public class AccessCountService extends BaseService {
private static final String DAY_FORMAT = "yyyyMMdd";
@Autowired
private AccessCountDao accessCountDao;
@Override
public AccessCountDao getDao() {
return accessCountDao;
}
public AccessCountStatVO stat() {
Date today = new Date();
String todayStr = DateFormatUtils.format(today, DAY_FORMAT);
String yesterdayStr = DateFormatUtils.format(DateUtils.addDays(today, -1), DAY_FORMAT);
List todayStatInfo = accessCountDao.stat(todayStr);
List yesterdayStatInfo = accessCountDao.stat(yesterdayStr);
List totalStatInfo = accessCountDao.stat(null);
return AccessCountStatVO.builder()
.today(todayStatInfo)
.yesterday(yesterdayStatInfo)
.total(totalStatInfo)
.build();
}
}