package mobi.cangol.web.modules.countly.service;

import java.util.List;

import mobi.cangol.web.common.search.Page;
import mobi.cangol.web.common.search.PageSearchEntity;
import mobi.cangol.web.common.service.BaseService;
import mobi.cangol.web.modules.countly.dao.TrafficInfoDao;
import mobi.cangol.web.modules.countly.entity.TrafficInfo;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class TrafficInfoService implements BaseService<TrafficInfo>{
	@Autowired
	private TrafficInfoDao trafficInfoDao;
	@Override
	public TrafficInfo get(String id) {
		return trafficInfoDao.get(id);
	}

	@Override
	public void delete(String id) throws Exception {
		trafficInfoDao.deleteByKey(id);
	}

	@Override
	public void deleteAll(List<TrafficInfo> list) throws Exception {
		trafficInfoDao.deleteAll(list);
	}

	@Override
	public Page findPage(PageSearchEntity pEntity, int pageNo, int pageSize)
			throws Exception {
		return trafficInfoDao.findByEntity(pEntity, pageNo, pageSize);
	}

	@Override
	public List<TrafficInfo> getList(PageSearchEntity pEntity) throws Exception {
		return trafficInfoDao.findListByEntity(pEntity);
	}

	@Override
	public void save(TrafficInfo t) throws Exception {
		if (StringUtils.isBlank(t.getId())){
			trafficInfoDao.save(t);
		}else{
			trafficInfoDao.update(t);
		}
	}
}
