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

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

@Controller("back.systemReportController")
@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);
			
			int totalRow = systemReportService.countByParams(paramMap);
			Pager pager = new Pager();
			pager.setPage(page);
			pager.setTotalRow(totalRow);
			
			List<SystemReport> reportList = systemReportService.findByParams(paramMap, pager);
			
			model.addAllAttributes(paramMap);
			model.addAttribute("pager",pager);
			model.addAttribute("reportList",reportList);
			
			return page("system");
			
	}

}
