package com.cloudcross.ssp.web.dsp;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import net.sf.json.JSONArray;
import net.sf.json.JSONException;
import net.sf.json.JSONObject;
import org.springframework.web.bind.annotation.RequestMapping;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.cloudcross.ssp.base.web.SimpleController;
import com.cloudcross.ssp.common.consts.FieldValidate;
import com.cloudcross.ssp.common.utils.Common;
import com.cloudcross.ssp.common.utils.FieldInfo;
import com.cloudcross.ssp.model.DspAgent;
import com.cloudcross.ssp.model.Log;
import com.cloudcross.ssp.service.IDspAgentService;
import com.cloudcross.ssp.service.ILogService;

import javax.servlet.http.HttpServletRequest;

/**
 * 
 * 类名称：DspAgentController
 * 类描述：dsp账户
 * 创建人：rongying
 * 创建时间：2015.12.11
 *
 */

@Controller
@RequestMapping("/dsp/main/dsp-agent")
public class DspAgentController extends SimpleController{
	
	@SuppressWarnings("unused")
	private static final Logger LOG = Logger.getLogger(DspAgentController.class);
	
	@Autowired
	private IDspAgentService dspAgentService;
	
	@Autowired
	private ILogService logService;
	
	/**
	 * 根据id，批量查询dsp账户
	 * 
	 * @param paramMap 参数
	 * 				dspIds:"1,2"  以逗号分隔的字符串
	 * @return
	 */
	@RequestMapping("/isCheck")
	public @ResponseBody boolean isCheck(HttpServletRequest request,@RequestParam Map<String,Object> paramMap){
		boolean success = false;
		if(paramMap.get("name") != null && !"".equals(paramMap.get("name")) &&
				paramMap.get("token") != null && !"".equals(paramMap.get("token"))){
			DspAgent dspAgent = new DspAgent();
			dspAgent.setName(String.valueOf(paramMap.get("name")));
			dspAgent.setToken(String.valueOf(paramMap.get("token")));
			int count = dspAgentService.isCheck(dspAgent);
			if(count > 0){
				success = true;
			}else{
				success = false;
			}
		}
		return success;		
	}

}
