package com.iamberry.wechat.service.banner;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.iamberry.wechat.core.entity.PaperBean;
import com.iamberry.wechat.core.entity.banner.ActionBanner;
import com.iamberry.wechat.core.entity.banner.ActionBannerImage;
import com.iamberry.wechat.face.banner.AdminBannerService;
import com.iamberry.wechat.service.banner.dao.AdminBannerDAO;
/**
 * @author 何秀刚
 * Introduction to the ： banner service 接口 实现
 * create date: 2016年1月9日
 */
@Service
public class AdminBannerServiceImpl implements AdminBannerService {

	@Autowired
	private AdminBannerDAO adminBannerDAO;
	public void setAdminBannerDAO(AdminBannerDAO adminBannerDAO) {
		this.adminBannerDAO = adminBannerDAO;
	}
	public List<ActionBanner> selectBannerListByPaper(String str, int pageSize,
			int pageNO) {
		// TODO Auto-generated method stub
		PaperBean bean = new PaperBean();
		bean.setStr(str);
		bean.setPaperData(pageNO, pageSize);
		return adminBannerDAO.selectBannerListByPaper(bean);
	}
	
	public int selectBannerCountByPaper(String str, int pageSize, int pageNO) {
		// TODO Auto-generated method stub
		PaperBean bean = new PaperBean();
		bean.setStr(str);
		bean.setPaperData(pageNO, pageSize);
		return adminBannerDAO.selectBannerCountByPaper(bean);
	}
	
	public boolean insertBanner(ActionBanner actionBanner) {
		// TODO Auto-generated method stub
		return adminBannerDAO.insertBanner(actionBanner) >= 1 ? true : false;
	}
	
	public boolean stopBannerById(Integer bannerId) {
		// TODO Auto-generated method stub
		return adminBannerDAO.stopBannerById(bannerId) >= 1 ? true : false;
	}
	
	public ActionBanner selectBannerById(Integer bannerId) {
		// TODO Auto-generated method stub
		return adminBannerDAO.selectBannerById(bannerId);
	}
	
	public boolean updateBannerById(ActionBanner actionBanner) {
		// TODO Auto-generated method stub
		return adminBannerDAO.updateBannerById(actionBanner) >= 1 ? true : false;
	}
	
	public List<ActionBannerImage> selectBannerImgByBannerId(Integer bannerId) {
		// TODO Auto-generated method stub
		return adminBannerDAO.selectBannerImgByBannerId(bannerId);
	}
	
	public boolean insertBannerImg(ActionBannerImage actionBannerImage) {
		// TODO Auto-generated method stub
		return adminBannerDAO.insertBannerImg(actionBannerImage) >= 1 ? true : false;
	}
	
	public boolean deleteBannerImgById(Integer id) {
		// TODO Auto-generated method stub
		return adminBannerDAO.deleteBannerImgById(id) >= 1 ? true : false;
	}
	
	public List<ActionBannerImage> selectNowBannerByType(Integer id) {
		// TODO Auto-generated method stub
		List<ActionBannerImage> list = adminBannerDAO.selectNowBannerByType(id);
		return list;
	}
	public void selectNowBannerByTypeToCache(Integer id) {
		// TODO Auto-generated method stub
		List<ActionBannerImage> list = adminBannerDAO.selectNowBannerByType(id);
//		StaticCacheMemory.actionBannerImagesList = list;
	}
}
