package com.cloudcross.ssp.web.advertiser.main;

import java.util.HashMap;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cloudcross.ssp.model.CodeSite;
import com.cloudcross.ssp.service.ICodeSiteService;
import  com.cloudcross.ssp.base.web.SimpleController;


@Controller("advertiser.codeSiteController")
@RequestMapping("/advertiser/main/code-site")
public  class CodeSiteController extends SimpleController {
	@Autowired
	protected ICodeSiteService codeSiteService;
	
	/**
	 * @return 返回到全站访客找回第一页。
	 */
	@RequestMapping
	public String index() {
		return redirect(page("list"));
	}
	
	@RequestMapping("/list")
	public String list(Model model,
			@RequestParam HashMap<String, Object> paramMap,
			@RequestParam(defaultValue="1") int page) {
           
		
		
			return page("list");
		
	}
	
	@RequestMapping("/sitelist")
	public String sitelist() {
		return page("sitelist");
	}
	
	
	
	
	@RequestMapping("/script")
	public String script(Model model) {	
					
		Long advertiserId = new Long(1);
		CodeSite codeSite = codeSiteService.findByAdvertiserId(advertiserId);
	
		model.addAttribute("codeSite", codeSite);
			
		return page("script");
		
	}
	
	
	@RequestMapping("/picture")
	public String picture(Model model) {	
		
		Long advertiserId = new Long(1);
		CodeSite codeSite = codeSiteService.findByAdvertiserId(advertiserId);

		model.addAttribute("codeSite", codeSite);
		
 		return page("picture");
	}
	

	
	
	
@RequestMapping("/getcode")
public @ResponseBody String getCode(
			@RequestParam long advertiserId,
			@RequestParam int type
			) {
	System.out.println("++++");
		// 校验参数
   		return codeSiteService.getCode(advertiserId,type);
   				
  		
}

}
