package com.cloudcross.ssp.back.service.impl;

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

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

import com.cloudcross.ssp.back.model.Direct;
import com.cloudcross.ssp.back.service.IDirectService;
import com.cloudcross.ssp.base.dao.GenericIBatisDao;
import com.cloudcross.ssp.common.utils.MapBuilder;
import com.cloudcross.ssp.common.utils.Pager;

@Service
public class DirectService implements IDirectService {
	@Autowired
	private GenericIBatisDao iBatisDao;
	
	@Override
	public boolean add(Direct t) {
	 
		iBatisDao.save("directSqlMapper.addDirect", t);
		return  true;
	}
	
	@Override
	public boolean edit(Direct t) {
  
		iBatisDao.save("directSqlMapper.editDirect", t);
		return true;
	}
	
	
	
	@Override
	public Direct findByadGroupId(Long adGroupId, String directType) {
		
 
		return 	iBatisDao.get("directSqlMapper.findByAdGroupId",MapBuilder.create(HashMap.class)
				.add("adGroupId", adGroupId)
				.add("directType", directType)
				.map());
	}
	 
	@Override
	public List<Direct>  findByBatch(Long adGroupId ) {
		
		return 	iBatisDao.getList("directSqlMapper.findByAdGroupId",MapBuilder.create(HashMap.class)
				.add("adGroupId", adGroupId)
				.map());
	}
		
	
	@Override
	public boolean deleteByadGroupId(Long adGroupId, String directType) {

		iBatisDao.delete("directSqlMapper.deleteDirect", MapBuilder.create(HashMap.class)
				.add("adGroupId", adGroupId)
				.add("directType", directType)
				.map());
		return true;
	}
	@Override
	public Direct findById(Long id) {
		throw new UnsupportedOperationException();
	}
	
	@Override
	public List<Direct> findByParams(Map<String, Object> paramMap, Pager pager) {
		throw new UnsupportedOperationException();
	}
	
	@Override
	public boolean updateStatus(List<Long> idList, int status) {
		throw new UnsupportedOperationException();
	}
	@Override
	public int countByParams(Map<String, Object> paramMap) {
		throw new UnsupportedOperationException();
	}
}
