GrayNginxSwitchCtrl.java 2.09 KB
package com.ui.ctrl;

import com.ui.http.HttpRestClient;
import com.ui.model.BaseResponse;
import org.springframework.beans.factory.annotation.Autowired;
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 java.util.HashMap;
import java.util.Map;

/**
 * 灰度的nginx切换
 *
 * @author craig.qin 2018-1-10
 */
@Controller
@RequestMapping("/grayNginxSwitch")
public class GrayNginxSwitchCtrl {

    @Autowired
    HttpRestClient httpRestClient;

    @RequestMapping(value = "/toGrayNginxSwitch")
    public ModelAndView toGrayNginxSwitch() {
        ModelAndView mdv = new ModelAndView("switch/switch_nginx_gray");
        return mdv;
    }

    /**
     * 展示配置文件信息
     *
     */
    @RequestMapping(value = "/viewGrayNginxCurrentConf")
    @ResponseBody
    public BaseResponse viewGrayNginxCurrentConf() {
        return  httpRestClient.defaultGet( "/grayNginxSwitch/viewGrayNginxCurrentConf", BaseResponse.class, null);
    }

    /**
     * 解析当前配置,绘图用
     *
     */
    @RequestMapping(value = "/getGrayNginxStatus")
    @ResponseBody
    public BaseResponse getGrayNginxStatus() {
        return  httpRestClient.defaultGet( "/grayNginxSwitch/getGrayNginxStatus", BaseResponse.class, null);
    }


    /**
     * 切换结果预览
     *
     */
    @RequestMapping(value = "/viewGrayNginxToChangeConf")
    @ResponseBody
    public BaseResponse viewGrayNginxToChangeConf(String onlineOrGray) {
        Map<String, String> map=new HashMap<>();
        map.put("onlineOrGray",onlineOrGray);
        return  httpRestClient.defaultGet( "/grayNginxSwitch/viewGrayNginxToChangeConf", BaseResponse.class, map);
    }


    /**
     * 确定切换
     *
     */
    @RequestMapping(value = "/switchGrayNginx")
    @ResponseBody
    public BaseResponse switchGrayNginx(String confContent) {
        return  httpRestClient.defaultPost("/grayNginxSwitch/switchGrayNginx",confContent,BaseResponse.class);
    }




}