package com.cloudcross.ssp.web.back.main.ad.report;

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

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 com.cloudcross.ssp.back.model.SystemReport;
import com.cloudcross.ssp.back.service.ISystemReportService;
import com.cloudcross.ssp.base.web.SimpleController;
import com.cloudcross.ssp.common.utils.Pager;

/**
 * 媒体数据报表中系统报表控制
 * @author Hao
 *
 */

@Controller
@RequestMapping("/back/main/ad/report/media-report")
public class SystemReportController extends SimpleController{
	
	@Autowired
	private ISystemReportService systemReportService;
	
	
	//系统报表
	@RequestMapping("/system")
	public String system(Model model,
				@RequestParam HashMap<String, Object> paramMap,
				@RequestParam(defaultValue="1") int page,
				@RequestParam(required = false) Long operatorId){
			
		       paramMap.put("operatorId", operatorId);
		       model.addAttribute("operatorId",operatorId);
		       System.out.println("operatorId" + operatorId + "aaaaaaaaaaaaaaaa");
			
			
			int totalRow = systemReportService.countByParams(paramMap);
			System.out.println("totalRow" + totalRow + "111111111111111");
			Pager pager = new Pager();
			pager.setPage(page);
			pager.setTotalRow(totalRow);
			
			List<SystemReport> reportList = systemReportService.findByParams(paramMap, pager);
			System.out.println("reportList" + reportList + "22222222222222");
			
			model.addAllAttributes(paramMap);
			model.addAttribute("pager",pager);
			model.addAttribute("reportList",reportList);
			
			return page("system");
			
	}

}
