package com.cloudcross.ssp.service.impl;

import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cloudcross.ssp.model.CodeSite;
import com.cloudcross.ssp.service.ICodeSiteService;
import com.cloudcross.ssp.base.dao.GenericIBatisDao;
import com.cloudcross.ssp.common.utils.Pager;
import com.cloudcross.ssp.common.utils.SqlHelper;
import com.cloudcross.ssp.model.CodeSite;

@Service
public class CodeSiteService implements ICodeSiteService{
	private static final Logger LOG = Logger.getLogger(CodeSiteService.class);
	
	@Autowired
	private GenericIBatisDao myBatisDao;

	//广告id
	@Override
	public CodeSite findById(Long id) {
		return myBatisDao.get("codeSiteSqlMapper.selectById", id);
	}
  
	
	@Override
	public CodeSite findByAdvertiserId(Long AdvertiserId) {
		return myBatisDao.get("codeSiteSqlMapper.selectByAdvertiserId", AdvertiserId);
	}
	
	
	@Override
	public int countByParams(Map<String, Object> paramMap) {
		String searchValue = SqlHelper.doLike(paramMap.get("searchValue"));
		paramMap.put("key", paramMap.get("searchKey"));
		paramMap.put("value", searchValue);
		return myBatisDao.get("codeSiteSqlMapper.countByParams", paramMap);
	}

	@Override
	public List<CodeSite> findByParams(Map<String, Object> paramMap, Pager pager) {
		// TODO Auto-generated method stub
		return null;
	}
	

	@Override
	public boolean add(CodeSite t) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean edit(CodeSite t) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean updateStatus(List<Long> idList, int status) {
		// TODO Auto-generated method stub
		return false;
	}


	@Override
	public String getCode(Long AdvertiserId, int type) {
		// TODO Auto-generated method stub
		if(type == 0){
			return myBatisDao.get("codeSiteSqlMapper.getScriptByAdId", AdvertiserId);
		}else{
			return myBatisDao.get("codeSiteSqlMapper.getPicyureByAdId", AdvertiserId);
		}
	}

}
