SearchCompareCtrl.java 2.48 KB
package com.ui.ctrl;

import java.util.HashMap;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.ui.http.HttpRestClient;
import com.ui.model.BaseResponse;

/**
 * 对双云的搜索结果进行比较controller
 * @author gemingdan
 *
 */
@Controller
@RequestMapping("/searchCompare")
public class SearchCompareCtrl {
	
	Logger log = LoggerFactory.getLogger(SearchCompareCtrl.class);
	
	@Autowired
    HttpRestClient httpRestClient;
	
	@Value("${monitor.service.url}")
	String MONITOR_SERVICE_URL;
	
	/**
	 * 获取页面
	 * @return
	 */
	@RequestMapping("/getComparePage")
	public ModelAndView getComparePage(){
		
		ModelAndView mav = new ModelAndView();
		mav.setViewName("searchCompare/list");
		return mav;
	}
	
	@RequestMapping("/toStop")
	@ResponseBody
	public BaseResponse toStop(){
		BaseResponse response = httpRestClient.get(MONITOR_SERVICE_URL+"/searchcompare/toStop", BaseResponse.class,null);
		return response;
	}
	
	
	/**
	 * 获取比较结果
	 * @return
	 */
	@RequestMapping("/getlist")
	@ResponseBody
	public BaseResponse getlist(Integer currentPage){
		//currentPage
		Map<String,Object> param=new HashMap<String,Object>();
		if(currentPage==null){
			currentPage=1;
		}
		param.put("currentPage", currentPage);
		BaseResponse awsResponse = httpRestClient.get(MONITOR_SERVICE_URL+"/searchcompare/getlist", BaseResponse.class,param);
		Map<String,Object> data=(Map<String,Object>)awsResponse.getData();
		Map<String,Object> pageList=(Map<String,Object>)data.get("pageList");
		pageList.put("lastUpdateLine", data.get("lastUpdateLine"));
		pageList.put("lastUpdateTime", data.get("lastUpdateTime"));
		pageList.put("comparing", data.get("comparing"));
		pageList.put("stopping", data.get("stopping"));
		awsResponse.setData(pageList);
		return awsResponse;
	}
	
	/**
	 * 刷新比较结果
	 * @return
	 */
	@RequestMapping("/refresh")
	@ResponseBody
	public BaseResponse refresh(Integer num){
		Map<String,Object> param=new HashMap<String,Object>();
		param.put("num", num);
		BaseResponse awsResponse = httpRestClient.get(MONITOR_SERVICE_URL+"/searchcompare/refresh", BaseResponse.class,param);
		return awsResponse;
	}
	
	
}