package com.cloudcross.ssp.service.impl;

import java.util.Date;
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.model.Log;
import com.cloudcross.ssp.service.ILogService;
import com.cloudcross.ssp.base.dao.GenericIBatisDao;
import com.cloudcross.ssp.common.utils.Pager;
import com.cloudcross.ssp.common.utils.SqlHelper;


@Service
public class LogService implements ILogService {
	@Autowired
	private GenericIBatisDao myBatisDao;

	@Override
	public Log findById(Long id) {
		return myBatisDao.get("logSqlMapper.selectById", id);
	}
	
	@Override
	public int countByParams(Map<String, Object> paramMap,String module) {
		String searchValue = SqlHelper.doLike(paramMap.get("searchValue"));
		paramMap.put("key", paramMap.get("searchKey"));
		paramMap.put("value", searchValue);
		paramMap.put("module", module);
		return myBatisDao.get("logSqlMapper.countByParams", paramMap);
	}

	@Override
	public List<Log> findByParams(Map<String, Object> paramMap, Pager pager,
			String module ) {
		String searchValue = SqlHelper.doLike(paramMap.get("searchValue"));
		paramMap.put("key", paramMap.get("searchKey"));
		paramMap.put("value", searchValue);
		paramMap.put("module", module);
		paramMap.put("pager", pager);
		return myBatisDao.getList("logSqlMapper.selectByParams", paramMap);
	}
	
	@Override
	public List<Log> findByParams1(HashMap<String, Object> paramMap) {
		return myBatisDao.getList("logSqlMapper.selectByParams1", paramMap);
	}

	@Override
	public boolean add(Log t) {
		t.setAccountId(t.getAccountId());
		t.setOperTime(new Date());
		myBatisDao.save("logSqlMapper.addLog", t);
		return true;
	}

	@Override
	public boolean edit(Log t) {
		t.setOperTime(new Date());
		myBatisDao.save("logSqlMapper.editLog", t);
		return true;
	}

	
	//通过模块查找信息修改记录
	@Override
	public Log findByModule(String module) {
		return myBatisDao.get("logSqlMapper.findByModule", module);
	}
	
	//涉及到信息修改记录的没用到这个方法
	@Override
	public boolean updateStatus(List<Long> idList, int status) {
		// TODO Auto-generated method stub
		return false;
	}
	//涉及到信息修改记录的没用到这两个方法
	@Override
	public int countByParams(Map<String, Object> paramMap) {
		// TODO Auto-generated method stub
		return 0;
	}

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

	@Override
	public List<Log> findDeliverEffectAnalysis(Map<String, Object> paramMap) {
		return myBatisDao.getList("logSqlMapper.findDeliverEffectAnalysis", paramMap);
	}

	@Override
	public int countByParamsBack(Map<String, Object> paramMap) {
		return myBatisDao.get("logSqlMapper.countByParamsBack", paramMap);
	}

	@Override
	public List<Log> findByParamsBack(Map<String, Object> paramMap, Pager pager) {
		paramMap.put("pager", pager);
		return myBatisDao.getList("logSqlMapper.findByParamsBack", paramMap);
	}

	@Override
	public List<Log> findByParamsBack(Map<String, Object> paramMap) {
		return myBatisDao.getList("logSqlMapper.findByParams1Back", paramMap);
	}


	
	
}
