All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.cory.service.AccessCountService Maven / Gradle / Ivy

There is a newer version: 0.0.35
Show newest version
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();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy